You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by cs...@apache.org on 2014/05/30 10:59:14 UTC

svn commit: r1598506 [2/2] - in /aries/trunk/subsystem: subsystem-core/ subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/ subsystem-itests/ subsystem-itests/src/test/java/org/apache/aries/subsystem/ctt/itests/ subsystem-itests/src/...

Modified: aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/NoRequirementFilterTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/NoRequirementFilterTest.java?rev=1598506&r1=1598505&r2=1598506&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/NoRequirementFilterTest.java (original)
+++ aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/NoRequirementFilterTest.java Fri May 30 08:59:13 2014
@@ -17,10 +17,7 @@ import java.io.IOException;
 import java.util.HashMap;
 import java.util.Map;
 
-import org.junit.Before;
 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.Constants;
 import org.osgi.service.subsystem.Subsystem;
@@ -32,7 +29,6 @@ import org.osgi.service.subsystem.Subsys
  * 
  * Generic capabilities are not required to use the namespace as an attribute.
  */
-@RunWith(MavenConfiguredJUnit4TestRunner.class)
 public class NoRequirementFilterTest extends SubsystemTest {
 	/*
 	 * Subsystem-SymbolicName: application.a.esa
@@ -62,27 +58,19 @@ public class NoRequirementFilterTest ext
 		createManifest(APPLICATION_A + ".mf", attributes);
 	}
 	
-	private static void createBundleA() throws IOException {
-		Map<String, String> headers = new HashMap<String, String>();
-		headers.put(Constants.REQUIRE_CAPABILITY, "y");
-		createBundle(BUNDLE_A, headers);
-	}
-	
-	private static void createBundleB() throws IOException {
-		Map<String, String> headers = new HashMap<String, String>();
-		headers.put(Constants.PROVIDE_CAPABILITY, "y");
-		createBundle(BUNDLE_B, headers);
-	}
-	
-	private static boolean createdTestFiles;
-	@Before
-	public static void createTestFiles() throws Exception {
-		if (createdTestFiles)
-			return;
+	private void createBundleA() throws IOException {
+		createBundle(name(BUNDLE_A), new Header(Constants.REQUIRE_CAPABILITY, "y"));
+	}
+	
+	private void createBundleB() throws IOException {
+		createBundle(name(BUNDLE_B), new Header(Constants.PROVIDE_CAPABILITY, "y"));
+	}
+	
+	@Override
+	protected void createApplications() throws Exception {
 		createBundleA();
 		createBundleB();
 		createApplicationA();
-		createdTestFiles = true;
 	}
 	
 	public void setUp() throws Exception {

Modified: aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/OptionalDependenciesTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/OptionalDependenciesTest.java?rev=1598506&r1=1598505&r2=1598506&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/OptionalDependenciesTest.java (original)
+++ aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/OptionalDependenciesTest.java Fri May 30 08:59:13 2014
@@ -19,15 +19,11 @@ import java.io.IOException;
 import java.util.HashMap;
 import java.util.Map;
 
-import org.junit.Before;
 import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.junit.MavenConfiguredJUnit4TestRunner;
 import org.osgi.framework.Constants;
 import org.osgi.service.subsystem.Subsystem;
 import org.osgi.service.subsystem.SubsystemConstants;
 
-@RunWith(MavenConfiguredJUnit4TestRunner.class)
 public class OptionalDependenciesTest extends SubsystemTest {
 	/*
 	 * Subsystem-SymbolicName: application.a.esa
@@ -54,22 +50,16 @@ public class OptionalDependenciesTest ex
 		createManifest(APPLICATION_A + ".mf", attributes);
 	}
 	
-	private static void createBundleA() throws IOException {
-		Map<String, String> headers = new HashMap<String, String>();
-		headers.put(Constants.IMPORT_PACKAGE, "x;resolution:=optional");
-		headers.put(Constants.REQUIRE_BUNDLE, "x;resolution:=optional");
-		headers.put(Constants.REQUIRE_CAPABILITY, "x;resolution:=optional");
-		createBundle(BUNDLE_A, headers);
+	private void createBundleA() throws IOException {
+		createBundle(name(BUNDLE_A), importPackage("x;resolution:=optional"), 
+				requireBundle("x;resolution:=optional"),
+				new Header(Constants.REQUIRE_CAPABILITY, "x;resolution:=optional"));
 	}
 	
-	private static boolean createdTestFiles;
-	@Before
-	public static void createTestFiles() throws Exception {
-		if (createdTestFiles)
-			return;
+	@Override
+	public void createApplications() throws Exception {
 		createBundleA();
 		createApplicationA();
-		createdTestFiles = true;
 	}
 	
 	@Test

Modified: aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/ProvisionPolicyTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/ProvisionPolicyTest.java?rev=1598506&r1=1598505&r2=1598506&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/ProvisionPolicyTest.java (original)
+++ aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/ProvisionPolicyTest.java Fri May 30 08:59:13 2014
@@ -20,16 +20,12 @@ import java.io.IOException;
 import java.util.HashMap;
 import java.util.Map;
 
-import org.junit.Before;
 import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.junit.MavenConfiguredJUnit4TestRunner;
 import org.osgi.framework.Constants;
 import org.osgi.service.subsystem.Subsystem;
 import org.osgi.service.subsystem.SubsystemConstants;
 import org.osgi.service.subsystem.SubsystemException;
 
-@RunWith(MavenConfiguredJUnit4TestRunner.class)
 public class ProvisionPolicyTest extends SubsystemTest {
 	/*
 	 * Subsystem-SymbolicName: application.a.esa
@@ -82,24 +78,20 @@ public class ProvisionPolicyTest extends
 		createManifest(APPLICATION_A + ".mf", attributes);
 	}
 	
-	private static void createBundleA() throws IOException {
-		Map<String, String> headers = new HashMap<String, String>();
-		headers.put(Constants.IMPORT_PACKAGE, "x");
-		createBundle(BUNDLE_A, headers);
+	private void createBundleA() throws IOException {
+		createBundle(name(BUNDLE_A), importPackage("x"));
 	}
 	
-	private static void createBundleB() throws IOException {
-		Map<String, String> headers = new HashMap<String, String>();
-		headers.put(Constants.EXPORT_PACKAGE, "x");
-		createBundle(BUNDLE_B, headers);
+	private void createBundleB() throws IOException {
+		createBundle(name(BUNDLE_B), exportPackage("x"));
 	}
 	
-	private static void createCompositeA() throws IOException {
+	private void createCompositeA() throws IOException {
 		createCompositeAManifest();
 		createSubsystem(COMPOSITE_A);
 	}
 	
-	private static void createCompositeAManifest() throws IOException {
+	private void createCompositeAManifest() throws IOException {
 		Map<String, String> attributes = new HashMap<String, String>();
 		attributes.put(SubsystemConstants.SUBSYSTEM_SYMBOLICNAME, COMPOSITE_A);
 		attributes.put(SubsystemConstants.SUBSYSTEM_TYPE, SubsystemConstants.SUBSYSTEM_TYPE_COMPOSITE);
@@ -107,12 +99,12 @@ public class ProvisionPolicyTest extends
 		createManifest(COMPOSITE_A + ".mf", attributes);
 	}
 	
-	private static void createFeatureA() throws IOException {
+	private void createFeatureA() throws IOException {
 		createFeatureAManifest();
 		createSubsystem(FEATURE_A);
 	}
 	
-	private static void createFeatureAManifest() throws IOException {
+	private void createFeatureAManifest() throws IOException {
 		Map<String, String> attributes = new HashMap<String, String>();
 		attributes.put(SubsystemConstants.SUBSYSTEM_SYMBOLICNAME, FEATURE_A);
 		attributes
@@ -138,18 +130,14 @@ public class ProvisionPolicyTest extends
 		createManifest(FEATURE_B + ".mf", attributes);
 	}
 	
-	private static boolean createdTestFiles;
-	@Before
-	public static void createTestFiles() throws Exception {
-		if (createdTestFiles)
-			return;
+	@Override
+	public void createApplications() throws Exception {
 		createBundleA();
 		createBundleB();
 		createApplicationA();
 		createCompositeA();
 		createFeatureA();
 		createFeatureB();
-		createdTestFiles = true;
 	}
 	
 	public void setUp() throws Exception {

Modified: aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/ResolutionTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/ResolutionTest.java?rev=1598506&r1=1598505&r2=1598506&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/ResolutionTest.java (original)
+++ aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/ResolutionTest.java Fri May 30 08:59:13 2014
@@ -30,8 +30,6 @@ import org.apache.aries.subsystem.core.a
 import org.apache.aries.subsystem.core.archive.RequireCapabilityHeader;
 import org.junit.Before;
 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.Constants;
 import org.osgi.service.resolver.ResolutionException;
@@ -42,7 +40,6 @@ import org.osgi.service.subsystem.Subsys
 /*
  * Contains a series of tests related to resolution.
  */
-@RunWith(MavenConfiguredJUnit4TestRunner.class)
 public class ResolutionTest extends SubsystemTest {
 	/*
 	 * Subsystem-SymbolicName: application.a.esa
@@ -87,7 +84,7 @@ public class ResolutionTest extends Subs
 	private static final String BUNDLE_E = "bundle.e.jar";
 	
 	@Before
-	public static void createApplications() throws Exception {
+	public void createApplications() throws Exception {
 		if (createdApplications) {
 			return;
 		};
@@ -135,37 +132,28 @@ public class ResolutionTest extends Subs
 		createManifest(APPLICATION_C + ".mf", attributes);
 	}
 	
-	private static void createBundleA() throws IOException {
-		Map<String, String> headers = new HashMap<String, String>();
-		headers.put(Constants.REQUIRE_CAPABILITY, "a");
-		createBundle(BUNDLE_A, headers);
-	}
-	
-	private static void createBundleB() throws IOException {
-		Map<String, String> headers = new HashMap<String, String>();
-		headers.put(Constants.PROVIDE_CAPABILITY, "a");
-		headers.put(Constants.REQUIRE_CAPABILITY, "b");
-		createBundle(BUNDLE_B, headers);
-	}
-	
-	private static void createBundleC() throws IOException {
-		Map<String, String> headers = new HashMap<String, String>();
-		headers.put(Constants.PROVIDE_CAPABILITY, "b");
-		createBundle(BUNDLE_C, headers);
+	private void createBundleA() throws IOException {
+		createBundle(name(BUNDLE_A), new Header(Constants.REQUIRE_CAPABILITY, "a"));
+	}
+	
+	private void createBundleB() throws IOException {
+		createBundle(name(BUNDLE_B), 
+				provideCapability("a"),
+				requireCapability("b"));
+	}
+	
+	private void createBundleC() throws IOException {
+		createBundle(name(BUNDLE_C), provideCapability("b"));
 	}
 	
 	@SuppressWarnings("deprecation")
-	private static void createBundleD() throws IOException {
-		Map<String, String> headers = new HashMap<String, String>();
-		headers.put(Constants.BUNDLE_REQUIREDEXECUTIONENVIRONMENT, "JavaSE-100.100");
-		createBundle(BUNDLE_D, headers);
+	private void createBundleD() throws IOException {
+		createBundle(name(BUNDLE_D), new Header(Constants.BUNDLE_REQUIREDEXECUTIONENVIRONMENT, "JavaSE-100.100"));
 	}
 	
 	@SuppressWarnings("deprecation")
-	private static void createBundleE() throws IOException {
-		Map<String, String> headers = new HashMap<String, String>();
-		headers.put(Constants.BUNDLE_REQUIREDEXECUTIONENVIRONMENT, "J2SE-1.4, J2SE-1.5,		J2SE-1.6,JavaSE-1.7");
-		createBundle(BUNDLE_E, headers);
+	private void createBundleE() throws IOException {
+		createBundle(name(BUNDLE_E), new Header(Constants.BUNDLE_REQUIREDEXECUTIONENVIRONMENT, "J2SE-1.4, J2SE-1.5,		J2SE-1.6,JavaSE-1.7"));
 	}
 	
 	/*
@@ -214,7 +202,7 @@ public class ResolutionTest extends Subs
 			}
 		}
 		catch (SubsystemException e) {
-			fail("Application A should have installed");
+			fail("Application A should have installed." + e.getMessage());
 		}
 		finally {
 			uninstallSilently(bundleC);

Modified: aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/RootSubsystemTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/RootSubsystemTest.java?rev=1598506&r1=1598505&r2=1598506&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/RootSubsystemTest.java (original)
+++ aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/RootSubsystemTest.java Fri May 30 08:59:13 2014
@@ -24,19 +24,14 @@ import java.util.Map;
 import org.eclipse.equinox.region.Region;
 import org.eclipse.equinox.region.RegionDigraph;
 import org.eclipse.equinox.region.RegionFilter;
-import org.junit.Before;
 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.BundleException;
-import org.osgi.framework.Constants;
 import org.osgi.framework.ServiceEvent;
 import org.osgi.framework.Version;
 import org.osgi.service.subsystem.Subsystem;
 import org.osgi.service.subsystem.SubsystemConstants;
 
-@RunWith(MavenConfiguredJUnit4TestRunner.class)
 public class RootSubsystemTest extends SubsystemTest {
 	/*
 	 * Subsystem-SymbolicName: application.a.esa
@@ -49,14 +44,10 @@ public class RootSubsystemTest extends S
 	 */
 	private static final String BUNDLE_A = "bundle.a.jar";
 	
-	private static boolean createdTestFiles;
-	@Before
-	public static void createTestFiles() throws Exception {
-		if (createdTestFiles)
-			return;
+	@Override
+	public void createApplications() throws Exception {
 		createBundleA();
 		createApplicationA();
-		createdTestFiles = true;
 	}
 	
 	private static void createApplicationA() throws IOException {
@@ -70,10 +61,8 @@ public class RootSubsystemTest extends S
 		createManifest(APPLICATION_A + ".mf", attributes);
 	}
 	
-	private static void createBundleA() throws IOException {
-		Map<String, String> headers = new HashMap<String, String>();
-		headers.put(Constants.IMPORT_PACKAGE, "org.osgi.framework");
-		createBundle(BUNDLE_A, headers);
+	private void createBundleA() throws IOException {
+		createBundle(name(BUNDLE_A), importPackage("org.osgi.framework"));
 	}
 	
 	// TODO Test root subsystem headers.
@@ -83,7 +72,7 @@ public class RootSubsystemTest extends S
 		bundleContext.installBundle(new File(BUNDLE_A).toURI().toURL().toString());
 		getSubsystemCoreBundle().stop();
 		getSubsystemCoreBundle().start();
-		Bundle bundleA = findBundleBySymbolicName(BUNDLE_A);
+		Bundle bundleA = context().getBundleByName(BUNDLE_A);
 		assertEquals("Extraneous root region bundle should not be started", Bundle.INSTALLED, bundleA.getState());
 	}
 	
@@ -177,7 +166,7 @@ public class RootSubsystemTest extends S
 	 */
 	@Test
 	public void testRegion() throws Exception {
-		RegionDigraph digraph = getOsgiService(RegionDigraph.class);
+		RegionDigraph digraph = context().getService(RegionDigraph.class);
 		Bundle core = getSubsystemCoreBundle();
 		Region kernel = digraph.getRegion(core);
 		Subsystem root = getRootSubsystem();

Modified: aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/ServiceDependencyTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/ServiceDependencyTest.java?rev=1598506&r1=1598505&r2=1598506&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/ServiceDependencyTest.java (original)
+++ aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/ServiceDependencyTest.java Fri May 30 08:59:13 2014
@@ -23,21 +23,16 @@ import java.util.List;
 import java.util.Map;
 
 import org.apache.aries.subsystem.itests.util.GenericMetadataWrapper;
-import org.apache.aries.unittest.fixture.ArchiveFixture;
 import org.apache.aries.util.manifest.ManifestHeaderProcessor;
 import org.apache.aries.util.manifest.ManifestHeaderProcessor.GenericMetadata;
 import org.junit.Assert;
-import org.junit.Before;
 import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.junit.MavenConfiguredJUnit4TestRunner;
 import org.osgi.framework.InvalidSyntaxException;
 import org.osgi.framework.Version;
 import org.osgi.service.subsystem.Subsystem;
 import org.osgi.service.subsystem.SubsystemConstants;
 import org.osgi.service.subsystem.SubsystemException;
 
-@RunWith(MavenConfiguredJUnit4TestRunner.class)
 public class ServiceDependencyTest extends SubsystemTest {
 	/*
 	 * Subsystem-SymbolicName: application.a.esa
@@ -147,15 +142,10 @@ public class ServiceDependencyTest exten
 		createManifest(symbolicName + ".mf", attributes);
 	}
 	
-	private static void createBundle(String symbolicName, String blueprintXml)
-			throws IOException {
-		write(symbolicName,
-				ArchiveFixture.newJar().manifest().symbolicName(symbolicName)
-						.end().file("OSGI-INF/blueprint/blueprint.xml", blueprintXml));
-	}
+
 	
 	private static void createBundleA() throws IOException {
-		createBundle(
+		createBlueprintBundle(
 				BUNDLE_A, 
 				new StringBuilder()
 					.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>")
@@ -173,7 +163,7 @@ public class ServiceDependencyTest exten
 	}
 	
 	private static void createBundleB() throws IOException {
-		createBundle(
+		createBlueprintBundle(
 				BUNDLE_B, 
 				new StringBuilder()
 					.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>")
@@ -214,11 +204,8 @@ public class ServiceDependencyTest exten
 		createManifest(COMPOSITE_A + ".mf", attributes);
 	}
 	
-	private static boolean createdTestFiles;
-	@Before
-	public static void createTestFiles() throws Exception {
-		if (createdTestFiles)
-			return;
+	@Override
+	public void createApplications() throws Exception {
 		createBundleA();
 		createBundleB();
 		createApplicationA();
@@ -226,7 +213,6 @@ public class ServiceDependencyTest exten
 		createApplicationC();
 		createCompositeA();
 		createApplicationD();
-		createdTestFiles = true;
 	}
 	
 	//@Test

Modified: aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/SharedResourceTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/SharedResourceTest.java?rev=1598506&r1=1598505&r2=1598506&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/SharedResourceTest.java (original)
+++ aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/SharedResourceTest.java Fri May 30 08:59:13 2014
@@ -17,17 +17,11 @@ import java.io.IOException;
 import java.util.HashMap;
 import java.util.Map;
 
-import org.junit.Before;
 import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.junit.MavenConfiguredJUnit4TestRunner;
 import org.osgi.framework.Bundle;
 import org.osgi.service.subsystem.Subsystem;
 import org.osgi.service.subsystem.SubsystemConstants;
 
-import aQute.lib.osgi.Constants;
-
-@RunWith(MavenConfiguredJUnit4TestRunner.class)
 public class SharedResourceTest extends SubsystemTest {
 	/*
 	 * Subsystem-SymbolicName: application.a.esa
@@ -80,35 +74,25 @@ public class SharedResourceTest extends 
 		createManifest(APPLICATION_B + ".mf", attributes);
 	}
 	
-	private static void createBundleA() throws IOException {
-		Map<String, String> headers = new HashMap<String, String>();
-		headers.put(Constants.IMPORT_PACKAGE, "x");
-		createBundle(BUNDLE_A, headers);
+	private void createBundleA() throws IOException {
+		createBundle(name(BUNDLE_A), importPackage("x"));
 	}
 	
-	private static void createBundleB() throws IOException {
-		Map<String, String> headers = new HashMap<String, String>();
-		headers.put(Constants.IMPORT_PACKAGE, "x");
-		createBundle(BUNDLE_B, headers);
+	private void createBundleB() throws IOException {
+		createBundle(name(BUNDLE_B), importPackage("x"));
 	}
 	
-	private static void createBundleC() throws IOException {
-		Map<String, String> headers = new HashMap<String, String>();
-		headers.put(Constants.EXPORT_PACKAGE, "x");
-		createBundle(BUNDLE_C, headers);
+	private void createBundleC() throws IOException {
+		createBundle(name(BUNDLE_C), exportPackage("x"));
 	}
 	
-	private static boolean createdTestFiles;
-	@Before
-	public static void createTestFiles() throws Exception {
-		if (createdTestFiles)
-			return;
+	@Override
+	public void createApplications() throws Exception {
 		createBundleA();
 		createBundleB();
 		createBundleC();
 		createApplicationA();
 		createApplicationB();
-		createdTestFiles = true;
 	}
 	
 	public void setUp() throws Exception {

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=1598506&r1=1598505&r2=1598506&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 Fri May 30 08:59:13 2014
@@ -19,8 +19,13 @@ import static org.junit.Assert.assertNot
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
-import static org.ops4j.pax.exam.CoreOptions.equinox;
+import static org.ops4j.pax.exam.CoreOptions.composite;
+import static org.ops4j.pax.exam.CoreOptions.junitBundles;
+import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
+import static org.ops4j.pax.exam.CoreOptions.streamBundle;
 import static org.ops4j.pax.exam.CoreOptions.systemProperty;
+import static org.ops4j.pax.exam.CoreOptions.vmOption;
+import static org.ops4j.pax.exam.CoreOptions.when;
 
 import java.io.File;
 import java.io.FileInputStream;
@@ -39,6 +44,8 @@ import java.util.Map;
 import java.util.Map.Entry;
 import java.util.concurrent.atomic.AtomicBoolean;
 
+import org.apache.aries.itest.AbstractIntegrationTest;
+import org.apache.aries.itest.RichBundleContext;
 import org.apache.aries.subsystem.AriesSubsystem;
 import org.apache.aries.subsystem.core.archive.ProvisionPolicyDirective;
 import org.apache.aries.subsystem.core.archive.SubsystemTypeHeader;
@@ -54,9 +61,14 @@ import org.apache.aries.unittest.fixture
 import org.apache.aries.util.filesystem.FileSystem;
 import org.eclipse.equinox.region.Region;
 import org.eclipse.equinox.region.RegionDigraph;
-import org.ops4j.pax.exam.CoreOptions;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
 import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.container.def.PaxRunnerOptions;
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerClass;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleException;
@@ -80,7 +92,19 @@ import org.osgi.service.subsystem.Subsys
 import org.osgi.service.subsystem.Subsystem.State;
 import org.osgi.service.subsystem.SubsystemConstants;
 
-public abstract class SubsystemTest extends IntegrationTest {
+@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerClass.class)
+public abstract class SubsystemTest extends AbstractIntegrationTest {
+	protected static boolean createdApplications = false;
+	boolean installModeler = true;
+	
+	public SubsystemTest() {
+	}
+	
+	public SubsystemTest(boolean installModeller) {
+		this.installModeler = installModeller;
+	}
+	
 	protected static class SubsystemEventHandler implements ServiceListener {
 		private static class ServiceEventInfo {
 			private final ServiceEvent event;
@@ -178,55 +202,57 @@ public abstract class SubsystemTest exte
 		}
 	}
 	
-	protected static Option[] defineOptions() {
+	public Option baseOptions() {
+        String localRepo = getLocalRepo();
+        return composite(
+                junitBundles(),
+                // this is how you set the default log level when using pax
+                // logging (logProfile)
+                systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("INFO"),
+                when(localRepo != null).useOptions(vmOption("-Dorg.ops4j.pax.url.mvn.localRepository=" + localRepo))
+         );
+    }
+	
+	@Configuration
+	public Option[] configuration() throws Exception {
+		// The itests need private packages from the core subsystems bundle.
+		InputStream fragment = SubsystemTest.class.getClassLoader().getResourceAsStream("core.fragment/core.fragment.jar");
 		return new Option[] {
-				// this is how you set the default log level when using pax
-				// logging (logProfile)
-				systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("INFO"),
+				baseOptions(),
 				systemProperty("org.osgi.framework.bsnversion").value("multiple"),
-				// Log
-				mavenBundle("org.ops4j.pax.logging", "pax-logging-api"),
-				mavenBundle("org.ops4j.pax.logging", "pax-logging-service"),
-				// Felix mvn url handler
-				mavenBundle("org.ops4j.pax.url", "pax-url-mvn"),
 				// Bundles
 				mavenBundle("org.apache.aries",             "org.apache.aries.util").versionAsInProject(),
-				mavenBundle("org.apache.aries.application", "org.apache.aries.application.api").versionAsInProject(),
-				mavenBundle("org.apache.aries.application", "org.apache.aries.application.modeller").versionAsInProject(),
 				mavenBundle("org.apache.aries.application", "org.apache.aries.application.utils").versionAsInProject(),
-				mavenBundle("org.apache.aries.blueprint",   "org.apache.aries.blueprint").versionAsInProject(),
-				mavenBundle("org.apache.aries.proxy",       "org.apache.aries.proxy").versionAsInProject(),
+				mavenBundle("org.apache.aries.application", "org.apache.aries.application.api").versionAsInProject(),
+				when(installModeler).useOptions(
+						mavenBundle("org.apache.aries.application", "org.apache.aries.application.modeller").versionAsInProject(),
+						mavenBundle("org.apache.aries.blueprint",   "org.apache.aries.blueprint").versionAsInProject(),
+						mavenBundle("org.apache.aries.proxy",       "org.apache.aries.proxy").versionAsInProject()),
 				mavenBundle("org.apache.aries.subsystem",   "org.apache.aries.subsystem.api").versionAsInProject(),
-				// The itests need private packages from the core subsystems bundle.
-				CoreOptions.provision(SubsystemTest.class.getClassLoader().getResourceAsStream("core.fragment/core.fragment.jar")),
+				streamBundle(fragment).noStart(),
 				mavenBundle("org.apache.aries.subsystem",   "org.apache.aries.subsystem.core").versionAsInProject(),
 				mavenBundle("org.apache.aries.subsystem",   "org.apache.aries.subsystem.itest.interfaces").versionAsInProject(),
 				mavenBundle("org.apache.aries.testsupport", "org.apache.aries.testsupport.unit").versionAsInProject(),
-				mavenBundle("org.apache.felix",             "org.apache.felix.resolver"),
+				mavenBundle("org.apache.felix",             "org.apache.felix.resolver").versionAsInProject(),
 				mavenBundle("org.eclipse.equinox",          "org.eclipse.equinox.coordinator").version("1.1.0.v20120522-1841"),
-				mavenBundle("org.eclipse.equinox",          "org.eclipse.equinox.event").version("1.2.200.v20120522-2049"),
+				mavenBundle("org.eclipse.equinox",          "org.eclipse.equinox.event").versionAsInProject(),
 				mavenBundle("org.eclipse.equinox",          "org.eclipse.equinox.region").version("1.1.0.v20120522-1841"),
 				mavenBundle("org.osgi",                     "org.osgi.enterprise").version("5.0.0"),
 				mavenBundle("org.easymock",					"easymock").versionAsInProject(),
 //				org.ops4j.pax.exam.container.def.PaxRunnerOptions.vmOption("-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=7777"),
-				PaxRunnerOptions.rawPaxRunnerOption("config", "classpath:ss-runner.properties"),
-				equinox().version("3.8.0.V20120529-1548")
 		};
 	}
 	
-	@org.ops4j.pax.exam.junit.Configuration
-	public static Option[] configuration() {
-		Option[] options = defineOptions();
-		options = updateOptions(options);
-		return options;
-	}
-	
 	protected final SubsystemEventHandler subsystemEvents = new SubsystemEventHandler();
 	
 	protected Collection<ServiceRegistration<?>> serviceRegistrations = new ArrayList<ServiceRegistration<?>>();
 	
+	@Before
 	public void setUp() throws Exception {
-		super.setUp();
+		if (!createdApplications) {
+			createApplications();
+			createdApplications = true;
+		}
 		try {
 			bundleContext.getBundle(0).getBundleContext().addServiceListener(subsystemEvents, '(' + Constants.OBJECTCLASS + '=' + Subsystem.class.getName() + ')');
 		}
@@ -236,13 +262,19 @@ public abstract class SubsystemTest exte
 		assertSubsystemNotNull(getRootSubsystem());
 	}
 	
+	protected abstract void createApplications() throws Exception;
+
+	@After
 	public void tearDown() throws Exception 
 	{
 		bundleContext.removeServiceListener(subsystemEvents);
 		for (ServiceRegistration<?> registration : serviceRegistrations)
 			Utils.unregisterQuietly(registration);
 		serviceRegistrations.clear();
-		super.tearDown();
+	}
+	
+	protected RichBundleContext context(Subsystem subsystem) {
+		return new RichBundleContext(subsystem.getBundleContext());
 	}
 	
 	protected void assertEmptySubsystem(Subsystem subsystem) {
@@ -252,7 +284,7 @@ public abstract class SubsystemTest exte
     }
 	
 	protected void assertBundleState(int state, String symbolicName, Subsystem subsystem) {
-    	Bundle bundle = getBundle(subsystem, symbolicName);
+    	Bundle bundle = context(subsystem).getBundleByName(symbolicName);
     	assertNotNull("Bundle not found: " + symbolicName, bundle);
     	assertBundleState(bundle, state);
     }
@@ -494,6 +526,7 @@ public abstract class SubsystemTest exte
 	}
 	
 	protected void assertStartLevel(Bundle bundle, int expected) {
+		assertNotNull("Bundle is null", bundle);
 		assertEquals("Wrong start level", expected, bundle.adapt(BundleStartLevel.class).getStartLevel());
 	}
 	
@@ -514,7 +547,7 @@ public abstract class SubsystemTest exte
 	}
 	
 	protected Subsystem assertSubsystemLifeCycle(File file) throws Exception {
-		Subsystem rootSubsystem = getOsgiService(Subsystem.class);
+		Subsystem rootSubsystem = context().getService(Subsystem.class);
         assertNotNull("Root subsystem was null", rootSubsystem);
         Subsystem subsystem = rootSubsystem.install(file.toURI().toURL().toExternalForm());
         assertNotNull("The subsystem was null", subsystem);
@@ -568,24 +601,43 @@ public abstract class SubsystemTest exte
 		assertEquals("Wrong version", expected, actual);
 	}
 	
-	protected static void createBundle(String symbolicName) throws IOException {
-		createBundle(symbolicName, null);
+	protected Header version(String version) {
+		return new Header(Constants.BUNDLE_VERSION, version);
 	}
 	
-	protected static void createBundle(String symbolicName, Map<String, String> headers) throws IOException {
-		createBundle(symbolicName, null, headers);
+	protected Header name(String name) {
+		return new Header(Constants.BUNDLE_SYMBOLICNAME, name);
 	}
 	
-	protected static void createBundle(String symbolicName, String version, Map<String, String> headers) throws IOException {
-		if (headers == null)
-			headers = new HashMap<String, String>();
-		headers.put(Constants.BUNDLE_SYMBOLICNAME, symbolicName);
-		if (version != null)
-			headers.put(Constants.BUNDLE_VERSION, version);
-		createBundle(headers);
+	protected Header exportPackage(String exportPackage) {
+		return new Header(Constants.EXPORT_PACKAGE, exportPackage);
+	}
+	
+	protected Header importPackage(String importPackage) {
+		return new Header(Constants.IMPORT_PACKAGE, importPackage);
+	}
+
+	protected Header requireBundle(String bundleName) {
+		return new Header(Constants.REQUIRE_BUNDLE, bundleName);
 	}
 	
-	protected static void createBundle(Map<String, String> headers) throws IOException 
+	protected Header requireCapability(String capability) {
+		return new Header(Constants.REQUIRE_CAPABILITY, capability);
+	}
+
+	protected Header provideCapability(String capability) {
+		return new Header(Constants.PROVIDE_CAPABILITY, capability);
+	}
+	
+	protected static void createBundle(Header...  headers) throws IOException {
+		HashMap<String, String> headerMap = new HashMap<String, String>();
+		for (Header header : headers) {
+			headerMap.put(header.key, header.value);
+		}
+		createBundle(headerMap);
+	}
+	
+	private static void createBundle(Map<String, String> headers) throws IOException 
 	{
 		String symbolicName = headers.get(Constants.BUNDLE_SYMBOLICNAME);
 		JarFixture bundle = ArchiveFixture.newJar();
@@ -596,11 +648,18 @@ public abstract class SubsystemTest exte
 		write(symbolicName, bundle);
 	}
 	
-	protected RepositoryContent createBundleRepositoryContent(String file) throws Exception {
+	protected static void createBlueprintBundle(String symbolicName, String blueprintXml)
+			throws IOException {
+		write(symbolicName,
+				ArchiveFixture.newJar().manifest().symbolicName(symbolicName)
+						.end().file("OSGI-INF/blueprint/blueprint.xml", blueprintXml));
+	}
+	
+	private RepositoryContent createBundleRepositoryContent(String file) throws Exception {
 		return createBundleRepositoryContent(new File(file));
 	}
 	
-	protected RepositoryContent createBundleRepositoryContent(File file) throws Exception {
+	private RepositoryContent createBundleRepositoryContent(File file) throws Exception {
 		return new BundleResource(FileSystem.getFSRoot(file));
 	}
 	
@@ -612,10 +671,6 @@ public abstract class SubsystemTest exte
 		write(name, manifest);
 	}
 	
-	protected static void createSubsystem(String name) throws IOException {
-		createSubsystem(name, new String[0]);
-	}
-	
 	protected static void createSubsystem(String name, String...contents) throws IOException {
 		File manifest = new File(name + ".mf");
 		ZipFixture fixture = ArchiveFixture.newZip();
@@ -633,16 +688,7 @@ public abstract class SubsystemTest exte
 	
 	protected Subsystem findSubsystemService(long id) throws InvalidSyntaxException {
 		String filter = "(" + SubsystemConstants.SUBSYSTEM_ID_PROPERTY + "=" + id + ")";
-		return getOsgiService(Subsystem.class, filter, 5000);
-	}
-	
-	protected Bundle getBundle(Subsystem subsystem, String symbolicName) {
-		for (Bundle bundle : subsystem.getBundleContext().getBundles()) {
-			if (symbolicName.equals(bundle.getSymbolicName())) { 
-				return bundle;
-			}
-		}
-		return null;
+		return context().getService(Subsystem.class, filter, 5000);
 	}
 	
 	protected Subsystem getChild(Subsystem parent, String symbolicName) {
@@ -707,7 +753,7 @@ public abstract class SubsystemTest exte
 	}
 	
 	protected Region getRegion(Subsystem subsystem) {
-		RegionDigraph digraph = getOsgiService(RegionDigraph.class);
+		RegionDigraph digraph = context().getService(RegionDigraph.class);
 		String name = getRegionName(subsystem);
 		Region region = digraph.getRegion(name);
 		assertNotNull("Region not found: " + name, region);
@@ -727,11 +773,11 @@ public abstract class SubsystemTest exte
 	}
 	
 	protected AriesSubsystem getRootAriesSubsystem() {
-		return getOsgiService(AriesSubsystem.class);
+		return context().getService(AriesSubsystem.class);
 	}
 	
 	protected Subsystem getRootSubsystem() {
-		return getOsgiService(Subsystem.class, "(&(objectClass=org.osgi.service.subsystem.Subsystem)(subsystem.id=0))", DEFAULT_TIMEOUT);
+		return context().getService(Subsystem.class, "(subsystem.id=0)");
 	}
 	
 	protected Subsystem getRootSubsystemInState(Subsystem.State state, long timeout) throws InterruptedException {
@@ -758,28 +804,24 @@ public abstract class SubsystemTest exte
 	}
 	
 	protected Bundle getSubsystemCoreBundle() {
-		return findBundleBySymbolicName("org.apache.aries.subsystem.core");
+		return context().getBundleByName("org.apache.aries.subsystem.core");
 	}
 	
 	protected Bundle installBundleFromFile(String fileName) throws FileNotFoundException, BundleException {
-		return installBundleFromFile(new File(fileName));
-	}
-	
-	protected Bundle installBundleFromFile(File file) throws FileNotFoundException, BundleException {
-		return installBundleFromFile(file, getRootSubsystem());
+		return installBundleFromFile(new File(fileName), getRootSubsystem());
 	}
 	
-	protected Bundle installBundleFromFile(String file, Subsystem subsystem) throws FileNotFoundException, BundleException {
-		return installBundleFromFile(new File(file), subsystem);
+	protected Bundle installBundleFromFile(String fileName, Subsystem subsystem) throws FileNotFoundException, BundleException {
+		return installBundleFromFile(new File(fileName), subsystem);
 	}
 	
-	protected Bundle installBundleFromFile(File file, Subsystem subsystem) throws FileNotFoundException, BundleException {
+	private Bundle installBundleFromFile(File file, Subsystem subsystem) throws FileNotFoundException, BundleException {
 		Bundle bundle = installBundleFromFile(file, subsystem.getBundleContext());
 		assertBundleState(Bundle.INSTALLED|Bundle.RESOLVED, bundle.getSymbolicName(), subsystem);
 		return bundle;
 	}
 	
-	protected Bundle installBundleFromFile(File file, BundleContext bundleContext) throws FileNotFoundException, BundleException {
+	private Bundle installBundleFromFile(File file, BundleContext bundleContext) throws FileNotFoundException, BundleException {
 		// The following input stream is closed by the bundle context.
 		return bundleContext.installBundle(file.toURI().toString(), new FileInputStream(file));
 	}
@@ -796,7 +838,7 @@ public abstract class SubsystemTest exte
 		return installSubsystem(parent, file.toURI().toURL().toExternalForm());
 	}
 	
-	protected Subsystem installSubsystemFromFile(File file) throws Exception {
+	private Subsystem installSubsystemFromFile(File file) throws Exception {
 		return installSubsystem(getRootSubsystem(), file.toURI().toURL().toExternalForm());
 	}
 	
@@ -929,7 +971,7 @@ public abstract class SubsystemTest exte
 		Collection<Subsystem> parents = subsystem.getParents();
 		Bundle b = null;
 		Region region = null;
-		RegionDigraph digraph = getOsgiService(RegionDigraph.class);
+		RegionDigraph digraph = context().getService(RegionDigraph.class);
 		if (subsystem.getType().equals(SubsystemConstants.SUBSYSTEM_TYPE_APPLICATION)
 				|| subsystem.getType().equals(SubsystemConstants.SUBSYSTEM_TYPE_COMPOSITE)) {
 			b = getRegionContextBundle(subsystem);
@@ -968,7 +1010,7 @@ public abstract class SubsystemTest exte
 		write(new File(file), fixture);
 	}
 	
-	protected static void write(File file, ArchiveFixture.AbstractFixture fixture) throws IOException {
+	private static void write(File file, ArchiveFixture.AbstractFixture fixture) throws IOException {
 		FileOutputStream fos = new FileOutputStream(file);
     	try {
     		fixture.writeOut(fos);
@@ -978,7 +1020,7 @@ public abstract class SubsystemTest exte
     	}
 	}
 	
-	static void createApplication(String name, String[] content) throws Exception 
+	static void createApplication(String name, String ... content) throws Exception 
 	{
 		ZipFixture feature = ArchiveFixture
 				.newZip()

Modified: aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/UnmanagedBundleTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/UnmanagedBundleTest.java?rev=1598506&r1=1598505&r2=1598506&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/UnmanagedBundleTest.java (original)
+++ aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/UnmanagedBundleTest.java Fri May 30 08:59:13 2014
@@ -21,10 +21,7 @@ package org.apache.aries.subsystem.itest
 import java.io.FileInputStream;
 import java.io.IOException;
 
-import org.junit.Before;
 import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.junit.MavenConfiguredJUnit4TestRunner;
 import org.osgi.framework.Bundle;
 import org.osgi.service.subsystem.Subsystem;
 
@@ -32,24 +29,19 @@ import org.osgi.service.subsystem.Subsys
  * Contains a series of tests for unmanaged bundles. An unmanaged bundle is a
  * bundle that was installed outside of the Subsystems API.
  */
-@RunWith(MavenConfiguredJUnit4TestRunner.class)
 public class UnmanagedBundleTest extends SubsystemTest {
 	/*
 	 * Bundle-SymbolicName: bundle.a.jar
 	 */
 	private static final String BUNDLE_A = "bundle.a.jar";
 	
-	@Before
-	public static void createApplications() throws Exception {
-		if (createdApplications) {
-			return;
-		};
+	@Override
+	public void createApplications() throws Exception {
 		createBundleA();
-		createdApplications = true;
 	}
 	
-	private static void createBundleA() throws IOException {
-		createBundle(BUNDLE_A);
+	private void createBundleA() throws IOException {
+		createBundle(name(BUNDLE_A));
 	}
 	
 	/*

Modified: aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/obr/felix/FelixCapabilityAdapter.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/obr/felix/FelixCapabilityAdapter.java?rev=1598506&r1=1598505&r2=1598506&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/obr/felix/FelixCapabilityAdapter.java (original)
+++ aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/obr/felix/FelixCapabilityAdapter.java Fri May 30 08:59:13 2014
@@ -31,6 +31,7 @@ public class FelixCapabilityAdapter exte
 		this.resource = resource;
 	}
 
+	@SuppressWarnings("unchecked")
 	public Map<String, Object> getAttributes() {
 		Map<String, Object> result = capability.getPropertiesAsMap();
 		result.put(getNamespace(), result.get(capability.getName()));

Modified: aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/obr/felix/OsgiResourceAdapter.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/obr/felix/OsgiResourceAdapter.java?rev=1598506&r1=1598505&r2=1598506&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/obr/felix/OsgiResourceAdapter.java (original)
+++ aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/obr/felix/OsgiResourceAdapter.java Fri May 30 08:59:13 2014
@@ -56,6 +56,7 @@ public class OsgiResourceAdapter impleme
 		return ResourceHelper.getSymbolicNameAttribute(resource);
 	}
 
+	@SuppressWarnings("rawtypes")
 	public Map getProperties() {
 		return Collections.emptyMap();
 	}

Modified: aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/util/RepositoryGenerator.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/util/RepositoryGenerator.java?rev=1598506&r1=1598505&r2=1598506&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/util/RepositoryGenerator.java (original)
+++ aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/util/RepositoryGenerator.java Fri May 30 08:59:13 2014
@@ -16,8 +16,6 @@ package org.apache.aries.subsystem.itest
 import java.io.File;
 import java.io.FileOutputStream;
 import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
@@ -30,15 +28,11 @@ import javax.xml.transform.stream.Stream
 
 import org.apache.aries.application.Content;
 import org.apache.aries.application.management.BundleInfo;
-import org.apache.aries.subsystem.core.internal.ResourceHelper;
 import org.apache.aries.subsystem.itests.obr.felix.FelixResourceAdapter;
 import org.apache.aries.subsystem.itests.obr.felix.OsgiResourceAdapter;
-import org.apache.felix.bundlerepository.Capability;
-import org.apache.felix.bundlerepository.Property;
 import org.apache.felix.bundlerepository.Reason;
 import org.apache.felix.bundlerepository.Repository;
 import org.apache.felix.bundlerepository.RepositoryAdmin;
-import org.apache.felix.bundlerepository.Requirement;
 import org.apache.felix.bundlerepository.Resolver;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceReference;
@@ -133,10 +127,9 @@ public class RepositoryGenerator {
 
     }
 
-    private void registerOBR() {
+	private void registerOBR() {
         // set repositoryAdmin
-        ServiceReference ref = context
-                .getServiceReference(RepositoryAdmin.class.getName());
+        ServiceReference<RepositoryAdmin> ref = context.getServiceReference(RepositoryAdmin.class);
         
         if (ref != null) {
             this.repositoryAdmin = (RepositoryAdmin) context.getService(ref);
@@ -159,7 +152,8 @@ public class RepositoryGenerator {
     /**
      * the format of resource is like bundlesymbolicname;version=1.0.0, for example com.ibm.ws.eba.example.blog.api;version=1.0.0,
      */
-    public Resource find(String resource) throws SubsystemException {
+    @SuppressWarnings({ "rawtypes", "unused" })
+	public Resource find(String resource) throws SubsystemException {
         generateOBR();
         
         Content content = new ContentImpl(resource);
@@ -197,47 +191,7 @@ public class RepositoryGenerator {
 
         return new FelixResourceAdapter(res);
     }
-    
-    /**
-     * the format of resource is like bundlesymbolicname;version=1.0.0, for example com.ibm.ws.eba.example.blog.api;version=1.0.0,
-     */
-    private org.apache.felix.bundlerepository.Resource findOBRResource(Resource resource) throws SubsystemException {
-        String symbolicName = ResourceHelper.getSymbolicNameAttribute(resource);
-        // this version could possibly be a range
-        Version version = ResourceHelper.getVersionAttribute(resource);
 
-        //org.apache.felix.bundlerepository.Resource[] res = this.repositoryAdmin.discoverResources(filterString.toString());
-        Repository[] repos = this.repositoryAdmin.listRepositories();
-        org.apache.felix.bundlerepository.Resource res = null;
-        for (Repository repo : repos) {
-            org.apache.felix.bundlerepository.Resource[] resources = repo.getResources();
-            for (int i = 0; i < resources.length; i++) {
-                if (resources[i].getSymbolicName().equals(symbolicName)) {
-                    if (resources[i].getVersion().compareTo(version) == 0) {
-                        res = resources[i];
-                    }
-                }
-            }
-        }
-        return res;
-    }
-
-    /**
-     * convert to the resource from the obr resource
-     */
-    private Resource toResource(org.apache.felix.bundlerepository.Resource resource) throws SubsystemException {
-        if (resource == null) {
-            throw new SubsystemException("unable to find the resource " + resource);
-        }
-        
-        Map props = resource.getProperties();
-        
-
-        Object type = props.get(IdentityNamespace.CAPABILITY_TYPE_ATTRIBUTE);
-
-        return new FelixResourceAdapter(resource);
-    }
-    
     public List<Resource> resolve(List<Resource> subsystemContent,
             List<Resource> subsystemResources) throws SubsystemException {
         generateOBR();
@@ -291,73 +245,5 @@ public class RepositoryGenerator {
         }
         return resources;
     }
-    
-    private org.apache.felix.bundlerepository.Resource convert(final Resource resource) {
-    	return new org.apache.felix.bundlerepository.Resource() {
-			public Capability[] getCapabilities() {
-				Collection<Capability> result = new ArrayList<Capability>(resource.getCapabilities(null).size());
-				for (org.osgi.resource.Capability capability : resource.getCapabilities(null)) {
-					result.add(new Capability() {
-						public String getName() {
-							// TODO Auto-generated method stub
-							return null;
-						}
-
-						public Property[] getProperties() {
-							// TODO Auto-generated method stub
-							return null;
-						}
-
-						public Map getPropertiesAsMap() {
-							// TODO Auto-generated method stub
-							return null;
-						}
-					});
-				}
-				return null;
-			}
-
-			public String[] getCategories() {
-				return new String[0];
-			}
-
-			public String getId() {
-				return getSymbolicName() + ";version=" + getVersion();
-			}
-
-			public String getPresentationName() {
-				return getSymbolicName();
-			}
-
-			public Map getProperties() {
-				return Collections.EMPTY_MAP;
-			}
-
-			public Requirement[] getRequirements() {
-				// TODO Auto-generated method stub
-				return null;
-			}
-
-			public Long getSize() {
-				return 0L;
-			}
-
-			public String getSymbolicName() {
-				return ResourceHelper.getSymbolicNameAttribute(resource);
-			}
-
-			public String getURI() {
-				return ResourceHelper.getContentAttribute(resource);
-			}
-
-			public Version getVersion() {
-				return ResourceHelper.getVersionAttribute(resource);
-			}
-
-			public boolean isLocal() {
-				return false;
-			}
-    	};
-    }
 
 }