if (update.hasWaveletSnapshot()) { openListener.onSnapshot(waveletId, update.getWaveletSnapshot(), lastCommittedVersion, currentVersion); } else if (update.hasDeltas() || update.hasLastCommittedVersion() ||
viewListener.onSnapshot(WAVELET_ID_1, update, null, null); fail("Expected exception on bad first message"); } catch (ChannelException ex) {
viewListener.onSnapshot(WAVELET_ID_1, update, null, null); fail("Expected exception on bad first message"); } catch (ChannelException ex) {
public void testNewWaveletSuppressesSnapshot() throws ChannelException { MockViewChannel view = openMux(); ViewChannel.Listener viewListener = view.takeListener(); viewListener.onConnected(); triggerAndCheckOpenFinished(viewListener); ConnectedChannel ch = createOperationChannel(WAVELET_ID_1, USER_ID); // Send and ack first op. checkSendDelta(view, ch.channel, HashedVersion.unsigned(0), WAVELET_ID_1); view.checkExpectationsSatisified(); checkAckDelta(view, ch.channel, ch.listener, 1, 1, SIG1); // Drop the empty snapshot sent by the server. ObservableWaveletData snapshot = createSnapshot(WAVELET_ID_1, 0, NOSIG); HashedVersion committed = HashedVersion.unsigned(0); viewListener.onSnapshot(snapshot.getWaveletId(), snapshot, committed, null); muxListener.verifyNoMoreInteractions(); // Now CC should have sent the first client delta so it's acked. view.checkExpectationsSatisified(); checkReceiveAndSend(viewListener, view, ch, WAVELET_ID_1, 1); view.checkExpectationsSatisified(); muxListener.verifyNoMoreInteractions(); }
public void testReceivedSnapshotClobbersOnlyAppropriateChannel() throws ChannelException { MockViewChannel viewChannel = openMux(); ViewChannel.Listener viewListener = viewChannel.takeListener(); muxListener.verifyNoMoreInteractions(); viewListener.onConnected(); ObservableWaveletData snapshotUpdate = createSnapshot(WAVELET_ID_1, 1, SIG1); HashedVersion committed = HashedVersion.unsigned(0); viewListener.onSnapshot(WAVELET_ID_1, snapshotUpdate, committed, null); OperationChannel ch = muxListener.verifyOperationChannelCreated(snapshotUpdate, Accessibility.READ_WRITE); // This snapshot should clobber wavelet 1's channel committed = HashedVersion.of(1, SIG1); checkSendClobberingSnapshot(viewListener, ch, snapshotUpdate, committed); muxListener.verifyNoMoreInteractions(); // This snapshot should only create a new channel and nothing else viewListener.onSnapshot(WAVELET_ID_2, snapshotUpdate, committed, null); muxListener.verifyOperationChannelCreated(snapshotUpdate, Accessibility.READ_WRITE); muxListener.verifyNoMoreInteractions(); }
public void testMuxFailsAfterChannelCorrupt() 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); // Receive a message that should not be received. ObservableWaveletData update = createSnapshot(WAVELET_ID_1, 1, SIG1); view.expectClose(); try { viewListener.onSnapshot(WAVELET_ID_1, update, null, null); fail("Expected exception corruption"); } catch (ChannelException ex) { // Expected } }
public void testReceivedSnapshotClobbersExistingChannel() throws ChannelException { MockViewChannel viewChannel = openMux(); ViewChannel.Listener viewListener = viewChannel.takeListener(); muxListener.verifyNoMoreInteractions(); viewListener.onConnected(); ObservableWaveletData snapshotUpdate = createSnapshot(WAVELET_ID_1, 1, SIG1); HashedVersion committed = HashedVersion.unsigned(0); viewListener.onSnapshot(WAVELET_ID_1, snapshotUpdate, committed, null); OperationChannel ch = muxListener.verifyOperationChannelCreated(snapshotUpdate, Accessibility.READ_WRITE); // The second snapshot may have a non-zero version. committed = HashedVersion.unsigned(1); ch = checkSendClobberingSnapshot(viewListener, ch, snapshotUpdate, committed); // Repeat the clobbering with a higher version. committed = HashedVersion.unsigned(2000); checkSendClobberingSnapshot(viewListener, ch, snapshotUpdate, committed); }
public void testNewWaveletSuppressesSnapshot() throws ChannelException { MockViewChannel view = openMux(); ViewChannel.Listener viewListener = view.takeListener(); viewListener.onConnected(); triggerAndCheckOpenFinished(viewListener); ConnectedChannel ch = createOperationChannel(WAVELET_ID_1, USER_ID); // Send and ack first op. checkSendDelta(view, ch.channel, HashedVersion.unsigned(0), WAVELET_ID_1); view.checkExpectationsSatisified(); checkAckDelta(view, ch.channel, ch.listener, 1, 1, SIG1); // Drop the empty snapshot sent by the server. ObservableWaveletData snapshot = createSnapshot(WAVELET_ID_1, 0, NOSIG); HashedVersion committed = HashedVersion.unsigned(0); viewListener.onSnapshot(snapshot.getWaveletId(), snapshot, committed, null); muxListener.verifyNoMoreInteractions(); // Now CC should have sent the first client delta so it's acked. view.checkExpectationsSatisified(); checkReceiveAndSend(viewListener, view, ch, WAVELET_ID_1, 1); view.checkExpectationsSatisified(); muxListener.verifyNoMoreInteractions(); }
public void testMuxFailsAfterChannelCorrupt() 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); // Receive a message that should not be received. ObservableWaveletData update = createSnapshot(WAVELET_ID_1, 1, SIG1); view.expectClose(); try { viewListener.onSnapshot(WAVELET_ID_1, update, null, null); fail("Expected exception corruption"); } catch (ChannelException ex) { // Expected } }
public void testReceivedSnapshotClobbersOnlyAppropriateChannel() throws ChannelException { MockViewChannel viewChannel = openMux(); ViewChannel.Listener viewListener = viewChannel.takeListener(); muxListener.verifyNoMoreInteractions(); viewListener.onConnected(); ObservableWaveletData snapshotUpdate = createSnapshot(WAVELET_ID_1, 1, SIG1); HashedVersion committed = HashedVersion.unsigned(0); viewListener.onSnapshot(WAVELET_ID_1, snapshotUpdate, committed, null); OperationChannel ch = muxListener.verifyOperationChannelCreated(snapshotUpdate, Accessibility.READ_WRITE); // This snapshot should clobber wavelet 1's channel committed = HashedVersion.of(1, SIG1); checkSendClobberingSnapshot(viewListener, ch, snapshotUpdate, committed); muxListener.verifyNoMoreInteractions(); // This snapshot should only create a new channel and nothing else viewListener.onSnapshot(WAVELET_ID_2, snapshotUpdate, committed, null); muxListener.verifyOperationChannelCreated(snapshotUpdate, Accessibility.READ_WRITE); muxListener.verifyNoMoreInteractions(); }
public void testReceivedSnapshotClobbersExistingChannel() throws ChannelException { MockViewChannel viewChannel = openMux(); ViewChannel.Listener viewListener = viewChannel.takeListener(); muxListener.verifyNoMoreInteractions(); viewListener.onConnected(); ObservableWaveletData snapshotUpdate = createSnapshot(WAVELET_ID_1, 1, SIG1); HashedVersion committed = HashedVersion.unsigned(0); viewListener.onSnapshot(WAVELET_ID_1, snapshotUpdate, committed, null); OperationChannel ch = muxListener.verifyOperationChannelCreated(snapshotUpdate, Accessibility.READ_WRITE); // The second snapshot may have a non-zero version. committed = HashedVersion.unsigned(1); ch = checkSendClobberingSnapshot(viewListener, ch, snapshotUpdate, committed); // Repeat the clobbering with a higher version. committed = HashedVersion.unsigned(2000); checkSendClobberingSnapshot(viewListener, ch, snapshotUpdate, committed); }
private ConnectedChannel connectChannelSnapshot(ViewChannel.Listener viewListener, ObservableWaveletData snapshot, HashedVersion committed) throws ChannelException { viewListener.onSnapshot(snapshot.getWaveletId(), snapshot, committed, null); OperationChannel channel = muxListener.verifyOperationChannelCreated(snapshot, Accessibility.READ_WRITE); MockOperationChannelListener listener = new MockOperationChannelListener(); channel.setListener(listener); return new ConnectedChannel(channel, listener); }
private OperationChannel checkSendClobberingSnapshot(ViewChannel.Listener viewListener, OperationChannel channelToClobber, ObservableWaveletData snapshotUpdate, HashedVersion committed) throws ChannelException { viewListener.onSnapshot(WAVELET_ID_1, snapshotUpdate, committed, null); muxListener.verifyOperationChannelRemoved(channelToClobber); return muxListener.verifyOperationChannelCreated(snapshotUpdate, Accessibility.READ_WRITE); }
private ConnectedChannel connectChannelSnapshot(ViewChannel.Listener viewListener, ObservableWaveletData snapshot, HashedVersion committed) throws ChannelException { viewListener.onSnapshot(snapshot.getWaveletId(), snapshot, committed, null); OperationChannel channel = muxListener.verifyOperationChannelCreated(snapshot, Accessibility.READ_WRITE); MockOperationChannelListener listener = new MockOperationChannelListener(); channel.setListener(listener); return new ConnectedChannel(channel, listener); }
private OperationChannel checkSendClobberingSnapshot(ViewChannel.Listener viewListener, OperationChannel channelToClobber, ObservableWaveletData snapshotUpdate, HashedVersion committed) throws ChannelException { viewListener.onSnapshot(WAVELET_ID_1, snapshotUpdate, committed, null); muxListener.verifyOperationChannelRemoved(channelToClobber); return muxListener.verifyOperationChannelCreated(snapshotUpdate, Accessibility.READ_WRITE); }