aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jwr...@apache.org
Subject svn commit: r1403783 - in /aries/trunk/subsystem: subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/ subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/ subsystem-itests/src/test/java/org/apache/aries/subsystem/ctt...
Date Tue, 30 Oct 2012 17:12:28 GMT
Author: jwross
Date: Tue Oct 30 17:12:27 2012
New Revision: 1403783

URL: http://svn.apache.org/viewvc?rev=1403783&view=rev
Log:
Bundles as directories. New installed location syntax.

Support was added for installing bundles as directories to compliment already existing support
for subsystems as directories.
Directory names representing bundles must end with ".jar".

The generated location used for installing embedded subsystems and bundles now uses the following
pattern:

<provision-to subsystem location>!/<resource location>

The format should be interpreted as "there is an entry for a resource located at <resource
location> within the subsystem
archive located at <provision-to subsystem location>." Typically, <resource location>
will be a file name. The syntax is
intended to support the loose config scenario introduced with the idirfinder URL scheme.

Also fixed a few compile warnings in some test classes.

Added:
    aries/trunk/subsystem/subsystem-itests/src/test/resources/compositeDir/a.jar/
    aries/trunk/subsystem/subsystem-itests/src/test/resources/compositeDir/a.jar/META-INF/
    aries/trunk/subsystem/subsystem-itests/src/test/resources/compositeDir/a.jar/META-INF/MANIFEST.MF
    aries/trunk/subsystem/subsystem-itests/src/test/resources/compositeDir/a.jar/a/
    aries/trunk/subsystem/subsystem-itests/src/test/resources/compositeDir/a.jar/a/A.class
    aries/trunk/subsystem/subsystem-itests/src/test/resources/compositeDir/applicationDir/b.jar/
    aries/trunk/subsystem/subsystem-itests/src/test/resources/compositeDir/applicationDir/b.jar/META-INF/
    aries/trunk/subsystem/subsystem-itests/src/test/resources/compositeDir/applicationDir/b.jar/META-INF/MANIFEST.MF
    aries/trunk/subsystem/subsystem-itests/src/test/resources/compositeDir/applicationDir/b.jar/b/
    aries/trunk/subsystem/subsystem-itests/src/test/resources/compositeDir/applicationDir/b.jar/b/B.class
    aries/trunk/subsystem/subsystem-itests/src/test/resources/compositeDir/applicationDir/featureDir/a.jar/
    aries/trunk/subsystem/subsystem-itests/src/test/resources/compositeDir/applicationDir/featureDir/a.jar/META-INF/
    aries/trunk/subsystem/subsystem-itests/src/test/resources/compositeDir/applicationDir/featureDir/a.jar/META-INF/MANIFEST.MF
    aries/trunk/subsystem/subsystem-itests/src/test/resources/compositeDir/applicationDir/featureDir/a.jar/a/
    aries/trunk/subsystem/subsystem-itests/src/test/resources/compositeDir/applicationDir/featureDir/a.jar/a/A.class
    aries/trunk/subsystem/subsystem-itests/src/test/resources/compositeDir/applicationDir/featureDir/b.jar/
    aries/trunk/subsystem/subsystem-itests/src/test/resources/compositeDir/applicationDir/featureDir/b.jar/META-INF/
    aries/trunk/subsystem/subsystem-itests/src/test/resources/compositeDir/applicationDir/featureDir/b.jar/META-INF/MANIFEST.MF
    aries/trunk/subsystem/subsystem-itests/src/test/resources/compositeDir/applicationDir/featureDir/b.jar/b/
    aries/trunk/subsystem/subsystem-itests/src/test/resources/compositeDir/applicationDir/featureDir/b.jar/b/B.class
Modified:
    aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/Manifest.java
    aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/BundleResource.java
    aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/BundleResourceInstaller.java
    aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/RawSubsystemResource.java
    aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/ResourceHelper.java
    aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/ResourceInstaller.java
    aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/SubsystemResource.java
    aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/ctt/itests/SubsystemDependency_4ATest.java
    aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/ctt/itests/SubsystemDependency_4CTest.java
    aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/ctt/itests/SubsystemDependency_4DTest.java
    aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/CompositeTest.java
    aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/InstallTest.java
    aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/SubsystemTest.java
    aries/trunk/subsystem/subsystem-itests/src/test/resources/compositeDir/OSGI-INF/SUBSYSTEM.MF

