Examples of FakeWaveViewServiceUpdate


Examples of org.waveprotocol.wave.concurrencycontrol.testing.FakeWaveViewServiceUpdate

    assertEquals(GENERATED_WAVELET_ID, createdWavelet.getId());
    assertNotNull(viewListener.addedWavelet);
    viewListener.reset();

    // Prime with channel id.
    openCallback.onUpdate(new FakeWaveViewServiceUpdate().setChannelId("1"));

    // Receive a new wavelet from the server.
    openCallback.onUpdate(new FakeWaveViewServiceUpdate()
        .setWaveletId(WaveletId.of("example.com", "newServerWavelet_1"))
        .setWaveletSnapshot(WAVE_ID, USER_ID, 0L, HashedVersion.of(1L, sig(123)))
        .setLastCommittedVersion(HashedVersion.unsigned(0)));

    assertNotNull(viewListener.addedWavelet);
    openCallback.onUpdate(new FakeWaveViewServiceUpdate().setMarker(false));
    assertTrue(openListener.opened);

    // Receive version-zero snapshot for locally generated wavelet.
    openCallback.onUpdate(new FakeWaveViewServiceUpdate()
        .setWaveletId(GENERATED_WAVELET_ID)
        .setWaveletSnapshot(WAVE_ID, USER_ID, 0L, HashedVersion.unsigned(0))
        .setLastCommittedVersion(HashedVersion.unsigned(0)));

    // Ack the configurator's add-participant
    assertEquals(1, waveViewService.submits.size());
    waveViewService.lastSubmit().callback
        .onSuccess(HashedVersion.of(1L, sig(111)), 1, null, ResponseCode.OK);

    DeltaTestUtil util = new DeltaTestUtil(USER_ID);

    // Receive an operation from the server that doesn't affect the document.
    TransformedWaveletDelta delta1 =
        util.delta(1L, util.addParticipant(new ParticipantId("reuben@example.com")));
    openCallback.onUpdate(new FakeWaveViewServiceUpdate()
        .setWaveletId(GENERATED_WAVELET_ID).addDelta(delta1));

    assertEquals(2, createdWavelet.getParticipantIds().size());

    // create an empty blip edit (i.e. implicit creation) and expect flush
    TransformedWaveletDelta delta2 = util.delta(2L, util.noOpDocOp(GENERATED_BLIP_ID));
    openCallback.onUpdate(new FakeWaveViewServiceUpdate()
        .setWaveletId(GENERATED_WAVELET_ID).addDelta(delta2));
    doc.expectedCall(MockCcDocument.MethodCall.FLUSH);
    doc.expectedCall(MockCcDocument.MethodCall.CONSUME);
    doc.expectedNothing();

    // now hold back flush on another server op
    doc.flush_return = false;
    TransformedWaveletDelta delta3 = util.delta(3L, util.noOpDocOp(GENERATED_BLIP_ID));
    openCallback.onUpdate(new FakeWaveViewServiceUpdate()
        .setWaveletId(GENERATED_WAVELET_ID).addDelta(delta3));
    MockCcDocument.MethodCallContext callContext =
        doc.expectedCall(MockCcDocument.MethodCall.FLUSH);
    doc.expectedNothing();
View Full Code Here

Examples of org.waveprotocol.wave.concurrencycontrol.testing.FakeWaveViewServiceUpdate

  /**
   * Simulates the server responding with the channel id.
   */
  private void respondWithChannelId() {
    waveViewService.lastOpen().callback.onUpdate(
        new FakeWaveViewServiceUpdate().setChannelId(CHANNEL_ID));
  }
View Full Code Here

Examples of org.waveprotocol.wave.concurrencycontrol.testing.FakeWaveViewServiceUpdate

  /**
   * Simulates the server responding with the open-finished marker.
   */
  private void respondWithMarker(boolean waveEmpty) {
    waveViewService.lastOpen().callback.onUpdate(
        new FakeWaveViewServiceUpdate().setMarker(waveEmpty));
  }
View Full Code Here

Examples of org.waveprotocol.wave.concurrencycontrol.testing.FakeWaveViewServiceUpdate

   * Simulates the server sending a streaming update.
   *
   * @param waveletId wavelet to update
   */
  private void respondWithEmptyUpdate(WaveletId waveletId) {
    waveViewService.lastOpen().callback.onUpdate(new FakeWaveViewServiceUpdate()
        .setWaveletId(waveletId)
        .setLastCommittedVersion(HashedVersion.unsigned(0))
        .addDelta(new TransformedWaveletDelta(null, HashedVersion.unsigned(0), 0L,
            Arrays.<WaveletOperation> asList())));
  }
View Full Code Here

Examples of org.waveprotocol.wave.concurrencycontrol.testing.FakeWaveViewServiceUpdate

   */
  public void testInitialUpdateWithoutAChannelIdFails() {
    halfOpen();

    // Receive an update with no channel id.
    waveViewService.lastOpen().callback.onUpdate(new FakeWaveViewServiceUpdate());
    viewOpenListener.expectedCall(MockViewChannelListener.MethodCall.ON_EXCEPTION);
  }
View Full Code Here

