aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jwr...@apache.org
Subject svn commit: r1369953 - in /aries/trunk/subsystem/subsystem-core/src: main/java/org/apache/aries/subsystem/core/archive/ main/java/org/apache/aries/subsystem/core/internal/ test/java/org/apache/aries/subsystem/core/ test/java/org/apache/aries/subsystem/...
Date Mon, 06 Aug 2012 19:50:38 GMT
Author: jwross
Date: Mon Aug  6 19:50:37 2012
New Revision: 1369953

URL: http://svn.apache.org/viewvc?rev=1369953&view=rev
Log:
ARIES-901: All packages in the same path will now be associated with the specified version
attribute or 0.0 if none.

Added:
    aries/trunk/subsystem/subsystem-core/src/test/java/org/apache/aries/subsystem/core/archive/
    aries/trunk/subsystem/subsystem-core/src/test/java/org/apache/aries/subsystem/core/archive/ImportPackageHeaderTest.java
Removed:
    aries/trunk/subsystem/subsystem-core/src/test/java/org/apache/aries/subsystem/core/Temp.java
Modified:
    aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/ImportPackageHeader.java
    aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/SubsystemResource.java

Modified: aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/ImportPackageHeader.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/ImportPackageHeader.java?rev=1369953&r1=1369952&r2=1369953&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/ImportPackageHeader.java
(original)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/ImportPackageHeader.java
Mon Aug  6 19:50:37 2012
@@ -178,14 +178,10 @@ public class ImportPackageHeader impleme
 	public static final String RESOLUTION_MANDATORY = PackageNamespace.RESOLUTION_MANDATORY;
 	public static final String RESOLUTION_OPTIONAL = PackageNamespace.RESOLUTION_OPTIONAL;
 	
-	private static final String REGEX = Grammar.IMPORT + "(?=,|\\z)";
-	private static final Pattern PATTERN = Pattern.compile(REGEX);
-	
 	private static Collection<Clause> processHeader(String header) {
-		Matcher matcher = PATTERN.matcher(header);
 		Set<Clause> clauses = new HashSet<Clause>();
-		while (matcher.find())
-			clauses.add(new Clause(matcher.group()));
+		for (String clause : new ClauseTokenizer(header).getClauses())
+			clauses.add(new Clause(clause));
 		return clauses;
 	}
 	

Modified: aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/SubsystemResource.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/SubsystemResource.java?rev=1369953&r1=1369952&r2=1369953&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/SubsystemResource.java
(original)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/SubsystemResource.java
Mon Aug  6 19:50:37 2012
@@ -257,6 +257,7 @@ public class SubsystemResource implement
 	}
 	
 	private boolean addDependenciesFromContentRepository(Requirement requirement, List<Capability>
capabilities) throws BundleException, IOException, InvalidSyntaxException, URISyntaxException
{
+		// TODO Why create this with each method call? What not cache it as an instance variable?
 		Repository repository = new ContentRepository(installableContent, sharedContent);
 		return addDependencies(repository, requirement, capabilities);
 	}

Added: aries/trunk/subsystem/subsystem-core/src/test/java/org/apache/aries/subsystem/core/archive/ImportPackageHeaderTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/test/java/org/apache/aries/subsystem/core/archive/ImportPackageHeaderTest.java?rev=1369953&view=auto
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/test/java/org/apache/aries/subsystem/core/archive/ImportPackageHeaderTest.java
(added)
+++ aries/trunk/subsystem/subsystem-core/src/test/java/org/apache/aries/subsystem/core/archive/ImportPackageHeaderTest.java
Mon Aug  6 19:50:37 2012
@@ -0,0 +1,48 @@
+package org.apache.aries.subsystem.core.archive;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import org.junit.Test;
+import org.osgi.framework.VersionRange;
+
+public class ImportPackageHeaderTest {
+	@Test
+	public void testVersionAttributeWithMultiplePackages() {
+		String headerStr = "org.foo;org.bar;org.foo.bar;version=1.3";
+		ImportPackageHeader header = new ImportPackageHeader(headerStr);
+		assertClauses(header, 1);
+		assertVersionAttribute(header, "org.foo;org.bar;org.foo.bar", "1.3");
+	}
+	
+	@Test
+	public void testVersionAttributeWithoutMultiplePackages() {
+		String headerStr = "org.foo,org.bar,org.foo.bar;version=1.3";
+		ImportPackageHeader header = new ImportPackageHeader(headerStr);
+		assertClauses(header, 3);
+		assertVersionAttribute(header, "org.foo", "0");
+		assertVersionAttribute(header, "org.bar", "0.0");
+		assertVersionAttribute(header, "org.foo.bar", "1.3");
+	}
+	
+	private void assertClauses(ImportPackageHeader header, int expectedClauses) {
+		assertEquals("Wrong number of clauses", expectedClauses, header.getClauses().size());
+	}
+	
+	private void assertVersionAttribute(ImportPackageHeader header, String path, String expectedVersion)
{
+		for (ImportPackageHeader.Clause clause : header.getClauses())
+			if (path.equals(clause.getPath())) {
+				assertVersionAttribute(clause, expectedVersion);
+				return;
+			}
+		fail("Path not found: " + path);
+	}
+	
+	private void assertVersionAttribute(ImportPackageHeader.Clause clause, String expectedVersion)
{
+		assertVersionAttribute(clause, new VersionRange(expectedVersion));
+	}
+	
+	private void assertVersionAttribute(ImportPackageHeader.Clause clause, VersionRange expectedVersion)
{
+		assertEquals("Wrong version attribute", expectedVersion, clause.getVersionRangeAttribute().getVersionRange());
+	}
+}



Mime
View raw message