Author: rickhall
Date: Thu Jul 22 14:03:40 2010
New Revision: 966664

URL: http://svn.apache.org/viewvc?rev=966664&view=rev
Log:
Improve testing of required bundles with substitutable exports.

Added:
    
felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/recipes/classloading.b006.bnd
    
felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/recipes/classloading.b007.bnd
    
felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/recipes/classloading.b008.bnd
    
felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/src/org/apache/felix/framework/test/classloading/b006/
    
felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/src/org/apache/felix/framework/test/classloading/b006/Hello.java
    
felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/src/org/apache/felix/framework/test/classloading/b007/
    
felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/src/org/apache/felix/framework/test/classloading/b007/Placeholder.java
    
felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/src/org/apache/felix/framework/test/classloading/b008/
    
felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/src/org/apache/felix/framework/test/classloading/b008/Placeholder.java
Modified:
    felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/bnd.bnd
    
felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/recipes/classloading.b003.bnd
    
felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/src/org/apache/felix/framework/test/TestClassLoading.java

Modified: 
felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/bnd.bnd
URL: 
http://svn.apache.org/viewvc/felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/bnd.bnd?rev=966664&r1=966663&r2=966664&view=diff
==============================================================================
--- felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/bnd.bnd 
(original)
+++ felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/bnd.bnd Thu 
Jul 22 14:03:40 2010
@@ -3,7 +3,8 @@
 Private-Package: ${p}
 Include-Resource: \
  classloading.b001.jar, classloading.b002.jar, classloading.b003.jar, \
- classloading.b004.jar, classloading.b005.jar, \
+ classloading.b004.jar, classloading.b005.jar, classloading.b006.jar, \
+ classloading.b007.jar, classloading.b008.jar, \
  concurrency.b1.jar, \
  resolver.b001.jar, resolver.b002.jar, resolver.b003.jar, resolver.b004.jar, \
  resolver.b005.jar, resolver.b006.jar, resolver.b007.jar, resolver.b008.jar, \

Modified: 
felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/recipes/classloading.b003.bnd
URL: 
http://svn.apache.org/viewvc/felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/recipes/classloading.b003.bnd?rev=966664&r1=966663&r2=966664&view=diff
==============================================================================
--- 
felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/recipes/classloading.b003.bnd
 (original)
+++ 
felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/recipes/classloading.b003.bnd
 Thu Jul 22 14:03:40 2010
@@ -3,8 +3,5 @@ Export-Package: \
  org.apache.felix.framework.test.classloading.b002b003split;-noimport:=true, \
  org.apache.felix.framework.test.classloading.b003
 Require-Bundle: org.apache.felix.framework.test.classloading.b002; 
visibility:="reexport"
-# We import our exported package explicitly in this case to test for the
-# situation where a required bundle imports its own exports to ensure
-# that requiring bundles still see the exported package.
-Import-Package: org.apache.felix.framework.test.classloading.b003,!*
+Import-Package: !*
 

Added: 
felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/recipes/classloading.b006.bnd
URL: 
http://svn.apache.org/viewvc/felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/recipes/classloading.b006.bnd?rev=966664&view=auto
==============================================================================
--- 
felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/recipes/classloading.b006.bnd
 (added)
+++ 
felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/recipes/classloading.b006.bnd
 Thu Jul 22 14:03:40 2010
@@ -0,0 +1,3 @@
+Bundle-SymbolicName: org.apache.felix.framework.test.classloading.b006
+Export-Package: org.apache.felix.framework.test.classloading.b006; 
version=1.0.0
+

Added: 
felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/recipes/classloading.b007.bnd
URL: 
http://svn.apache.org/viewvc/felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/recipes/classloading.b007.bnd?rev=966664&view=auto
==============================================================================
--- 
felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/recipes/classloading.b007.bnd
 (added)
+++ 
felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/recipes/classloading.b007.bnd
 Thu Jul 22 14:03:40 2010
@@ -0,0 +1,4 @@
+Bundle-SymbolicName: org.apache.felix.framework.test.classloading.b007
+Private-Package: org.apache.felix.framework.test.classloading.b007
+Require-Bundle: org.apache.felix.framework.test.classloading.b006
+

Added: 
felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/recipes/classloading.b008.bnd
URL: 
http://svn.apache.org/viewvc/felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/recipes/classloading.b008.bnd?rev=966664&view=auto
==============================================================================
--- 
felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/recipes/classloading.b008.bnd
 (added)
+++ 
felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/recipes/classloading.b008.bnd
 Thu Jul 22 14:03:40 2010
@@ -0,0 +1,4 @@
+Bundle-SymbolicName: org.apache.felix.framework.test.classloading.b008
+Private-Package: org.apache.felix.framework.test.classloading.b008
+Export-Package: org.apache.felix.framework.test.classloading.b006; 
version=2.0.0
+

