Search in sources :

Example 1 with Bar

use of spoon.test.invocations.testclasses.Bar in project spoon by INRIA.

the class InvocationTest method testTargetNullForStaticMethod.

@Test
public void testTargetNullForStaticMethod() throws Exception {
    final Factory factory = build(Bar.class);
    final CtClass<Bar> barClass = factory.Class().get(Bar.class);
    final CtMethod<?> staticMethod = barClass.getMethodsByName("staticMethod").get(0);
    final CtExecutableReference<?> reference = factory.Method().createReference(staticMethod);
    try {
        final CtInvocation<?> invocation = factory.Code().createInvocation(null, reference);
        assertNull(invocation.getTarget());
    } catch (NullPointerException e) {
        fail();
    }
}
Also used : Bar(spoon.test.invocations.testclasses.Bar) Factory(spoon.reflect.factory.Factory) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 Factory (spoon.reflect.factory.Factory)1 Bar (spoon.test.invocations.testclasses.Bar)1