- new JavaTestKit(getSystem()) {{
- ActorContext actorContext = new ActorContext(getSystem(), getRef(),
- mock(ClusterWrapper.class), mock(Configuration.class));
-
- final DataTreeChangeListenerProxy<DOMDataTreeChangeListener> proxy =
- new DataTreeChangeListenerProxy<>(actorContext, mockListener);
-
- final YangInstanceIdentifier path = YangInstanceIdentifier.of(TestModel.TEST_QNAME);
- new Thread() {
- @Override
- public void run() {
- proxy.init("shard-1", path);
- }
-
- }.start();
-
- FiniteDuration timeout = duration("5 seconds");
- FindLocalShard findLocalShard = expectMsgClass(timeout, FindLocalShard.class);
- Assert.assertEquals("getShardName", "shard-1", findLocalShard.getShardName());
-
- reply(new NotInitializedException("not initialized"));
-
- new Within(duration("1 seconds")) {
- @Override
- protected void run() {
- expectNoMsg();
- }
- };
- }};
+ final TestKit kit = new TestKit(getSystem());
+ ActorUtils actorUtils = new ActorUtils(getSystem(), kit.getRef(), mock(ClusterWrapper.class),
+ mock(Configuration.class));
+
+ final YangInstanceIdentifier path = YangInstanceIdentifier.of(TestModel.TEST_QNAME);
+ final DataTreeChangeListenerProxy<DOMDataTreeChangeListener> proxy = new DataTreeChangeListenerProxy<>(
+ actorUtils, mockListener, path);
+
+ new Thread(() -> proxy.init("shard-1")).start();
+
+ Duration timeout = Duration.ofSeconds(5);
+ FindLocalShard findLocalShard = kit.expectMsgClass(timeout, FindLocalShard.class);
+ assertEquals("getShardName", "shard-1", findLocalShard.getShardName());
+
+ kit.reply(new NotInitializedException("not initialized"));
+
+ kit.within(Duration.ofSeconds(1), () -> {
+ kit.expectNoMessage();
+ return null;
+ });
+
+ proxy.close();