+ @Test
+ public void accessorCanBeCreatedByGuice() {
+ Injector injector = Guice.createInjector(
+ new Module() {
+ @Override
+ public void configure(Binder binder) {
+ binder.bind(Core.class).toInstance(mock(Core.class));
+ }
+ }
+ );
+ assertThat(injector.getInstance(IdentityAccessor.class), notNullValue());
+ }
+
+ @Test
+ public void accessorIsCreatedAsSingleton() {
+ Injector injector = Guice.createInjector(
+ new Module() {
+ @Override
+ public void configure(Binder binder) {
+ binder.bind(Core.class).toInstance(mock(Core.class));
+ }
+ }
+ );
+ IdentityAccessor firstAccessor = injector.getInstance(IdentityAccessor.class);
+ IdentityAccessor secondAccessor = injector.getInstance(IdentityAccessor.class);
+ assertThat(firstAccessor, sameInstance(secondAccessor));
+ }
+