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 2009/04/30 10:11:36 UTC
svn commit: r770108 - in
/felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test: bnd.bnd
recipes/fragment.b3.bnd src/org/apache/felix/framework/test/TestFragment.java
src/org/apache/felix/framework/test/fragment/b3/FragmentClass.java
Author: rickhall
Date: Thu Apr 30 08:11:35 2009
New Revision: 770108
URL: http://svn.apache.org/viewvc?rev=770108&view=rev
Log:
Add another fragment test.
Added:
felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/recipes/fragment.b3.bnd
felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/src/org/apache/felix/framework/test/fragment/b3/FragmentClass.java
Modified:
felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/bnd.bnd
felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/src/org/apache/felix/framework/test/TestFragment.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=770108&r1=770107&r2=770108&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 Apr 30 08:11:35 2009
@@ -4,8 +4,8 @@
concurrency.b1.jar, \
resolver.b1.jar, resolver.b2.jar, resolver.b3.jar, resolver.b4.jar, \
resolver.b5.jar, resolver.b6.jar, resolver.b7.jar, \
- fragment.b1.jar, fragment.b2.jar, fragment.b4.jar, \
- fragment.b5.jar, \
+ fragment.b1.jar, fragment.b2.jar, fragment.b3.jar, \
+ fragment.b4.jar, fragment.b5.jar, \
org/apache/felix/framework/test/fragment/Message.properties=src/resource/Message.properties,org/apache/felix/framework/test/fragment/Message_fr.properties=src/resource/Message_fr.properties
-buildpath: \
Added: felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/recipes/fragment.b3.bnd
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/recipes/fragment.b3.bnd?rev=770108&view=auto
==============================================================================
--- felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/recipes/fragment.b3.bnd (added)
+++ felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/recipes/fragment.b3.bnd Thu Apr 30 08:11:35 2009
@@ -0,0 +1,3 @@
+Bundle-SymbolicName: org.apache.felix.framework.test.fragment.b3
+Fragment-Host: org.apache.felix.framework.test.fragment.b1
+Private-Package: org.apache.felix.framework.test.fragment.b3
Modified: felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/src/org/apache/felix/framework/test/TestFragment.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/src/org/apache/felix/framework/test/TestFragment.java?rev=770108&r1=770107&r2=770108&view=diff
==============================================================================
--- felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/src/org/apache/felix/framework/test/TestFragment.java (original)
+++ felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/src/org/apache/felix/framework/test/TestFragment.java Thu Apr 30 08:11:35 2009
@@ -226,6 +226,60 @@
}
}
+ public void testFragmentImports() throws Exception
+ {
+ InputStream is = null;
+
+ // Scenario #1
+ //
+ // Install host, then try to load PackageAdmin class, which should fail.
+ try
+ {
+ is = this.getClass().getClassLoader().getResourceAsStream("fragment.b1.jar");
+ m_bundleA = getBundleContext().installBundle("fragment.b1.jar", is);
+
+ try
+ {
+ Class clazz = m_bundleA.loadClass("org.osgi.service.packageadmin.PackageAdmin");
+ assertNull("Importer should be wired to host", clazz);
+ }
+ catch (ClassNotFoundException ex)
+ {
+ // This is correct, so ignore.
+ }
+ }
+ finally
+ {
+ cleanup();
+ }
+
+ // Scenario #2
+ //
+ // Install host and fragment importing package admin package, then
+ // try to load PackageAdmin class, which should fail.
+ try
+ {
+ is = this.getClass().getClassLoader().getResourceAsStream("fragment.b1.jar");
+ m_bundleA = getBundleContext().installBundle("fragment.b1.jar", is);
+ is = this.getClass().getClassLoader().getResourceAsStream("fragment.b3.jar");
+ m_bundleB = getBundleContext().installBundle("fragment.b3.jar", is);
+
+ try
+ {
+ Class clazz = m_bundleA.loadClass("org.osgi.service.packageadmin.PackageAdmin");
+ assertNotNull("Importer should be wired to host", clazz);
+ }
+ catch (ClassNotFoundException ex)
+ {
+ assertTrue("Should have access: " + ex, 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/fragment/b3/FragmentClass.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/src/org/apache/felix/framework/test/fragment/b3/FragmentClass.java?rev=770108&view=auto
==============================================================================
--- felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/src/org/apache/felix/framework/test/fragment/b3/FragmentClass.java (added)
+++ felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/src/org/apache/felix/framework/test/fragment/b3/FragmentClass.java Thu Apr 30 08:11:35 2009
@@ -0,0 +1,29 @@
+/*
+ * 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.fragment.b3;
+
+import org.osgi.service.packageadmin.PackageAdmin;
+
+public class FragmentClass
+{
+ public FragmentClass()
+ {
+ PackageAdmin.class.getName();
+ }
+}
\ No newline at end of file