use of org.powermock.reflect.testclasses.ClassWithPrivateMethods in project powermock by powermock.
the class WhiteBoxTest method testInvokePrivateMethodWithArrayArgument.
@Test
public void testInvokePrivateMethodWithArrayArgument() throws Exception {
ClassWithPrivateMethods tested = new ClassWithPrivateMethods();
assertEquals("Hello World", Whitebox.invokeMethod(tested, "evilConcatOfStrings", new Object[] { new String[] { "Hello ", "World" } }));
}
use of org.powermock.reflect.testclasses.ClassWithPrivateMethods in project powermock by powermock.
the class WhiteBoxTest method testInvokePrivateMethodWithASubTypeOfTheArgumentType.
@Test
public void testInvokePrivateMethodWithASubTypeOfTheArgumentType() throws Exception {
ClassWithPrivateMethods tested = new ClassWithPrivateMethods();
ClassWithChildThatHasInternalState argument = new ClassWithChildThatHasInternalState();
assertSame(argument, Whitebox.invokeMethod(tested, "methodWithObjectArgument", argument));
}
use of org.powermock.reflect.testclasses.ClassWithPrivateMethods in project powermock by powermock.
the class WhiteBoxTest method testSetInternalStateBasedOnObjectSubClassTypeAtASpecificPlaceInTheClassHierarchy.
@Test
public void testSetInternalStateBasedOnObjectSubClassTypeAtASpecificPlaceInTheClassHierarchy() throws Exception {
final ClassWithPrivateMethods value = new ClassWithPrivateMethods() {
};
ClassWithChildThatHasInternalState tested = new ClassWithChildThatHasInternalState();
Whitebox.setInternalState(tested, value, ClassWithInternalState.class);
assertSame(value, tested.getClassWithPrivateMethods());
}
use of org.powermock.reflect.testclasses.ClassWithPrivateMethods in project powermock by powermock.
the class WhiteBoxTest method testSetInternalStateWithMultipleValues.
@Test
public void testSetInternalStateWithMultipleValues() throws Exception {
ClassWithInternalState tested = new ClassWithInternalState();
final ClassWithPrivateMethods classWithPrivateMethods = new ClassWithPrivateMethods();
final String stringState = "someStringState";
Whitebox.setInternalState(tested, classWithPrivateMethods, stringState);
assertEquals(stringState, Whitebox.getInternalState(tested, String.class));
assertSame(classWithPrivateMethods, Whitebox.getInternalState(tested, ClassWithPrivateMethods.class));
}
use of org.powermock.reflect.testclasses.ClassWithPrivateMethods in project powermock by powermock.
the class WhiteBoxTest method testInvokeVarArgsMethod_noArguments.
@Test
public void testInvokeVarArgsMethod_noArguments() throws Exception {
ClassWithPrivateMethods tested = new ClassWithPrivateMethods();
assertEquals(0, Whitebox.invokeMethod(tested, "varArgsMethod"));
}
Aggregations