use of org.apache.cayenne.remote.MockClientConnection 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);
ServerModule.contributeProperties(binder).put(Constants.SERVER_CONTEXTS_SYNC_PROPERTY, String.valueOf(true));
}
};
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());
}
Aggregations