@Override public void close() { Object[] expected = expectations.remove(); assertEquals(expected[0], Method.CLOSE); // Emulate the real view channel in sending close() synchronously. for (Listener l : listeners) { l.onClosed(); } }
@Override public void close() { Object[] expected = expectations.remove(); assertEquals(expected[0], Method.CLOSE); // Emulate the real view channel in sending close() synchronously. for (Listener l : listeners) { l.onClosed(); } }
openListener.onClosed();
viewListener.onClosed();
viewListener.onClosed();
viewListener.onClosed();
viewListener.onClosed();
public void testMuxReconnectsAgainAfterReconnectFailure() throws ChannelException { final ConnectionInfo chInfo = 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, chInfo); triggerAndCheckOpenFinished(viewListener); // Disconnect, expect reconnection. view.expectClose(); MockViewChannel view2 = viewFactory.expectCreate(); view2.expectOpen(IdFilters.ALL_IDS, createKnownVersions(WAVELET_ID_1, 1, SIG1)); viewListener.onClosed(); ViewChannel.Listener viewListener2 = view2.takeListener(); // Disconnect, expect reconnection again. view2.expectClose(); MockViewChannel view3 = viewFactory.expectCreate(); view3.expectOpen(IdFilters.ALL_IDS, createKnownVersions(WAVELET_ID_1, 1, SIG1)); viewListener2.onClosed(); view2.checkExpectationsSatisified(); view3.checkExpectationsSatisified(); muxListener.verifyNoMoreInteractions(); }
public void testMuxReconnectsAgainAfterReconnectFailure() throws ChannelException { final ConnectionInfo chInfo = 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, chInfo); triggerAndCheckOpenFinished(viewListener); // Disconnect, expect reconnection. view.expectClose(); MockViewChannel view2 = viewFactory.expectCreate(); view2.expectOpen(IdFilters.ALL_IDS, createKnownVersions(WAVELET_ID_1, 1, SIG1)); viewListener.onClosed(); ViewChannel.Listener viewListener2 = view2.takeListener(); // Disconnect, expect reconnection again. view2.expectClose(); MockViewChannel view3 = viewFactory.expectCreate(); view3.expectOpen(IdFilters.ALL_IDS, createKnownVersions(WAVELET_ID_1, 1, SIG1)); viewListener2.onClosed(); view2.checkExpectationsSatisified(); view3.checkExpectationsSatisified(); muxListener.verifyNoMoreInteractions(); }
/** * Sends a ChannelException to a view listener and expects a new view to be opened * to reconnect it. * * @return the new mock view */ private MockViewChannel failViewAndExpectReconnection(ViewChannel.Listener viewListenerToFail, MockViewChannel failingView, String failureReason, Map<WaveletId, List<HashedVersion>> expectedReconnectionSigs) { failingView.expectClose(); MockViewChannel newView = viewFactory.expectCreate(); newView.expectOpen(IdFilters.ALL_IDS, expectedReconnectionSigs); viewListenerToFail.onException(new ChannelException(failureReason, Recoverable.RECOVERABLE)); viewListenerToFail.onClosed(); failingView.checkExpectationsSatisified(); return newView; }
/** * Sends a ChannelException to a view listener and expects a new view to be opened * to reconnect it. * * @return the new mock view */ private MockViewChannel failViewAndExpectReconnection(ViewChannel.Listener viewListenerToFail, MockViewChannel failingView, String failureReason, Map<WaveletId, List<HashedVersion>> expectedReconnectionSigs) { failingView.expectClose(); MockViewChannel newView = viewFactory.expectCreate(); newView.expectOpen(IdFilters.ALL_IDS, expectedReconnectionSigs); viewListenerToFail.onException(new ChannelException(failureReason, Recoverable.RECOVERABLE)); viewListenerToFail.onClosed(); failingView.checkExpectationsSatisified(); return newView; }