use of org.apache.cayenne.remote.service.LocalConnection in project cayenne by apache.
the class ClientServerChannelProvider method get.
public ClientServerChannel get() throws ConfigurationException {
LocalConnection connection = (LocalConnection) clientRuntimeProvider.get().getConnection();
ClientServerDataChannelDecorator channelDecorator = (ClientServerDataChannelDecorator) connection.getChannel();
return (ClientServerChannel) channelDecorator.getDelegate();
}
use of org.apache.cayenne.remote.service.LocalConnection in project cayenne by apache.
the class ClientLocalRuntimeTest method testGetConnection.
@Test
public void testGetConnection() {
final DataContext serverContext = mock(DataContext.class);
Module serverModule = binder -> binder.bind(ObjectContextFactory.class).toInstance(new ObjectContextFactory() {
public ObjectContext createContext(DataChannel parent) {
return null;
}
public ObjectContext createContext() {
return serverContext;
}
});
ClientRuntime runtime = ClientRuntime.builder().local(DIBootstrap.createInjector(serverModule)).build();
ClientConnection connection = runtime.getConnection();
assertNotNull(connection);
assertTrue(connection instanceof LocalConnection);
LocalConnection localConnection = (LocalConnection) connection;
assertTrue(localConnection.getChannel() instanceof ClientServerChannel);
ClientServerChannel clientServerChannel = (ClientServerChannel) localConnection.getChannel();
assertSame(serverContext, clientServerChannel.getParentChannel());
}
use of org.apache.cayenne.remote.service.LocalConnection in project cayenne by apache.
the class LocalConnectionTest method testConstructors.
@Test
public void testConstructors() {
DataChannel handler1 = new MockDataChannel();
LocalConnection connector1 = new LocalConnection(handler1);
assertFalse(connector1.isSerializingMessages());
assertSame(handler1, connector1.getChannel());
DataChannel handler2 = new MockDataChannel();
LocalConnection connector2 = new LocalConnection(handler2, LocalConnection.JAVA_SERIALIZATION);
assertTrue(connector2.isSerializingMessages());
assertSame(handler2, connector2.getChannel());
}
Aggregations