aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject svn commit: r1567152 - in /aries/trunk/spi-fly/spi-fly-static-tool/src: main/java/org/apache/aries/spifly/statictool/Main.java test/java/org/apache/aries/spifly/statictool/RequirementTest.java
Date Tue, 11 Feb 2014 14:40:56 GMT
Author: davidb
Date: Tue Feb 11 14:40:55 2014
New Revision: 1567152

URL: http://svn.apache.org/r1567152
Log:
[ARIES-1156] SPI-Fly static tool does not work with Require-Capability bundles

This commit should fix the issue.
Updated unit tests included.

Modified:
    aries/trunk/spi-fly/spi-fly-static-tool/src/main/java/org/apache/aries/spifly/statictool/Main.java
    aries/trunk/spi-fly/spi-fly-static-tool/src/test/java/org/apache/aries/spifly/statictool/RequirementTest.java

Modified: aries/trunk/spi-fly/spi-fly-static-tool/src/main/java/org/apache/aries/spifly/statictool/Main.java
URL: http://svn.apache.org/viewvc/aries/trunk/spi-fly/spi-fly-static-tool/src/main/java/org/apache/aries/spifly/statictool/Main.java?rev=1567152&r1=1567151&r2=1567152&view=diff
==============================================================================
--- aries/trunk/spi-fly/spi-fly-static-tool/src/main/java/org/apache/aries/spifly/statictool/Main.java
(original)
+++ aries/trunk/spi-fly/spi-fly-static-tool/src/main/java/org/apache/aries/spifly/statictool/Main.java
Tue Feb 11 14:40:55 2014
@@ -97,20 +97,22 @@ public class Main {
 
             if (SpiFlyConstants.SPI_CONSUMER_HEADER.equals(consumerHeaderKey)) {
                 manifest.getMainAttributes().remove(new Attributes.Name(SpiFlyConstants.SPI_CONSUMER_HEADER));
+                manifest.getMainAttributes().putValue(SpiFlyConstants.PROCESSED_SPI_CONSUMER_HEADER,
consumerHeaderVal);
             } else {
                 // It's SpiFlyConstants.REQUIRE_CAPABILITY
 
                 // Take out the processor requirement, this probably needs to be improved
a little bit
                 String newConsumerHeaderVal = consumerHeaderVal.replaceAll(
-                        "osgi[.]extender;\\s*filter[:][=][\"]?[(]osgi[.]extender[=]osgi[.]serviceloader[.]processor[)][\"]?",
"");
+                        "osgi[.]extender;\\s*filter[:][=][\"]?[(]osgi[.]extender[=]osgi[.]serviceloader[.]processor[)][\"]?",
"").
+                        trim();
                 if (newConsumerHeaderVal.startsWith(","))
                     newConsumerHeaderVal = newConsumerHeaderVal.substring(1);
 
                 if (newConsumerHeaderVal.endsWith(","))
                     newConsumerHeaderVal = newConsumerHeaderVal.substring(0, newConsumerHeaderVal.length()-1);
                 manifest.getMainAttributes().putValue(SpiFlyConstants.REQUIRE_CAPABILITY,
newConsumerHeaderVal);
+                manifest.getMainAttributes().putValue("X-SpiFly-Processed-Require-Capability",
consumerHeaderVal);
             }
-            manifest.getMainAttributes().putValue(SpiFlyConstants.PROCESSED_SPI_CONSUMER_HEADER,
consumerHeaderVal);
 
             // TODO if new packages needed then...
             extendImportPackage(manifest);

Modified: aries/trunk/spi-fly/spi-fly-static-tool/src/test/java/org/apache/aries/spifly/statictool/RequirementTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/spi-fly/spi-fly-static-tool/src/test/java/org/apache/aries/spifly/statictool/RequirementTest.java?rev=1567152&r1=1567151&r2=1567152&view=diff
==============================================================================
--- aries/trunk/spi-fly/spi-fly-static-tool/src/test/java/org/apache/aries/spifly/statictool/RequirementTest.java
(original)
+++ aries/trunk/spi-fly/spi-fly-static-tool/src/test/java/org/apache/aries/spifly/statictool/RequirementTest.java
Tue Feb 11 14:40:55 2014
@@ -58,7 +58,7 @@ public class RequirementTest {
             mainAttributes.putValue("Foo", "Bar Bar");
             mainAttributes.putValue("Import-Package", "org.foo.bar");
             mainAttributes.putValue(SpiFlyConstants.REQUIRE_CAPABILITY,
-                    "osgi.serviceloader; filter:=\"(osgi.serviceloader=org.apache.aries.spifly.mysvc.SPIProvider)\";cardinality:=multiple,"
+
+                    "osgi.serviceloader; filter:=\"(osgi.serviceloader=org.apache.aries.spifly.mysvc.SPIProvider)\";cardinality:=multiple,
" +
                     "osgi.extender; filter:=\"(osgi.extender=osgi.serviceloader.processor)\"");
 
             JarOutputStream jos = new JarOutputStream(new FileOutputStream(jarFile), mf);
@@ -76,14 +76,16 @@ public class RequirementTest {
             Assert.assertTrue("A processed separate bundle should have been created", expectedFile.exists());
             // Check manifest in generated bundle.
             JarFile transformedJarFile = new JarFile(expectedFile);
-            Manifest expectedMF = transformedJarFile.getManifest();
-            Assert.assertEquals("1.0", expectedMF.getMainAttributes().getValue("Manifest-Version"));
-            Assert.assertEquals("2.0", expectedMF.getMainAttributes().getValue("Bundle-ManifestVersion"));
-            Assert.assertEquals("testbundle", expectedMF.getMainAttributes().getValue("Bundle-SymbolicName"));
-            Assert.assertEquals("Bar Bar", expectedMF.getMainAttributes().getValue("Foo"));
+            Manifest actualMF = transformedJarFile.getManifest();
+            Assert.assertEquals("1.0", actualMF.getMainAttributes().getValue("Manifest-Version"));
+            Assert.assertEquals("2.0", actualMF.getMainAttributes().getValue("Bundle-ManifestVersion"));
+            Assert.assertEquals("testbundle", actualMF.getMainAttributes().getValue("Bundle-SymbolicName"));
+            Assert.assertEquals("Bar Bar", actualMF.getMainAttributes().getValue("Foo"));
             Assert.assertEquals("osgi.serviceloader; filter:=\"(osgi.serviceloader=org.apache.aries.spifly.mysvc.SPIProvider)\";cardinality:=multiple",
-                    expectedMF.getMainAttributes().getValue(SpiFlyConstants.REQUIRE_CAPABILITY));
-            String importPackage = expectedMF.getMainAttributes().getValue("Import-Package");
+                    actualMF.getMainAttributes().getValue(SpiFlyConstants.REQUIRE_CAPABILITY));
+            Assert.assertNull("Should not generate this header when processing Require-Capability",
+                    actualMF.getMainAttributes().getValue(SpiFlyConstants.PROCESSED_SPI_CONSUMER_HEADER));
+            String importPackage = actualMF.getMainAttributes().getValue("Import-Package");
             Assert.assertTrue(
                 "org.foo.bar,org.apache.aries.spifly;version=\"[1.0.0,1.1.0)\"".equals(importPackage)
||
                 "org.apache.aries.spifly;version=\"[1.0.0,1.1.0)\",org.foo.bar".equals(importPackage));



Mime
View raw message