use of org.apache.cayenne.di.Injector in project cayenne by apache.
the class DbImportModuleTest method testModuleContents.
@Test
public void testModuleContents() {
Logger log = mock(Logger.class);
Injector i = DIBootstrap.createInjector(new DbSyncModule(), new ToolsModule(log), new DbImportModule());
assertTrue(i.getInstance(DbImportAction.class) instanceof DbImportAction);
}
use of org.apache.cayenne.di.Injector in project cayenne by apache.
the class DefaultDbImportActionTest method testSaveLoadedNoProject.
@Test
public void testSaveLoadedNoProject() throws Exception {
Logger log = mock(Logger.class);
Injector i = DIBootstrap.createInjector(new DbSyncModule(), new ToolsModule(log), new DbImportModule());
DbImportConfiguration params = mock(DbImportConfiguration.class);
when(params.getCayenneProject()).thenReturn(null);
URL outUrl = new URL(getPackageURL(), "dbimport/testSaveLoaded1.map.xml");
DefaultDbImportAction action = (DefaultDbImportAction) i.getInstance(DbImportAction.class);
File out = new File(outUrl.toURI());
out.delete();
assertFalse(out.exists());
DataMap map = new DataMap("testSaveLoaded1");
map.setConfigurationSource(new URLResource(outUrl));
action.saveLoaded(map, params);
assertTrue(out.isFile());
String contents = Util.stringFromFile(out);
assertTrue("Has no project version saved", contents.contains("project-version=\""));
}
use of org.apache.cayenne.di.Injector in project cayenne by apache.
the class ModuleLoaderTest method testLoadCustom.
@Test
public void testLoadCustom() {
List<Module> modules = new ModuleLoader().load(CustomModuleProvider.class);
assertEquals(2, modules.size());
assertTrue(String.valueOf(modules.get(0)), modules.get(0) instanceof Module5);
assertTrue(String.valueOf(modules.get(1)), modules.get(1) instanceof Module6);
Injector i = DIBootstrap.createInjector(modules);
assertEquals(Integer.valueOf(66), i.getInstance(Integer.class));
}
use of org.apache.cayenne.di.Injector in project cayenne by apache.
the class XMPPBridgeProviderTest method testUseDefaultProperties.
@Test
public void testUseDefaultProperties() throws Exception {
Injector injector = DIBootstrap.createInjector(new DefaultBindings(), new XMPPModule());
XMPPBridge bridge = (XMPPBridge) injector.getInstance(EventBridge.class);
assertEquals(XMPPBridge.DEFAULT_CHAT_SERVICE, bridge.getChatService());
assertEquals(0, bridge.getXmppPort());
assertEquals(false, bridge.isSecureConnection());
}
use of org.apache.cayenne.di.Injector in project cayenne by apache.
the class XMPPBridgeProviderTest method testGetXMPPBridge.
@Test
public void testGetXMPPBridge() throws Exception {
Injector injector = DIBootstrap.createInjector(new DefaultBindings(), new XMPPModule());
EventBridge bridge = injector.getInstance(EventBridge.class);
assertNotNull(bridge);
assertTrue(bridge instanceof XMPPBridge);
}
Aggregations