@Test public void testSetOwnerProperties_propertiesAreMoved() throws Exception { InMemoryClient client = new InMemoryClient( new InMemoryRoutingContext(), RecipientKind.DM ); RoboconfMessageQueue queue = new RoboconfMessageQueue(); client.setMessageQueue( queue ); client.openConnection(); MessagingContext ctx = new MessagingContext( RecipientKind.AGENTS, "domain", "app" ); client.subscribe( ctx ); String ownerId_1 = client.getOwnerId(); Map<String,Set<MessagingContext>> sub = client.getRoutingContext().subscriptions; Map<String,LinkedBlockingQueue<Message>> ctxToQueue = ((InMemoryRoutingContext) client.getRoutingContext()).ctxToQueue; Assert.assertEquals( queue, ctxToQueue.get( ownerId_1 )); Set<MessagingContext> subscribedContexts = sub.get( ownerId_1 ); Assert.assertNotNull( subscribedContexts ); Assert.assertEquals( 1, subscribedContexts.size()); Assert.assertTrue( subscribedContexts.contains( ctx )); client.setOwnerProperties( RecipientKind.AGENTS, "domain", "app1", "root1" ); String ownerId_2 = client.getOwnerId(); Assert.assertFalse( ownerId_2.equals( ownerId_1 )); Assert.assertEquals( queue, ctxToQueue.get( ownerId_2 )); Assert.assertNull( ctxToQueue.get( ownerId_1 )); Assert.assertNull( sub.get( ownerId_1 )); subscribedContexts = sub.get( ownerId_2 ); Assert.assertNotNull( subscribedContexts ); Assert.assertEquals( 1, subscribedContexts.size()); Assert.assertTrue( subscribedContexts.contains( ctx )); }
@Override public void setMessageQueue( RoboconfMessageQueue messageQueue ) { this.ctxToQueue.put( this.ownerId, messageQueue ); }
InMemoryClient extends AbstractRoutingClient<LinkedBlockingQueue<Message>> { @Override public void setMessageQueue( RoboconfMessageQueue messageQueue ) { this.ctxToQueue.put( this.ownerId, messageQueue ); } }
InMemoryClient extends AbstractRoutingClient<LinkedBlockingQueue<Message>> { @Override public void setMessageQueue( RoboconfMessageQueue messageQueue ) { this.ctxToQueue.put( this.ownerId, messageQueue ); } InMemoryClient( InMemoryRoutingContext routingContext, RecipientKind ownerKind ); }
InMemoryClient extends AbstractRoutingClient<LinkedBlockingQueue<Message>> { @Override public void setMessageQueue( RoboconfMessageQueue messageQueue ) { this.ctxToQueue.put( this.ownerId, messageQueue ); } InMemoryClient( InMemoryRoutingContext routingContext, RecipientKind ownerKind ); @Override void setMessageQueue( RoboconfMessageQueue messageQueue ); @Override String getMessagingType(); }
InMemoryClient extends AbstractRoutingClient<LinkedBlockingQueue<Message>> { @Override public void setMessageQueue( RoboconfMessageQueue messageQueue ) { this.ctxToQueue.put( this.ownerId, messageQueue ); } InMemoryClient( InMemoryRoutingContext routingContext, RecipientKind ownerKind ); @Override void setMessageQueue( RoboconfMessageQueue messageQueue ); @Override String getMessagingType();  }