예제 #1
0
 @Test
 public void testGetPublicationsEmptyList() {
   SlaveServer mockSlave = mock(SlaveServer.class);
   when(mockSlave.getPublications()).thenReturn(Lists.<DefaultPublisher<?>>newArrayList());
   SlaveXmlRpcEndpointImpl slave = new SlaveXmlRpcEndpointImpl(mockSlave);
   List<Object> response = slave.getPublications("/foo");
   assertEquals(response.get(0), StatusCode.SUCCESS.toInt());
   assertEquals(response.get(2), Lists.newArrayList());
 }
예제 #2
0
 @Test
 public void testGetPublications() {
   SlaveServer mockSlave = mock(SlaveServer.class);
   DefaultPublisher<?> mockPublisher = mock(DefaultPublisher.class);
   when(mockSlave.getPublications())
       .thenReturn(Lists.<DefaultPublisher<?>>newArrayList(mockPublisher));
   when(mockPublisher.getTopicName()).thenReturn(GraphName.of("/bar"));
   when(mockPublisher.getTopicMessageType()).thenReturn("/baz");
   when(mockPublisher.getTopicDeclarationAsList()).thenReturn(Lists.newArrayList("/bar", "/baz"));
   SlaveXmlRpcEndpointImpl slave = new SlaveXmlRpcEndpointImpl(mockSlave);
   List<Object> response = slave.getPublications("/foo");
   assertEquals(StatusCode.SUCCESS.toInt(), response.get(0));
   List<List<String>> protocols = Lists.newArrayList();
   protocols.add(Lists.newArrayList("/bar", "/baz"));
   assertEquals(protocols, response.get(2));
 }