use of org.opendaylight.controller.cluster.access.commands.AbortLocalTransactionRequest in project controller by opendaylight.
the class AbstractClientHandleTest method testAbort.
@Test
public void testAbort() throws Exception {
doHandleOperation(handle);
handle.abort();
final Envelope<?> envelope = backendProbe.expectMsgClass(Envelope.class);
final AbortLocalTransactionRequest request = (AbortLocalTransactionRequest) envelope.getMessage();
Assert.assertEquals(TRANSACTION_ID, request.getTarget());
checkClosed();
}
use of org.opendaylight.controller.cluster.access.commands.AbortLocalTransactionRequest in project controller by opendaylight.
the class AbstractClientHandleTest method testLocalAbort.
@Test
public void testLocalAbort() throws Exception {
doHandleOperation(handle);
handle.localAbort(new RuntimeException("fail"));
final Envelope<?> envelope = backendProbe.expectMsgClass(Envelope.class);
final AbortLocalTransactionRequest request = (AbortLocalTransactionRequest) envelope.getMessage();
Assert.assertEquals(TRANSACTION_ID, request.getTarget());
checkClosed();
}
use of org.opendaylight.controller.cluster.access.commands.AbortLocalTransactionRequest in project controller by opendaylight.
the class AbstractProxyTransactionTest method testReplayMessages.
@Test
public void testReplayMessages() throws Exception {
final TestProbe probe = new TestProbe(system);
final List<ConnectionEntry> entries = new ArrayList<>();
final Consumer<Response<?, ?>> callback = createCallbackMock();
final ReadTransactionRequest request1 = new ReadTransactionRequest(TRANSACTION_ID, 2L, probe.ref(), PATH_2, true);
final ExistsTransactionRequest request2 = new ExistsTransactionRequest(TRANSACTION_ID, 3L, probe.ref(), PATH_3, true);
entries.add(AccessClientUtil.createConnectionEntry(request1, callback, 0L));
entries.add(AccessClientUtil.createConnectionEntry(request2, callback, 0L));
final TransactionTester<RemoteProxyTransaction> successor = createRemoteProxyTransactionTester();
final AbortLocalTransactionRequest successful1 = new AbortLocalTransactionRequest(TRANSACTION_ID, probe.ref());
transaction.recordSuccessfulRequest(successful1);
final ReadTransactionRequest successful2 = new ReadTransactionRequest(TRANSACTION_ID, 1L, probe.ref(), PATH_1, true);
transaction.recordSuccessfulRequest(successful2);
transaction.startReconnect();
final ProxyHistory mockSuccessor = mock(ProxyHistory.class);
when(mockSuccessor.createTransactionProxy(TRANSACTION_ID, transaction.isSnapshotOnly(), false)).thenReturn(successor.getTransaction());
transaction.replayMessages(mockSuccessor, entries);
final ModifyTransactionRequest transformed = successor.expectTransactionRequest(ModifyTransactionRequest.class);
Assert.assertNotNull(transformed);
Assert.assertEquals(successful1.getSequence(), transformed.getSequence());
Assert.assertTrue(transformed.getPersistenceProtocol().isPresent());
Assert.assertEquals(PersistenceProtocol.ABORT, transformed.getPersistenceProtocol().get());
ReadTransactionRequest tmpRead = successor.expectTransactionRequest(ReadTransactionRequest.class);
Assert.assertNotNull(tmpRead);
Assert.assertEquals(successful2.getTarget(), tmpRead.getTarget());
Assert.assertEquals(successful2.getSequence(), tmpRead.getSequence());
Assert.assertEquals(successful2.getPath(), tmpRead.getPath());
Assert.assertEquals(successor.localActor(), tmpRead.getReplyTo());
tmpRead = successor.expectTransactionRequest(ReadTransactionRequest.class);
Assert.assertNotNull(tmpRead);
Assert.assertEquals(request1.getTarget(), tmpRead.getTarget());
Assert.assertEquals(request1.getSequence(), tmpRead.getSequence());
Assert.assertEquals(request1.getPath(), tmpRead.getPath());
Assert.assertEquals(successor.localActor(), tmpRead.getReplyTo());
final ExistsTransactionRequest tmpExist = successor.expectTransactionRequest(ExistsTransactionRequest.class);
Assert.assertNotNull(tmpExist);
Assert.assertEquals(request2.getTarget(), tmpExist.getTarget());
Assert.assertEquals(request2.getSequence(), tmpExist.getSequence());
Assert.assertEquals(request2.getPath(), tmpExist.getPath());
Assert.assertEquals(successor.localActor(), tmpExist.getReplyTo());
}
use of org.opendaylight.controller.cluster.access.commands.AbortLocalTransactionRequest in project controller by opendaylight.
the class LocalProxyTransactionTest method testForwardToRemoteAbort.
@Override
@Test
public void testForwardToRemoteAbort() throws Exception {
final TestProbe probe = createProbe();
final AbortLocalTransactionRequest request = new AbortLocalTransactionRequest(TRANSACTION_ID, probe.ref());
final ModifyTransactionRequest modifyRequest = testForwardToRemote(request, ModifyTransactionRequest.class);
Assert.assertTrue(modifyRequest.getPersistenceProtocol().isPresent());
Assert.assertEquals(PersistenceProtocol.ABORT, modifyRequest.getPersistenceProtocol().get());
}
use of org.opendaylight.controller.cluster.access.commands.AbortLocalTransactionRequest in project controller by opendaylight.
the class LocalProxyTransactionTest method testForwardToLocalAbort.
@Test
public void testForwardToLocalAbort() throws Exception {
final TestProbe probe = createProbe();
final AbortLocalTransactionRequest request = new AbortLocalTransactionRequest(TRANSACTION_ID, probe.ref());
testForwardToLocal(request, AbortLocalTransactionRequest.class);
}
Aggregations