public void testThrowsExceptionForNullRef() throws Exception { Method m = MethodCallAdapterTest.class.getMethod("nonstaticMethod", String.class); MethodCallAdapter mc = new MethodCallAdapter(m); try { mc.handleCall(null, "hello"); fail(); } catch (EvaluationException e) { assertTrue(e.getMessage().startsWith("Tried to invoke method from null reference")); return; } fail(); }
public void testThrowsExceptionForIncompatibleRef() throws Exception { Method m = MethodCallAdapterTest.class.getMethod("nonstaticMethod", String.class); MethodCallAdapter mc = new MethodCallAdapter(m); try { mc.handleCall(new Object(), "hello"); fail(); } catch (EvaluationException e) { assertTrue( e.getMessage() .startsWith( "Tried to invoke method from a context not compatible with method's declaring class.")); return; } fail(); }