/** * Simulates channel termination. */ private void closeChannel() { deltaChannel.reset(null); }
/** * Simulates channel termination. */ private void closeChannel() { deltaChannel.reset(null); }
/** * Tests that resetting a new channel does nothing. */ public void testResetNewChannel() { deltaChannel.reset(null); waveletChannel.checkExpectationsSatisfied(); }
/** * Tests that resetting a new channel does nothing. */ public void testResetNewChannel() { deltaChannel.reset(null); waveletChannel.checkExpectationsSatisfied(); }
/** * 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 that when the client terminates the channel the receiver * is not notified. */ public void testClientResetTerminatesSilently() throws ChannelException { checkedConnectChannel(57); deltaChannel.reset(null); receiver.checkExpectationsSatisfied(); }
@Override public void setUp() { waveletChannel = new MockWaveletChannel(); receiver = new MockReceiver(); deltaChannel = new WaveletDeltaChannelImpl(waveletChannel, logger); deltaChannel.reset(receiver); }
@Override public void setUp() { waveletChannel = new MockWaveletChannel(); receiver = new MockReceiver(); deltaChannel = new WaveletDeltaChannelImpl(waveletChannel, logger); deltaChannel.reset(receiver); }
/** * Tests that a channel with no receivers quietly drops messages. */ public void testChannelWithNoReceiverDropsMessages() throws ChannelException { final long initialVersion = 57; final byte[] signature = sig(1); final ObservableWaveletData wavelet = buildSnapshot(initialVersion, signature); final TransformedWaveletDelta delta = buildServerDelta(initialVersion, 3); deltaChannel.reset(null); // Clear receiver. connectChannel(wavelet); receiveUpdateOnConnectedChannel(delta, initialVersion, signature); receiver.checkExpectationsSatisfied(); }
/** * Tests that a channel with no receivers quietly drops messages. */ public void testChannelWithNoReceiverDropsMessages() throws ChannelException { final long initialVersion = 57; final byte[] signature = sig(1); final ObservableWaveletData wavelet = buildSnapshot(initialVersion, signature); final TransformedWaveletDelta delta = buildServerDelta(initialVersion, 3); deltaChannel.reset(null); // Clear receiver. connectChannel(wavelet); receiveUpdateOnConnectedChannel(delta, initialVersion, signature); receiver.checkExpectationsSatisfied(); }
/** * Tests that an ack received for a delta submitted before a channel * reconnects is dropped. */ public void testAckAfterReconnectIgnored() throws ChannelException { final long initialVersion = 57; final byte[] initialSignature = sig(4); checkedConnectChannel(initialVersion); // Submit delta. final int clientOps = 5; final WaveletDelta clientDelta = buildDelta(initialVersion, clientOps); submitDeltaOnConnectedChannel(clientDelta); // Reset channel. deltaChannel.reset(receiver); final List<TransformedWaveletDelta> reconnect = buildReconnect(initialVersion, initialSignature); checkedReconnectChannel(reconnect, 0, new byte[0]); // Acknowledge outstanding submit. final long versionAfterClient = initialVersion + clientOps; final byte[] ackedSignature = sig(1); // Don't expect the ack at the receiver. ackDeltaOnConnectedChannel(versionAfterClient, clientOps, ackedSignature); receiver.checkExpectationsSatisfied(); }
/** * Tests that an ack received for a delta submitted before a channel * reconnects is dropped. */ public void testAckAfterReconnectIgnored() throws ChannelException { final long initialVersion = 57; final byte[] initialSignature = sig(4); checkedConnectChannel(initialVersion); // Submit delta. final int clientOps = 5; final WaveletDelta clientDelta = buildDelta(initialVersion, clientOps); submitDeltaOnConnectedChannel(clientDelta); // Reset channel. deltaChannel.reset(receiver); final List<TransformedWaveletDelta> reconnect = buildReconnect(initialVersion, initialSignature); checkedReconnectChannel(reconnect, 0, new byte[0]); // Acknowledge outstanding submit. final long versionAfterClient = initialVersion + clientOps; final byte[] ackedSignature = sig(1); // Don't expect the ack at the receiver. ackDeltaOnConnectedChannel(versionAfterClient, clientOps, ackedSignature); receiver.checkExpectationsSatisfied(); }
/** * Tests that a delta submitted after a reset has sequence number 1. */ public void testSubmitAfterResetRestartsSequence() 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); checkedConnectChannel(currentVersion); // Send delta1. submitDeltaOnConnectedChannel(delta1); // All ops are acked. receiver.expectAck(ops1, HashedVersion.of(currentVersion + ops1, signature1)); ackDeltaOnConnectedChannel(currentVersion + ops1, ops1, signature1); deltaChannel.reset(receiver); checkedReconnectChannel(buildReconnect(currentVersion + ops1, signature1), currentVersion + ops1, signature1); // Send delta2. submitDeltaOnConnectedChannel(delta2); // Close. closeChannel(); receiver.checkExpectationsSatisfied(); }
/** * Tests that a delta submitted after a reset has sequence number 1. */ public void testSubmitAfterResetRestartsSequence() 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); checkedConnectChannel(currentVersion); // Send delta1. submitDeltaOnConnectedChannel(delta1); // All ops are acked. receiver.expectAck(ops1, HashedVersion.of(currentVersion + ops1, signature1)); ackDeltaOnConnectedChannel(currentVersion + ops1, ops1, signature1); deltaChannel.reset(receiver); checkedReconnectChannel(buildReconnect(currentVersion + ops1, signature1), currentVersion + ops1, signature1); // Send delta2. submitDeltaOnConnectedChannel(delta2); // Close. closeChannel(); receiver.checkExpectationsSatisfied(); }