Search in sources :

Example 1 with MockDataChannel

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
    }
}
Also used : CayenneRuntimeException(org.apache.cayenne.CayenneRuntimeException) ClientMessage(org.apache.cayenne.remote.ClientMessage) MockDataChannel(org.apache.cayenne.MockDataChannel) Test(org.junit.Test)

Example 2 with MockDataChannel

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]);
}
Also used : QueryMessage(org.apache.cayenne.remote.QueryMessage) MockQuery(org.apache.cayenne.query.MockQuery) Query(org.apache.cayenne.query.Query) EntityResolver(org.apache.cayenne.map.EntityResolver) ObjectContext(org.apache.cayenne.ObjectContext) MockQuery(org.apache.cayenne.query.MockQuery) MockDataChannel(org.apache.cayenne.MockDataChannel) Test(org.junit.Test)

Example 3 with MockDataChannel

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());
}
Also used : MockDataChannel(org.apache.cayenne.MockDataChannel) DataChannel(org.apache.cayenne.DataChannel) LocalConnection(org.apache.cayenne.remote.service.LocalConnection) MockDataChannel(org.apache.cayenne.MockDataChannel) Test(org.junit.Test)

Example 4 with MockDataChannel

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()));
}
Also used : BootstrapMessage(org.apache.cayenne.remote.BootstrapMessage) EntityResolver(org.apache.cayenne.map.EntityResolver) MockDataChannel(org.apache.cayenne.MockDataChannel) Test(org.junit.Test)

Aggregations

MockDataChannel (org.apache.cayenne.MockDataChannel)4 Test (org.junit.Test)4 EntityResolver (org.apache.cayenne.map.EntityResolver)2 CayenneRuntimeException (org.apache.cayenne.CayenneRuntimeException)1 DataChannel (org.apache.cayenne.DataChannel)1 ObjectContext (org.apache.cayenne.ObjectContext)1 MockQuery (org.apache.cayenne.query.MockQuery)1 Query (org.apache.cayenne.query.Query)1 BootstrapMessage (org.apache.cayenne.remote.BootstrapMessage)1 ClientMessage (org.apache.cayenne.remote.ClientMessage)1 QueryMessage (org.apache.cayenne.remote.QueryMessage)1 LocalConnection (org.apache.cayenne.remote.service.LocalConnection)1