use of org.apache.cayenne.MockDataChannel in project cayenne by apache.
the class DispatchHelperTest method testUnknownMessage.
@Test
public void testUnknownMessage() {
try {
DispatchHelper.dispatch(new MockDataChannel(), mock(ClientMessage.class));
fail("Unknown message must have failed");
} catch (CayenneRuntimeException e) {
// expected
}
}
use of org.apache.cayenne.MockDataChannel in project cayenne by apache.
the class ClientServerChannelIT method testOnQuery.
@Test
public void testOnQuery() {
final boolean[] genericDone = new boolean[1];
MockDataChannel parent = new MockDataChannel(new EntityResolver()) {
@Override
public QueryResponse onQuery(ObjectContext context, Query query) {
genericDone[0] = true;
return super.onQuery(context, query);
}
};
DataContext context = (DataContext) runtime.newContext(parent);
QueryMessage message = new QueryMessage(new MockQuery());
new ClientServerChannel(context).onQuery(null, message.getQuery());
assertTrue(genericDone[0]);
}
use of org.apache.cayenne.MockDataChannel 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());
}
use of org.apache.cayenne.MockDataChannel in project cayenne by apache.
the class DispatchHelperTest method testBootstrapMessage.
@Test
public void testBootstrapMessage() {
EntityResolver resolver = new EntityResolver();
MockDataChannel channel = new MockDataChannel(resolver);
assertSame(resolver.getClientEntityResolver(), DispatchHelper.dispatch(channel, new BootstrapMessage()));
}
Aggregations