FileDocCategorySizeDatePackage
GenericReflectionTestsBase.javaAPI DocAndroid 1.5 API2692Wed May 06 22:41:04 BST 2009tests.api.java.lang.reflect

GenericReflectionTestsBase

public class GenericReflectionTestsBase extends TestCase

Fields Summary
Constructors Summary
Methods Summary
public static voidassertInstanceOf(java.lang.Class expectedClass, java.lang.Object actual)

        TestCase.assertTrue(actual.getClass().getName() + " is not instance of :" + expectedClass.getName(), expectedClass
                .isInstance(actual));
    
public static voidassertLenghtOne(java.lang.Object[] array)

        TestCase.assertEquals("Array does NOT contain exactly one element.", 1, array.length);
    
public static voidassertLenghtZero(java.lang.Object[] array)

        TestCase.assertEquals("Array has more than zero elements.", 0, array.length);
    
public static voidassertNotEquals(java.lang.Object expected, java.lang.Object actual)

        TestCase.assertFalse(actual.toString() + " has not to be equal to " + expected.toString(), expected.equals(actual));
    
public java.lang.reflect.TypeVariablegetTypeParameter(java.lang.reflect.Method method)
Returns the type parameter of the declaring method.

param
method the declaring method
return
the type parameter of the method

        TypeVariable<Method>[] typeParameters = method.getTypeParameters();
        assertLenghtOne(typeParameters);
        TypeVariable<Method> typeParameter = typeParameters[0];
        return typeParameter;
    
public java.lang.reflect.TypeVariablegetTypeParameter(java.lang.Class clazz)
Returns the type parameter of the declaring class.

param
method the declaring method.
return
the type parameter of the method.

        TypeVariable[] typeParameters = clazz.getTypeParameters();
        assertLenghtOne(typeParameters);
        TypeVariable<Class> typeVariable = typeParameters[0];
        assertEquals(clazz, typeVariable.getGenericDeclaration());
        assertEquals("T", typeVariable.getName()); 
        return typeVariable;