use of org.apache.cayenne.di.Binder in project cayenne by apache.
the class ClientRuntimeBuilderTest method testDataChannel_NoChannelEvents.
@Test
public void testDataChannel_NoChannelEvents() {
Map<String, String> properties1 = new HashMap<>();
properties1.put(ClientConstants.ROP_CHANNEL_EVENTS_PROPERTY, "true");
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);
ServerModule.contributeProperties(binder).putAll(properties1);
}
};
Injector injector = DIBootstrap.createInjector(module);
DataChannel channel = injector.getInstance(DataChannel.class);
ClientChannel clientChannel = (ClientChannel) channel;
assertTrue(clientChannel.isChannelEventsEnabled());
}
use of org.apache.cayenne.di.Binder in project cayenne by apache.
the class ClientRuntimeBuilderTest method testClientConnection.
@Test
public void testClientConnection() {
Map<String, String> properties1 = new HashMap<>();
properties1.put(ClientConstants.ROP_SERVICE_URL_PROPERTY, "http://localhost/YuM");
ClientModule module = new ClientModule() {
@Override
public void configure(Binder binder) {
super.configure(binder);
ServerModule.contributeProperties(binder).putAll(properties1);
}
};
Injector injector = DIBootstrap.createInjector(module);
ClientConnection connection = injector.getInstance(ClientConnection.class);
assertNotNull(connection);
assertTrue(connection instanceof HttpClientConnection);
assertSame("Connection must be a singleton", connection, injector.getInstance(ClientConnection.class));
}
use of org.apache.cayenne.di.Binder in project cayenne by apache.
the class JGroupsModuleIT 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 JGroupsModule(), configModule);
EventBridge bridge = injector.getInstance(EventBridge.class);
assertThat(bridge, instanceOf(JavaGroupsBridge.class));
EventBridge bridge2 = injector.getInstance(EventBridge.class);
assertThat(bridge2, instanceOf(JavaGroupsBridge.class));
assertNotSame(bridge, bridge2);
}
use of org.apache.cayenne.di.Binder in project cayenne by apache.
the class JavaGroupsBridgeProviderTest method testUseProperties.
@Test
public void testUseProperties() throws Exception {
Module module = binder -> {
JGroupsModule.contributeMulticastAddress(binder, MCAST_ADDRESS_TEST);
JGroupsModule.contributeMulticastPort(binder, Integer.parseInt(MCAST_PORT_TEST));
JGroupsModule.contributeConfigUrl(binder, CONFIG_URL_TEST);
};
Injector injector = DIBootstrap.createInjector(new DefaultBindings(), new JGroupsModule(), module);
JavaGroupsBridge bridge = (JavaGroupsBridge) injector.getInstance(EventBridge.class);
assertEquals(MCAST_ADDRESS_TEST, bridge.getMulticastAddress());
assertEquals(MCAST_PORT_TEST, bridge.getMulticastPort());
assertEquals(CONFIG_URL_TEST, bridge.getConfigURL());
}
Aggregations