Search in sources :

Example 1 with ClassWithPrivateMethods

use of org.powermock.reflect.testclasses.ClassWithPrivateMethods in project powermock by powermock.

the class WhiteBoxTest method testInvokeVarArgsMethod_multipleValues.

@Test
public void testInvokeVarArgsMethod_multipleValues() throws Exception {
    ClassWithPrivateMethods tested = new ClassWithPrivateMethods();
    assertEquals(6, Whitebox.invokeMethod(tested, "varArgsMethod", 1, 2, 3));
}
Also used : ClassWithPrivateMethods(org.powermock.reflect.testclasses.ClassWithPrivateMethods) Test(org.junit.Test)

Example 2 with ClassWithPrivateMethods

use of org.powermock.reflect.testclasses.ClassWithPrivateMethods in project powermock by powermock.

the class WhiteBoxTest method testInvokeVarArgsMethod_invokeVarArgsWithOneArgument.

@Test
public void testInvokeVarArgsMethod_invokeVarArgsWithOneArgument() throws Exception {
    ClassWithPrivateMethods tested = new ClassWithPrivateMethods();
    assertEquals(1, Whitebox.invokeMethod(tested, "varArgsMethod", new Class<?>[] { int[].class }, 1));
}
Also used : ClassWithPrivateMethods(org.powermock.reflect.testclasses.ClassWithPrivateMethods) AbstractClass(org.powermock.reflect.testclasses.AbstractClass) Test(org.junit.Test)

Example 3 with ClassWithPrivateMethods

use of org.powermock.reflect.testclasses.ClassWithPrivateMethods in project powermock by powermock.

the class WhiteBoxTest method testInvokeVarArgsMethod_oneArgument.

@Test
public void testInvokeVarArgsMethod_oneArgument() throws Exception {
    ClassWithPrivateMethods tested = new ClassWithPrivateMethods();
    assertEquals(4, Whitebox.invokeMethod(tested, "varArgsMethod", 2));
}
Also used : ClassWithPrivateMethods(org.powermock.reflect.testclasses.ClassWithPrivateMethods) Test(org.junit.Test)

Example 4 with ClassWithPrivateMethods

use of org.powermock.reflect.testclasses.ClassWithPrivateMethods in project powermock by powermock.

the class WhiteBoxTest method testInvokeMethodWithBothNormalAndVarArgsParameter.

/**
     * Asserts that <a
     * href="http://code.google.com/p/powermock/issues/detail?id=118">issue
     * 118</a> is fixed. Thanks to cemcatik for finding this.
     */
@Test
public void testInvokeMethodWithBothNormalAndVarArgsParameter() throws Exception {
    ClassWithPrivateMethods tested = new ClassWithPrivateMethods();
    assertEquals(4, Whitebox.invokeMethod(tested, "varArgsMethod2", 1, 2, 3));
}
Also used : ClassWithPrivateMethods(org.powermock.reflect.testclasses.ClassWithPrivateMethods) Test(org.junit.Test)

Example 5 with ClassWithPrivateMethods

use of org.powermock.reflect.testclasses.ClassWithPrivateMethods 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());
}
Also used : ClassWithPrivateMethods(org.powermock.reflect.testclasses.ClassWithPrivateMethods) ClassWithChildThatHasInternalState(org.powermock.reflect.testclasses.ClassWithChildThatHasInternalState) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)11 ClassWithPrivateMethods (org.powermock.reflect.testclasses.ClassWithPrivateMethods)11 ClassWithChildThatHasInternalState (org.powermock.reflect.testclasses.ClassWithChildThatHasInternalState)4 AbstractClass (org.powermock.reflect.testclasses.AbstractClass)1 ClassWithInternalState (org.powermock.reflect.testclasses.ClassWithInternalState)1