Search in sources :

Example 1 with OLiveCommandResultListener

use of com.orientechnologies.orient.server.network.protocol.binary.OLiveCommandResultListener in project orientdb by orientechnologies.

the class OLiveCommandResultListenerTest method testSimpleMessageSend.

@Test
public void testSimpleMessageSend() throws IOException {
    OLiveCommandResultListener listener = new OLiveCommandResultListener(server, connection, 20, new TestResultListener());
    ORecordOperation op = new ORecordOperation(new ODocument(), ORecordOperation.CREATED);
    listener.onLiveResult(10, op);
    Mockito.verify(channelBinary, VerificationModeFactory.atLeastOnce()).writeBytes(Mockito.any(byte[].class));
}
Also used : ORecordOperation(com.orientechnologies.orient.core.db.record.ORecordOperation) OLiveCommandResultListener(com.orientechnologies.orient.server.network.protocol.binary.OLiveCommandResultListener) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) Test(org.junit.Test)

Example 2 with OLiveCommandResultListener

use of com.orientechnologies.orient.server.network.protocol.binary.OLiveCommandResultListener in project orientdb by orientechnologies.

the class OLiveCommandResultListenerTest method testNetworkError.

@Test
public void testNetworkError() throws IOException {
    Mockito.when(channelBinary.writeInt(Mockito.anyInt())).thenThrow(new IOException("Mock Exception"));
    OLiveCommandResultListener listener = new OLiveCommandResultListener(server, connection, 20, new TestResultListener());
    OLiveQueryHook.subscribe(10, rawListener, db);
    assertTrue(OLiveQueryHook.getOpsReference(db).getQueueThread().hasToken(10));
    ORecordOperation op = new ORecordOperation(new ODocument(), ORecordOperation.CREATED);
    listener.onLiveResult(10, op);
    assertFalse(OLiveQueryHook.getOpsReference(db).getQueueThread().hasToken(10));
}
Also used : ORecordOperation(com.orientechnologies.orient.core.db.record.ORecordOperation) OLiveCommandResultListener(com.orientechnologies.orient.server.network.protocol.binary.OLiveCommandResultListener) IOException(java.io.IOException) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) Test(org.junit.Test)

Aggregations

ORecordOperation (com.orientechnologies.orient.core.db.record.ORecordOperation)2 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)2 OLiveCommandResultListener (com.orientechnologies.orient.server.network.protocol.binary.OLiveCommandResultListener)2 Test (org.junit.Test)2 IOException (java.io.IOException)1