Search in sources :

Example 46 with MockInterface1

use of org.apache.cayenne.di.mock.MockInterface1 in project cayenne by apache.

the class DefaultInjectorTest method testShutdown.

@Test
public void testShutdown() {
    MockImplementation1_EventAnnotations.reset();
    Module module = binder -> binder.bind(MockInterface1.class).to(MockImplementation1_EventAnnotations.class).inSingletonScope();
    DefaultInjector injector = new DefaultInjector(module);
    MockInterface1 instance1 = injector.getInstance(MockInterface1.class);
    assertEquals("XuI", instance1.getName());
    assertFalse(MockImplementation1_EventAnnotations.shutdown1);
    assertFalse(MockImplementation1_EventAnnotations.shutdown2);
    assertFalse(MockImplementation1_EventAnnotations.shutdown3);
    injector.shutdown();
    assertTrue(MockImplementation1_EventAnnotations.shutdown1);
    assertTrue(MockImplementation1_EventAnnotations.shutdown2);
    assertTrue(MockImplementation1_EventAnnotations.shutdown3);
}
Also used : MockInterface1(org.apache.cayenne.di.mock.MockInterface1) Module(org.apache.cayenne.di.Module) Test(org.junit.Test) MockImplementation1_EventAnnotations(org.apache.cayenne.di.mock.MockImplementation1_EventAnnotations) Assert(org.junit.Assert) MockImplementation1_EventAnnotations(org.apache.cayenne.di.mock.MockImplementation1_EventAnnotations) MockInterface1(org.apache.cayenne.di.mock.MockInterface1) Module(org.apache.cayenne.di.Module) Test(org.junit.Test)

Aggregations

Module (org.apache.cayenne.di.Module)46 MockInterface1 (org.apache.cayenne.di.mock.MockInterface1)46 Test (org.junit.Test)46 MockImplementation1 (org.apache.cayenne.di.mock.MockImplementation1)41 Assert (org.junit.Assert)37 Key (org.apache.cayenne.di.Key)30 MockImplementation1Alt (org.apache.cayenne.di.mock.MockImplementation1Alt)30 MockImplementation1Alt2 (org.apache.cayenne.di.mock.MockImplementation1Alt2)30 DIRuntimeException (org.apache.cayenne.di.DIRuntimeException)29 MockImplementation2 (org.apache.cayenne.di.mock.MockImplementation2)29 MockImplementation3 (org.apache.cayenne.di.mock.MockImplementation3)29 MockInterface2 (org.apache.cayenne.di.mock.MockInterface2)29 MockInterface3 (org.apache.cayenne.di.mock.MockInterface3)29 ArrayList (java.util.ArrayList)25 Collection (java.util.Collection)25 Map (java.util.Map)25 MockImplementation1_ListConfiguration (org.apache.cayenne.di.mock.MockImplementation1_ListConfiguration)25 MockImplementation1_ListConfigurationMock5 (org.apache.cayenne.di.mock.MockImplementation1_ListConfigurationMock5)25 MockImplementation1_MapConfiguration (org.apache.cayenne.di.mock.MockImplementation1_MapConfiguration)25 MockImplementation1_MapWithWildcards (org.apache.cayenne.di.mock.MockImplementation1_MapWithWildcards)25