Search in sources :

Example 6 with FieldNotFoundException

use of org.powermock.reflect.exceptions.FieldNotFoundException in project powermock by powermock.

the class WhiteBoxTest method assertThatErrorMessageIsCorrectWhenNoInstanceFieldFound.

@Test
public void assertThatErrorMessageIsCorrectWhenNoInstanceFieldFound() throws Exception {
    ClassWithInternalState classWithInternalState = new ClassWithInternalState();
    try {
        Whitebox.setInternalState(classWithInternalState, (byte) 23);
        fail("Should throw a FieldNotFoundException.");
    } catch (FieldNotFoundException e) {
        assertEquals("No instance field assignable from \"java.lang.Byte\" could be found in the class hierarchy of " + ClassWithInternalState.class.getName() + ".", e.getMessage());
    }
}
Also used : ClassWithInternalState(org.powermock.reflect.testclasses.ClassWithInternalState) FieldNotFoundException(org.powermock.reflect.exceptions.FieldNotFoundException) Test(org.junit.Test)

Aggregations

FieldNotFoundException (org.powermock.reflect.exceptions.FieldNotFoundException)6 Field (java.lang.reflect.Field)4 MethodNotFoundException (org.powermock.reflect.exceptions.MethodNotFoundException)2 Constructor (java.lang.reflect.Constructor)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1 Map (java.util.Map)1 Test (org.junit.Test)1 ConstructorNotFoundException (org.powermock.reflect.exceptions.ConstructorNotFoundException)1 MethodInvocationException (org.powermock.reflect.exceptions.MethodInvocationException)1 TooManyConstructorsFoundException (org.powermock.reflect.exceptions.TooManyConstructorsFoundException)1 TooManyFieldsFoundException (org.powermock.reflect.exceptions.TooManyFieldsFoundException)1 TooManyMethodsFoundException (org.powermock.reflect.exceptions.TooManyMethodsFoundException)1 ClassWithInternalState (org.powermock.reflect.testclasses.ClassWithInternalState)1