ClassResolverUtil { public static Class<?> resolve(String className, ClassLoader classLoader) throws ClassNotFoundException { try { return Class.forName(className, false, classLoader); } catch (ClassNotFoundException classNotFoundException) { Class<?> clazz = _primitiveClasses.get(className); if (clazz != null) { return clazz; } throw classNotFoundException; } }  static Class<?> resolve(String className, ClassLoader classLoader);  }
@Test public void testResolve() throws ClassNotFoundException { Assert.assertSame( ClassResolverUtilTest.class, ClassResolverUtil.resolve( ClassResolverUtilTest.class.getName(), ClassResolverUtilTest.class.getClassLoader())); }
@Test public void testResolveWithDifferentClassLoader() throws ClassNotFoundException { Assert.assertSame( ClassResolverUtilTest.class, ClassResolverUtil.resolve( ClassResolverUtilTest.class.getName(), new URLClassLoader(new URL[0]))); }
@Test(expected = ClassNotFoundException.class) public void testResolveWithDifferentClassLoaderAndException() throws ClassNotFoundException { ClassResolverUtil.resolve( ClassResolverUtilTest.class.getName(), new URLClassLoader(new URL[0], null)); }
@Test(expected = ClassNotFoundException.class) public void testResolveWithException() throws ClassNotFoundException { ClassResolverUtil.resolve( "not.a.real.Class", ClassResolverUtilTest.class.getClassLoader()); }
@Test public void testResolveWithPrimitive() throws ClassNotFoundException { Assert.assertSame( boolean.class, ClassResolverUtil.resolve( "boolean", ClassResolverUtilTest.class.getClassLoader())); }