@Test public void testForNameWithPrimitiveClasses() throws ClassNotFoundException { assertEquals(boolean.class, ClassUtils.forName("boolean", classLoader)); assertEquals(byte.class, ClassUtils.forName("byte", classLoader)); assertEquals(char.class, ClassUtils.forName("char", classLoader)); assertEquals(short.class, ClassUtils.forName("short", classLoader)); assertEquals(int.class, ClassUtils.forName("int", classLoader)); assertEquals(long.class, ClassUtils.forName("long", classLoader)); assertEquals(float.class, ClassUtils.forName("float", classLoader)); assertEquals(double.class, ClassUtils.forName("double", classLoader)); assertEquals(void.class, ClassUtils.forName("void", classLoader)); }
@Test public void testForNameWithPrimitiveArrays() throws ClassNotFoundException { assertEquals(boolean[].class, ClassUtils.forName("boolean[]", classLoader)); assertEquals(byte[].class, ClassUtils.forName("byte[]", classLoader)); assertEquals(char[].class, ClassUtils.forName("char[]", classLoader)); assertEquals(short[].class, ClassUtils.forName("short[]", classLoader)); assertEquals(int[].class, ClassUtils.forName("int[]", classLoader)); assertEquals(long[].class, ClassUtils.forName("long[]", classLoader)); assertEquals(float[].class, ClassUtils.forName("float[]", classLoader)); assertEquals(double[].class, ClassUtils.forName("double[]", classLoader)); }
@Test public void testForNameWithPrimitiveArraysInternalName() throws ClassNotFoundException { assertEquals(boolean[].class, ClassUtils.forName(boolean[].class.getName(), classLoader)); assertEquals(byte[].class, ClassUtils.forName(byte[].class.getName(), classLoader)); assertEquals(char[].class, ClassUtils.forName(char[].class.getName(), classLoader)); assertEquals(short[].class, ClassUtils.forName(short[].class.getName(), classLoader)); assertEquals(int[].class, ClassUtils.forName(int[].class.getName(), classLoader)); assertEquals(long[].class, ClassUtils.forName(long[].class.getName(), classLoader)); assertEquals(float[].class, ClassUtils.forName(float[].class.getName(), classLoader)); assertEquals(double[].class, ClassUtils.forName(double[].class.getName(), classLoader)); }
@Test public void testForName() throws ClassNotFoundException { assertEquals(String.class, ClassUtils.forName("java.lang.String", classLoader)); assertEquals(String[].class, ClassUtils.forName("java.lang.String[]", classLoader)); assertEquals(String[].class, ClassUtils.forName(String[].class.getName(), classLoader)); assertEquals(String[][].class, ClassUtils.forName(String[][].class.getName(), classLoader)); assertEquals(String[][][].class, ClassUtils.forName(String[][][].class.getName(), classLoader)); assertEquals( TestObject.class, ClassUtils.forName("org.springframework.tests.sample.objects.TestObject", classLoader)); assertEquals( TestObject[].class, ClassUtils.forName("org.springframework.tests.sample.objects.TestObject[]", classLoader)); assertEquals(TestObject[].class, ClassUtils.forName(TestObject[].class.getName(), classLoader)); assertEquals( TestObject[][].class, ClassUtils.forName("org.springframework.tests.sample.objects.TestObject[][]", classLoader)); assertEquals( TestObject[][].class, ClassUtils.forName(TestObject[][].class.getName(), classLoader)); assertEquals(short[][][].class, ClassUtils.forName("[[[S", classLoader)); }