Author: thomas.diesler(a)jboss.com
Date: 2010-03-26 00:33:32 -0400 (Fri, 26 Mar 2010)
New Revision: 103003
Modified:
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/OSGiFrameworkTest.java
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/OSGiTest.java
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/OSGiTestHelper.java
Log:
Expose shrinkwrap archives to test cases
Modified:
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/OSGiFrameworkTest.java
===================================================================
---
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/OSGiFrameworkTest.java 2010-03-26
04:11:33 UTC (rev 103002)
+++
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/OSGiFrameworkTest.java 2010-03-26
04:33:32 UTC (rev 103003)
@@ -30,6 +30,7 @@
import static org.junit.Assert.fail;
import java.io.IOException;
+import java.io.InputStream;
import java.net.URL;
import java.util.Arrays;
import java.util.HashSet;
@@ -105,24 +106,30 @@
return (PackageAdmin)systemContext.getService(sref);
}
- protected Bundle installBundle(String location) throws BundleException, IOException
- {
- URL bundleURL = getTestHelper().getTestArchiveURL(location);
- return installBundle(AbstractVFS.getRoot(bundleURL));
- }
-
protected Bundle installBundle(Archive<?> archive) throws BundleException,
IOException
{
VirtualFile virtualFile = OSGiTestHelper.toVirtualFile(archive);
- return installBundle(virtualFile);
+ return installBundle(archive.getName(), virtualFile.openStream());
}
protected Bundle installBundle(VirtualFile virtualFile) throws BundleException,
IOException
{
String location = virtualFile.getPathName();
- return systemContext.installBundle(location, virtualFile.openStream());
+ return installBundle(location, virtualFile.openStream());
}
+ protected Bundle installBundle(String location) throws BundleException, IOException
+ {
+ URL bundleURL = getTestHelper().getTestArchiveURL(location);
+ VirtualFile virtualFile = AbstractVFS.getRoot(bundleURL);
+ return installBundle(location, virtualFile.openStream());
+ }
+
+ protected Bundle installBundle(String location, InputStream inputStream) throws
BundleException
+ {
+ return systemContext.installBundle(location, inputStream);
+ }
+
protected void assertLoadClass(Bundle bundle, String className, Bundle exporter)
{
Class<?> clazz = assertLoadClass(bundle, className);
Modified:
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/OSGiTest.java
===================================================================
---
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/OSGiTest.java 2010-03-26
04:11:33 UTC (rev 103002)
+++
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/OSGiTest.java 2010-03-26
04:33:32 UTC (rev 103003)
@@ -22,6 +22,8 @@
package org.jboss.osgi.testing;
import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
import java.net.URL;
import javax.naming.InitialContext;
@@ -29,6 +31,7 @@
import org.jboss.logging.Logger;
import org.jboss.osgi.vfs.VirtualFile;
+import org.jboss.shrinkwrap.api.Archive;
import org.junit.After;
import org.junit.Before;
import org.osgi.framework.Bundle;
@@ -173,15 +176,20 @@
/**
* Delegates to {@link OSGiTestHelper#assembleArchive(String, String, Class...)}
*/
- public VirtualFile assembleArchive(String name, String resource, Class<?>...
packages) throws Exception
+ public Archive<?> assembleArchive(String name, String resource,
Class<?>... packages) throws Exception
{
return getTestHelper().assembleArchive(name, resource, packages);
}
+ public VirtualFile toVirtualFile(Archive<?> archive) throws IOException,
MalformedURLException
+ {
+ return OSGiTestHelper.toVirtualFile(archive);
+ }
+
/**
* Delegates to {@link OSGiTestHelper#assembleArchive(String, String[], Class...)}
*/
- public VirtualFile assembleArchive(String name, String[] resources, Class<?>...
packages) throws Exception
+ public Archive<?> assembleArchive(String name, String[] resources,
Class<?>... packages) throws Exception
{
return getTestHelper().assembleArchive(name, resources, packages);
}
Modified:
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/OSGiTestHelper.java
===================================================================
---
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/OSGiTestHelper.java 2010-03-26
04:11:33 UTC (rev 103002)
+++
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/OSGiTestHelper.java 2010-03-26
04:33:32 UTC (rev 103003)
@@ -172,12 +172,12 @@
return framework;
}
- public VirtualFile assembleArchive(String name, String resource, Class<?>...
packages) throws Exception
+ public Archive<?> assembleArchive(String name, String resource,
Class<?>... packages) throws Exception
{
return assembleArchive(name, new String[] { resource }, packages);
}
- public VirtualFile assembleArchive(String name, String[] resources, Class<?>...
packages) throws IOException
+ public Archive<?> assembleArchive(String name, String[] resources,
Class<?>... packages) throws IOException
{
JavaArchive archive = Archives.create(name + ".jar", JavaArchive.class);
if (resources != null)
@@ -213,17 +213,14 @@
addResources(archive, base, classes);
}
}
-
- // Convert archive to file URL
- VirtualFile virtualFile = toVirtualFile(archive);
- return virtualFile;
+ return archive;
}
@SuppressWarnings("rawtypes")
public static VirtualFile toVirtualFile(Archive archive) throws IOException,
MalformedURLException
{
ZipExporter exporter = archive.as(ZipExporter.class);
- File target = File.createTempFile("archive_", ".jar");
+ File target = File.createTempFile("osgi-bundle_", ".jar");
exporter.exportZip(target, true);
target.deleteOnExit();
return AbstractVFS.getRoot(target.toURI().toURL());