- private void verifyRouting(FooService product) {
- Map<InstanceIdentifier,FooService> routingTable = new HashMap<>();
- setRoutingTable(product, BaseIdentity.class, routingTable);
-
- assertSame("Returned routing table should be same instance",routingTable,getRoutingTable(product, BaseIdentity.class));
-
+ @Test
+ public void testInvoker() throws Exception {
+
+ FooListenerImpl fooListener = new FooListenerImpl();
+
+ NotificationInvoker invokerFoo = invokerFactory.invokerFor(fooListener);
+
+
+ assertSame(fooListener,invokerFoo.getDelegate());
+ assertNotNull(invokerFoo.getSupportedNotifications());
+ assertEquals(1, invokerFoo.getSupportedNotifications().size());
+ assertNotNull(invokerFoo.getInvocationProxy());
+
+ FooUpdateImpl fooOne = new FooUpdateImpl();
+ invokerFoo.getInvocationProxy().onNotification(fooOne);
+
+ assertEquals(1, fooListener.receivedFoos.size());
+ assertSame(fooOne, fooListener.receivedFoos.get(0));
+
+ CompositeListenerImpl composite = new CompositeListenerImpl();
+
+ NotificationInvoker invokerComposite = invokerFactory.invokerFor(composite);
+
+ assertNotNull(invokerComposite.getSupportedNotifications());
+ assertEquals(3, invokerComposite.getSupportedNotifications().size());
+ assertNotNull(invokerComposite.getInvocationProxy());
+
+ invokerComposite.getInvocationProxy().onNotification(fooOne);
+
+ assertEquals(1, composite.receivedFoos.size());
+ assertSame(fooOne, composite.receivedFoos.get(0));
+
+ assertEquals(0, composite.receivedBars.size());
+
+ BarUpdateImpl barOne = new BarUpdateImpl();
+
+ invokerComposite.getInvocationProxy().onNotification(barOne);
+
+ assertEquals(1, composite.receivedFoos.size());
+ assertEquals(1, composite.receivedBars.size());
+ assertSame(barOne, composite.receivedBars.get(0));
+
+ }
+
+ private void verifyRouting(final RpcRouter<FooService> product) {
+ assertNotNull("Routing table should be initialized", product.getRoutingTable(BaseIdentity.class));
+
+ RpcRoutingTable<BaseIdentity, FooService> routingTable = product.getRoutingTable(BaseIdentity.class);
+