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.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
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
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
00063 assertGraphNameEquals("/ns2/node/foo", r.resolve("~/foo"));
00064 }
00065 }