You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by pa...@apache.org on 2017/04/04 23:05:38 UTC
svn commit: r1790167 - in /felix/trunk/framework/src:
main/java/org/apache/felix/framework/util/manifestparser/ManifestParser.java
test/java/org/apache/felix/framework/util/manifestparser/ManifestParserTest.java
Author: pauls
Date: Tue Apr 4 23:05:38 2017
New Revision: 1790167
URL: http://svn.apache.org/viewvc?rev=1790167&view=rev
Log:
Normalize require capabilites the same way we normalize provide capabilites as per spec (FELIX-5604).
Modified:
felix/trunk/framework/src/main/java/org/apache/felix/framework/util/manifestparser/ManifestParser.java
felix/trunk/framework/src/test/java/org/apache/felix/framework/util/manifestparser/ManifestParserTest.java
Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/util/manifestparser/ManifestParser.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/util/manifestparser/ManifestParser.java?rev=1790167&r1=1790166&r2=1790167&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/util/manifestparser/ManifestParser.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/util/manifestparser/ManifestParser.java Tue Apr 4 23:05:38 2017
@@ -196,7 +196,7 @@ public class ManifestParser
List<ParsedHeaderClause> requireClauses =
parseStandardHeader((String) headerMap.get(Constants.REQUIRE_CAPABILITY));
- importClauses = normalizeRequireCapabilityClauses(
+ importClauses = normalizeCapabilityClauses(
m_logger, requireClauses, getManifestVersion());
List<BundleRequirement> requireReqs = convertRequireCapabilities(importClauses, owner);
@@ -222,7 +222,7 @@ public class ManifestParser
List<ParsedHeaderClause> provideClauses =
parseStandardHeader((String) headerMap.get(Constants.PROVIDE_CAPABILITY));
- exportClauses = normalizeProvideCapabilityClauses(
+ exportClauses = normalizeCapabilityClauses(
logger, provideClauses, getManifestVersion());
List<BundleCapability> provideCaps = convertProvideCapabilities(provideClauses, owner);
@@ -551,19 +551,6 @@ public class ManifestParser
return clauses;
}
- private static List<ParsedHeaderClause> normalizeRequireCapabilityClauses(
- Logger logger, List<ParsedHeaderClause> clauses, String mv)
- throws BundleException
- {
-
- if (!mv.equals("2") && !clauses.isEmpty())
- {
- // Should we error here if we are not an R4 bundle?
- }
-
- return clauses;
- }
-
private static List<BundleRequirement> convertRequireCapabilities(
List<ParsedHeaderClause> clauses, BundleRevision owner)
throws BundleException
@@ -715,7 +702,7 @@ public class ManifestParser
return result;
}
- private static List<ParsedHeaderClause> normalizeProvideCapabilityClauses(
+ private static List<ParsedHeaderClause> normalizeCapabilityClauses(
Logger logger, List<ParsedHeaderClause> clauses, String mv)
throws BundleException
{
Modified: felix/trunk/framework/src/test/java/org/apache/felix/framework/util/manifestparser/ManifestParserTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/test/java/org/apache/felix/framework/util/manifestparser/ManifestParserTest.java?rev=1790167&r1=1790166&r2=1790167&view=diff
==============================================================================
--- felix/trunk/framework/src/test/java/org/apache/felix/framework/util/manifestparser/ManifestParserTest.java (original)
+++ felix/trunk/framework/src/test/java/org/apache/felix/framework/util/manifestparser/ManifestParserTest.java Tue Apr 4 23:05:38 2017
@@ -22,6 +22,7 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
@@ -112,6 +113,37 @@ public class ManifestParserTest extends
}
+ @SuppressWarnings("unchecked")
+ public void testAttributes() throws BundleException {
+ Map<String, Object> headers = new HashMap<String, Object>();
+ headers.put(Constants.BUNDLE_MANIFESTVERSION, "2");
+ headers.put(Constants.BUNDLE_SYMBOLICNAME,"com.example.test.sample");
+ headers.put(Constants.PROVIDE_CAPABILITY,
+ "com.example;theList:List<String>=\"red,green,blue\";theLong:Long=111");
+ headers.put(Constants.REQUIRE_CAPABILITY,
+ "com.example.other;theList:List<String>=\"one,two,three\";theLong:Long=999");
+
+ BundleRevision mockBundleRevision = mock(BundleRevision.class);
+
+ when(mockBundleRevision.getSymbolicName()).thenReturn("com.example.test.sample");
+
+ ManifestParser mp = new ManifestParser(null, null, mockBundleRevision, headers);
+
+ BundleCapability bc = findCapability(mp.getCapabilities(), "com.example");
+ Long cLong = (Long) bc.getAttributes().get("theLong");
+ assertEquals(Long.valueOf(111), cLong);
+ List<String> cList = (List<String>)
+ bc.getAttributes().get("theList");
+ assertEquals(3, cList.size());
+ assertTrue(cList.contains("red"));
+
+ BundleRequirement br = findRequirement(mp.getRequirements(), "com.example.other");
+ Long rLong = (Long) br.getAttributes().get("theLong");
+ assertEquals(Long.valueOf(999), rLong);
+ List<String> rList = (List<String>) br.getAttributes().get("theList");
+ assertEquals(3, rList.size());
+ }
+
public void testConvertNativeCode() throws InvalidSyntaxException
{
List<NativeLibraryClause> nativeLibraryClauses = new ArrayList<NativeLibraryClause>();