/** * 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(); }
public void testMuxReconnectsAfterDisconnectWithOutstandingSubmit() throws ChannelException { final ConnectionInfo chInfo1 = new ConnectionInfo(WAVELET_ID_1, 1, SIG1); MockViewChannel view = openMux(); muxListener.verifyNoMoreInteractions(); ViewChannel.Listener viewListener = view.takeListener(); viewListener.onConnected(); // Receive initial snapshots. ConnectedChannel ch = connectChannelSnapshot(viewListener, chInfo1); triggerAndCheckOpenFinished(viewListener); // Send but don't ack delta. WaveletDelta delta = checkSendDelta(view, ch.channel, chInfo1.initialHashedVersion, WAVELET_ID_1); // Reconnect channel. MockViewChannel view2 = failViewAndExpectReconnection(viewListener, view, "View failed with outstanding submit", createKnownVersions(WAVELET_ID_1, 1, SIG1)); // Expect retransmit of the sent delta after reconnect. view2.expectSubmitDelta(WAVELET_ID_1, delta); ViewChannel.Listener viewListener2 = reconnectView(view2, chInfo1); muxListener.verifyNoMoreInteractions(); // No callback on reconnection. checkAckDelta(view2, ch.channel, ch.listener, 1, chInfo1.initialVersion + 1, SIG1); checkReceiveAndSend(viewListener2, view2, ch, WAVELET_ID_1, chInfo1.initialVersion + 1); // If the submit is then acked, it should be ignored. view.ackSubmit(1, chInfo1.initialVersion + 1, SIG5); view.checkExpectationsSatisified(); view2.checkExpectationsSatisified(); ch.listener.checkOpsReceived(0); muxListener.verifyNoMoreInteractions(); }
public void testMuxReconnectsAfterDisconnectWithOutstandingSubmit() throws ChannelException { final ConnectionInfo chInfo1 = new ConnectionInfo(WAVELET_ID_1, 1, SIG1); MockViewChannel view = openMux(); muxListener.verifyNoMoreInteractions(); ViewChannel.Listener viewListener = view.takeListener(); viewListener.onConnected(); // Receive initial snapshots. ConnectedChannel ch = connectChannelSnapshot(viewListener, chInfo1); triggerAndCheckOpenFinished(viewListener); // Send but don't ack delta. WaveletDelta delta = checkSendDelta(view, ch.channel, chInfo1.initialHashedVersion, WAVELET_ID_1); // Reconnect channel. MockViewChannel view2 = failViewAndExpectReconnection(viewListener, view, "View failed with outstanding submit", createKnownVersions(WAVELET_ID_1, 1, SIG1)); // Expect retransmit of the sent delta after reconnect. view2.expectSubmitDelta(WAVELET_ID_1, delta); ViewChannel.Listener viewListener2 = reconnectView(view2, chInfo1); muxListener.verifyNoMoreInteractions(); // No callback on reconnection. checkAckDelta(view2, ch.channel, ch.listener, 1, chInfo1.initialVersion + 1, SIG1); checkReceiveAndSend(viewListener2, view2, ch, WAVELET_ID_1, chInfo1.initialVersion + 1); // If the submit is then acked, it should be ignored. view.ackSubmit(1, chInfo1.initialVersion + 1, SIG5); view.checkExpectationsSatisified(); view2.checkExpectationsSatisified(); ch.listener.checkOpsReceived(0); muxListener.verifyNoMoreInteractions(); }