Search in sources :

Example 1 with AClassWithNativeMethod

use of org.robolectric.testing.AClassWithNativeMethod in project robolectric by robolectric.

the class SandboxClassLoaderTest method callingNativeMethodShouldInvokeClassHandler.

@Test
public void callingNativeMethodShouldInvokeClassHandler() throws Exception {
    Class<?> exampleClass = loadClass(AClassWithNativeMethod.class);
    Method normalMethod = exampleClass.getDeclaredMethod("nativeMethod", String.class, int.class);
    Object exampleInstance = exampleClass.newInstance();
    assertEquals("response from methodInvoked: AClassWithNativeMethod.nativeMethod(java.lang.String value1, int 123)", normalMethod.invoke(exampleInstance, "value1", 123));
    assertThat(transcript).containsExactly("methodInvoked: AClassWithNativeMethod.__constructor__()", "methodInvoked: AClassWithNativeMethod.nativeMethod(java.lang.String value1, int 123)");
}
Also used : Method(java.lang.reflect.Method) AClassWithNativeMethod(org.robolectric.testing.AClassWithNativeMethod) AClassWithStaticMethod(org.robolectric.testing.AClassWithStaticMethod) Test(org.junit.Test)

Aggregations

Method (java.lang.reflect.Method)1 Test (org.junit.Test)1 AClassWithNativeMethod (org.robolectric.testing.AClassWithNativeMethod)1 AClassWithStaticMethod (org.robolectric.testing.AClassWithStaticMethod)1