Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 package org.ros.internal.node.server;
00018
00019 import static org.junit.Assert.assertEquals;
00020 import static org.junit.Assert.assertTrue;
00021 import static org.junit.Assert.fail;
00022
00023 import java.net.URI;
00024
00025 import org.junit.Test;
00026 import org.ros.address.Address;
00027 import org.ros.address.AdvertiseAddress;
00028 import org.ros.address.BindAddress;
00029 import org.ros.internal.node.xmlrpc.XmlRpcEndpoint;
00030
00034 public class XmlRpcServerTest {
00035
00036 class FakeNode implements XmlRpcEndpoint {
00037 }
00038
00039 @Test
00040 public void testGetPublicUri() {
00041 BindAddress bindAddress = BindAddress.newPublic();
00042 XmlRpcServer xmlRpcServer = new XmlRpcServer(bindAddress, new AdvertiseAddress("override"));
00043 try {
00044 xmlRpcServer.getUri();
00045 fail("Should not have succeeded before startup.");
00046 } catch (RuntimeException e) {
00047 }
00048
00049 xmlRpcServer.start(FakeNode.class, new FakeNode());
00050 URI uri = xmlRpcServer.getUri();
00051 assertEquals("override", uri.getHost());
00052 assertTrue(uri.getPort() > 0);
00053
00054 xmlRpcServer.shutdown();
00055 }
00056
00057 @Test
00058 public void testGetPrivateUri() {
00059 BindAddress bindAddress = BindAddress.newPrivate();
00060 XmlRpcServer xmlRpcServer = new XmlRpcServer(bindAddress, AdvertiseAddress.newPrivate());
00061 try {
00062 xmlRpcServer.getUri();
00063 fail("Should not have succeeded before startup.");
00064 } catch (RuntimeException e) {
00065 }
00066
00067 xmlRpcServer.start(FakeNode.class, new FakeNode());
00068 URI uri = xmlRpcServer.getUri();
00069 assertEquals(Address.LOOPBACK, uri.getHost());
00070 assertTrue(uri.getPort() > 0);
00071
00072 xmlRpcServer.shutdown();
00073 }
00074 }