use of org.opendaylight.controller.cluster.access.concepts.Response in project controller by opendaylight.
the class TransmittingTransmitQueueTest method testSlicedRequestOnComplete.
@Test
public void testSlicedRequestOnComplete() throws Exception {
doReturn(true).when(mockMessageSlicer).slice(any());
ModifyTransactionRequestBuilder reqBuilder = new ModifyTransactionRequestBuilder(TRANSACTION_IDENTIFIER, probe.ref());
reqBuilder.setSequence(0L);
final Request<?, ?> request = reqBuilder.build();
final long now = now();
final Consumer<Response<?, ?>> mockConsumer = createConsumerMock();
queue.enqueueOrForward(new ConnectionEntry(request, mockConsumer, now), now);
ArgumentCaptor<SliceOptions> sliceOptions = ArgumentCaptor.forClass(SliceOptions.class);
verify(mockMessageSlicer).slice(sliceOptions.capture());
assertTrue(sliceOptions.getValue().getMessage() instanceof RequestEnvelope);
final Request<?, ?> request2 = new TransactionPurgeRequest(TRANSACTION_IDENTIFIER, 1L, probe.ref());
queue.enqueueOrForward(new ConnectionEntry(request2, mockConsumer, now), now);
verifyNoMoreInteractions(mockMessageSlicer);
probe.expectNoMsg();
RequestEnvelope requestEnvelope = (RequestEnvelope) sliceOptions.getValue().getMessage();
queue.complete(new FailureEnvelope(request.toRequestFailure(mock(RequestException.class)), requestEnvelope.getSessionId(), requestEnvelope.getTxSequence(), 0), 0);
requestEnvelope = probe.expectMsgClass(RequestEnvelope.class);
assertEquals(request2, requestEnvelope.getMessage());
final Request<?, ?> request3 = new TransactionPurgeRequest(TRANSACTION_IDENTIFIER, 3L, probe.ref());
queue.enqueueOrForward(new ConnectionEntry(request3, mockConsumer, now), now);
requestEnvelope = probe.expectMsgClass(RequestEnvelope.class);
assertEquals(request3, requestEnvelope.getMessage());
}
use of org.opendaylight.controller.cluster.access.concepts.Response in project controller by opendaylight.
the class TransmittingTransmitQueueTest method testSetForwarder.
@Test
public void testSetForwarder() throws Exception {
final FakeTicker ticker = new FakeTicker();
ticker.setAutoIncrementStep(1, TimeUnit.MICROSECONDS);
final Request<?, ?> request = new TransactionPurgeRequest(TRANSACTION_IDENTIFIER, 0L, probe.ref());
final Consumer<Response<?, ?>> callback = createConsumerMock();
final ConnectionEntry entry = new ConnectionEntry(request, callback, ticker.read());
final ReconnectForwarder forwarder = mock(ReconnectForwarder.class);
queue.setForwarder(forwarder, ticker.read());
final long secondEnqueueNow = ticker.read();
queue.enqueueOrForward(entry, secondEnqueueNow);
verify(forwarder).forwardEntry(entry, secondEnqueueNow);
}
use of org.opendaylight.controller.cluster.access.concepts.Response in project controller by opendaylight.
the class LocalProxyTransactionTest method testHandleForwardedRemoteExistsRequest.
@Test
public void testHandleForwardedRemoteExistsRequest() throws Exception {
final TestProbe probe = createProbe();
final ExistsTransactionRequest request = new ExistsTransactionRequest(TRANSACTION_ID, 0L, probe.ref(), PATH_1, true);
final Consumer<Response<?, ?>> callback = createCallbackMock();
setupExecuteInActor();
transaction.handleReplayedRemoteRequest(request, callback, Ticker.systemTicker().read());
final ArgumentCaptor<Response> captor = ArgumentCaptor.forClass(Response.class);
verify(callback).accept(captor.capture());
final Response<?, ?> value = captor.getValue();
Assert.assertTrue(value instanceof ExistsTransactionSuccess);
final ExistsTransactionSuccess success = (ExistsTransactionSuccess) value;
Assert.assertTrue(success.getExists());
}
use of org.opendaylight.controller.cluster.access.concepts.Response in project controller by opendaylight.
the class LocalReadWriteProxyTransactionTest method applyModifyTransactionRequest.
private void applyModifyTransactionRequest(final boolean coordinated) {
final TestProbe probe = createProbe();
final ModifyTransactionRequestBuilder builder = new ModifyTransactionRequestBuilder(TRANSACTION_ID, probe.ref());
final TransactionModification write = new TransactionWrite(PATH_1, DATA_1);
final TransactionModification merge = new TransactionMerge(PATH_2, DATA_2);
final TransactionModification delete = new TransactionDelete(PATH_3);
builder.addModification(write);
builder.addModification(merge);
builder.addModification(delete);
builder.setSequence(0L);
builder.setCommit(coordinated);
final ModifyTransactionRequest request = builder.build();
final Consumer<Response<?, ?>> callback = createCallbackMock();
transaction.replayModifyTransactionRequest(request, callback, Ticker.systemTicker().read());
verify(modification).write(PATH_1, DATA_1);
verify(modification).merge(PATH_2, DATA_2);
verify(modification).delete(PATH_3);
final CommitLocalTransactionRequest commitRequest = getTester().expectTransactionRequest(CommitLocalTransactionRequest.class);
Assert.assertEquals(modification, commitRequest.getModification());
Assert.assertEquals(coordinated, commitRequest.isCoordinated());
}
use of org.opendaylight.controller.cluster.access.concepts.Response in project controller by opendaylight.
the class LocalReadWriteProxyTransactionTest method testApplyModifyTransactionRequestAbort.
@Test
public void testApplyModifyTransactionRequestAbort() throws Exception {
final TestProbe probe = createProbe();
final ModifyTransactionRequestBuilder builder = new ModifyTransactionRequestBuilder(TRANSACTION_ID, probe.ref());
builder.setSequence(0L);
builder.setAbort();
final ModifyTransactionRequest request = builder.build();
final Consumer<Response<?, ?>> callback = createCallbackMock();
transaction.replayModifyTransactionRequest(request, callback, Ticker.systemTicker().read());
getTester().expectTransactionRequest(AbortLocalTransactionRequest.class);
}
Aggregations