aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tjwat...@apache.org
Subject svn commit: r1759615 - in /aries/trunk/subsystem: subsystem-itests/ subsystem-itests/src/test/bundles/aries1608provider/ subsystem-itests/src/test/bundles/aries1608provider/META-INF/ subsystem-itests/src/test/bundles/aries1608required/ subsystem-itests...
Date Wed, 07 Sep 2016 14:04:48 GMT
Author: tjwatson
Date: Wed Sep  7 14:04:48 2016
New Revision: 1759615

URL: http://svn.apache.org/viewvc?rev=1759615&view=rev
Log:
[ARIES-1608] Application with bundle in archive and required bundle in OBR will fail to resolve.

Make sure osgi.wiring.bundle capabilities from OBR have the bundle-version attribute

Added:
    aries/trunk/subsystem/subsystem-itests/src/test/bundles/aries1608provider/
    aries/trunk/subsystem/subsystem-itests/src/test/bundles/aries1608provider/META-INF/
    aries/trunk/subsystem/subsystem-itests/src/test/bundles/aries1608provider/META-INF/MANIFEST.MF
    aries/trunk/subsystem/subsystem-itests/src/test/bundles/aries1608required/
    aries/trunk/subsystem/subsystem-itests/src/test/bundles/aries1608required/META-INF/
    aries/trunk/subsystem/subsystem-itests/src/test/bundles/aries1608required/META-INF/MANIFEST.MF
    aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/defect/Aries1608Test.java
Modified:
    aries/trunk/subsystem/subsystem-itests/pom.xml
    aries/trunk/subsystem/subsystem-obr/src/main/java/org/apache/aries/subsystem/util/felix/FelixCapabilityAdapter.java

Modified: aries/trunk/subsystem/subsystem-itests/pom.xml
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/pom.xml?rev=1759615&r1=1759614&r2=1759615&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-itests/pom.xml (original)
+++ aries/trunk/subsystem/subsystem-itests/pom.xml Wed Sep  7 14:04:48 2016
@@ -580,7 +580,45 @@
                     </execution>
 
                     <!-- End of new pom for hello tests, part 1 -->