Modified: aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/Manifest.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/Manifest.java?rev=1403783&r1=1403782&r2=1403783&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/Manifest.java
(original)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/Manifest.java
Tue Oct 30 17:12:27 2012
@@ -59,6 +59,10 @@ public abstract class Manifest {
 	public Collection<Header> getHeaders() {
 		return Collections.unmodifiableCollection(headers.values());
 	}
+	
+	public java.util.jar.Manifest getManifest() {
+		return manifest;
+	}
 
 	public Header getManifestVersion() {
 		return getHeader(Attributes.Name.MANIFEST_VERSION.toString());

Modified: aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/BundleResource.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/BundleResource.java?rev=1403783&r1=1403782&r2=1403783&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/BundleResource.java
(original)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/BundleResource.java
Tue Oct 30 17:12:27 2012
@@ -13,13 +13,17 @@
  */
 package org.apache.aries.subsystem.core.internal;
 
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
-import java.net.URL;
+import java.net.MalformedURLException;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
+import java.util.jar.JarEntry;
+import java.util.jar.JarOutputStream;
 
 import org.apache.aries.application.modelling.ExportedService;
 import org.apache.aries.application.modelling.ImportedService;
@@ -38,9 +42,8 @@ import org.apache.aries.subsystem.core.a
 import org.apache.aries.subsystem.core.archive.RequireBundleRequirement;
 import org.apache.aries.subsystem.core.archive.RequireCapabilityHeader;
 import org.apache.aries.subsystem.core.archive.RequireCapabilityRequirement;
-import org.apache.aries.util.filesystem.FileSystem;
-import org.apache.aries.util.filesystem.ICloseableDirectory;
 import org.apache.aries.util.filesystem.IDirectory;
+import org.apache.aries.util.filesystem.IFile;
 import org.apache.aries.util.io.IOUtils;
 import org.osgi.namespace.service.ServiceNamespace;
 import org.osgi.resource.Capability;
@@ -58,38 +61,19 @@ public class BundleResource implements R
 	}
 	
 	private final List<Capability> capabilities = new ArrayList<Capability>();
-	private final URL content;
+	private final IFile content;
 	private final BundleManifest manifest;
 	private final List<Requirement> requirements = new ArrayList<Requirement>();
 	
-	public BundleResource(URL content) throws IOException, ModellerException {
+	public BundleResource(IFile content) throws ModellerException {
 		this.content = content;
-		InputStream is = content.openStream();
-		try {
-			ICloseableDirectory directory = FileSystem.getFSRoot(is);
-			try {
-				manifest = computeManifest(directory);
-				// TODO Could use ModelledResourceManager.getServiceElements
-				// instead. Only the service dependency info is being used
-				// right now.
-				ModelledResource resource = getModelledResourceManager().getModelledResource(directory);
-				computeRequirements(resource);
-				computeCapabilities(resource);
-			}
-			finally {
-				IOUtils.close(directory);
-			}
-		}
-		finally {
-			// Although FileSystem.getFSRoot ultimately tries to close the
-			// provided input stream, it is possible an exception will be thrown
-			// before that happens.
-			IOUtils.close(is);
-		}
-	}
-	
-	public BundleResource(String content) throws IOException, ModellerException {
-		this(new URL(content));
+		IDirectory dir = content.isDirectory() ? content.convert() : content.convertNested();
+		manifest = computeManifest(dir);
+		// TODO Could use ModelledResourceManager.getServiceElements instead. 
+		// Only the service dependency info is being used right now.
+		ModelledResource resource = getModelledResourceManager().getModelledResource(dir);
+		computeRequirements(resource);
+		computeCapabilities(resource);
 	}
 
 	public List<Capability> getCapabilities(String namespace) {
@@ -103,12 +87,33 @@ public class BundleResource implements R
 		return Collections.unmodifiableList(result);
 	}
 	
+	public String getLocation() {
+		return getFileName(content);
+	}
+	
 	@Override
 	public InputStream getContent() {
 		try {
-			return content.openStream();
+			if (content.isFile())
+				return content.open();
+			try {
+				// Give the IDirectory a shot at opening in case it supports it.
+				return content.open();
+			}
+			catch (UnsupportedOperationException e) {
+				// As a last ditch effort, try to jar up the contents.
+				ByteArrayOutputStream baos = new ByteArrayOutputStream();
+				JarOutputStream out = new JarOutputStream(baos, manifest.getManifest());
+				try {
+					jar(out, "", content.convert());
+				}
+				finally {
+					IOUtils.close(out);
+				}
+				return new ByteArrayInputStream(baos.toByteArray());
+			}
 		}
-		catch (IOException e) {
+		catch (Exception e) {
 			throw new SubsystemException(e);
 		}
 	}
@@ -126,7 +131,7 @@ public class BundleResource implements R
 	
 	@Override
 	public String toString() {
-        return content.toExternalForm();
+        return content.toString();
     }
 	
 	private void computeCapabilities(ModelledResource resource) {
@@ -223,7 +228,47 @@ public class BundleResource implements R
 		// TODO Bundle-RequiredExecutionEnvironment
 	}
 	
+	private String getFileName(IFile file) {
+		String name = file.getName();
+		if ("".equals(name)) {
+			// The file is the root directory of an archive. Use the URL
+			// instead. Using the empty string will likely result in duplicate
+			// locations during installation.
+			try {
+				name = file.toURL().toString();
+			}
+			catch (MalformedURLException e) {
+				throw new SubsystemException(e);
+			}
+		}
+		int index = name.lastIndexOf('/');
+		if (index == -1 || index == name.length() - 1)
+			return name;
+		return name.substring(index + 1);
+	}
+
 	private ModelledResourceManager getModelledResourceManager() {
 		return Activator.getInstance().getModelledResourceManager();
 	}
+
+	private void jar(JarOutputStream out, String prefix, IDirectory directory) throws IOException
{
+		List<IFile> files = directory.listFiles();
+		for (IFile f : files) {        
+			String fileName; 
+			if (f.isDirectory())
+				fileName = prefix + getFileName(f) + "/";
+			else
+				fileName = prefix + getFileName(f);
+			if ("META-INF/".equalsIgnoreCase(fileName) || "META-INF/MANIFEST.MF".equalsIgnoreCase(fileName))
+				continue;
+			JarEntry entry = new JarEntry(fileName);
+			entry.setSize(f.getSize());
+			entry.setTime(f.getLastModified());
+			out.putNextEntry(entry);
+			if (f.isDirectory()) 
+				jar(out, fileName, f.convert());
+			else
+				IOUtils.copy(f.open(), out);
+		}
+	}
 }

Modified: aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/BundleResourceInstaller.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/BundleResourceInstaller.java?rev=1403783&r1=1403782&r2=1403783&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/BundleResourceInstaller.java
(original)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/BundleResourceInstaller.java
Tue Oct 30 17:12:27 2012
@@ -166,7 +166,7 @@ public class BundleResourceInstaller ext
 		final Bundle bundle;
 		InputStream is = ((RepositoryContent)resource).getContent();
 		try {
-			bundle = provisionTo.getRegion().installBundle(getLocation(), is);
+			bundle = provisionTo.getRegion().installBundleAtLocation(getLocation(), is);
 		}
 		catch (BundleException e) {
 			throw new SubsystemException(e);

Modified: aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/RawSubsystemResource.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/RawSubsystemResource.java?rev=1403783&r1=1403782&r2=1403783&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/RawSubsystemResource.java
(original)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/RawSubsystemResource.java
Tue Oct 30 17:12:27 2012
@@ -326,13 +326,15 @@ public class RawSubsystemResource implem
 			String name = file.getName();
 			if (file.isFile()) {
 				if (name.endsWith(".jar"))
-					result.add(new BundleResource(file.toURL()));
+					result.add(new BundleResource(file));
 				else if (name.endsWith(".esa"))
 					result.add(new RawSubsystemResource(convertFileToLocation(file), file.open()));
 			}
 			else {
 				if (name.endsWith(".esa"))
 					result.add(new RawSubsystemResource(convertFileToLocation(file), file.convert()));
+				else if (name.endsWith(".jar"))
+					result.add(new BundleResource(file));
 			}
 		}
 		result.trimToSize();

Modified: aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/ResourceHelper.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/ResourceHelper.java?rev=1403783&r1=1403782&r2=1403783&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/ResourceHelper.java
(original)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/ResourceHelper.java
Tue Oct 30 17:12:27 2012
@@ -24,6 +24,7 @@ import org.osgi.framework.FrameworkUtil;
 import org.osgi.framework.InvalidSyntaxException;
 import org.osgi.framework.Version;
 import org.osgi.framework.namespace.IdentityNamespace;
+import org.osgi.framework.wiring.BundleRevision;
 import org.osgi.resource.Capability;
 import org.osgi.resource.Requirement;
 import org.osgi.resource.Resource;
@@ -63,6 +64,20 @@ public class ResourceHelper {
 		return capability.getAttributes().get(name);
 	}
 	
+	public static String getLocation(Resource resource) {
+		if (resource instanceof BundleResource)
+			return ((BundleResource)resource).getLocation();
+		if (resource instanceof BundleRevision)
+			return ((BundleRevision)resource).getBundle().getLocation();
+		if (resource instanceof AriesSubsystem)
+			return ((AriesSubsystem)resource).getLocation();
+		if (resource instanceof SubsystemResource)
+			return ((SubsystemResource)resource).getLocation();
+		if (resource instanceof RawSubsystemResource)
+			return ((RawSubsystemResource)resource).getLocation().getValue();
+		return getSymbolicNameAttribute(resource) + '@' + getVersionAttribute(resource);
+	}
+	
 	public static Resource getResource(Requirement requirement, Repository repository) {
 		Map<Requirement, Collection<Capability>> map = repository.findProviders(Arrays.asList(requirement));
 		Collection<Capability> capabilities = map.get(requirement);

Modified: aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/ResourceInstaller.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/ResourceInstaller.java?rev=1403783&r1=1403782&r2=1403783&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/ResourceInstaller.java
(original)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/ResourceInstaller.java
Tue Oct 30 17:12:27 2012
@@ -99,7 +99,7 @@ public abstract class ResourceInstaller 
 	}
 	
 	protected String getLocation() {
-		return provisionTo.getSubsystemId() + "@" + provisionTo.getSymbolicName() + "@" + ResourceHelper.getSymbolicNameAttribute(resource);
+		return provisionTo.getLocation() + "!/" + ResourceHelper.getLocation(resource);
 	}
 	
 	protected boolean isContent() {

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=1403783&r1=1403782&r2=1403783&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
Tue Oct 30 17:12:27 2012
@@ -58,7 +58,6 @@ import org.osgi.framework.ServiceReferen
 import org.osgi.framework.hooks.weaving.WeavingHook;
 import org.osgi.framework.namespace.IdentityNamespace;
 import org.osgi.framework.wiring.BundleRevision;
-import org.osgi.framework.wiring.BundleWiring;
 import org.osgi.resource.Capability;
 import org.osgi.resource.Requirement;
 import org.osgi.resource.Resource;

Modified: aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/ctt/itests/SubsystemDependency_4ATest.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/ctt/itests/SubsystemDependency_4ATest.java?rev=1403783&r1=1403782&r2=1403783&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/ctt/itests/SubsystemDependency_4ATest.java
(original)
+++ aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/ctt/itests/SubsystemDependency_4ATest.java
Tue Oct 30 17:12:27 2012
@@ -1,13 +1,9 @@
 package org.apache.aries.subsystem.ctt.itests;
 
-import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
 
 import java.util.HashMap;
-import java.util.HashSet;
 import java.util.Map;
-import java.util.Set;
 
 import org.junit.Before;
 import org.junit.Test;

Modified: aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/ctt/itests/SubsystemDependency_4CTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/ctt/itests/SubsystemDependency_4CTest.java?rev=1403783&r1=1403782&r2=1403783&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/ctt/itests/SubsystemDependency_4CTest.java
(original)
+++ aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/ctt/itests/SubsystemDependency_4CTest.java
Tue Oct 30 17:12:27 2012
@@ -1,17 +1,11 @@
 package org.apache.aries.subsystem.ctt.itests;
 
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.util.Arrays;
-import java.util.Collection;
 import java.util.HashMap;
 import java.util.Map;
 
 import org.junit.Before;
 import org.junit.Test;
 import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
 import org.osgi.service.subsystem.Subsystem;
 import org.osgi.service.subsystem.SubsystemConstants;

Modified: aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/ctt/itests/SubsystemDependency_4DTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/ctt/itests/SubsystemDependency_4DTest.java?rev=1403783&r1=1403782&r2=1403783&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/ctt/itests/SubsystemDependency_4DTest.java
(original)
+++ aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/ctt/itests/SubsystemDependency_4DTest.java
Tue Oct 30 17:12:27 2012
@@ -8,7 +8,6 @@ import java.util.Map;
 import org.junit.Before;
 import org.junit.Test;
 import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
 import org.osgi.service.subsystem.Subsystem;
 import org.osgi.service.subsystem.SubsystemConstants;
 

Modified: aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/CompositeTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/CompositeTest.java?rev=1403783&r1=1403782&r2=1403783&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/CompositeTest.java
(original)
+++ aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/CompositeTest.java
Tue Oct 30 17:12:27 2012
@@ -20,7 +20,6 @@ import java.util.Map;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.junit.JUnit4TestRunner;
 import org.ops4j.pax.exam.junit.MavenConfiguredJUnit4TestRunner;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.Constants;

Modified: aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/InstallTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/InstallTest.java?rev=1403783&r1=1403782&r2=1403783&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/InstallTest.java
(original)
+++ aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/InstallTest.java
Tue Oct 30 17:12:27 2012
@@ -36,6 +36,7 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.ops4j.pax.exam.junit.MavenConfiguredJUnit4TestRunner;
 import org.osgi.framework.Bundle;
+import org.osgi.framework.Version;
 import org.osgi.framework.startlevel.BundleStartLevel;
 import org.osgi.framework.startlevel.FrameworkStartLevel;
 import org.osgi.service.subsystem.Subsystem;
@@ -47,18 +48,41 @@ public class InstallTest extends Subsyst
 		if (createdApplications) {
 			return;
 		}
-		
 		ZipFixture feature = ArchiveFixture
 				.newZip()
 				.binary("OSGI-INF/SUBSYSTEM.MF",
 						SubsystemTest.class.getClassLoader().getResourceAsStream(
 								"compositeDir" + "/OSGI-INF/SUBSYSTEM.MF"))
+				.binary("a.jar/META-INF/MANIFEST.MF", 
+						SubsystemTest.class.getClassLoader().getResourceAsStream(
+								"compositeDir" + "/a.jar/META-INF/MANIFEST.MF"))
+				.binary("a.jar/a/A.class", 
+						SubsystemTest.class.getClassLoader().getResourceAsStream(
+								"compositeDir" + "/a.jar/a/A.class"))
 				.binary("applicationDir.esa/OSGI-INF/SUBSYSTEM.MF",
 						SubsystemTest.class.getClassLoader().getResourceAsStream(
 								"compositeDir" + "/applicationDir/OSGI-INF/SUBSYSTEM.MF"))
+				.binary("applicationDir.esa/b.jar/META-INF/MANIFEST.MF", 
+						SubsystemTest.class.getClassLoader().getResourceAsStream(
+								"compositeDir" + "/applicationDir/b.jar/META-INF/MANIFEST.MF"))
+				.binary("applicationDir.esa/b.jar/b/B.class", 
+						SubsystemTest.class.getClassLoader().getResourceAsStream(
+								"compositeDir" + "/applicationDir/b.jar/b/B.class"))
 				.binary("applicationDir.esa/featureDir.esa/OSGI-INF/SUBSYSTEM.MF",
 						SubsystemTest.class.getClassLoader().getResourceAsStream(
-								"compositeDir" + "/applicationDir/featureDir/OSGI-INF/SUBSYSTEM.MF"));
+								"compositeDir" + "/applicationDir/featureDir/OSGI-INF/SUBSYSTEM.MF"))
+				.binary("applicationDir.esa/featureDir.esa/a.jar/META-INF/MANIFEST.MF", 
+						SubsystemTest.class.getClassLoader().getResourceAsStream(
+								"compositeDir" + "/applicationDir/featureDir/a.jar/META-INF/MANIFEST.MF"))
+				.binary("applicationDir.esa/featureDir.esa/a.jar/a/A.class", 
+						SubsystemTest.class.getClassLoader().getResourceAsStream(
+								"compositeDir" + "/applicationDir/featureDir/a.jar/a/A.class"))
+				.binary("applicationDir.esa/featureDir.esa/b.jar/META-INF/MANIFEST.MF", 
+						SubsystemTest.class.getClassLoader().getResourceAsStream(
+								"compositeDir" + "/applicationDir/featureDir/b.jar/META-INF/MANIFEST.MF"))
+				.binary("applicationDir.esa/featureDir.esa/b.jar/b/B.class", 
+						SubsystemTest.class.getClassLoader().getResourceAsStream(
+								"compositeDir" + "/applicationDir/featureDir/b.jar/b/B.class"));
 		feature.end();
 		FileOutputStream fos = new FileOutputStream("compositeDir" + ".esa");
 		try {
@@ -66,7 +90,6 @@ public class InstallTest extends Subsyst
 		} finally {
 			Utils.closeQuietly(fos);
 		}
-		
 		createApplication("feature3", new String[]{"tb3.jar"});
 		createApplication("feature2", new String[]{"tb3.jar", "tb2.jar"});
 		createdApplications = true;
@@ -95,7 +118,8 @@ public class InstallTest extends Subsyst
 	
 	/*
      * Install a subsystem using a location string and a null input stream. The
-     * location string is a file URL pointing to a directory.
+     * location string is a file URL pointing to a subsystem directory 
+     * containing nested subsystem and bundle directories.
      */
     @Test
     public void testLocationAsDirectoryUrl() throws Exception {
@@ -103,16 +127,46 @@ public class InstallTest extends Subsyst
     	try {
     		Subsystem subsystem = installSubsystem(getRootSubsystem(), file.toURI().toString(),
null);
     		try {
-    			assertSymbolicName("org.apache.aries.subsystem.itests.composite.dir", subsystem);
+    			assertSymbolicName("org.apache.aries.subsystem.itests.composite.dir", subsystem);

+    			assertConstituents(3, subsystem);
+    			assertConstituent(subsystem, "org.apache.aries.subsystem.itests.composite.dir.bundle.a");
+    			Bundle b = getConstituentAsBundle(
+    					subsystem, 
+    					"org.apache.aries.subsystem.itests.composite.dir.bundle.a", 
+    					null, null);
+    			assertLocation(subsystem.getLocation() + "!/" + "a.jar", b.getLocation());
+    			assertClassLoadable("a.A", b);
     			assertChildren(1, subsystem);
     			Subsystem child = subsystem.getChildren().iterator().next();
     			assertSymbolicName(
     					"org.apache.aries.subsystem.itests.application.dir",
     					child);
+    			assertConstituent(child, "org.apache.aries.subsystem.itests.composite.dir.bundle.b");
+    			b = getConstituentAsBundle(
+    					child, 
+    					"org.apache.aries.subsystem.itests.composite.dir.bundle.b", 
+    					null, null);
+    			assertLocation(child.getLocation() + "!/" + "b.jar", b.getLocation());
+    			assertClassLoadable("b.B", b);
     			assertChildren(1, child);
+    			child = child.getChildren().iterator().next();
     			assertSymbolicName(
     					"org.apache.aries.subsystem.itests.feature.dir",
-    					child.getChildren().iterator().next());
+    					child);
+    			assertConstituent(subsystem, "org.apache.aries.subsystem.itests.composite.dir.bundle.a");
+    			b = getConstituentAsBundle(
+    					child, 
+    					"org.apache.aries.subsystem.itests.composite.dir.bundle.a", 
+    					null, null);
+    			assertLocation(child.getLocation() + "!/" + "a.jar", b.getLocation());
+    			assertClassLoadable("a.A", b);
+    			assertConstituent(child, "org.apache.aries.subsystem.itests.composite.dir.bundle.b",
Version.parseVersion("1"));
+    			b = getConstituentAsBundle(
+    					child, 
+    					"org.apache.aries.subsystem.itests.composite.dir.bundle.b", 
+    					Version.parseVersion("1"), null);
+    			assertLocation(child.getLocation() + "!/" + "b.jar", b.getLocation());
+    			assertClassLoadable("b.B", b);
     		}
     		finally {
     			uninstallSubsystemSilently(subsystem);

Modified: aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/SubsystemTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/SubsystemTest.java?rev=1403783&r1=1403782&r2=1403783&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/SubsystemTest.java
(original)
+++ aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/SubsystemTest.java
Tue Oct 30 17:12:27 2012
@@ -50,6 +50,7 @@ import org.apache.aries.unittest.fixture
 import org.apache.aries.unittest.fixture.ArchiveFixture.JarFixture;
 import org.apache.aries.unittest.fixture.ArchiveFixture.ManifestFixture;
 import org.apache.aries.unittest.fixture.ArchiveFixture.ZipFixture;
+import org.apache.aries.util.filesystem.FileSystem;
 import org.eclipse.equinox.region.Region;
 import org.eclipse.equinox.region.RegionDigraph;
 import org.ops4j.pax.exam.Option;
@@ -259,6 +260,16 @@ public abstract class SubsystemTest exte
 		assertTrue("Parent did not contain all children", parent.getChildren().containsAll(children));
 	}
 	
+	protected void assertClassLoadable(String clazz, Bundle bundle) {
+		try {
+			bundle.loadClass(clazz);
+		}
+		catch (Exception e) {
+			e.printStackTrace();
+			fail("Class " + clazz + " from bundle " + bundle + " should be loadable");
+		}
+	}
+	
 	protected void assertConstituent(Subsystem subsystem, String symbolicName) {
 		assertConstituent(subsystem, symbolicName, Version.emptyVersion);
 	}
@@ -517,7 +528,7 @@ public abstract class SubsystemTest exte
 	}
 	
 	protected RepositoryContent createBundleRepositoryContent(File file) throws Exception {
-		return new BundleResource(file.toURI().toURL());
+		return new BundleResource(FileSystem.getFSRoot(file));
 	}
 	
 	protected static void createManifest(String name, Map<String, String> headers) throws
IOException {

Modified: aries/trunk/subsystem/subsystem-itests/src/test/resources/compositeDir/OSGI-INF/SUBSYSTEM.MF
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/src/test/resources/compositeDir/OSGI-INF/SUBSYSTEM.MF?rev=1403783&r1=1403782&r2=1403783&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-itests/src/test/resources/compositeDir/OSGI-INF/SUBSYSTEM.MF
(original)
+++ aries/trunk/subsystem/subsystem-itests/src/test/resources/compositeDir/OSGI-INF/SUBSYSTEM.MF
Tue Oct 30 17:12:27 2012
@@ -1,3 +1,5 @@
 Subsystem-SymbolicName: org.apache.aries.subsystem.itests.composite.dir
 Subsystem-Type: org.osgi.subsystem.composite
-Subsystem-Content: org.apache.aries.subsystem.itests.application.dir;version="[0,0]";type=osgi.subsystem.application
+Subsystem-Content: 
+ org.apache.aries.subsystem.itests.application.dir;version="[0,0]";type=osgi.subsystem.application,
+ org.apache.aries.subsystem.itests.composite.dir.bundle.a;version="[0,0]"

Added: aries/trunk/subsystem/subsystem-itests/src/test/resources/compositeDir/a.jar/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/src/test/resources/compositeDir/a.jar/META-INF/MANIFEST.MF?rev=1403783&view=auto
==============================================================================
--- aries/trunk/subsystem/subsystem-itests/src/test/resources/compositeDir/a.jar/META-INF/MANIFEST.MF
(added)
+++ aries/trunk/subsystem/subsystem-itests/src/test/resources/compositeDir/a.jar/META-INF/MANIFEST.MF
Tue Oct 30 17:12:27 2012
@@ -0,0 +1,4 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: org.apache.aries.subsystem.itests.composite.dir.bundle.a
+Export-Package: a

Added: aries/trunk/subsystem/subsystem-itests/src/test/resources/compositeDir/a.jar/a/A.class
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/src/test/resources/compositeDir/a.jar/a/A.class?rev=1403783&view=auto
==============================================================================
Files aries/trunk/subsystem/subsystem-itests/src/test/resources/compositeDir/a.jar/a/A.class
(added) and aries/trunk/subsystem/subsystem-itests/src/test/resources/compositeDir/a.jar/a/A.class
Tue Oct 30 17:12:27 2012 differ

Added: aries/trunk/subsystem/subsystem-itests/src/test/resources/compositeDir/applicationDir/b.jar/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/src/test/resources/compositeDir/applicationDir/b.jar/META-INF/MANIFEST.MF?rev=1403783&view=auto
==============================================================================
--- aries/trunk/subsystem/subsystem-itests/src/test/resources/compositeDir/applicationDir/b.jar/META-INF/MANIFEST.MF
(added)
+++ aries/trunk/subsystem/subsystem-itests/src/test/resources/compositeDir/applicationDir/b.jar/META-INF/MANIFEST.MF
Tue Oct 30 17:12:27 2012
@@ -0,0 +1,4 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: org.apache.aries.subsystem.itests.composite.dir.bundle.b
+Export-Package: b

Added: aries/trunk/subsystem/subsystem-itests/src/test/resources/compositeDir/applicationDir/b.jar/b/B.class
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/src/test/resources/compositeDir/applicationDir/b.jar/b/B.class?rev=1403783&view=auto
==============================================================================
Files aries/trunk/subsystem/subsystem-itests/src/test/resources/compositeDir/applicationDir/b.jar/b/B.class
(added) and aries/trunk/subsystem/subsystem-itests/src/test/resources/compositeDir/applicationDir/b.jar/b/B.class
Tue Oct 30 17:12:27 2012 differ

Added: aries/trunk/subsystem/subsystem-itests/src/test/resources/compositeDir/applicationDir/featureDir/a.jar/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/src/test/resources/compositeDir/applicationDir/featureDir/a.jar/META-INF/MANIFEST.MF?rev=1403783&view=auto
==============================================================================
--- aries/trunk/subsystem/subsystem-itests/src/test/resources/compositeDir/applicationDir/featureDir/a.jar/META-INF/MANIFEST.MF
(added)
+++ aries/trunk/subsystem/subsystem-itests/src/test/resources/compositeDir/applicationDir/featureDir/a.jar/META-INF/MANIFEST.MF
Tue Oct 30 17:12:27 2012
@@ -0,0 +1,4 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: org.apache.aries.subsystem.itests.composite.dir.bundle.a
+Export-Package: a

Added: aries/trunk/subsystem/subsystem-itests/src/test/resources/compositeDir/applicationDir/featureDir/a.jar/a/A.class
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/src/test/resources/compositeDir/applicationDir/featureDir/a.jar/a/A.class?rev=1403783&view=auto
==============================================================================
Files aries/trunk/subsystem/subsystem-itests/src/test/resources/compositeDir/applicationDir/featureDir/a.jar/a/A.class
(added) and aries/trunk/subsystem/subsystem-itests/src/test/resources/compositeDir/applicationDir/featureDir/a.jar/a/A.class
Tue Oct 30 17:12:27 2012 differ

Added: aries/trunk/subsystem/subsystem-itests/src/test/resources/compositeDir/applicationDir/featureDir/b.jar/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/src/test/resources/compositeDir/applicationDir/featureDir/b.jar/META-INF/MANIFEST.MF?rev=1403783&view=auto
==============================================================================
--- aries/trunk/subsystem/subsystem-itests/src/test/resources/compositeDir/applicationDir/featureDir/b.jar/META-INF/MANIFEST.MF
(added)
+++ aries/trunk/subsystem/subsystem-itests/src/test/resources/compositeDir/applicationDir/featureDir/b.jar/META-INF/MANIFEST.MF
Tue Oct 30 17:12:27 2012
@@ -0,0 +1,5 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: org.apache.aries.subsystem.itests.composite.dir.bundle.b
+Bundle-Version: 1.0
+Export-Package: b

Added: aries/trunk/subsystem/subsystem-itests/src/test/resources/compositeDir/applicationDir/featureDir/b.jar/b/B.class
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/src/test/resources/compositeDir/applicationDir/featureDir/b.jar/b/B.class?rev=1403783&view=auto
==============================================================================
Files aries/trunk/subsystem/subsystem-itests/src/test/resources/compositeDir/applicationDir/featureDir/b.jar/b/B.class
(added) and aries/trunk/subsystem/subsystem-itests/src/test/resources/compositeDir/applicationDir/featureDir/b.jar/b/B.class
Tue Oct 30 17:12:27 2012 differ



Mime
View raw message