Examples of org.waveprotocol.wave.concurrencycontrol.testing.FakeWaveViewServiceUpdate

  /**
   * Tests that a channel fails if it receives a message before it is opened.
   */
  public void testMessageBeforeOpenThrowsException() {
    try {
      channel.onUpdate(new FakeWaveViewServiceUpdate());
      fail("Should not be able to receive update without open call");
    } catch (IllegalStateException expected) {
      // Expected.
    }
  }
View Full Code Here

Examples of org.waveprotocol.wave.concurrencycontrol.testing.FakeWaveViewServiceUpdate

    assertEquals(1, waveViewService.opens.size());
    WaveViewService.OpenCallback openCallback = waveViewService.lastOpen().callback;

    // Pretend we got the initial snapshot at version 1 signature1.
    muxListener.verifyNoMoreInteractions();
    openCallback.onUpdate(new FakeWaveViewServiceUpdate().setChannelId(CHANNEL_ID));
    FakeWaveViewServiceUpdate update = new FakeWaveViewServiceUpdate()
        .setWaveletId(WAVELET_ID_1)
        .setWaveletSnapshot(WAVE_ID, USER_NAME, 0L, HashedVersion.of(1L, SIGNATURE1))
        .setLastCommittedVersion(HashedVersion.unsigned(0));
    openCallback.onUpdate(update);
    OperationChannel channel = muxListener.verifyOperationChannelCreated(
        update.getWaveletSnapshot(), Accessibility.READ_WRITE);
    openCallback.onUpdate(new FakeWaveViewServiceUpdate().setMarker(false));
    muxListener.verifyOpenFinished();

    channel.send(createAddParticipantOp());
    assertEquals(1, waveViewService.submits.size());
    assertUnsavedDataInfo(1, 1, 1, 0, 0);

    // Server ack's the previous add participant op.
    HashedVersion v2 = HashedVersion.of(2, SIGNATURE2);
    WaveViewService.SubmitCallback submitCallback = waveViewService.lastSubmit().callback;
    submitCallback.onSuccess(v2, 1, null, ResponseCode.OK);

    assertUnsavedDataInfo(0, 1, 0, 2, 0);

    // Server sends commit for the add participant op.
    openCallback.onUpdate(
        new FakeWaveViewServiceUpdate().setWaveletId(WAVELET_ID_1).setLastCommittedVersion(v2));
    // Now we expect to be told everything is committed.
    assertUnsavedDataInfo(0, 0, 0, 2, 2);

    // Send another op, now it should be uncommitted.
    channel.send(createAddParticipantOp());
View Full Code Here

Examples of org.waveprotocol.wave.concurrencycontrol.testing.FakeWaveViewServiceUpdate

    assertEquals(1, waveViewService.opens.size());
    WaveViewService.OpenCallback openCallback = waveViewService.lastOpen().callback;

    // Pretend we got the initial snapshot at version 1 signature1.
    muxListener.verifyNoMoreInteractions();
    openCallback.onUpdate(new FakeWaveViewServiceUpdate().setChannelId(CHANNEL_ID));
    FakeWaveViewServiceUpdate update = new FakeWaveViewServiceUpdate()
        .setWaveletId(WAVELET_ID_1)
        .setWaveletSnapshot(WAVE_ID, USER_NAME, 0L, HashedVersion.of(1L, SIGNATURE1))
        .setLastCommittedVersion(HashedVersion.unsigned(0));
    openCallback.onUpdate(update);
    OperationChannel channel = muxListener.verifyOperationChannelCreated(
        update.getWaveletSnapshot(), Accessibility.READ_WRITE);
    openCallback.onUpdate(new FakeWaveViewServiceUpdate().setMarker(false));
    muxListener.verifyOpenFinished();

    // Send Op, get ack.
    channel.send(createAddParticipantOp());
    assertEquals(1, waveViewService.submits.size());
    WaveViewService.SubmitCallback submitCallback1 = waveViewService.lastSubmit().callback;
    HashedVersion v2 = HashedVersion.of(2, SIGNATURE2);
    submitCallback1.onSuccess(v2, 1, null, ResponseCode.OK);
    assertUnsavedDataInfo(0, 1, 0, 2, 0);

    // Send another Op, get ack.
    channel.send(createAddParticipantOp());
    assertEquals(2, waveViewService.submits.size());
    WaveViewService.SubmitCallback submitCallback2 = waveViewService.lastSubmit().callback;
    HashedVersion v3 = HashedVersion.of(3, SIGNATURE3);
    submitCallback2.onSuccess(v3, 1, null, ResponseCode.OK);
    assertUnsavedDataInfo(0, 2, 0, 3, 0);

    // Server sends commit for the first addParticipant op.
    openCallback.onUpdate(
        new FakeWaveViewServiceUpdate().setWaveletId(WAVELET_ID_1).setLastCommittedVersion(v2));
    // Now we expect to be told that NOT everything is committed.
    assertUnsavedDataInfo(0, 1, 0, 3, 2);

    // Server sends commit for the second addParticipant op.
    openCallback.onUpdate(
        new FakeWaveViewServiceUpdate().setWaveletId(WAVELET_ID_1).setLastCommittedVersion(v3));
    // Now we expect to be told that everything is committed.
    assertUnsavedDataInfo(0, 0, 0, 3, 3);

    mux.close();
    assertEquals(1, waveViewService.closes.size());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.