private ConnectedChannel createOperationChannel(WaveletId waveletId, ParticipantId address) { mux.createOperationChannel(waveletId, address); OperationChannel channel = muxListener.verifyOperationChannelCreated(createSnapshot( WAVELET_ID_1, 0, NOSIG), Accessibility.READ_WRITE); MockOperationChannelListener channelListener = new MockOperationChannelListener(); channel.setListener(channelListener); return new ConnectedChannel(channel, channelListener); }
public void testMuxOpenOpensView() { // Connect to the server. MockViewChannel viewChannel = viewFactory.expectCreate(); viewChannel.expectOpen(IdFilters.ALL_IDS, NO_KNOWN_WAVELETS); mux.open(muxListener, IdFilters.ALL_IDS); viewChannel.takeListener().onConnected(); viewChannel.checkExpectationsSatisified(); muxListener.verifyNoMoreInteractions(); }
public void testMuxCloseClosesAllUnsavedDataUpdaters() { mux.open(muxListener, IdFilters.ALL_IDS); MockOperationChannelListener listener1 = new MockOperationChannelListener(); MockOperationChannelListener listener2 = new MockOperationChannelListener(); OperationChannel ch1 = createOperationChannel(WAVELET_ID_1, USER_NAME); OperationChannel ch2 = createOperationChannel(WAVELET_ID_2, USER_NAME); ch1.setListener(listener1); ch2.setListener(listener2); mux.close(); assertEquals(2, fakeUnsavedDataListener.closeCalls); }
public void testReceivedSnapshotOpensChannel() throws ChannelException { final ConnectionInfo chInfo = new ConnectionInfo(WAVELET_ID_1, 1, SIG1); MockViewChannel viewChannel = openMux(); ViewChannel.Listener viewListener = viewChannel.takeListener(); muxListener.verifyNoMoreInteractions(); viewListener.onConnected(); ConnectedChannel opChannel = connectChannelSnapshot(viewListener, chInfo); triggerAndCheckOpenFinished(viewListener); viewChannel.checkExpectationsSatisified(); muxListener.verifyNoMoreInteractions(); // Also proves that an expected (initial) snapshot doesn't clobber the channel }
public void testSubmitDeltaOnClosedChannelThrowsIllegalStateException() { open(); close(); // submit a delta should fail try { channel.submitDelta(WAVELET_ID, emptyDelta(), new MockSubmitListener()); fail("Should not be able to submit on a closed channel"); } catch (IllegalStateException ex) { // expect exception } }
private ConnectedChannel expectConnectedChannel(ObservableWaveletData knownSnapshot, Accessibility accessibility) { OperationChannel channel = muxListener.verifyOperationChannelCreated(knownSnapshot, accessibility); MockOperationChannelListener listener = new MockOperationChannelListener(); channel.setListener(listener); return new ConnectedChannel(channel, listener); }
@Override public void setUp() { waveletChannel = new MockWaveletChannel(); receiver = new MockReceiver(); deltaChannel = new WaveletDeltaChannelImpl(waveletChannel, logger); deltaChannel.reset(receiver); }
/** * Test a simple connect then successful disconnection. */ public void testConnectThenDisconnectSuccess() throws ChannelException { connectChannel(10, SIG1); listener.checkOpsReceived(0); // Disconnect operationChannel.reset(); checkExpectationsSatisfied(); }
private MockViewChannel openMux(IdFilter idFilter) { MockViewChannel viewChannel = viewFactory.expectCreate(); viewChannel.expectOpen(idFilter, NO_KNOWN_WAVELETS); mux.open(muxListener, idFilter); return viewChannel; }
/** * Tests a channel fails if it receives success before channel id. */ public void testSuccessBeforeChannelIdFails() { halfOpen(); channel.onSuccess("for testing"); viewOpenListener.expectedCall(MockViewChannelListener.MethodCall.ON_EXCEPTION); }
/** * Tests that when the client terminates the channel the receiver * is not notified. */ public void testClientResetTerminatesSilently() throws ChannelException { checkedConnectChannel(57); deltaChannel.reset(null); receiver.checkExpectationsSatisfied(); }
/** * Tests a channel closes if it receives failure before channel id. */ public void testFailureBeforeChannelIdClosesChannel() { halfOpen(); channel.onFailure("for testing"); viewOpenListener.expectedCall(MockViewChannelListener.MethodCall.ON_CLOSED); }
public void testReceivedSnapshotOpensChannel() throws ChannelException { final ConnectionInfo chInfo = new ConnectionInfo(WAVELET_ID_1, 1, SIG1); MockViewChannel viewChannel = openMux(); ViewChannel.Listener viewListener = viewChannel.takeListener(); muxListener.verifyNoMoreInteractions(); viewListener.onConnected(); ConnectedChannel opChannel = connectChannelSnapshot(viewListener, chInfo); triggerAndCheckOpenFinished(viewListener); viewChannel.checkExpectationsSatisified(); muxListener.verifyNoMoreInteractions(); // Also proves that an expected (initial) snapshot doesn't clobber the channel }
public void testMuxOpenOpensView() { // Connect to the server. MockViewChannel viewChannel = viewFactory.expectCreate(); viewChannel.expectOpen(IdFilters.ALL_IDS, NO_KNOWN_WAVELETS); mux.open(muxListener, IdFilters.ALL_IDS); viewChannel.takeListener().onConnected(); viewChannel.checkExpectationsSatisified(); muxListener.verifyNoMoreInteractions(); }
public void testMuxCloseClosesAllUnsavedDataUpdaters() { mux.open(muxListener, IdFilters.ALL_IDS); MockOperationChannelListener listener1 = new MockOperationChannelListener(); MockOperationChannelListener listener2 = new MockOperationChannelListener(); OperationChannel ch1 = createOperationChannel(WAVELET_ID_1, USER_NAME); OperationChannel ch2 = createOperationChannel(WAVELET_ID_2, USER_NAME); ch1.setListener(listener1); ch2.setListener(listener2); mux.close(); assertEquals(2, fakeUnsavedDataListener.closeCalls); }
private ConnectedChannel createOperationChannel(WaveletId waveletId, ParticipantId address) { mux.createOperationChannel(waveletId, address); OperationChannel channel = muxListener.verifyOperationChannelCreated(createSnapshot( WAVELET_ID_1, 0, NOSIG), Accessibility.READ_WRITE); MockOperationChannelListener channelListener = new MockOperationChannelListener(); channel.setListener(channelListener); return new ConnectedChannel(channel, channelListener); }
private ConnectedChannel expectConnectedChannel(ObservableWaveletData knownSnapshot, Accessibility accessibility) { OperationChannel channel = muxListener.verifyOperationChannelCreated(knownSnapshot, accessibility); MockOperationChannelListener listener = new MockOperationChannelListener(); channel.setListener(listener); return new ConnectedChannel(channel, listener); }
/** * Test a simple connect then successful disconnection. */ public void testConnectThenDisconnectSuccess() throws ChannelException { connectChannel(10, SIG1); listener.checkOpsReceived(0); // Disconnect operationChannel.reset(); checkExpectationsSatisfied(); }
/** * Tests a channel fails if it receives success before channel id. */ public void testSuccessBeforeChannelIdFails() { halfOpen(); channel.onSuccess("for testing"); viewOpenListener.expectedCall(MockViewChannelListener.MethodCall.ON_EXCEPTION); }
/** * Tests that when the client terminates the channel the receiver * is not notified. */ public void testClientResetTerminatesSilently() throws ChannelException { checkedConnectChannel(57); deltaChannel.reset(null); receiver.checkExpectationsSatisfied(); }