/** * Test simple reconnect. */ public void testSimpleReconnect() throws ChannelException { connectChannel(10, SIG1); listener.checkOpsReceived(0); // Now disconnect server-side, forcing a reconnect. reconnectChannel(10, SIG1); // No new messages. listener.checkOpsReceived(0); checkExpectationsSatisfied(); }
/** * Test simple reconnect. */ public void testSimpleReconnect() throws ChannelException { connectChannel(10, SIG1); listener.checkOpsReceived(0); // Now disconnect server-side, forcing a reconnect. reconnectChannel(10, SIG1); // No new messages. listener.checkOpsReceived(0); checkExpectationsSatisfied(); }
/** * Test a simple connect. */ public void testConnectSuccess() throws ChannelException { connectChannel(10, SIG1); listener.checkOpsReceived(0); checkExpectationsSatisfied(); }
/** * Test a simple connect. */ public void testConnectSuccess() throws ChannelException { connectChannel(10, SIG1); listener.checkOpsReceived(0); checkExpectationsSatisfied(); }
/** * 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 a simple connect then successful disconnection. */ public void testConnectThenDisconnectSuccess() throws ChannelException { connectChannel(10, SIG1); listener.checkOpsReceived(0); // Disconnect operationChannel.reset(); checkExpectationsSatisfied(); }
/** * Test a simple connect then successful disconnection. */ public void testConnectThenDisconnectSuccess() throws ChannelException { connectChannel(10, SIG1); listener.checkOpsReceived(0); // Disconnect operationChannel.reset(); checkExpectationsSatisfied(); }
/** * Reconnects a view with a single operation channel and checks that the channel * is usable and expectations are satisfied. */ private void reconnectViewAndCheckEverythingStillWorks(MockViewChannel view, ConnectionInfo chInfo, ConnectedChannel ch) throws ChannelException { // Perform the reconnect. ViewChannel.Listener viewListener2 = reconnectView(view, chInfo); ch.listener.checkOpsReceived(0); // Check everything still works. checkReceiveAndSend(viewListener2, view, ch, WAVELET_ID_1, chInfo.initialVersion); view.checkExpectationsSatisified(); } }
/** * Reconnects a view with a single operation channel and checks that the channel * is usable and expectations are satisfied. */ private void reconnectViewAndCheckEverythingStillWorks(MockViewChannel view, ConnectionInfo chInfo, ConnectedChannel ch) throws ChannelException { // Perform the reconnect. ViewChannel.Listener viewListener2 = reconnectView(view, chInfo); ch.listener.checkOpsReceived(0); // Check everything still works. checkReceiveAndSend(viewListener2, view, ch, WAVELET_ID_1, chInfo.initialVersion); view.checkExpectationsSatisified(); } }
/** * 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(); }
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()); }
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(); }
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(); }
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()); }
public void testMuxCloseClosesViewAndChannels() throws ChannelException { final ConnectionInfo chInfo1 = new ConnectionInfo(WAVELET_ID_1, 1, SIG1); final ConnectionInfo chInfo2 = new ConnectionInfo(WAVELET_ID_2, 20, SIG2); MockViewChannel view = openMux(); ViewChannel.Listener viewListener = view.takeListener(); viewListener.onConnected(); // Receive initial snapshots. ConnectedChannel ch1 = connectChannelSnapshot(viewListener, chInfo1); ConnectedChannel ch2 = connectChannelSnapshot(viewListener, chInfo2); triggerAndCheckOpenFinished(viewListener); view.expectClose(); mux.close(); // Receive lagging delta from view channel, expect nothing. final List<TransformedWaveletDelta> update = createServerDeltaList(1, 1, SIG4); viewListener.onUpdate(chInfo1.waveletId, update, null, null); ch1.listener.checkOpsReceived(0); view.checkExpectationsSatisified(); muxListener.verifyNoMoreInteractions(); }
public void testMuxCloseClosesViewAndChannels() throws ChannelException { final ConnectionInfo chInfo1 = new ConnectionInfo(WAVELET_ID_1, 1, SIG1); final ConnectionInfo chInfo2 = new ConnectionInfo(WAVELET_ID_2, 20, SIG2); MockViewChannel view = openMux(); ViewChannel.Listener viewListener = view.takeListener(); viewListener.onConnected(); // Receive initial snapshots. ConnectedChannel ch1 = connectChannelSnapshot(viewListener, chInfo1); ConnectedChannel ch2 = connectChannelSnapshot(viewListener, chInfo2); triggerAndCheckOpenFinished(viewListener); view.expectClose(); mux.close(); // Receive lagging delta from view channel, expect nothing. final List<TransformedWaveletDelta> update = createServerDeltaList(1, 1, SIG4); viewListener.onUpdate(chInfo1.waveletId, update, null, null); ch1.listener.checkOpsReceived(0); view.checkExpectationsSatisified(); muxListener.verifyNoMoreInteractions(); }