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/20 00:24:39 UTC

svn commit: r1024437 - in /felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.bootdelegation: ./ src/org/apache/felix/framework/bootdelegation/ src/org/apache/felix/test/ src/org/apache/felix/test/framework/ src/org/apache/felix/test/framework/...

Author: rickhall
Date: Tue Oct 19 22:24:39 2010
New Revision: 1024437

URL: http://svn.apache.org/viewvc?rev=1024437&view=rev
Log:
Add some implicit boot delegation tests.

Added:
    felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.bootdelegation/src/org/apache/felix/test/
    felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.bootdelegation/src/org/apache/felix/test/framework/
    felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.bootdelegation/src/org/apache/felix/test/framework/bootdelegation/
    felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.bootdelegation/src/org/apache/felix/test/framework/bootdelegation/BootDelegationTest.java
      - copied, changed from r962652, felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.bootdelegation/src/org/apache/felix/framework/bootdelegation/BootDelegationTest.java
    felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.bootdelegation/src/org/apache/felix/test/framework/bootdelegation/external/
    felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.bootdelegation/src/org/apache/felix/test/framework/bootdelegation/external/BundleLoader.java
Removed:
    felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.bootdelegation/src/org/apache/felix/framework/bootdelegation/BootDelegationTest.java
Modified:
    felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.bootdelegation/bnd.bnd

Modified: felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.bootdelegation/bnd.bnd
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.bootdelegation/bnd.bnd?rev=1024437&r1=1024436&r2=1024437&view=diff
==============================================================================
--- felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.bootdelegation/bnd.bnd (original)
+++ felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.bootdelegation/bnd.bnd Tue Oct 19 22:24:39 2010
@@ -1,4 +1,12 @@
-Private-Package: ${p}
+-runvm = -Xdebug, "-Xrunjdwp:transport=dt_socket,address=8001,server=y,suspend=y"
+
+# Override runpath to include content on class path
+-runpath                = \
+        org.apache.felix.framework; version=3.1.0, \
+        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"
+
+Private-Package: ${p}.*
 
 -buildpath: \
 	org.osgi.core; version=1.2.0, \
@@ -7,6 +15,8 @@ Private-Package: ${p}
 
 	
 -runproperties: report=true, \
-        org.osgi.framework.bootdelegation="javax.swing,javax.swing.text.html,javax.swing.text.html.*,org.omg*"
+        org.osgi.framework.bootdelegation="javax.swing,javax.swing.text.html,javax.swing.text.html.*,org.omg*,org.apache.felix.test.framework.bootdelegation.external", \
+        org.osgi.framework.bundle.parent=app, \
+        felix.log.level=5
 
 Test-Cases = ${classes;extending;*TestCase}

Copied: felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.bootdelegation/src/org/apache/felix/test/framework/bootdelegation/BootDelegationTest.java (from r962652, felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.bootdelegation/src/org/apache/felix/framework/bootdelegation/BootDelegationTest.java)
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.bootdelegation/src/org/apache/felix/test/framework/bootdelegation/BootDelegationTest.java?p2=felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.bootdelegation/src/org/apache/felix/test/framework/bootdelegation/BootDelegationTest.java&p1=felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.bootdelegation/src/org/apache/felix/framework/bootdelegation/BootDelegationTest.java&r1=962652&r2=1024437&rev=1024437&view=diff
==============================================================================
--- felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.bootdelegation/src/org/apache/felix/framework/bootdelegation/BootDelegationTest.java (original)
+++ felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.bootdelegation/src/org/apache/felix/test/framework/bootdelegation/BootDelegationTest.java Tue Oct 19 22:24:39 2010
@@ -16,9 +16,10 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.felix.framework.bootdelegation;
+package org.apache.felix.test.framework.bootdelegation;
 
 import junit.framework.TestCase;
+import org.apache.felix.test.framework.bootdelegation.external.BundleLoader;
 import org.osgi.framework.BundleContext;
 
 public class BootDelegationTest extends TestCase
@@ -104,4 +105,35 @@ public class BootDelegationTest extends 
             // Ignore.
         }
     }
+
+    public void testImplicitBootDelegation()
+    {
+        // Try to load a non-boot-delegated class from a bundle via
+        // external code using Bundle.loadClass(). Implicit boot delegation
+        // should not occur.
+        try
+        {
+            Class clazz =
+                BundleLoader.loadClass(m_context.getBundle(), "javax.management.Attribute");
+            assertTrue("Class should have failed: " + clazz, false);
+        }
+        catch (ClassNotFoundException ex)
+        {
+            // We are expecting a failure.
+        }
+
+        // Try to load a non-boot-delegated class from a bundle via
+        // external code using the bundle's class loader. Implicit boot
+        // delegation should occur.
+        try
+        {
+            Class clazz =
+                BundleLoader.loadClass(
+                    this.getClass().getClassLoader(), "javax.management.Attribute");
+        }
+        catch (ClassNotFoundException ex)
+        {
+            assertTrue("Class should have succeeded: " + ex, false);
+        }
+    }
 }
\ No newline at end of file

Added: felix/sandbox/rickhall/bnd-test/org.apache.felix.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.framework.bootdelegation/src/org/apache/felix/test/framework/bootdelegation/external/BundleLoader.java?rev=1024437&view=auto
==============================================================================
--- felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.bootdelegation/src/org/apache/felix/test/framework/bootdelegation/external/BundleLoader.java (added)
+++ felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.bootdelegation/src/org/apache/felix/test/framework/bootdelegation/external/BundleLoader.java Tue Oct 19 22:24:39 2010
@@ -0,0 +1,34 @@
+/*
+ * 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.external;
+
+import org.osgi.framework.Bundle;
+
+public class BundleLoader
+{
+    public static Class loadClass(Bundle bundle, String name) throws ClassNotFoundException
+    {
+        return bundle.loadClass(name);
+    }
+
+    public static Class loadClass(ClassLoader cl, String name) throws ClassNotFoundException
+    {
+        return cl.loadClass(name);
+    }
+}
\ No newline at end of file