use of org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType.OPERATIONAL in project genius by opendaylight.
the class ManagedNewTransactionRunnerImplTest method testCallWithNewWriteOnlyTransactionAndSubmitPutButLaterException.
@Test
public void testCallWithNewWriteOnlyTransactionAndSubmitPutButLaterException() throws Exception {
try {
managedNewTransactionRunner.callWithNewWriteOnlyTransactionAndSubmit(writeTx -> {
writeTx.put(OPERATIONAL, TEST_PATH, newTestDataObject());
// We now throw an arbitrary kind of checked (not unchecked!) exception here
throw new IOException("something didn't quite go as expected...");
}).get();
fail("This should have lead to an ExecutionException!");
} catch (ExecutionException e) {
assertThat(e.getCause() instanceof IOException).isTrue();
}
assertThat(singleTransactionDataBroker.syncReadOptional(OPERATIONAL, TEST_PATH)).isAbsent();
}
use of org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType.OPERATIONAL in project genius by opendaylight.
the class ManagedNewTransactionRunnerImplTest method testCallWithNewWriteOnlyTransactionOptimisticLockFailedException.
@Test
public void testCallWithNewWriteOnlyTransactionOptimisticLockFailedException() throws Exception {
try {
testableDataBroker.failSubmits(2, new OptimisticLockFailedException("bada boum bam!"));
managedNewTransactionRunner.callWithNewWriteOnlyTransactionAndSubmit(writeTx -> writeTx.put(LogicalDatastoreType.OPERATIONAL, TEST_PATH, newTestDataObject())).get();
fail("This should have lead to an ExecutionException!");
} catch (ExecutionException e) {
assertThat(e.getCause() instanceof OptimisticLockFailedException).isTrue();
}
assertThat(singleTransactionDataBroker.syncReadOptional(OPERATIONAL, TEST_PATH)).isAbsent();
}
use of org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType.OPERATIONAL in project genius by opendaylight.
the class ManagedNewTransactionRunnerImplTest method testCallWithNewWriteOnlyTransactionCommitFailedException.
@Test
public void testCallWithNewWriteOnlyTransactionCommitFailedException() throws Exception {
try {
testableDataBroker.failSubmits(new TransactionCommitFailedException("bada boum bam!"));
managedNewTransactionRunner.callWithNewWriteOnlyTransactionAndSubmit(writeTx -> writeTx.put(LogicalDatastoreType.OPERATIONAL, TEST_PATH, newTestDataObject())).get();
fail("This should have lead to an ExecutionException!");
} catch (ExecutionException e) {
assertThat(e.getCause() instanceof TransactionCommitFailedException).isTrue();
}
assertThat(singleTransactionDataBroker.syncReadOptional(OPERATIONAL, TEST_PATH)).isAbsent();
}
use of org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType.OPERATIONAL in project genius by opendaylight.
the class RetryingManagedNewTransactionRunnerTest method testCallWithNewWriteOnlyTransactionOptimisticLockFailedException.
@Override
public void testCallWithNewWriteOnlyTransactionOptimisticLockFailedException() throws Exception {
// contrary to the super() test implementation for (just) ManagedNewTransactionRunnerImpl, in the parent class
// here we expect the x2 OptimisticLockFailedException to be retried, and then eventually succeed:
testableDataBroker.failSubmits(2, new OptimisticLockFailedException("bada boum bam!"));
managedNewTransactionRunner.callWithNewWriteOnlyTransactionAndSubmit(writeTx -> writeTx.put(LogicalDatastoreType.OPERATIONAL, TEST_PATH, newTestDataObject())).get();
singleTransactionDataBroker.syncRead(OPERATIONAL, TEST_PATH);
}
Aggregations