Пример #1
0
 @Test
 public void testGetPidNotSupported() {
   SlaveServer mockSlave = mock(SlaveServer.class);
   AdvertiseAddress address = AdvertiseAddress.newPrivate();
   address.setStaticPort(1234);
   when(mockSlave.getPid()).thenThrow(new UnsupportedOperationException());
   SlaveXmlRpcEndpointImpl slave = new SlaveXmlRpcEndpointImpl(mockSlave);
   List<Object> response = slave.getPid("/foo");
   assertEquals(response.get(0), StatusCode.FAILURE.toInt());
 }
Пример #2
0
 @Test
 public void testGetPid() {
   SlaveServer mockSlave = mock(SlaveServer.class);
   AdvertiseAddress address = AdvertiseAddress.newPrivate();
   address.setStaticPort(1234);
   when(mockSlave.getPid()).thenReturn(1234);
   SlaveXmlRpcEndpointImpl slave = new SlaveXmlRpcEndpointImpl(mockSlave);
   List<Object> response = slave.getPid("/foo");
   assertEquals(response.get(0), StatusCode.SUCCESS.toInt());
   assertEquals(response.get(2), 1234);
 }
Пример #3
0
 @Test
 public void testRequestTopic() throws ServerException {
   SlaveServer mockSlave = mock(SlaveServer.class);
   AdvertiseAddress address = AdvertiseAddress.newPrivate();
   address.setStaticPort(1234);
   TcpRosProtocolDescription protocol = new TcpRosProtocolDescription(address);
   when(mockSlave.requestTopic(
           Matchers.<String>any(),
           Matchers.eq(Sets.newHashSet(ProtocolNames.TCPROS, ProtocolNames.UDPROS))))
       .thenReturn(protocol);
   SlaveXmlRpcEndpointImpl slave = new SlaveXmlRpcEndpointImpl(mockSlave);
   Object[][] protocols = new Object[][] {{ProtocolNames.TCPROS}, {ProtocolNames.UDPROS}};
   List<Object> response = slave.requestTopic("/foo", "/bar", protocols);
   assertEquals(response.get(0), StatusCode.SUCCESS.toInt());
   assertEquals(response.get(2), protocol.toList());
 }
 @Override
 public int hashCode() {
   final int prime = 31;
   int result = 1;
   result = prime * result + ((address == null) ? 0 : address.hashCode());
   result = prime * result + ((name == null) ? 0 : name.hashCode());
   return result;
 }
 @Override
 public boolean equals(Object obj) {
   if (this == obj) return true;
   if (obj == null) return false;
   if (getClass() != obj.getClass()) return false;
   ProtocolDescription other = (ProtocolDescription) obj;
   if (address == null) {
     if (other.address != null) return false;
   } else if (!address.equals(other.address)) return false;
   if (name == null) {
     if (other.name != null) return false;
   } else if (!name.equals(other.name)) return false;
   return true;
 }
 public List<Object> toList() {
   return Lists.newArrayList((Object) name, address.getHost(), address.getPort());
 }
 public InetSocketAddress getAddress() {
   return address.toInetSocketAddress();
 }