/** * Tests that closing the channel prevents updates that arrive later from * being passed to the channel listener. */ public void testCloseMasksFutureUpdatesFromOpenListener() { open(); close(); viewOpenListener.clear(); respondWithEmptyUpdate(WAVELET_ID); viewOpenListener.expectedNothing(); }
/** * Tests that closing the channel prevents updates that arrive later from * being passed to the channel listener. */ public void testCloseMasksFutureUpdatesFromOpenListener() { open(); close(); viewOpenListener.clear(); respondWithEmptyUpdate(WAVELET_ID); viewOpenListener.expectedNothing(); }
public void testOpenRpcTerminationAfterUpdatesAndCloseTriggersCloseCallback() { open(); respondWithEmptyUpdate(WAVELET_ID); viewOpenListener.clear(); close(); // The service should cause the open rpc to terminate successfully. terminateOpenRpcWithSuccess(); viewOpenListener.expectedCall(MockViewChannelListener.MethodCall.ON_CLOSED); }
public void testOpenRpcTerminationAfterUpdatesAndCloseTriggersCloseCallback() { open(); respondWithEmptyUpdate(WAVELET_ID); viewOpenListener.clear(); close(); // The service should cause the open rpc to terminate successfully. terminateOpenRpcWithSuccess(); viewOpenListener.expectedCall(MockViewChannelListener.MethodCall.ON_CLOSED); }
/** * Tests that updates that arrive before the end-marker are passed on as * updates, and that when the end-marker eventually arrives, open-finished * is triggered then. */ public void testUpdatesBeforeOpenFinishedStillTriggersOpenFinished() { halfOpen(); respondWithChannelId(); viewOpenListener.clear(); respondWithEmptyUpdate(WAVELET_ID); viewOpenListener.expectedCall(MockViewChannelListener.MethodCall.ON_UPDATE, WAVELET_ID); respondWithMarker(false); viewOpenListener.expectedCall(MockViewChannelListener.MethodCall.ON_OPEN_FINISHED); }
/** * Tests that updates that arrive before the end-marker are passed on as * updates, and that when the end-marker eventually arrives, open-finished * is triggered then. */ public void testUpdatesBeforeOpenFinishedStillTriggersOpenFinished() { halfOpen(); respondWithChannelId(); viewOpenListener.clear(); respondWithEmptyUpdate(WAVELET_ID); viewOpenListener.expectedCall(MockViewChannelListener.MethodCall.ON_UPDATE, WAVELET_ID); respondWithMarker(false); viewOpenListener.expectedCall(MockViewChannelListener.MethodCall.ON_OPEN_FINISHED); }
/** * Test that when everything is ok, we can connect, submit, create wavelet and disconnect. * This is not supposed to be a thorough test. */ public void testSunnyDayScenario() { open(); viewOpenListener.expectedCall(MockViewChannelListener.MethodCall.ON_CONNECTED); viewOpenListener.expectedCall(MockViewChannelListener.MethodCall.ON_OPEN_FINISHED); // pretend an update with update wavelet. Note we don't add any data in the wavelet // because it's not really relevant for the test. respondWithEmptyUpdate(WAVELET_ID); viewOpenListener.expectedCall(MockViewChannelListener.MethodCall.ON_UPDATE, WAVELET_ID); // Submit a delta and check that we have the right channel id remembered. MockSubmitListener submitListener = new MockSubmitListener(); channel.submitDelta(WAVELET_ID, emptyDelta(), submitListener); assertEquals(1, waveViewService.submits.size()); assertEquals(CHANNEL_ID, waveViewService.lastSubmit().channelId); // Return a success message on the submitted delta byte[] hash = new byte[] {1, 2, 3, 4}; respondToSubmit(HashedVersion.of(2, hash), 1, null, ResponseCode.OK); submitListener.expectedCall(MockSubmitListener.MethodCall.ON_SUCCESS, 1, HashedVersion.of(2, hash)); // Check disconnect channel.close(); assertEquals(1, waveViewService.closes.size()); waveViewService.lastClose().callback.onSuccess(); }
/** * Test that when everything is ok, we can connect, submit, create wavelet and disconnect. * This is not supposed to be a thorough test. */ public void testSunnyDayScenario() { open(); viewOpenListener.expectedCall(MockViewChannelListener.MethodCall.ON_CONNECTED); viewOpenListener.expectedCall(MockViewChannelListener.MethodCall.ON_OPEN_FINISHED); // pretend an update with update wavelet. Note we don't add any data in the wavelet // because it's not really relevant for the test. respondWithEmptyUpdate(WAVELET_ID); viewOpenListener.expectedCall(MockViewChannelListener.MethodCall.ON_UPDATE, WAVELET_ID); // Submit a delta and check that we have the right channel id remembered. MockSubmitListener submitListener = new MockSubmitListener(); channel.submitDelta(WAVELET_ID, emptyDelta(), submitListener); assertEquals(1, waveViewService.submits.size()); assertEquals(CHANNEL_ID, waveViewService.lastSubmit().channelId); // Return a success message on the submitted delta byte[] hash = new byte[] {1, 2, 3, 4}; respondToSubmit(HashedVersion.of(2, hash), 1, null, ResponseCode.OK); submitListener.expectedCall(MockSubmitListener.MethodCall.ON_SUCCESS, 1, HashedVersion.of(2, hash)); // Check disconnect channel.close(); assertEquals(1, waveViewService.closes.size()); waveViewService.lastClose().callback.onSuccess(); }