Modified: 
felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/src/org/apache/felix/framework/test/TestClassLoading.java
URL: 
http://svn.apache.org/viewvc/felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/src/org/apache/felix/framework/test/TestClassLoading.java?rev=966664&r1=966663&r2=966664&view=diff
==============================================================================
--- 
felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/src/org/apache/felix/framework/test/TestClassLoading.java
 (original)
+++ 
felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/src/org/apache/felix/framework/test/TestClassLoading.java
 Thu Jul 22 14:03:40 2010
@@ -206,6 +206,68 @@ public class TestClassLoading extends Fe
         }
     }
 
+    public void testRequireImportExport() throws Exception
+    {
+        try
+        {
+            // Load bundle that imports its own export.
+            InputStream is = 
this.getClass().getClassLoader().getResourceAsStream("classloading.b006.jar");
+            m_bundleA = 
getBundleContext().installBundle("classloading.b006.jar", is);
+            // Load a bundle that requires previous bundle.
+            is = 
this.getClass().getClassLoader().getResourceAsStream("classloading.b007.jar");
+            m_bundleB = 
getBundleContext().installBundle("classloading.b007.jar", is);
+
+            // Try to load a required class from A via B.
+            Class clazz;
+            try
+            {
+                clazz = m_bundleB.loadClass(
+                    "org.apache.felix.framework.test.classloading.b006.Hello");
+                assertNotNull("Class should not be null.", clazz);
+            }
+            catch (Exception ex)
+            {
+                assertTrue("Exported class should be visible.", false);
+            }
+        }
+        finally
+        {
+            cleanup();
+        }
+
+        try
+        {
+            // Load bundle that imports its own export.
+            InputStream is = 
this.getClass().getClassLoader().getResourceAsStream("classloading.b006.jar");
+            m_bundleA = 
getBundleContext().installBundle("classloading.b006.jar", is);
+            // Load a bundle that requires previous bundle.
+            is = 
this.getClass().getClassLoader().getResourceAsStream("classloading.b007.jar");
+            m_bundleB = 
getBundleContext().installBundle("classloading.b007.jar", is);
+            // Load bundle that exports a higher version of A's package, so A
+            // will wire to C instead of using its own package.
+            is = 
this.getClass().getClassLoader().getResourceAsStream("classloading.b008.jar");
+            m_bundleC = 
getBundleContext().installBundle("classloading.b008.jar", is);
+
+            // Try to load a required class from A via B which will ultimately 
come
+            // from C.
+            Class clazz;
+            try
+            {
+                clazz = m_bundleB.loadClass(
+                    "org.apache.felix.framework.test.classloading.b006.Hello");
+                assertNotNull("Class should not be null.", clazz);
+            }
+            catch (Exception ex)
+            {
+                assertTrue("Exported class should be visible.", false);
+            }
+        }
+        finally
+        {
+            cleanup();
+        }
+    }
+
     private void cleanup()
     {
         if (m_bundleA != null)

Added: 
felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/src/org/apache/felix/framework/test/classloading/b006/Hello.java
URL: 
http://svn.apache.org/viewvc/felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/src/org/apache/felix/framework/test/classloading/b006/Hello.java?rev=966664&view=auto
==============================================================================
--- 
felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/src/org/apache/felix/framework/test/classloading/b006/Hello.java
 (added)
+++ 
felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/src/org/apache/felix/framework/test/classloading/b006/Hello.java
 Thu Jul 22 14:03:40 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.framework.test.classloading.b006;
+
+public class Hello
+{
+
+}
\ No newline at end of file

Added: 
felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/src/org/apache/felix/framework/test/classloading/b007/Placeholder.java
URL: 
http://svn.apache.org/viewvc/felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/src/org/apache/felix/framework/test/classloading/b007/Placeholder.java?rev=966664&view=auto
==============================================================================
--- 
felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/src/org/apache/felix/framework/test/classloading/b007/Placeholder.java
 (added)
+++ 
felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/src/org/apache/felix/framework/test/classloading/b007/Placeholder.java
 Thu Jul 22 14:03:40 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.framework.test.classloading.b007;
+
+public class Placeholder
+{
+
+}
\ No newline at end of file

Added: 
felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/src/org/apache/felix/framework/test/classloading/b008/Placeholder.java
URL: 
http://svn.apache.org/viewvc/felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/src/org/apache/felix/framework/test/classloading/b008/Placeholder.java?rev=966664&view=auto
==============================================================================
--- 
felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/src/org/apache/felix/framework/test/classloading/b008/Placeholder.java
 (added)
+++ 
felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/src/org/apache/felix/framework/test/classloading/b008/Placeholder.java
 Thu Jul 22 14:03:40 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.framework.test.classloading.b008;
+
+public class Placeholder
+{
+
+}
\ No newline at end of file


Reply via email to