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/02/27 17:59:17 UTC
svn commit: r748592 - in
/felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test: ./
recipes/ src/org/apache/felix/framework/test/
src/org/apache/felix/framework/test/resolver/
src/org/apache/felix/framework/test/resolver/b1/ src/org/apache/fe...
Author: rickhall
Date: Fri Feb 27 16:59:16 2009
New Revision: 748592
URL: http://svn.apache.org/viewvc?rev=748592&view=rev
Log:
Added a test case for the resolver which should fail due to a "uses" constraint
violation.
Added:
felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/recipes/resolver.b1.bnd
felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/recipes/resolver.b2.bnd
felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/recipes/resolver.b3.bnd
felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/src/org/apache/felix/framework/test/TestResolver.java
felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/src/org/apache/felix/framework/test/resolver/
felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/src/org/apache/felix/framework/test/resolver/b1/
felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/src/org/apache/felix/framework/test/resolver/b2/
felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/src/org/apache/felix/framework/test/resolver/b3/
Modified:
felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/bnd.bnd
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=748592&r1=748591&r2=748592&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 Fri Feb 27 16:59:16 2009
@@ -1,5 +1,10 @@
Private-Package: ${p}
-Include-Resource: cyclea.jar,cycleb.jar,host.jar,fragment.jar,requirehost.jar,org/apache/felix/framework/test/Message.properties=src/resource/Message.properties,org/apache/felix/framework/test/Message_fr.properties=src/resource/Message_fr.properties
+Include-Resource: \
+ resolver.b1.jar, resolver.b2.jar, resolver.b3.jar, \
+ cyclea.jar, cycleb.jar, \
+ importer.jar, host.jar, exportfragment.jar, \
+ resourcefragment.jar, requirehost.jar, \
+ org/apache/felix/framework/test/Message.properties=src/resource/Message.properties,org/apache/felix/framework/test/Message_fr.properties=src/resource/Message_fr.properties
-buildpath: \
org.osgi.core; version=1.2.0, \
Added: felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/recipes/resolver.b1.bnd
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/recipes/resolver.b1.bnd?rev=748592&view=auto
==============================================================================
--- felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/recipes/resolver.b1.bnd (added)
+++ felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/recipes/resolver.b1.bnd Fri Feb 27 16:59:16 2009
@@ -0,0 +1,3 @@
+Bundle-SymbolicName: org.apache.felix.framework.test.resolver.b1
+-failok : true
+Import-Package: foo,bar,baz
Added: felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/recipes/resolver.b2.bnd
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/recipes/resolver.b2.bnd?rev=748592&view=auto
==============================================================================
--- felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/recipes/resolver.b2.bnd (added)
+++ felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/recipes/resolver.b2.bnd Fri Feb 27 16:59:16 2009
@@ -0,0 +1,5 @@
+Bundle-SymbolicName: org.apache.felix.framework.test.resolver.b2
+-failok : true
+-removeheaders : Import-Package
+Export-Package: bar; uses:="foo", foo
+Include-Resource: bar/resource.txt; literal="BAR", foo/resource.txt; literal="FOO"
Added: felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/recipes/resolver.b3.bnd
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/recipes/resolver.b3.bnd?rev=748592&view=auto
==============================================================================
--- felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/recipes/resolver.b3.bnd (added)
+++ felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/recipes/resolver.b3.bnd Fri Feb 27 16:59:16 2009
@@ -0,0 +1,5 @@
+Bundle-SymbolicName: org.apache.felix.framework.test.resolver.b3
+-failok : true
+-removeheaders : Import-Package
+Export-Package: baz; uses:="foo", foo
+Include-Resource: baz/resource.txt; literal="BAZ", foo/resource.txt; literal="FOO"
Added: felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/src/org/apache/felix/framework/test/TestResolver.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/src/org/apache/felix/framework/test/TestResolver.java?rev=748592&view=auto
==============================================================================
--- felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/src/org/apache/felix/framework/test/TestResolver.java (added)
+++ felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/src/org/apache/felix/framework/test/TestResolver.java Fri Feb 27 16:59:16 2009
@@ -0,0 +1,109 @@
+/*
+ * 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;
+
+import java.io.InputStream;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleException;
+import org.osgi.service.packageadmin.PackageAdmin;
+
+public class TestResolver extends FelixTestCase
+{
+ private Bundle m_host = null;
+ private Bundle m_b1 = null;
+ private Bundle m_b2 = null;
+ private Bundle m_b3 = null;
+
+ public void testResolver() throws Exception
+ {
+ InputStream is = null;
+ PackageAdmin pa = getPackageAdmin();
+
+ // Scenario #1
+ //
+ // Install b1, b2, and b3. Bundle b1 imports foo, bar, and baz.
+ // Bundle b2 exports bar and foo, where bar uses foo. Bundle b3
+ // exports baz and foo, where baz uses foo. This means it should
+ // be impossible to resolve b1.
+ try
+ {
+ is = this.getClass().getClassLoader().getResourceAsStream("resolver.b1.jar");
+ m_b1 = getBundleContext().installBundle("resolver.b1.jar", is);
+ is = this.getClass().getClassLoader().getResourceAsStream("resolver.b2.jar");
+ m_b2 = getBundleContext().installBundle("resolver.b2.jar", is);
+ is = this.getClass().getClassLoader().getResourceAsStream("resolver.b3.jar");
+ m_b3 = getBundleContext().installBundle("resolver.b3.jar", is);
+
+ try
+ {
+ m_b1.start();
+ throw new Exception("Bundle should not resolve!");
+ }
+ catch (BundleException ex)
+ {
+ // We should get this exception.
+ }
+ }
+ finally
+ {
+ cleanup();
+ }
+ }
+
+ private void cleanup()
+ {
+ if (m_b1 != null)
+ {
+ try
+ {
+ m_b1.uninstall();
+ }
+ catch (Exception ex)
+ {
+ // Ummm?
+ }
+ m_b1 = null;
+ }
+ if (m_b2 != null)
+ {
+ try
+ {
+ m_b2.uninstall();
+ }
+ catch (Exception ex)
+ {
+ // Ummm?
+ }
+ m_b2 = null;
+ }
+ if (m_b3 != null)
+ {
+ try
+ {
+ m_b3.uninstall();
+ }
+ catch (Exception ex)
+ {
+ // Ummm?
+ }
+ m_b3 = null;
+ }
+ refreshAndWait();
+ }
+}
\ No newline at end of file