use of org.apache.cayenne.di.Binder in project cayenne by apache.
the class CAY_743Test method testLoad2MapsWithCrossMapInheritance.
@Test
public void testLoad2MapsWithCrossMapInheritance() throws Exception {
Injector injector = DIBootstrap.createInjector(new ServerModule() {
@Override
public void configure(Binder binder) {
super.configure(binder);
ServerModule.contributeProjectLocations(binder).add("cay743/cayenne-domain.xml");
}
});
try {
DataDomain domain = injector.getInstance(DataDomain.class);
assertEquals(2, domain.getDataMaps().size());
DataMap m1 = domain.getDataMap("map1");
DataMap m2 = domain.getDataMap("map2");
ObjEntity oe11 = m1.getObjEntity("Entity11");
ObjEntity oe12 = m1.getObjEntity("Entity12");
ObjEntity oe21 = m2.getObjEntity("Entity21");
ObjEntity oe22 = m2.getObjEntity("Entity22");
// this causes StackOverflow per CAY-743
ObjEntity oe21Super = oe21.getSuperEntity();
ObjEntity oe12Super = oe12.getSuperEntity();
assertSame(oe12Super, oe22);
assertSame(oe21Super, oe11);
} finally {
injector.shutdown();
}
}
use of org.apache.cayenne.di.Binder in project cayenne by apache.
the class JMSBridgeProviderTest method testUseProperties.
@Test
public void testUseProperties() {
Module module = binder -> JMSModule.contributeTopicConnectionFactory(binder, TOPIC_CONNECTION_FACTORY_TEST);
Injector injector = DIBootstrap.createInjector(new DefaultBindings(), new JMSModule(), module);
JMSBridge bridge = (JMSBridge) injector.getInstance(EventBridge.class);
assertEquals(TOPIC_CONNECTION_FACTORY_TEST, bridge.getTopicConnectionFactoryName());
}
use of org.apache.cayenne.di.Binder in project cayenne by apache.
the class JMSModuleIT method testModule.
@Test
public void testModule() {
Module configModule = new Module() {
public void configure(Binder binder) {
ServerModule.contributeProperties(binder).put(Constants.SERVER_DOMAIN_NAME_PROPERTY, "test");
}
};
Injector injector = DIBootstrap.createInjector(new ServerModule(), new JMSModule(), configModule);
EventBridge bridge = injector.getInstance(EventBridge.class);
assertThat(bridge, instanceOf(JMSBridge.class));
EventBridge bridge2 = injector.getInstance(EventBridge.class);
assertThat(bridge2, instanceOf(JMSBridge.class));
assertNotSame(bridge, bridge2);
}
use of org.apache.cayenne.di.Binder in project cayenne by apache.
the class XMPPModuleIT method testModule.
@Test
public void testModule() {
Module configModule = new Module() {
public void configure(Binder binder) {
ServerModule.contributeProperties(binder).put(Constants.SERVER_DOMAIN_NAME_PROPERTY, "test");
}
};
Injector injector = DIBootstrap.createInjector(new ServerModule(), new XMPPModule(), configModule);
EventBridge bridge = injector.getInstance(EventBridge.class);
assertThat(bridge, instanceOf(XMPPBridge.class));
EventBridge bridge2 = injector.getInstance(EventBridge.class);
assertThat(bridge2, instanceOf(XMPPBridge.class));
assertNotSame(bridge, bridge2);
}
use of org.apache.cayenne.di.Binder in project cayenne by apache.
the class XMPPBridgeProviderTest method testUseProperties.
@Test
public void testUseProperties() throws Exception {
Module module = binder -> {
XMPPModule.contributeSecureConnection(binder, SECURE_CONNECTION_TEST);
XMPPModule.contributeHost(binder, HOST_TEST);
XMPPModule.contributePort(binder, PORT_TEST);
XMPPModule.contributeLogin(binder, LOGIN_TEST, PASSWORD_TEST);
XMPPModule.contributeChatService(binder, CHAT_SERVICE_TEST);
};
Injector injector = DIBootstrap.createInjector(new DefaultBindings(), new XMPPModule(), module);
XMPPBridge bridge = (XMPPBridge) injector.getInstance(EventBridge.class);
assertEquals(HOST_TEST, bridge.getXmppHost());
assertEquals(CHAT_SERVICE_TEST, bridge.getChatService());
assertEquals(LOGIN_TEST, bridge.getLoginId());
assertEquals(PASSWORD_TEST, bridge.getPassword());
assertEquals(SECURE_CONNECTION_TEST, bridge.isSecureConnection());
assertEquals(PORT_TEST, bridge.getXmppPort());
}
Aggregations