@Override public void tearDown() { listener.clear(); }
@Override public void tearDown() { listener.clear(); }
/** * Acks a delta and checks that the fake version-incrementing op is received * from the operation channel. */ private static void checkAckDelta(MockViewChannel viewChannel, OperationChannel opChannel, MockOperationChannelListener opChannelListener, int ackedOps, long version, byte[] signature) throws ChannelException { viewChannel.ackSubmit(ackedOps, version, signature); opChannelListener.checkOpsReceived(1); opChannelListener.clear(); assertNotNull(opChannel.receive()); opChannelListener.checkOpsReceived(0); opChannelListener.clear(); }
/** * Acks a delta and checks that the fake version-incrementing op is received * from the operation channel. */ private static void checkAckDelta(MockViewChannel viewChannel, OperationChannel opChannel, MockOperationChannelListener opChannelListener, int ackedOps, long version, byte[] signature) throws ChannelException { viewChannel.ackSubmit(ackedOps, version, signature); opChannelListener.checkOpsReceived(1); opChannelListener.clear(); assertNotNull(opChannel.receive()); opChannelListener.checkOpsReceived(0); opChannelListener.clear(); }
/** * Test simple NACK and onDelta. * Nack is not supposed to happen, so it should be death. */ public void testSimpleNackAndReceive() throws Exception { final int initialVersion = 42; connectChannel(initialVersion, SIG1); sendAndCheckRandomOp(operationChannel, initialVersion, SIG1); listener.clear(); try { operationChannel.onNack(ResponseCode.OK, null, 43); fail("Should have thrown ChannelException"); } catch (ChannelException expected) { } checkExpectationsSatisfied(); }
/** * Test simple NACK and onDelta. * Nack is not supposed to happen, so it should be death. */ public void testSimpleNackAndReceive() throws Exception { final int initialVersion = 42; connectChannel(initialVersion, SIG1); sendAndCheckRandomOp(operationChannel, initialVersion, SIG1); listener.clear(); try { operationChannel.onNack(ResponseCode.OK, null, 43); fail("Should have thrown ChannelException"); } catch (ChannelException expected) { } checkExpectationsSatisfied(); }
private static void checkReceiveDelta(ViewChannel.Listener viewListener, OperationChannel opChannel, MockOperationChannelListener opChannelListener, WaveletId waveletId, long version, int numOps, byte[] signature) throws ChannelException { // Receive delta from view channel, expect ops on op channel. final List<TransformedWaveletDelta> update = createServerDeltaList(version, numOps, signature); viewListener.onUpdate(waveletId, update, null, null); opChannelListener.checkOpsReceived(1); opChannelListener.clear(); for (int i = 0; i < numOps; ++i) { assertNotNull(opChannel.receive()); } assertNull(opChannel.receive()); }
private static void checkReceiveDelta(ViewChannel.Listener viewListener, OperationChannel opChannel, MockOperationChannelListener opChannelListener, WaveletId waveletId, long version, int numOps, byte[] signature) throws ChannelException { // Receive delta from view channel, expect ops on op channel. final List<TransformedWaveletDelta> update = createServerDeltaList(version, numOps, signature); viewListener.onUpdate(waveletId, update, null, null); opChannelListener.checkOpsReceived(1); opChannelListener.clear(); for (int i = 0; i < numOps; ++i) { assertNotNull(opChannel.receive()); } assertNull(opChannel.receive()); }
/** * Test receiving a simple delta that was committed. */ public void testSimpleReceive() throws ChannelException { final int initialVersion = 42; connectChannel(initialVersion, SIG1); operationChannel.onDelta(createRandomTransformedDelta(initialVersion, 1, SIG2)); listener.checkOpsReceived(1); listener.clear(); assertNotNull(operationChannel.receive()); listener.checkOpsReceived(0); // TODO(anorth): test OnCommit by mocking CC operationChannel.onCommit(initialVersion + 1); checkExpectationsSatisfied(); }
/** * Test receiving a simple delta that was committed. */ public void testSimpleReceive() throws ChannelException { final int initialVersion = 42; connectChannel(initialVersion, SIG1); operationChannel.onDelta(createRandomTransformedDelta(initialVersion, 1, SIG2)); listener.checkOpsReceived(1); listener.clear(); assertNotNull(operationChannel.receive()); listener.checkOpsReceived(0); // TODO(anorth): test OnCommit by mocking CC operationChannel.onCommit(initialVersion + 1); checkExpectationsSatisfied(); }
public void testSimpleSendAndAck() throws Exception { final int initialVersion = 42; connectChannel(initialVersion, SIG1); sendAndCheckRandomOp(operationChannel, initialVersion, SIG1); listener.clear(); HashedVersion signature = HashedVersion.of(43, SIG2); operationChannel.onAck(1, signature); // Listener should receive a version update op. listener.checkOpsReceived(1); WaveletOperation op = operationChannel.receive(); WaveletOperationContext context = op.getContext(); assertEquals(1, context.getVersionIncrement()); assertEquals(signature, context.getHashedVersion()); }
public void testSimpleSendAndAck() throws Exception { final int initialVersion = 42; connectChannel(initialVersion, SIG1); sendAndCheckRandomOp(operationChannel, initialVersion, SIG1); listener.clear(); HashedVersion signature = HashedVersion.of(43, SIG2); operationChannel.onAck(1, signature); // Listener should receive a version update op. listener.checkOpsReceived(1); WaveletOperation op = operationChannel.receive(); WaveletOperationContext context = op.getContext(); assertEquals(1, context.getVersionIncrement()); assertEquals(signature, context.getHashedVersion()); }
listener.clear();
public void testReconnectAfterCommit() throws Exception { final int initialVersion = 42; connectChannel(initialVersion, SIG1); sendAndCheckRandomOp(operationChannel, 42, SIG1); operationChannel.onAck(1, HashedVersion.of(43, SIG2)); // Take the fake op resulting from ack that updates version info. listener.checkOpsReceived(1); assertNotNull(operationChannel.receive()); listener.clear(); operationChannel.onCommit(43); // Causes cc to remove old operations from memory reconnectChannel(43, SIG2); // Receive next delta. TransformedWaveletDelta delta = createRandomTransformedDelta(43, 1, SIG3); operationChannel.onDelta(delta); listener.checkOpsReceived(1); assertNotNull(operationChannel.receive()); assertNull(operationChannel.receive()); checkExpectationsSatisfied(); }
listener.clear();
public void testReconnectAfterCommit() throws Exception { final int initialVersion = 42; connectChannel(initialVersion, SIG1); sendAndCheckRandomOp(operationChannel, 42, SIG1); operationChannel.onAck(1, HashedVersion.of(43, SIG2)); // Take the fake op resulting from ack that updates version info. listener.checkOpsReceived(1); assertNotNull(operationChannel.receive()); listener.clear(); operationChannel.onCommit(43); // Causes cc to remove old operations from memory reconnectChannel(43, SIG2); // Receive next delta. TransformedWaveletDelta delta = createRandomTransformedDelta(43, 1, SIG3); operationChannel.onDelta(delta); listener.checkOpsReceived(1); assertNotNull(operationChannel.receive()); assertNull(operationChannel.receive()); checkExpectationsSatisfied(); }
listener.clear();
listener.clear();