- new JavaTestKit(getSystem()) {{
- ActorSystem mockActorSystem = mock(ActorSystem.class);
-
- ActorRef mockActor = getSystem().actorOf(Props.create(DoNothingActor.class),
- "testFailedRegistration");
- doReturn(mockActor).when(mockActorSystem).actorOf(any(Props.class));
- ExecutionContextExecutor executor = ExecutionContexts.fromExecutor(
- MoreExecutors.sameThreadExecutor());
- doReturn(executor).when(mockActorSystem).dispatcher();
-
- ActorContext actorContext = mock(ActorContext.class);
-
- String shardName = "shard-1";
- final DataChangeListenerRegistrationProxy proxy = new DataChangeListenerRegistrationProxy(
- shardName, actorContext, mockListener);
-
- doReturn(mockActorSystem).when(actorContext).getActorSystem();
- doReturn(duration("5 seconds")).when(actorContext).getOperationDuration();
- doReturn(Futures.successful(getRef())).when(actorContext).findLocalShardAsync(eq(shardName),
- any(Timeout.class));
- doReturn(Futures.failed(new RuntimeException("mock"))).
- when(actorContext).executeOperationAsync(any(ActorRef.class),
- any(Object.class), any(Timeout.class));
-
- proxy.init(YangInstanceIdentifier.of(TestModel.TEST_QNAME),
- AsyncDataBroker.DataChangeScope.ONE);
-
- Assert.assertEquals("getListenerRegistrationActor", null,
- proxy.getListenerRegistrationActor());
- }};
+ new JavaTestKit(getSystem()) {
+ {
+ ActorSystem mockActorSystem = mock(ActorSystem.class);
+
+ ActorRef mockActor = getSystem().actorOf(Props.create(DoNothingActor.class),
+ "testFailedRegistration");
+ doReturn(mockActor).when(mockActorSystem).actorOf(any(Props.class));
+ ExecutionContextExecutor executor = ExecutionContexts.fromExecutor(
+ MoreExecutors.directExecutor());
+
+
+ ActorContext actorContext = mock(ActorContext.class);
+
+ doReturn(executor).when(actorContext).getClientDispatcher();
+
+ String shardName = "shard-1";
+ final DataChangeListenerRegistrationProxy proxy = new DataChangeListenerRegistrationProxy(
+ shardName, actorContext, mockListener);
+
+ doReturn(mockActorSystem).when(actorContext).getActorSystem();
+ doReturn(duration("5 seconds")).when(actorContext).getOperationDuration();
+ doReturn(Futures.successful(getRef())).when(actorContext).findLocalShardAsync(eq(shardName));
+ doReturn(Futures.failed(new RuntimeException("mock")))
+ .when(actorContext).executeOperationAsync(any(ActorRef.class),
+ any(Object.class), any(Timeout.class));
+ doReturn(mock(DatastoreContext.class)).when(actorContext).getDatastoreContext();
+
+ proxy.init(YangInstanceIdentifier.of(TestModel.TEST_QNAME),
+ AsyncDataBroker.DataChangeScope.ONE);
+
+ Assert.assertEquals("getListenerRegistrationActor", null, proxy.getListenerRegistrationActor());
+
+ proxy.close();
+ }
+ };