receiver.expectNack(error, versionAfterServer1); nackDeltaOnConnectedChannel(versionAfterServer1, sigAfterServer1, error, ResponseCode.BAD_REQUEST);
receiver.expectNack(error, versionAfterServer1); nackDeltaOnConnectedChannel(versionAfterServer1, sigAfterServer1, error, ResponseCode.BAD_REQUEST);
/** * Tests that a delta sent down the channel is received and the acknowledgment * delivered. */ public void testSubmitDelta() throws ChannelException { final long currentVersion = 57; final int ops1 = 7; final WaveletDelta delta1 = buildDelta(currentVersion, ops1); final byte[] signature1 = sig(1); final WaveletDelta delta2 = buildDelta(currentVersion + ops1, 2); final int opsCommitted = 3; final String errorMsg2 = "SERVER_ERROR"; checkedConnectChannel(currentVersion); // Send delta1. submitDeltaOnConnectedChannel(delta1); // All ops are acked. receiver.expectAck(ops1, HashedVersion.of(currentVersion + ops1, signature1)); ackDeltaOnConnectedChannel(currentVersion + ops1, ops1, signature1); // Send delta2. submitDeltaOnConnectedChannel(delta2); // Nack with a randomly injected error, as if something just went wrong // server-side. receiver.expectNack(errorMsg2, currentVersion + ops1); nackDeltaOnConnectedChannel(currentVersion + ops1, signature1, errorMsg2, ResponseCode.INTERNAL_ERROR); // Close. closeChannel(); receiver.checkExpectationsSatisfied(); }
/** * Tests that a delta sent down the channel is received and the acknowledgment * delivered. */ public void testSubmitDelta() throws ChannelException { final long currentVersion = 57; final int ops1 = 7; final WaveletDelta delta1 = buildDelta(currentVersion, ops1); final byte[] signature1 = sig(1); final WaveletDelta delta2 = buildDelta(currentVersion + ops1, 2); final int opsCommitted = 3; final String errorMsg2 = "SERVER_ERROR"; checkedConnectChannel(currentVersion); // Send delta1. submitDeltaOnConnectedChannel(delta1); // All ops are acked. receiver.expectAck(ops1, HashedVersion.of(currentVersion + ops1, signature1)); ackDeltaOnConnectedChannel(currentVersion + ops1, ops1, signature1); // Send delta2. submitDeltaOnConnectedChannel(delta2); // Nack with a randomly injected error, as if something just went wrong // server-side. receiver.expectNack(errorMsg2, currentVersion + ops1); nackDeltaOnConnectedChannel(currentVersion + ops1, signature1, errorMsg2, ResponseCode.INTERNAL_ERROR); // Close. closeChannel(); receiver.checkExpectationsSatisfied(); }