EgovObjectUtil { public static Class<?> loadClass(String className) throws ClassNotFoundException, Exception { Class<?> clazz = Thread.currentThread().getContextClassLoader().loadClass(className); if (clazz == null) { clazz = Class.forName(className); } return clazz; } private  EgovObjectUtil(); static Class<?> loadClass(String className); static Object instantiate(String className); static Object instantiate(String className, String[] types, Object[] values); static boolean isNull(Object object);  }
@Test @SuppressWarnings("unchecked") public void testLoadClass() throws Exception { String className = "egovframework.rte.fdl.string.EgovStringUtil"; String wrongClassName = "egovframework.rte.fdl.string.EgovStringUtil1"; Class<?> clazz = EgovObjectUtil.loadClass(className); assertNotNull(clazz); clazz = null; assertNull(clazz); Class<Exception> exceptionClass = null; try { clazz = EgovObjectUtil.loadClass(wrongClassName); } catch (Exception e) { LOGGER.error("### Exception : {}", e.toString()); exceptionClass = (Class<Exception>) e.getClass(); } finally { assertEquals(ClassNotFoundException.class, exceptionClass); assertNotSame(InstantiationException.class, exceptionClass); assertNotSame(IllegalAccessException.class, exceptionClass); } }