use of org.powermock.reflect.testclasses.ClassWithInternalState in project powermock by powermock.
the class WhiteBoxTest method whiteboxSetInternalStateWorksOnArraysWhenNotDefiningMethodName.
@Test
public void whiteboxSetInternalStateWorksOnArraysWhenNotDefiningMethodName() {
ClassWithInternalState tested = new ClassWithInternalState();
final String[] expected = new String[] { "string1", "string2" };
Whitebox.setInternalState(tested, expected);
assertArrayEquals(expected, tested.getStringArray());
}
use of org.powermock.reflect.testclasses.ClassWithInternalState in project powermock by powermock.
the class WhiteBoxTest method testGetInternalState_object.
@Test
public void testGetInternalState_object() throws Exception {
ClassWithInternalState tested = new ClassWithInternalState();
tested.increaseInteralState();
Object internalState = Whitebox.getInternalState(tested, "internalState");
assertTrue("InternalState should be instanceof Integer", internalState instanceof Integer);
assertEquals(1, internalState);
}
use of org.powermock.reflect.testclasses.ClassWithInternalState in project powermock by powermock.
the class WhiteBoxTest method testGetInternalState_parmaterizedType.
@SuppressWarnings("deprecation")
@Test
public void testGetInternalState_parmaterizedType() throws Exception {
ClassWithInternalState tested = new ClassWithInternalState();
tested.increaseInteralState();
int internalState = Whitebox.getInternalState(tested, "internalState", tested.getClass(), int.class);
assertEquals(1, internalState);
}
use of org.powermock.reflect.testclasses.ClassWithInternalState in project powermock by powermock.
the class WhiteBoxTest method whiteboxSetInternalStateWorksOnArraysWhenDefiningMethodName.
@Test
public void whiteboxSetInternalStateWorksOnArraysWhenDefiningMethodName() {
ClassWithInternalState tested = new ClassWithInternalState();
final String[] expected = new String[] { "string1", "string2" };
Whitebox.setInternalState(tested, "stringArray", expected);
assertArrayEquals(expected, tested.getStringArray());
}
use of org.powermock.reflect.testclasses.ClassWithInternalState in project powermock by powermock.
the class WhiteBoxTest method getInternalStateThrowsTooManyFieldsFoundWhenTooManyFieldsMatchTheSuppliedType.
@Test(expected = TooManyFieldsFoundException.class)
public void getInternalStateThrowsTooManyFieldsFoundWhenTooManyFieldsMatchTheSuppliedType() {
ClassWithInternalState tested = new ClassWithInternalState();
assertNotNull(Whitebox.getInternalState(tested, Object.class));
}
Aggregations