XmlRpcServerTest.java
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2011 Google Inc.
00003  * 
00004  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
00005  * use this file except in compliance with the License. You may obtain a copy of
00006  * the License at
00007  * 
00008  * http://www.apache.org/licenses/LICENSE-2.0
00009  * 
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
00012  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
00013  * License for the specific language governing permissions and limitations under
00014  * the License.
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 }


rosjava_core
Author(s):
autogenerated on Wed Aug 26 2015 16:06:49