Search in sources :

Example 6 with Support_Proxy_I1

use of tests.support.Support_Proxy_I1 in project robovm by robovm.

the class ProxyTest method test_getInvocationHandlerLjava_lang_Object.

/**
     * java.lang.reflect.Proxy#getInvocationHandler(java.lang.Object)
     */
public void test_getInvocationHandlerLjava_lang_Object() {
    InvocationHandler handler = new InvocationHandler() {

        public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
            return null;
        }
    };
    Object p = Proxy.newProxyInstance(Support_Proxy_I1.class.getClassLoader(), new Class[] { Support_Proxy_I1.class }, handler);
    assertTrue("Did not return invocation handler ", Proxy.getInvocationHandler(p) == handler);
    boolean aborted = false;
    try {
        Proxy.getInvocationHandler("");
    } catch (IllegalArgumentException e) {
        aborted = true;
    }
    assertTrue("Did not detect non proxy object ", aborted);
}
Also used : Support_Proxy_I1(tests.support.Support_Proxy_I1) Method(java.lang.reflect.Method) InvocationHandler(java.lang.reflect.InvocationHandler)

Aggregations

InvocationHandler (java.lang.reflect.InvocationHandler)6 Method (java.lang.reflect.Method)6 Support_Proxy_I1 (tests.support.Support_Proxy_I1)6 Proxy (java.lang.reflect.Proxy)2 Support_Proxy_ParentException (tests.support.Support_Proxy_ParentException)2 Support_Proxy_SubException (tests.support.Support_Proxy_SubException)2 UndeclaredThrowableException (java.lang.reflect.UndeclaredThrowableException)1