Merge "Bug-1338: Create a grouping for order to help create generic OrderComparator...
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / test / java / org / opendaylight / controller / cluster / datastore / ShardTransactionFailureTest.java
index 0f9e771ab4d13781c99a52ee293981dbd82699af..02ceee82e05d2f78981bb89f3e1c6e9a3b4e1f61 100644 (file)
@@ -122,6 +122,41 @@ public class ShardTransactionFailureTest extends AbstractActorTest {
         Await.result(future, Duration.Zero());
 
 
+    }
+
+    @Test(expected = ReadFailedException.class)
+    public void testNegativeExistsWithReadWriteOnlyTransactionClosed()
+        throws Throwable {
+
+        final ActorRef shard =
+            getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP));
+        final Props props =
+            ShardTransaction.props(store.newReadWriteTransaction(), shard,
+                TestModel.createTestContext());
+
+        final TestActorRef<ShardTransaction> subject = TestActorRef
+            .create(getSystem(), props,
+                "testNegativeExistsWithReadWriteOnlyTransactionClosed");
+
+        ShardTransactionMessages.DataExists dataExists =
+            ShardTransactionMessages.DataExists.newBuilder()
+                .setInstanceIdentifierPathArguments(
+                    NormalizedNodeMessages.InstanceIdentifier.newBuilder()
+                        .build()
+                ).build();
+
+        Future<Object> future =
+            akka.pattern.Patterns.ask(subject, dataExists, 3000);
+        assertTrue(future.isCompleted());
+        Await.result(future, Duration.Zero());
+
+        ((ShardReadWriteTransaction) subject.underlyingActor())
+            .forUnitTestOnlyExplicitTransactionClose();
+
+        future = akka.pattern.Patterns.ask(subject, dataExists, 3000);
+        Await.result(future, Duration.Zero());
+
+
     }
 
     @Test(expected = IllegalStateException.class)