/** * 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(); }
/** * 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); }
/** * Tests that a channel fails if it does not receive a channel id in the first * message. */ public void testInitialUpdateWithoutAChannelIdFails() { halfOpen(); // Receive an update with no channel id. waveViewService.lastOpen().callback.onUpdate(new FakeWaveViewServiceUpdate()); viewOpenListener.expectedCall(MockViewChannelListener.MethodCall.ON_EXCEPTION); }
public void testFailedOpenCallsListenerFailure() { halfOpen(); // fail the open terminateOpenRpcWithFailure("WAVE_SERVER_ERROR"); viewOpenListener.expectedCall(MockViewChannelListener.MethodCall.ON_CLOSED); }
/** * 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); }
/** * Tests that a channel fails if it does not receive a channel id in the first * message. */ public void testInitialUpdateWithoutAChannelIdFails() { halfOpen(); // Receive an update with no channel id. waveViewService.lastOpen().callback.onUpdate(new FakeWaveViewServiceUpdate()); viewOpenListener.expectedCall(MockViewChannelListener.MethodCall.ON_EXCEPTION); }
public void testCloseWithoutOpen() { close(); 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 testCloseTriggersCloseCallback() { open(); viewOpenListener.clear(); close(); // The underlying service is expected to have the following behaviour. terminateOpenRpcWithSuccess(); viewOpenListener.expectedCall(MockViewChannelListener.MethodCall.ON_CLOSED); }
/** * 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 testOpenRpcTerminationWithoutCloseTriggersFailureAndClose() { open(); viewOpenListener.clear(); 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); }
public void testCloseWithoutOpen() { close(); viewOpenListener.expectedNothing(); }
public void testOpenRpcOnFailureAndThenTerminationWithoutCloseTriggersOneFailureAndClose() { open(); viewOpenListener.clear(); terminateOpenRpcWithFailure("WAVE_SERVER_ERROR"); viewOpenListener.expectedCall(MockViewChannelListener.MethodCall.ON_CLOSED); terminateOpenRpcWithError(); viewOpenListener.expectedNothing(); }
/** * Tests that an update with the end-marker triggers the open-finished * callback. */ public void testChannelIdTriggersConnectCallback() { halfOpen(); respondWithChannelId(); viewOpenListener.expectedCall(MockViewChannelListener.MethodCall.ON_CONNECTED); }
/** * 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); }
/** * 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); }
public void testOpenRpcOnFailureAndThenTerminationWithoutCloseTriggersOneFailureAndClose() { open(); viewOpenListener.clear(); terminateOpenRpcWithFailure("WAVE_SERVER_ERROR"); viewOpenListener.expectedCall(MockViewChannelListener.MethodCall.ON_CLOSED); terminateOpenRpcWithError(); viewOpenListener.expectedNothing(); }