use of org.powermock.reflect.testclasses.ClassWithChildThatHasInternalState in project powermock by powermock.
the class WhiteBoxTest method testSetInternalState_superClass.
@Test
public void testSetInternalState_superClass() throws Exception {
ClassWithChildThatHasInternalState tested = new ClassWithChildThatHasInternalState();
tested.increaseInteralState();
Whitebox.setInternalState(tested, "anotherInternalState", 2, ClassWithInternalState.class);
assertEquals(2, tested.getAnotherInternalState());
}
use of org.powermock.reflect.testclasses.ClassWithChildThatHasInternalState in project powermock by powermock.
the class WhiteBoxTest method testSetInternalStateBasedOnObjectTypeAtANonSpecificPlaceInTheClassHierarchyForPrimitiveType.
@Test
public void testSetInternalStateBasedOnObjectTypeAtANonSpecificPlaceInTheClassHierarchyForPrimitiveType() throws Exception {
final long value = 31;
ClassWithChildThatHasInternalState tested = new ClassWithChildThatHasInternalState();
Whitebox.setInternalState(tested, value);
assertEquals(value, tested.getInternalLongState());
}
use of org.powermock.reflect.testclasses.ClassWithChildThatHasInternalState in project powermock by powermock.
the class WhiteBoxTest method testSetAndGetInternalStateBasedOnFieldType.
@Test
public void testSetAndGetInternalStateBasedOnFieldType() throws Exception {
final int value = 22;
ClassWithChildThatHasInternalState tested = new ClassWithChildThatHasInternalState();
Whitebox.setInternalState(tested, int.class, value);
assertEquals(value, (int) Whitebox.getInternalState(tested, int.class));
assertEquals(value, Whitebox.getInternalState(tested, "anotherInternalState"));
assertEquals(value, Whitebox.getInternalState(tested, "anotherInternalState", ClassWithChildThatHasInternalState.class));
}
use of org.powermock.reflect.testclasses.ClassWithChildThatHasInternalState in project powermock by powermock.
the class WhiteBoxTest method testGetAllInstanceFields.
@Test
public void testGetAllInstanceFields() throws Exception {
Set<Field> allFields = Whitebox.getAllInstanceFields(new ClassWithChildThatHasInternalState());
assertEquals(8, allFields.size());
}
use of org.powermock.reflect.testclasses.ClassWithChildThatHasInternalState in project powermock by powermock.
the class WhiteBoxTest method testSetInternalStateBasedOnObjectSubClassType.
@Test
public void testSetInternalStateBasedOnObjectSubClassType() throws Exception {
final ClassWithPrivateMethods value = new ClassWithPrivateMethods() {
};
ClassWithChildThatHasInternalState tested = new ClassWithChildThatHasInternalState() {
};
Whitebox.setInternalState(tested, value);
assertSame(value, tested.getClassWithPrivateMethods());
}
Aggregations