JavaClassNames { public static String resolveName(Object context, String path) { Preconditions.checkNotNull(path, "path must not be null"); if (path.startsWith("/") || Urls.isUrlWithProtocol(path)) return path; Preconditions.checkNotNull(context, "context must not be null when path is relative"); return packagePath(context)+path; }  static Class<?> type(Object x); static Class<?> componentType(Object x); static String superSimpleClassName(Class<?> t); static String superSimpleClassName(Object o); static String simpleClassName(Class<?> t); static String verySimpleClassName(Class<?> t); static String simpleClassName(Object x); static String simplifyClassName(String className); static String cleanSimpleClassName(Object x); static String cleanSimpleClassName(Class<?> x); static String packageName(Object x); static String packagePath(Object x); static String resolveName(Object context, String path); static String resolveClasspathUrl(Object context, String path); static StackTraceElement[] currentStackTraceCleaned(); static StackTraceElement currentStackElement(); static StackTraceElement callerStackElement(int depth); static String niceClassAndMethod(StackTraceElement st); static String callerNiceClassAndMethod(int depth); static String niceClassAndMethod();  }
@Test public void testResolveName() { Assert.assertEquals(JavaClassNames.resolveName(this, "foo.txt"), "/org/apache/brooklyn/util/javalang/foo.txt"); Assert.assertEquals(JavaClassNames.resolveName(JavaClassNamesTest.class, "foo.txt"), "/org/apache/brooklyn/util/javalang/foo.txt"); Assert.assertEquals(JavaClassNames.resolveName(this, "/foo.txt"), "/foo.txt"); Assert.assertEquals(JavaClassNames.resolveName(this, "/bar/foo.txt"), "/bar/foo.txt"); Assert.assertEquals(JavaClassNames.resolveName(this, "bar/foo.txt"), "/org/apache/brooklyn/util/javalang/bar/foo.txt"); }