Search in sources :

Example 1 with WeavingHelper

use of org.apache.aries.proxy.weavinghook.WeavingHelper in project aries by apache.

the class WeavingProxyTest method checkProxyController.

@Test(expected = FinalModifierException.class)
public void checkProxyController() throws Exception {
    bundleContext.registerService(ProxyWeavingController.class.getName(), new ProxyWeavingController() {

        public boolean shouldWeave(WovenClass arg0, WeavingHelper arg1) {
            return false;
        }
    }, null);
    Bundle b = bundleContext.getBundle();
    Callable<Object> c = new TestCallable();
    Collection<Class<?>> classes = new ArrayList<Class<?>>();
    // Don't use anonymous inner class in this test as IBM and Sun load it at a different time
    // For IBM JDK, the anonymous inner class will be loaded prior to the controller is registered.
    Callable<?> callable = new TestFinalDelegate();
    classes.add(callable.getClass());
    Object o = mgr.createDelegatingProxy(b, classes, c, callable);
    if (o instanceof WovenProxy)
        fail("Proxy should not have been woven!");
}
Also used : Bundle(org.osgi.framework.Bundle) WovenClass(org.osgi.framework.hooks.weaving.WovenClass) ArrayList(java.util.ArrayList) WovenProxy(org.apache.aries.proxy.weaving.WovenProxy) WovenClass(org.osgi.framework.hooks.weaving.WovenClass) ProxyWeavingController(org.apache.aries.proxy.weavinghook.ProxyWeavingController) WeavingHelper(org.apache.aries.proxy.weavinghook.WeavingHelper) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)1 WovenProxy (org.apache.aries.proxy.weaving.WovenProxy)1 ProxyWeavingController (org.apache.aries.proxy.weavinghook.ProxyWeavingController)1 WeavingHelper (org.apache.aries.proxy.weavinghook.WeavingHelper)1 Test (org.junit.Test)1 Bundle (org.osgi.framework.Bundle)1 WovenClass (org.osgi.framework.hooks.weaving.WovenClass)1