org.testng.internal
Class ClassHelper

java.lang.Object
  extended by org.testng.internal.ClassHelper

public final class ClassHelper
extends java.lang.Object

Utility class for different class manipulations.

Author:
Alex Popescu

Method Summary
static java.lang.Object createInstance(java.lang.Class<?> declaringClass, java.util.Map<java.lang.Class,IClass> classes, XmlTest xmlTest, IAnnotationFinder finder, IObjectFactory objectFactory)
          Create an instance for the given class.
static IAnnotationFinder createJdkAnnotationFinder(IAnnotationTransformer annoTransformer)
           
static IMethodSelector createSelector(XmlMethodSelector selector)
           
static IJUnitTestRunner createTestRunner(TestRunner runner)
           
static java.lang.reflect.Method findFactoryMethod(java.lang.Class<?> cls, IAnnotationFinder finder)
          For the given class, returns the method annotated with @Factory or null if none is found.
static java.lang.Class<?> forName(java.lang.String className)
          Tries to load the specified class using the context ClassLoader or if none, than from the default ClassLoader.
static java.util.Set<java.lang.reflect.Method> getAvailableMethods(java.lang.Class<?> clazz)
          Extract all callable methods of a class and all its super (keeping in mind the Java access rules).
static
<T> T
newInstance(java.lang.Class<T> clazz)
           
static
<T> T
tryOtherConstructor(java.lang.Class<T> declaringClass)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

newInstance

public static <T> T newInstance(java.lang.Class<T> clazz)

forName

public static java.lang.Class<?> forName(java.lang.String className)
Tries to load the specified class using the context ClassLoader or if none, than from the default ClassLoader. This method differs from the standard class loading methods in that it does not throw an exception if the class is not found but returns null instead.

Parameters:
className - the class name to be loaded.
Returns:
the class or null if the class is not found.

findFactoryMethod

public static java.lang.reflect.Method findFactoryMethod(java.lang.Class<?> cls,
                                                         IAnnotationFinder finder)
For the given class, returns the method annotated with @Factory or null if none is found. This method does not search up the superclass hierarchy. If more than one method is @Factory annotated, a TestNGException is thrown.

Parameters:
cls - The class to search for the @Factory annotation.
finder - The finder (JDK 1.4 or JDK 5.0+) use to search for the annotation.
Returns:
the @Factory method or null FIXME: @Factory method must be public! TODO rename this method to findDeclaredFactoryMethod

getAvailableMethods

public static java.util.Set<java.lang.reflect.Method> getAvailableMethods(java.lang.Class<?> clazz)
Extract all callable methods of a class and all its super (keeping in mind the Java access rules).

Parameters:
clazz -
Returns:

createTestRunner

public static IJUnitTestRunner createTestRunner(TestRunner runner)
Parameters:
runner -
Returns:

createJdkAnnotationFinder

public static IAnnotationFinder createJdkAnnotationFinder(IAnnotationTransformer annoTransformer)

createSelector

public static IMethodSelector createSelector(XmlMethodSelector selector)

createInstance

public static java.lang.Object createInstance(java.lang.Class<?> declaringClass,
                                              java.util.Map<java.lang.Class,IClass> classes,
                                              XmlTest xmlTest,
                                              IAnnotationFinder finder,
                                              IObjectFactory objectFactory)
Create an instance for the given class.


tryOtherConstructor

public static <T> T tryOtherConstructor(java.lang.Class<T> declaringClass)


Copyright © 2010. All Rights Reserved.