-                    
+
+                    <execution>
+                        <id>aries1608provider</id>
+                        <goals>
+                            <goal>jar</goal>
+                        </goals>
+                        <configuration>
+                            <archive>
+                                <manifestFile>src/test/bundles/aries1608provider/META-INF/MANIFEST.MF</manifestFile>
+                            </archive>
+                            <classesDirectory>${project.build.directory}/test-classes</classesDirectory>
+                            <includes>
+                                <include>org/apache/aries/subsystem/itests/aries1608provider/**</include>
+                            </includes>
+                            <outputDirectory>${project.build.directory}/test-classes/aries1608</outputDirectory>
+                            <finalName>aries1608provider</finalName>
+                        </configuration>
+                        <phase>process-test-classes</phase>
+                    </execution>
+
+                    <execution>
+                        <id>aries.bundlearies1608required</id>
+                        <goals>
+                            <goal>jar</goal>
+                        </goals>
+                        <configuration>
+                            <archive>
+                                <manifestFile>src/test/bundles/aries1608required/META-INF/MANIFEST.MF</manifestFile>
+                            </archive>
+                            <classesDirectory>${project.build.directory}/test-classes</classesDirectory>
+                            <includes>
+                                <include>org/apache/aries/subsystem/itests/aries1608required/**</include>
+                            </includes>
+                            <outputDirectory>${project.build.directory}/test-classes/aries1608</outputDirectory>
+                            <finalName>aries1608required</finalName>
+                        </configuration>
+                        <phase>process-test-classes</phase>
+                    </execution>
+
                     <execution>
                         <id>aries1523host</id>
                         <goals>
@@ -717,7 +755,32 @@
                     </execution>
 
                     <!-- End of new pom for hello tests, part 2 -->
-                    
+                    <execution>
+                        <id>add-source-aries1608provider</id>
+                        <phase>generate-sources</phase>
+                        <goals>
+                            <goal>add-test-source</goal>
+                        </goals>
+                        <configuration>
+                            <sources>
+                                <source>src/test/bundles/aries1608provider</source>
+                            </sources>
+                        </configuration>
+                    </execution>
+
+                    <execution>
+                        <id>add-source-aries1608required</id>
+                        <phase>generate-sources</phase>
+                        <goals>
+                            <goal>add-test-source</goal>
+                        </goals>
+                        <configuration>
+                            <sources>
+                                <source>src/test/bundles/aries1608required</source>
+                            </sources>
+                        </configuration>
+                    </execution>
+
                     <execution>
                         <id>add-source-aries1523host</id>
                         <phase>generate-sources</phase>

Added: aries/trunk/subsystem/subsystem-itests/src/test/bundles/aries1608provider/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/src/test/bundles/aries1608provider/META-INF/MANIFEST.MF?rev=1759615&view=auto
==============================================================================
--- aries/trunk/subsystem/subsystem-itests/src/test/bundles/aries1608provider/META-INF/MANIFEST.MF
(added)
+++ aries/trunk/subsystem/subsystem-itests/src/test/bundles/aries1608provider/META-INF/MANIFEST.MF
Wed Sep  7 14:04:48 2016
@@ -0,0 +1,5 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Bundle namespace provider
+Bundle-SymbolicName: org.apache.aries.subsystem.itests.aries1608provider
+Bundle-Version: 1.0.0

Added: aries/trunk/subsystem/subsystem-itests/src/test/bundles/aries1608required/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/src/test/bundles/aries1608required/META-INF/MANIFEST.MF?rev=1759615&view=auto
==============================================================================
--- aries/trunk/subsystem/subsystem-itests/src/test/bundles/aries1608required/META-INF/MANIFEST.MF
(added)
+++ aries/trunk/subsystem/subsystem-itests/src/test/bundles/aries1608required/META-INF/MANIFEST.MF
Wed Sep  7 14:04:48 2016
@@ -0,0 +1,6 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Bundle namespace required
+Bundle-SymbolicName: org.apache.aries.subsystem.itests.aries1608required
+Require-Bundle: org.apache.aries.subsystem.itests.aries1608provider
+Bundle-Version: 1.0.0

Added: aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/defect/Aries1608Test.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/defect/Aries1608Test.java?rev=1759615&view=auto
==============================================================================
--- aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/defect/Aries1608Test.java
(added)
+++ aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/defect/Aries1608Test.java
Wed Sep  7 14:04:48 2016
@@ -0,0 +1,141 @@
+/*
+ * 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.aries.subsystem.itests.defect;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.net.URL;
+
+import org.apache.aries.subsystem.core.archive.AriesProvisionDependenciesDirective;
+import org.apache.aries.subsystem.itests.SubsystemTest;
+import org.apache.aries.subsystem.itests.util.SubsystemArchiveBuilder;
+import org.apache.felix.bundlerepository.DataModelHelper;
+import org.apache.felix.bundlerepository.Repository;
+import org.apache.felix.bundlerepository.RepositoryAdmin;
+import org.apache.felix.bundlerepository.Resource;
+import org.junit.Test;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.subsystem.Subsystem;
+import org.osgi.service.subsystem.SubsystemConstants;
+import org.osgi.service.subsystem.SubsystemException;
+
+public class Aries1608Test extends SubsystemTest {
+	private RepositoryAdmin repositoryAdmin;
+	private URL url;
+	
+	@Override
+    public void setUp() throws Exception {
+        super.setUp();
+        BundleContext context = context();
+        ServiceReference<RepositoryAdmin> ref = context.getServiceReference(RepositoryAdmin.class);
+        assertNotNull("The RepositoryAdmin service does not exist", ref);
+        try {
+        	repositoryAdmin = (RepositoryAdmin)context.getService(ref);
+        	DataModelHelper helper = repositoryAdmin.getHelper();
+        	url = createRepositoryXml(helper);
+        	Repository repository = repositoryAdmin.addRepository(url);
+        	Resource resource = repository.getResources()[0];
+        	System.out.println(resource.getURI());
+        }
+        finally {
+        	context.ungetService(ref);
+        }
+    }
+	
+	@Override
+	public void tearDown() throws Exception {
+		repositoryAdmin.removeRepository(url.toString());
+		super.tearDown();
+	}
+	
+	@Test
+	public void testApacheAriesProvisionDependenciesInstall() throws Exception {
+		test(AriesProvisionDependenciesDirective.INSTALL);
+	}
+	
+	@Test
+	public void testApacheAriesProvisionDependenciesResolve() throws Exception {
+		test(AriesProvisionDependenciesDirective.RESOLVE);
+	}
+	
+	private void test(AriesProvisionDependenciesDirective provisionDependencies) throws Exception
{
+		boolean flag = AriesProvisionDependenciesDirective.INSTALL.equals(provisionDependencies);
+		Subsystem root = getRootSubsystem();
+		try {
+			Subsystem subsystem = installSubsystem(
+					root,
+					"subsystem", 
+					new SubsystemArchiveBuilder()
+							.symbolicName("subsystem")
+							.type(SubsystemConstants.SUBSYSTEM_TYPE_APPLICATION + ';' 
+										+ provisionDependencies.toString())
+							.content("org.apache.aries.subsystem.itests.aries1608provider,org.apache.aries.subsystem.itests.aries1608required")
+							.bundle(
+									"aries1608required", 
+									getClass().getClassLoader().getResourceAsStream("aries1608/aries1608required.jar"))
+							.build(),
+					flag
+			);
+			try {
+				startSubsystem(subsystem, flag);
+				stopSubsystem(subsystem);
+			}
+			catch (SubsystemException e) {
+				e.printStackTrace();
+				fail("Subsystem should have started");
+			}
+			finally {
+				uninstallSubsystemSilently(subsystem);
+			}
+		}
+		catch (SubsystemException e) {
+			e.printStackTrace();
+			fail("Subsystem should have installed");
+		}
+	}
+	
+	private URL createRepositoryXml(DataModelHelper helper) throws Exception {
+		File dir;
+		String cwd = new File("").getAbsolutePath();
+		if (cwd.endsWith(File.separator + "target")) {
+			dir = new File("test-classes/aries1608");
+		}
+		else {
+			dir = new File("target/test-classes/aries1608");
+		}
+		File jar = new File(dir, "aries1608provider.jar");
+		assertTrue("The bundle jar does not exist: " + jar.getAbsolutePath(), jar.exists());
+		Resource resource = helper.createResource(jar.toURI().toURL());
+		Repository repository = helper.repository(new Resource[] {resource});
+		File file = new File(dir, "repository.xml");
+		FileWriter fw = new FileWriter(file);
+		try {
+			helper.writeRepository(repository, fw);
+			return file.toURI().toURL();
+		}
+		finally {
+			fw.close();
+		}
+	}
+}

Modified: aries/trunk/subsystem/subsystem-obr/src/main/java/org/apache/aries/subsystem/util/felix/FelixCapabilityAdapter.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-obr/src/main/java/org/apache/aries/subsystem/util/felix/FelixCapabilityAdapter.java?rev=1759615&r1=1759614&r2=1759615&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-obr/src/main/java/org/apache/aries/subsystem/util/felix/FelixCapabilityAdapter.java
(original)
+++ aries/trunk/subsystem/subsystem-obr/src/main/java/org/apache/aries/subsystem/util/felix/FelixCapabilityAdapter.java
Wed Sep  7 14:04:48 2016
@@ -38,8 +38,10 @@ public class FelixCapabilityAdapter exte
 		String namespace = getNamespace();
 		if (ServiceNamespace.SERVICE_NAMESPACE.equals(namespace))
 			result.put(ServiceNamespace.CAPABILITY_OBJECTCLASS_ATTRIBUTE, result.get(ServiceNamespace.CAPABILITY_OBJECTCLASS_ATTRIBUTE.toLowerCase()));
-		else if (BundleNamespace.BUNDLE_NAMESPACE.equals(namespace))
+		else if (BundleNamespace.BUNDLE_NAMESPACE.equals(namespace)) {
 			result.put(BundleNamespace.BUNDLE_NAMESPACE, result.get(org.apache.felix.bundlerepository.Resource.SYMBOLIC_NAME));
+			result.put(BundleNamespace.CAPABILITY_BUNDLE_VERSION_ATTRIBUTE, result.get(org.apache.felix.bundlerepository.Resource.VERSION));
+		}
 		else
 			result.put(namespace, result.get(capability.getName()));
 		return result;



Mime
View raw message