@Test public void testRegisterPublisher() throws Exception { MasterServer mockMaster = mock(MasterServer.class); final GraphName nodeName = GraphName.of("/slave"); final URI nodeSlaveUri = new URI("http: final GraphName topicName = GraphName.of("/topic"); final String messageType = "/topicType"; when( mockMaster .registerPublisher(eq(nodeName), eq(nodeSlaveUri), eq(topicName), eq(messageType))) .thenReturn(Lists.<URI>newArrayList(nodeSlaveUri)); MasterXmlRpcEndpointImpl master = new MasterXmlRpcEndpointImpl(mockMaster); List<Object> response = master.registerPublisher(nodeName.toString(), topicName.toString(), messageType, nodeSlaveUri.toString()); assertEquals(StatusCode.SUCCESS.toInt(), response.get(0)); assertEquals(Lists.newArrayList(nodeSlaveUri.toString()), response.get(2)); }
@Override public List<Object> registerPublisher(String callerId, String topicName, String topicMessageType, String callerSlaveUri) { try { List<URI> subscribers = master.registerPublisher(GraphName.of(callerId), new URI(callerSlaveUri), GraphName.of( topicName), topicMessageType); List<String> urls = Lists.newArrayList(); for (URI uri : subscribers) { urls.add(uri.toString()); } return Response.newSuccess("Success", urls).toList(); } catch (URISyntaxException e) { throw new RosRuntimeException(String.format("Improperly formatted URI %s for publisher", callerSlaveUri), e); } }
MasterXmlRpcEndpointImpl implements MasterXmlRpcEndpoint,
    ParameterServerXmlRpcEndpoint { @Override public List<Object> registerPublisher(String callerId, String topicName, String topicMessageType, String callerSlaveUri) { try { List<URI> subscribers = master.registerPublisher(GraphName.of(callerId), new URI(callerSlaveUri), GraphName.of( topicName), topicMessageType); List<String> urls = Lists.newArrayList(); for (URI uri : subscribers) { urls.add(uri.toString()); } return Response.newSuccess("Success", urls).toList(); } catch (URISyntaxException e) { throw new RosRuntimeException(String.format("Improperly formatted URI %s for publisher", callerSlaveUri), e); } } }
MasterXmlRpcEndpointImpl implements MasterXmlRpcEndpoint,
    ParameterServerXmlRpcEndpoint { @Override public List<Object> registerPublisher(String callerId, String topicName, String topicMessageType, String callerSlaveUri) { try { List<URI> subscribers = master.registerPublisher(GraphName.of(callerId), new URI(callerSlaveUri), GraphName.of( topicName), topicMessageType); List<String> urls = Lists.newArrayList(); for (URI uri : subscribers) { urls.add(uri.toString()); } return Response.newSuccess("Success", urls).toList(); } catch (URISyntaxException e) { throw new RosRuntimeException(String.format("Improperly formatted URI %s for publisher", callerSlaveUri), e); } } MasterXmlRpcEndpointImpl(MasterServer master); }
MasterXmlRpcEndpointImpl implements MasterXmlRpcEndpoint,
    ParameterServerXmlRpcEndpoint { @Override public List<Object> registerPublisher(String callerId, String topicName, String topicMessageType, String callerSlaveUri) { try { List<URI> subscribers = master.registerPublisher(GraphName.of(callerId), new URI(callerSlaveUri), GraphName.of( topicName), topicMessageType); List<String> urls = Lists.newArrayList(); for (URI uri : subscribers) { urls.add(uri.toString()); } return Response.newSuccess("Success", urls).toList(); } catch (URISyntaxException e) { throw new RosRuntimeException(String.format("Improperly formatted URI %s for publisher", callerSlaveUri), e); } } MasterXmlRpcEndpointImpl(MasterServer master); @Override List<Object> getPid(String callerId); @Override List<Object> getPublishedTopics(String callerId, String subgraph); @Override List<Object> getTopicTypes(String callerId); @Override List<Object> getSystemState(String callerId); @Override List<Object> getUri(String callerId); @Override List<Object> lookupNode(String callerId, String nodeName); @Override List<Object> registerPublisher(String callerId, String topicName, String topicMessageType,
      String callerSlaveUri); @Override List<Object> unregisterPublisher(String callerId, String topicName, String callerSlaveUri); @Override List<Object> registerSubscriber(String callerId, String topicName,
      String topicMessageType, String callerSlaveUri); @Override List<Object> unregisterSubscriber(String callerId, String topicName, String callerSlaveUri); @Override List<Object> lookupService(String callerId, String serviceName); @Override List<Object> registerService(String callerId, String serviceName, String serviceUri,
      String callerSlaveUri); @Override List<Object> unregisterService(String callerId, String serviceName, String serviceUri); @Override List<Object> setParam(String callerId, String key, Boolean value); @Override List<Object> setParam(String callerId, String key, Integer value); @Override List<Object> setParam(String callerId, String key, Double value); @Override List<Object> setParam(String callerId, String key, String value); @Override List<Object> setParam(String callerId, String key, List<?> value); @Override List<Object> setParam(String callerId, String key, Map<?, ?> value); @Override List<Object> getParam(String callerId, String key); @Override List<Object> searchParam(String callerId, String key); @Override List<Object> subscribeParam(String callerId, String callerSlaveUri, String key); @Override List<Object> unsubscribeParam(String callerId, String callerSlaveUri, String key); @Override List<Object> deleteParam(String callerId, String key); @Override List<Object> hasParam(String callerId, String key); @Override List<Object> getParamNames(String callerId); }
MasterXmlRpcEndpointImpl implements MasterXmlRpcEndpoint,
    ParameterServerXmlRpcEndpoint { @Override public List<Object> registerPublisher(String callerId, String topicName, String topicMessageType, String callerSlaveUri) { try { List<URI> subscribers = master.registerPublisher(GraphName.of(callerId), new URI(callerSlaveUri), GraphName.of( topicName), topicMessageType); List<String> urls = Lists.newArrayList(); for (URI uri : subscribers) { urls.add(uri.toString()); } return Response.newSuccess("Success", urls).toList(); } catch (URISyntaxException e) { throw new RosRuntimeException(String.format("Improperly formatted URI %s for publisher", callerSlaveUri), e); } } MasterXmlRpcEndpointImpl(MasterServer master); @Override List<Object> getPid(String callerId); @Override List<Object> getPublishedTopics(String callerId, String subgraph); @Override List<Object> getTopicTypes(String callerId); @Override List<Object> getSystemState(String callerId); @Override List<Object> getUri(String callerId); @Override List<Object> lookupNode(String callerId, String nodeName); @Override List<Object> registerPublisher(String callerId, String topicName, String topicMessageType,
      String callerSlaveUri); @Override List<Object> unregisterPublisher(String callerId, String topicName, String callerSlaveUri); @Override List<Object> registerSubscriber(String callerId, String topicName,
      String topicMessageType, String callerSlaveUri); @Override List<Object> unregisterSubscriber(String callerId, String topicName, String callerSlaveUri); @Override List<Object> lookupService(String callerId, String serviceName); @Override List<Object> registerService(String callerId, String serviceName, String serviceUri,
      String callerSlaveUri); @Override List<Object> unregisterService(String callerId, String serviceName, String serviceUri); @Override List<Object> setParam(String callerId, String key, Boolean value); @Override List<Object> setParam(String callerId, String key, Integer value); @Override List<Object> setParam(String callerId, String key, Double value); @Override List<Object> setParam(String callerId, String key, String value); @Override List<Object> setParam(String callerId, String key, List<?> value); @Override List<Object> setParam(String callerId, String key, Map<?, ?> value); @Override List<Object> getParam(String callerId, String key); @Override List<Object> searchParam(String callerId, String key); @Override List<Object> subscribeParam(String callerId, String callerSlaveUri, String key); @Override List<Object> unsubscribeParam(String callerId, String callerSlaveUri, String key); @Override List<Object> deleteParam(String callerId, String key); @Override List<Object> hasParam(String callerId, String key); @Override List<Object> getParamNames(String callerId);  }