use of org.apache.cayenne.di.Injector in project cayenne by apache.
the class JMSBridgeProviderTest method testUseDefaultProperties.
@Test
public void testUseDefaultProperties() throws Exception {
Injector injector = DIBootstrap.createInjector(new DefaultBindings(), new JMSModule());
JMSBridge bridge = (JMSBridge) injector.getInstance(EventBridge.class);
assertEquals(JMSBridge.TOPIC_CONNECTION_FACTORY_DEFAULT, bridge.getTopicConnectionFactoryName());
}
use of org.apache.cayenne.di.Injector in project cayenne by apache.
the class CompatibilityDataMapLoaderIT method testLoad.
@Test
public void testLoad() throws Exception {
Injector injector = getInjector();
DataMapLoader loader = injector.getInstance(DataMapLoader.class);
assertTrue(loader instanceof CompatibilityDataMapLoader);
URL resourceUrl = getClass().getResource("../../project/compatibility/test-map-v6.map.xml");
Resource resource = new URLResource(resourceUrl);
DataMap dataMap = loader.load(resource);
assertNotNull(dataMap);
assertEquals(1, dataMap.getDbEntities().size());
assertEquals(1, dataMap.getObjEntities().size());
assertNotNull(dataMap.getObjEntity("Artist"));
assertNotNull(dataMap.getDbEntity("Artist"));
assertEquals(2, dataMap.getDbEntity("Artist").getAttributes().size());
}
use of org.apache.cayenne.di.Injector in project cayenne by apache.
the class CompatibilityUpgradeServiceIT method testUpgradeStandAloneDataMapDom.
@Test
public void testUpgradeStandAloneDataMapDom() throws Exception {
Injector injector = getInjector();
CompatibilityUpgradeService upgradeService = (CompatibilityUpgradeService) injector.getInstance(UpgradeService.class);
DocumentProvider documentProvider = injector.getInstance(DocumentProvider.class);
URL dataMapUrl = getClass().getResource("test-map-v6.map.xml");
Document dataMapDocument = documentProvider.getDocument(dataMapUrl);
assertNull(dataMapDocument);
Resource resource = new URLResource(dataMapUrl);
upgradeService.upgradeDataMap(resource);
dataMapDocument = documentProvider.getDocument(dataMapUrl);
assertNotNull(dataMapDocument);
assertEquals("10", dataMapDocument.getDocumentElement().getAttribute("project-version"));
}
use of org.apache.cayenne.di.Injector in project cayenne by apache.
the class ClientModuleTest method testDataChannel.
@Test
public void testDataChannel() {
Map<String, String> properties = new HashMap<>();
ClientModule module = new ClientModule() {
@Override
public void configure(Binder binder) {
super.configure(binder);
// use a noop connection to prevent startup errors...
binder.bind(ClientConnection.class).to(MockClientConnection.class);
}
};
Injector injector = DIBootstrap.createInjector(module);
DataChannel channel = injector.getInstance(DataChannel.class);
assertNotNull(channel);
assertTrue(channel instanceof ClientChannel);
assertSame("DataChannel must be a singleton", channel, injector.getInstance(DataChannel.class));
ClientChannel clientChannel = (ClientChannel) channel;
assertTrue(clientChannel.getConnection() instanceof MockClientConnection);
assertTrue(clientChannel.getEventManager() instanceof DefaultEventManager);
assertFalse(clientChannel.isChannelEventsEnabled());
}
use of org.apache.cayenne.di.Injector in project cayenne by apache.
the class ClientModuleTest method testObjectContextFactory.
@Test
public void testObjectContextFactory() {
Map<String, String> properties = new HashMap<>();
ClientModule module = new ClientModule() {
@Override
public void configure(Binder binder) {
super.configure(binder);
// use a noop connection to prevent startup errors...
binder.bind(ClientConnection.class).to(MockClientConnection.class);
}
};
Injector injector = DIBootstrap.createInjector(module);
ObjectContextFactory factory = injector.getInstance(ObjectContextFactory.class);
assertNotNull(factory);
assertSame("ObjectContextFactory must be a singleton", factory, injector.getInstance(ObjectContextFactory.class));
}
Aggregations