You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by ri...@apache.org on 2010/10/22 19:59:48 UTC
svn commit: r1026433 - in
/felix/sandbox/rickhall/bnd-test/org.apache.felix.test.framework.bootdelegation:
./ src/org/apache/felix/test/framework/bootdelegation/
src/org/apache/felix/test/framework/bootdelegation/external/
Author: rickhall
Date: Fri Oct 22 17:59:47 2010
New Revision: 1026433
URL: http://svn.apache.org/viewvc?rev=1026433&view=rev
Log:
Add some more tests.
Added:
felix/sandbox/rickhall/bnd-test/org.apache.felix.test.framework.bootdelegation/src/org/apache/felix/test/framework/bootdelegation/Hello.java
Modified:
felix/sandbox/rickhall/bnd-test/org.apache.felix.test.framework.bootdelegation/bnd.bnd
felix/sandbox/rickhall/bnd-test/org.apache.felix.test.framework.bootdelegation/src/org/apache/felix/test/framework/bootdelegation/BootDelegationTest.java
felix/sandbox/rickhall/bnd-test/org.apache.felix.test.framework.bootdelegation/src/org/apache/felix/test/framework/bootdelegation/external/BundleLoader.java
Modified: felix/sandbox/rickhall/bnd-test/org.apache.felix.test.framework.bootdelegation/bnd.bnd
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/bnd-test/org.apache.felix.test.framework.bootdelegation/bnd.bnd?rev=1026433&r1=1026432&r2=1026433&view=diff
==============================================================================
--- felix/sandbox/rickhall/bnd-test/org.apache.felix.test.framework.bootdelegation/bnd.bnd (original)
+++ felix/sandbox/rickhall/bnd-test/org.apache.felix.test.framework.bootdelegation/bnd.bnd Fri Oct 22 17:59:47 2010
@@ -6,6 +6,7 @@
tmp/org.apache.felix.test.framework.bootdelegation.jar; version=file; export=org.apache.felix.test.framework.bootdelegation.external, \
junit.junit; version=3.8; export="junit.framework;version=3.8"
+Import-Package: !javax.*,!org.omg.*,*
Private-Package: ${p}.*
-buildpath: \
Modified: felix/sandbox/rickhall/bnd-test/org.apache.felix.test.framework.bootdelegation/src/org/apache/felix/test/framework/bootdelegation/BootDelegationTest.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/bnd-test/org.apache.felix.test.framework.bootdelegation/src/org/apache/felix/test/framework/bootdelegation/BootDelegationTest.java?rev=1026433&r1=1026432&r2=1026433&view=diff
==============================================================================
--- felix/sandbox/rickhall/bnd-test/org.apache.felix.test.framework.bootdelegation/src/org/apache/felix/test/framework/bootdelegation/BootDelegationTest.java (original)
+++ felix/sandbox/rickhall/bnd-test/org.apache.felix.test.framework.bootdelegation/src/org/apache/felix/test/framework/bootdelegation/BootDelegationTest.java Fri Oct 22 17:59:47 2010
@@ -18,6 +18,9 @@
*/
package org.apache.felix.test.framework.bootdelegation;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
import junit.framework.TestCase;
import org.apache.felix.test.framework.bootdelegation.external.BundleLoader;
import org.apache.felix.test.framework.bootdelegation.external.ExternalClassLoader;
@@ -472,5 +475,70 @@ public class BootDelegationTest extends
catch (ClassNotFoundException ex)
{
}
+
+ // Try to trigger implicit boot delegation under these conditions:
+ // - Instigating stack:
+ // - this bundle class,
+ // - external class.
+ // - Class load requested via:
+ // - Class.forName() using bundle class loader.
+ // Implicit boot delegation should occur.
+ try
+ {
+ Class clazz = BundleLoader.forName(
+ "javax.management.Attribute", this.getClass().getClassLoader());
+ }
+ catch (ClassNotFoundException ex)
+ {
+ fail("Class load should have succeeded: " + ex);
+ }
+ }
+
+ public void testImplicitBootDelegationWithProxies()
+ {
+ // Try to trigger implicit boot delegation under these conditions:
+ // - Instigating stack:
+ // - this bundle class,
+ // - external class.
+ // - Class load requested via:
+ // - Bundle.loadClass().
+ // Implicit boot delegation should NOT occur.
+ InvocationHandler ih = new InvocationHandler() {
+ public Object invoke(Object o, Method method, Object[] os) throws Throwable
+ {
+ // No matter what method is thrown, just print hello.
+ System.out.println("1: Hello from proxied object!");
+ return null;
+ }
+ };
+ Hello hello = (Hello) Proxy.newProxyInstance(
+ this.getClass().getClassLoader(),
+ new Class[] { Hello.class },
+ ih);
+ hello.sayHello();
+
+ // Try to trigger implicit boot delegation under these conditions:
+ // - Instigating stack:
+ // - this bundle class,
+ // - external class.
+ // - Class load requested via:
+ // - Bundle.loadClass().
+ // Implicit boot delegation should NOT occur.
+ ih = new InvocationHandler() {
+ public Object invoke(Object o, Method method, Object[] os) throws Throwable
+ {
+ // No matter what method is thrown, just print hello.
+ System.out.println("2: Hello from proxied object!");
+ return null;
+ }
+ };
+ hello = (Hello) Proxy.newProxyInstance(
+ this.getClass().getClassLoader(),
+ new Class[] { Hello.class },
+ ih);
+// for (int i = 0; i < 10000; i++)
+ {
+ hello.sayHello();
+ }
}
}
\ No newline at end of file
Added: felix/sandbox/rickhall/bnd-test/org.apache.felix.test.framework.bootdelegation/src/org/apache/felix/test/framework/bootdelegation/Hello.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/bnd-test/org.apache.felix.test.framework.bootdelegation/src/org/apache/felix/test/framework/bootdelegation/Hello.java?rev=1026433&view=auto
==============================================================================
--- felix/sandbox/rickhall/bnd-test/org.apache.felix.test.framework.bootdelegation/src/org/apache/felix/test/framework/bootdelegation/Hello.java (added)
+++ felix/sandbox/rickhall/bnd-test/org.apache.felix.test.framework.bootdelegation/src/org/apache/felix/test/framework/bootdelegation/Hello.java Fri Oct 22 17:59:47 2010
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.test.framework.bootdelegation;
+
+public interface Hello
+{
+ void sayHello();
+}
\ No newline at end of file
Modified: felix/sandbox/rickhall/bnd-test/org.apache.felix.test.framework.bootdelegation/src/org/apache/felix/test/framework/bootdelegation/external/BundleLoader.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/bnd-test/org.apache.felix.test.framework.bootdelegation/src/org/apache/felix/test/framework/bootdelegation/external/BundleLoader.java?rev=1026433&r1=1026432&r2=1026433&view=diff
==============================================================================
--- felix/sandbox/rickhall/bnd-test/org.apache.felix.test.framework.bootdelegation/src/org/apache/felix/test/framework/bootdelegation/external/BundleLoader.java (original)
+++ felix/sandbox/rickhall/bnd-test/org.apache.felix.test.framework.bootdelegation/src/org/apache/felix/test/framework/bootdelegation/external/BundleLoader.java Fri Oct 22 17:59:47 2010
@@ -31,4 +31,9 @@ public class BundleLoader
{
return cl.loadClass(name);
}
+
+ public static Class forName(String name, ClassLoader cl) throws ClassNotFoundException
+ {
+ return Class.forName(name, true, cl);
+ }
}
\ No newline at end of file