@Override protected Class<?> resolveClassName(String className) throws ClassNotFoundException { return ClassUtils.forName(className, this.beanClassLoader); }
@Override protected Class<?> resolveClassName(String className) throws ClassNotFoundException { return ClassUtils.forName(className, this.beanClassLoader); }
@Override protected Class<?> resolveClassName(String className) throws ClassNotFoundException { return ClassUtils.forName(className, this.beanClassLoader); }
/** * Resolve the given class name into a Class. * <p>The default implementations uses {@code ClassUtils.forName}, * using the thread context class loader. * @param className the class name to resolve * @return the resolved Class * @throws ClassNotFoundException if the class name was invalid */ protected Class<?> resolveClassName(String className) throws ClassNotFoundException { return ClassUtils.forName(className, ClassUtils.getDefaultClassLoader()); }
private static Class<?> resolveDefaultTestContextBootstrapper(Class<?> testClass) throws Exception { ClassLoader classLoader = BootstrapUtils.class.getClassLoader(); AnnotationAttributes attributes = AnnotatedElementUtils.findMergedAnnotationAttributes(testClass, WEB_APP_CONFIGURATION_ANNOTATION_CLASS_NAME, false, false); if (attributes != null) { return ClassUtils.forName(DEFAULT_WEB_TEST_CONTEXT_BOOTSTRAPPER_CLASS_NAME, classLoader); } return ClassUtils.forName(DEFAULT_TEST_CONTEXT_BOOTSTRAPPER_CLASS_NAME, classLoader); }
@SuppressWarnings("unchecked") public JtaTransactionManagerFactoryBean() { String className = resolveJtaTransactionManagerClassName(); try { Class<? extends JtaTransactionManager> clazz = (Class<? extends JtaTransactionManager>) ClassUtils.forName(className, JtaTransactionManagerFactoryBean.class.getClassLoader()); this.transactionManager = BeanUtils.instantiateClass(clazz); } catch (ClassNotFoundException ex) { throw new IllegalStateException("Failed to load JtaTransactionManager class: " + className, ex); } }
@Override public Class<?> loadClass(String name) throws ClassNotFoundException { Assert.state(this.resourceLoader != null, "ResourceLoaderClassLoadHelper not initialized"); return ClassUtils.forName(name, this.resourceLoader.getClassLoader()); }
/** * Get the singleton {@link HsqlEmbeddedDatabaseConfigurer} instance. * @return the configurer instance * @throws ClassNotFoundException if HSQL is not on the classpath */ @SuppressWarnings("unchecked") public static synchronized HsqlEmbeddedDatabaseConfigurer getInstance() throws ClassNotFoundException { if (instance == null) { instance = new HsqlEmbeddedDatabaseConfigurer( (Class<? extends Driver>) ClassUtils.forName("org.hsqldb.jdbcDriver", HsqlEmbeddedDatabaseConfigurer.class.getClassLoader())); } return instance; }
/** * Get the singleton {@code H2EmbeddedDatabaseConfigurer} instance. * @return the configurer instance * @throws ClassNotFoundException if H2 is not on the classpath */ @SuppressWarnings("unchecked") public static synchronized H2EmbeddedDatabaseConfigurer getInstance() throws ClassNotFoundException { if (instance == null) { instance = new H2EmbeddedDatabaseConfigurer( (Class<? extends Driver>) ClassUtils.forName("org.h2.Driver", H2EmbeddedDatabaseConfigurer.class.getClassLoader())); } return instance; }
@SuppressWarnings("unchecked") private static <T> T instantiateFactory(String instanceClassName, Class<T> factoryClass, ClassLoader classLoader) { try { Class<?> instanceClass = ClassUtils.forName(instanceClassName, classLoader); if (!factoryClass.isAssignableFrom(instanceClass)) { throw new IllegalArgumentException( "Class [" + instanceClassName + "] is not assignable to [" + factoryClass.getName() + "]"); } return (T) ReflectionUtils.accessibleConstructor(instanceClass).newInstance(); } catch (Throwable ex) { throw new IllegalArgumentException("Unable to instantiate factory class: " + factoryClass.getName(), ex); } }
public FailingBeforeAndAfterMethodsTestNGTests(String testClassName, int expectedTestStartCount, int expectedTestSuccessCount, int expectedFailureCount, int expectedFailedConfigurationsCount) throws Exception { this.clazz = ClassUtils.forName(getClass().getName() + "." + testClassName, getClass().getClassLoader()); this.expectedTestStartCount = expectedTestStartCount; this.expectedTestSuccessCount = expectedTestSuccessCount; this.expectedFailureCount = expectedFailureCount; this.expectedFailedConfigurationsCount = expectedFailedConfigurationsCount; }
public RepeatedSpringRunnerTests(String testClassName, int expectedFailureCount, int expectedTestStartedCount, int expectedTestFinishedCount, int expectedInvocationCount) throws Exception { this.testClass = ClassUtils.forName(getClass().getName() + "." + testClassName, getClass().getClassLoader()); this.expectedFailureCount = expectedFailureCount; this.expectedStartedCount = expectedTestStartedCount; this.expectedFinishedCount = expectedTestFinishedCount; this.expectedInvocationCount = expectedInvocationCount; }
public GenericXmlContextLoaderResourceLocationsTests(final String testClassName, final String[] expectedLocations) throws Exception { this.testClass = ClassUtils.forName(getClass().getName() + "$1" + testClassName, getClass().getClassLoader()); this.expectedLocations = expectedLocations; }
public FailingBeforeAndAfterMethodsSpringRunnerTests(String testClassName) throws Exception { this.clazz = ClassUtils.forName(getClass().getName() + "." + testClassName, getClass().getClassLoader()); }
public Class<?> loadClass() throws ClassNotFoundException { if (this.source instanceof Class) { return (Class<?>) this.source; } String className = ((MetadataReader) this.source).getClassMetadata().getClassName(); return ClassUtils.forName(className, resourceLoader.getClassLoader()); }
@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 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 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 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)); }
@Test public void embeddedCandidatesAreDetected() throws IOException, ClassNotFoundException { // Validate nested type structure String nestedType = "org.springframework.context.index.sample.SampleEmbedded.Another$AnotherPublicCandidate"; Class<?> type = ClassUtils.forName(nestedType, getClass().getClassLoader()); assertThat(type, sameInstance(SampleEmbedded.Another.AnotherPublicCandidate.class)); CandidateComponentsMetadata metadata = compile(SampleEmbedded.class); assertThat(metadata, hasComponent( SampleEmbedded.PublicCandidate.class, Component.class)); assertThat(metadata, hasComponent(nestedType, Component.class.getName())); assertThat(metadata.getItems(), hasSize(2)); }