use of akka.testkit.javadsl.TestKit in project controller by opendaylight.
the class ShardTransactionTest method testOnReceiveBatchedModificationsReadyWithIncorrectTotalMessageCount.
@Test(expected = IllegalStateException.class)
public void testOnReceiveBatchedModificationsReadyWithIncorrectTotalMessageCount() throws Exception {
new TestKit(getSystem()) {
{
final ActorRef transaction = newTransactionActor(WO, readWriteTransaction(), "testOnReceiveBatchedModificationsReadyWithIncorrectTotalMessageCount");
TestKit watcher = new TestKit(getSystem());
watcher.watch(transaction);
BatchedModifications batched = new BatchedModifications(nextTransactionId(), DataStoreVersions.CURRENT_VERSION);
batched.setReady(true);
batched.setTotalMessagesSent(2);
transaction.tell(batched, getRef());
Failure failure = expectMsgClass(duration("5 seconds"), akka.actor.Status.Failure.class);
watcher.expectMsgClass(duration("5 seconds"), Terminated.class);
if (failure != null) {
Throwables.throwIfInstanceOf(failure.cause(), Exception.class);
Throwables.throwIfUnchecked(failure.cause());
throw new RuntimeException(failure.cause());
}
}
};
}
use of akka.testkit.javadsl.TestKit in project controller by opendaylight.
the class ShardTransactionTest method testOnReceiveBatchedModificationsReadyWithImmediateCommit.
@Test
public void testOnReceiveBatchedModificationsReadyWithImmediateCommit() throws Exception {
new TestKit(getSystem()) {
{
final ActorRef transaction = newTransactionActor(WO, readWriteTransaction(), "testOnReceiveBatchedModificationsReadyWithImmediateCommit");
TestKit watcher = new TestKit(getSystem());
watcher.watch(transaction);
YangInstanceIdentifier writePath = TestModel.TEST_PATH;
NormalizedNode<?, ?> writeData = ImmutableContainerNodeBuilder.create().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TestModel.TEST_QNAME)).withChild(ImmutableNodes.leafNode(TestModel.DESC_QNAME, "foo")).build();
BatchedModifications batched = new BatchedModifications(nextTransactionId(), DataStoreVersions.CURRENT_VERSION);
batched.addModification(new WriteModification(writePath, writeData));
batched.setReady(true);
batched.setDoCommitOnReady(true);
batched.setTotalMessagesSent(1);
transaction.tell(batched, getRef());
expectMsgClass(duration("5 seconds"), CommitTransactionReply.class);
watcher.expectMsgClass(duration("5 seconds"), Terminated.class);
}
};
}
use of akka.testkit.javadsl.TestKit in project controller by opendaylight.
the class ShardTransactionTest method testShardTransactionInactivity.
@Test
public void testShardTransactionInactivity() {
datastoreContext = DatastoreContext.newBuilder().shardTransactionIdleTimeout(500, TimeUnit.MILLISECONDS).build();
new TestKit(getSystem()) {
{
final ActorRef transaction = newTransactionActor(RW, readWriteTransaction(), "testShardTransactionInactivity");
watch(transaction);
expectMsgClass(duration("3 seconds"), Terminated.class);
}
};
}
use of akka.testkit.javadsl.TestKit in project controller by opendaylight.
the class ShardTransactionTest method testOnReceiveDataExistsPositive.
@Test
public void testOnReceiveDataExistsPositive() throws Exception {
new TestKit(getSystem()) {
{
testOnReceiveDataExistsPositive(newTransactionActor(RO, readOnlyTransaction(), "testDataExistsPositiveRO"));
testOnReceiveDataExistsPositive(newTransactionActor(RW, readWriteTransaction(), "testDataExistsPositiveRW"));
}
private void testOnReceiveDataExistsPositive(final ActorRef transaction) {
transaction.tell(new DataExists(YangInstanceIdentifier.EMPTY, DataStoreVersions.CURRENT_VERSION), getRef());
DataExistsReply reply = expectMsgClass(duration("5 seconds"), DataExistsReply.class);
assertTrue(reply.exists());
}
};
}
use of akka.testkit.javadsl.TestKit in project controller by opendaylight.
the class ShardTransactionTest method testOnReceiveReadData.
@Test
public void testOnReceiveReadData() throws Exception {
new TestKit(getSystem()) {
{
testOnReceiveReadData(newTransactionActor(RO, readOnlyTransaction(), "testReadDataRO"));
testOnReceiveReadData(newTransactionActor(RW, readWriteTransaction(), "testReadDataRW"));
}
private void testOnReceiveReadData(final ActorRef transaction) {
transaction.tell(new ReadData(YangInstanceIdentifier.EMPTY, DataStoreVersions.CURRENT_VERSION), getRef());
ReadDataReply reply = expectMsgClass(duration("5 seconds"), ReadDataReply.class);
assertNotNull(reply.getNormalizedNode());
}
};
}
Aggregations