- public void testNegativeExistsWithReadWriteOnlyTransactionClosed()
- throws Throwable {
-
- final ActorRef shard =
- getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP,null));
- 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)
- public void testNegativeWriteWithTransactionReady() throws Exception {
-
-
- final ActorRef shard =
- getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP,null));
- final Props props =
- ShardTransaction.props(store.newWriteOnlyTransaction(), shard,
- TestModel.createTestContext());
-
- final TestActorRef<ShardTransaction> subject = TestActorRef
- .create(getSystem(), props,
- "testNegativeWriteWithTransactionReady");
-
- ShardTransactionMessages.ReadyTransaction readyTransaction =
- ShardTransactionMessages.ReadyTransaction.newBuilder().build();
-
- Future<Object> future =
- akka.pattern.Patterns.ask(subject, readyTransaction, 3000);
- assertTrue(future.isCompleted());
- Await.result(future, Duration.Zero());
-
- ShardTransactionMessages.WriteData writeData =
- ShardTransactionMessages.WriteData.newBuilder()
- .setInstanceIdentifierPathArguments(
- NormalizedNodeMessages.InstanceIdentifier.newBuilder()
- .build()).setNormalizedNode(
- NormalizedNodeMessages.Node.newBuilder().build()
-
- ).build();
-
- future = akka.pattern.Patterns.ask(subject, writeData, 3000);
- assertTrue(future.isCompleted());
- Await.result(future, Duration.Zero());
-
-
- }
-
-
- @Test(expected = IllegalStateException.class)
- public void testNegativeReadWriteWithTransactionReady() throws Exception {
-
-
- final ActorRef shard =
- getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP,null));
- final Props props =
- ShardTransaction.props(store.newReadWriteTransaction(), shard,
- TestModel.createTestContext());
-
- final TestActorRef<ShardTransaction> subject = TestActorRef
- .create(getSystem(), props,
- "testNegativeReadWriteWithTransactionReady");
-
- ShardTransactionMessages.ReadyTransaction readyTransaction =
- ShardTransactionMessages.ReadyTransaction.newBuilder().build();
-
- Future<Object> future =
- akka.pattern.Patterns.ask(subject, readyTransaction, 3000);
- assertTrue(future.isCompleted());
- Await.result(future, Duration.Zero());
-
- ShardTransactionMessages.WriteData writeData =
- ShardTransactionMessages.WriteData.newBuilder()
- .setInstanceIdentifierPathArguments(
- NormalizedNodeMessages.InstanceIdentifier.newBuilder()
- .build()).setNormalizedNode(
- NormalizedNodeMessages.Node.newBuilder().build()
-
- ).build();
-
- future = akka.pattern.Patterns.ask(subject, writeData, 3000);
- assertTrue(future.isCompleted());
- Await.result(future, Duration.Zero());
-
-
- }
-
- @Test(expected = IllegalStateException.class)
- public void testNegativeMergeTransactionReady() throws Exception {
-
-
- final ActorRef shard =
- getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP,null));
- final Props props =
- ShardTransaction.props(store.newReadWriteTransaction(), shard,
- TestModel.createTestContext());
-
- final TestActorRef<ShardTransaction> subject = TestActorRef
- .create(getSystem(), props, "testNegativeMergeTransactionReady");
-
- ShardTransactionMessages.ReadyTransaction readyTransaction =
- ShardTransactionMessages.ReadyTransaction.newBuilder().build();
-
- Future<Object> future =
- akka.pattern.Patterns.ask(subject, readyTransaction, 3000);
- assertTrue(future.isCompleted());
- Await.result(future, Duration.Zero());
-
- ShardTransactionMessages.MergeData mergeData =
- ShardTransactionMessages.MergeData.newBuilder()
- .setInstanceIdentifierPathArguments(
- NormalizedNodeMessages.InstanceIdentifier.newBuilder()
- .build()).setNormalizedNode(
- NormalizedNodeMessages.Node.newBuilder().build()
-
- ).build();
-
- future = akka.pattern.Patterns.ask(subject, mergeData, 3000);
- assertTrue(future.isCompleted());
- Await.result(future, Duration.Zero());
-
-
- }
-
-
- @Test(expected = IllegalStateException.class)
- public void testNegativeDeleteDataWhenTransactionReady() throws Exception {
-
-
- final ActorRef shard =
- getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP,null));
- final Props props =
- ShardTransaction.props(store.newReadWriteTransaction(), shard,
- TestModel.createTestContext());
-
- final TestActorRef<ShardTransaction> subject = TestActorRef
- .create(getSystem(), props,
- "testNegativeDeleteDataWhenTransactionReady");
-
- ShardTransactionMessages.ReadyTransaction readyTransaction =
- ShardTransactionMessages.ReadyTransaction.newBuilder().build();