- private static ListeningExecutorService storeExecutor = MoreExecutors.listeningDecorator(MoreExecutors.sameThreadExecutor());
-
- private static final InMemoryDOMDataStore store = new InMemoryDOMDataStore("OPER", storeExecutor,
- MoreExecutors.sameThreadExecutor());
-
- static {
- store.onGlobalContextUpdated(TestModel.createTestContext());
- }
-
-
- @Test
- public void testOnReceiveCloseListenerRegistration() throws Exception {
- new JavaTestKit(getSystem()) {{
- final Props props = DataChangeListenerRegistration.props(store
- .registerChangeListener(TestModel.TEST_PATH, noOpDataChangeListener(),
- AsyncDataBroker.DataChangeScope.BASE));
- final ActorRef subject = getSystem().actorOf(props, "testCloseListenerRegistration");
-
- new Within(duration("1 seconds")) {
- @Override
- protected void run() {
-
- subject.tell(new CloseDataChangeListenerRegistration().toSerializable(), getRef());
-
- final String out = new ExpectMsg<String>(duration("1 seconds"), "match hint") {
- // do not put code outside this method, will run afterwards
- @Override
- protected String match(Object in) {
- if (in.getClass().equals(CloseDataChangeListenerRegistrationReply.SERIALIZABLE_CLASS)) {
- return "match";
- } else {
- throw noMatch();
- }
+ private static final InMemoryDOMDataStore STORE = new InMemoryDOMDataStore("OPER",
+ MoreExecutors.newDirectExecutorService());
+
+ static {
+ STORE.onGlobalContextUpdated(TestModel.createTestContext());
+ }
+
+ @Test
+ public void testOnReceiveCloseListenerRegistration() throws Exception {
+ new JavaTestKit(getSystem()) {
+ {
+ final Props props = DataChangeListenerRegistrationActor.props(STORE.registerChangeListener(
+ TestModel.TEST_PATH, noOpDataChangeListener(), AsyncDataBroker.DataChangeScope.BASE));
+ final ActorRef subject = getSystem().actorOf(props, "testCloseListenerRegistration");
+
+ new Within(duration("1 seconds")) {
+ @Override
+ protected void run() {
+
+ subject.tell(CloseDataChangeListenerRegistration.INSTANCE, getRef());
+
+ final String out = new ExpectMsg<String>(duration("1 seconds"), "match hint") {
+ // do not put code outside this method, will run
+ // afterwards
+ @Override
+ protected String match(final Object in) {
+ if (in.getClass().equals(CloseDataChangeListenerRegistrationReply.class)) {
+ return "match";
+ } else {
+ throw noMatch();
+ }
+ }
+ }.get(); // this extracts the received message
+
+ assertEquals("match", out);
+
+ expectNoMsg();
+ }
+
+ };