NodeNameResolverTest.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.namespace;
00018 
00019 import static org.ros.Assert.assertGraphNameEquals;
00020 
00021 import java.util.HashMap;
00022 import java.util.Map;
00023 
00024 import org.junit.Test;
00025 
00029 public class NodeNameResolverTest {
00030 
00031   @Test
00032   public void testResolveNameOneArg() {
00033     Map<GraphName, GraphName> remappings = new HashMap<GraphName, GraphName>();
00034     GraphName nodeName = GraphName.of("/node");
00035     NodeNameResolver r = new NodeNameResolver(nodeName, NameResolver.newRootFromRemappings(remappings));
00036 
00037     assertGraphNameEquals("/foo", r.resolve("foo"));
00038     assertGraphNameEquals("/foo", r.resolve("/foo"));
00039     assertGraphNameEquals("/foo/bar", r.resolve("foo/bar"));
00040 
00041     assertGraphNameEquals("/node/foo", r.resolve("~foo"));
00042     assertGraphNameEquals("/node/foo/bar", r.resolve("~foo/bar"));
00043     // https://code.ros.org/trac/ros/ticket/3044
00044     assertGraphNameEquals("/node/foo", r.resolve("~/foo"));
00045 
00046     nodeName = GraphName.of("/ns1/node");
00047     r = new NodeNameResolver(nodeName, NameResolver.newRootFromRemappings(remappings));
00048     assertGraphNameEquals("/ns1/node/foo", r.resolve("~foo"));
00049     assertGraphNameEquals("/ns1/node/foo", r.resolve("~/foo"));
00050     assertGraphNameEquals("/ns1/node/foo/bar", r.resolve("~/foo/bar"));
00051 
00052     // Test case where private name is not is same namespace as default
00053     nodeName = GraphName.of("/ns2/node");
00054     r = new NodeNameResolver(nodeName, NameResolver.newFromNamespaceAndRemappings("/ns1", remappings));
00055 
00056     assertGraphNameEquals("/ns1/foo", r.resolve("foo"));
00057     assertGraphNameEquals("/foo", r.resolve("/foo"));
00058     assertGraphNameEquals("/ns1/foo/bar", r.resolve("foo/bar"));
00059 
00060     assertGraphNameEquals("/ns2/node/foo", r.resolve("~foo"));
00061     assertGraphNameEquals("/ns2/node/foo/bar", r.resolve("~foo/bar"));
00062     // https://code.ros.org/trac/ros/ticket/3044
00063     assertGraphNameEquals("/ns2/node/foo", r.resolve("~/foo"));
00064   }
00065 }


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