You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by tj...@apache.org on 2014/06/30 18:55:06 UTC
svn commit: r1606837 [3/27] - in /aries/branches/subsystemsR6: ./
application/ application/application-api/ application/application-bundle/
application/application-converters/
application/application-default-local-platform/
application/application-depl...
Modified: aries/branches/subsystemsR6/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/IsolatedCfgAdminRuntimeTest.java
URL: http://svn.apache.org/viewvc/aries/branches/subsystemsR6/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/IsolatedCfgAdminRuntimeTest.java?rev=1606837&r1=1606836&r2=1606837&view=diff
==============================================================================
--- aries/branches/subsystemsR6/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/IsolatedCfgAdminRuntimeTest.java (original)
+++ aries/branches/subsystemsR6/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/IsolatedCfgAdminRuntimeTest.java Mon Jun 30 16:54:57 2014
@@ -18,21 +18,11 @@
*/
package org.apache.aries.application.runtime.itests;
-//import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.vmOption;
+import static org.ops4j.pax.exam.CoreOptions.*;
-import static org.apache.aries.itest.ExtraOptions.mavenBundle;
-import static org.apache.aries.itest.ExtraOptions.mavenBundleInTest;
-import static org.apache.aries.itest.ExtraOptions.paxLogging;
-import static org.apache.aries.itest.ExtraOptions.testOptions;
-import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.repository;
-
-import java.io.File;
-import java.io.FileOutputStream;
+import java.io.*;
import java.net.URL;
-import java.util.Arrays;
-import java.util.Dictionary;
-import java.util.Hashtable;
-import java.util.List;
+import java.util.*;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
@@ -53,12 +43,14 @@ import org.apache.aries.util.filesystem.
import org.apache.aries.util.filesystem.IDirectory;
import org.junit.After;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.container.def.PaxRunnerOptions;
-import org.ops4j.pax.exam.junit.MavenConfiguredJUnit4TestRunner;
+import org.ops4j.pax.exam.junit.PaxExam;
import org.ops4j.pax.exam.options.MavenArtifactProvisionOption;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerClass;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Constants;
import org.osgi.framework.InvalidSyntaxException;
@@ -73,113 +65,122 @@ import org.osgi.util.tracker.ServiceTrac
/**
* This test suite is responsible for validating that an application can package and use the
* isolated configuration admin deployed. This includes both from Blueprint and manually.
- *
+ * <p/>
* Blueprint Specific:
- *
+ * <p/>
* Note that, the CmNamespaceHandler has been rewired to create a service reference to the configuration
- * admin that resides within the application framework. This will allow the configuration admin bundle
- * activator sufficient time to register a config admin service before the blueprint container for the bundle
+ * admin that resides within the application framework. This will allow the configuration admin bundle
+ * activator sufficient time to register a config admin service before the blueprint container for the bundle
* requiring it is started (i.e. no configuration admin race condition).
- *
+ * <p/>
* Other notes:
- *
+ * <p/>
* In order to avoid boundary issues (i.e. class casting exceptions etc), the actual configuration admin bundle
* classes are loaded from the shared framework. This is necessary as the blueprint-cm bundle refers to the
- * configuration admin classes directly, as we register a configuration admin and managed service in the
+ * configuration admin classes directly, as we register a configuration admin and managed service in the
* application scope, any attempt to use those services from the CM bundle would end up in a class cast exception.
* This is why we use the classes already loaded in the root container, which are imported into the shared framework.
- * Behind the scenes a manifest transformer is used to make sure that the DEPLOYMENT.MF is augmented with the
+ * Behind the scenes a manifest transformer is used to make sure that the DEPLOYMENT.MF is augmented with the
* necessary org.osgi.service.cm package import to make the class space consistent everywhere. From the developers
* perspective, it appears as if they are deploying into a flat container as the wiring magic is hidden when the
* application is created and installed. Note that the config package import only includes the CM API, nothing else.
*
* @version $Rev$ $Date$
*/
-@RunWith(MavenConfiguredJUnit4TestRunner.class)
+@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerClass.class)
public class IsolatedCfgAdminRuntimeTest extends AbstractIntegrationTest {
-
+
private static final String APP_HWBP = "helloworld-bp.eba";
private static final String APP_HWMN = "helloworld-mn.eba";
private static final List<String> APPLICATIONS = Arrays.asList(APP_HWBP, APP_HWMN);
-
+
/**
* Creates two applications, as follows:
- *
- * - helloworld-bp.eba ------
- * |
- * | This application contains a helloworld bundle which contains an interface and impl for HelloWorld. Upon being started
- * | blueprint will create a new container for this bundle and register the HelloWorld service. The service will be injected
- * | with a message coming from the ConfigurationAdmin service using the PID: helloworld-bp. As a CM property placeholder is
- * | used, a ManagedService will also be registered on the bundles behalf so that further updates can be captured. Note that
- * | the blueprint configuration is wired to reload the container on a configuration update (to allow easier tracking of when
- * | to test service contents etc).
- * |
- * | The application also contains a configuration admin bundle (pulled from Maven).
- * ---------------------------
- *
- * - helloworld-mn.eba -------
- * |
- * | This application contains a helloworld bundle containing an activator that will register itself as a ManagedService for the
- * | PID: helloworld-mn. The activator will also expose out a HelloWorld service. Upon recieving an update from the packaged
- * | Configuration Admin service, the HelloWorld service will be re-registered using the latest configuration, namely the "message".
- * |
- * | The application also contains a configuration admin bundle (pulled from Maven).
- * ---------------------------
- *
+ * <p/>
+ * - helloworld-bp.eba ------
+ * |
+ * | This application contains a helloworld bundle which contains an interface and impl for HelloWorld. Upon being started
+ * | blueprint will create a new container for this bundle and register the HelloWorld service. The service will be injected
+ * | with a message coming from the ConfigurationAdmin service using the PID: helloworld-bp. As a CM property placeholder is
+ * | used, a ManagedService will also be registered on the bundles behalf so that further updates can be captured. Note that
+ * | the blueprint configuration is wired to reload the container on a configuration update (to allow easier tracking of when
+ * | to test service contents etc).
+ * |
+ * | The application also contains a configuration admin bundle (pulled from Maven).
+ * ---------------------------
+ * <p/>
+ * - helloworld-mn.eba -------
+ * |
+ * | This application contains a helloworld bundle containing an activator that will register itself as a ManagedService for the
+ * | PID: helloworld-mn. The activator will also expose out a HelloWorld service. Upon recieving an update from the packaged
+ * | Configuration Admin service, the HelloWorld service will be re-registered using the latest configuration, namely the "message".
+ * |
+ * | The application also contains a configuration admin bundle (pulled from Maven).
+ * ---------------------------
+ *
* @throws Exception
*/
@Before
- public void constructApplications() throws Exception {
-
+ public void constructApplications() throws Exception {
+
Assert.assertNotNull("Could not find Maven URL handler", (new RichBundleContext(context())).getService(URLStreamHandlerService.class, "url.handler.protocol=mvn", 300000));
MavenArtifactProvisionOption configAdminProvisionOption = mavenBundleInTest(getClass().getClassLoader(), "org.apache.felix", "org.apache.felix.configadmin");
Assert.assertNotNull("Unable to lookup config admin maven bundle", configAdminProvisionOption);
URL configAdminUrl = new URL(configAdminProvisionOption.getURL());
-
+
ZipFixture helloWorldBluePrintEba = ArchiveFixture
.newZip()
- .binary("META-INF/APPLICATION.MF",
- IsolatedCfgAdminRuntimeTest.class.getClassLoader()
- .getResourceAsStream("isolated/config/APPLICATION-BP.MF"))
- .binary("org.apache.felix.configadmin.jar", configAdminUrl.openStream())
- .jar("helloworld-bundle.jar")
- .manifest()
- .symbolicName("org.apache.aries.isolated.helloworldbp")
- .attribute("Bundle-Version", "1.0.0")
- .attribute("Import-Package", "org.osgi.service.cm")
- .end()
- .binary("org/apache/aries/isolated/sample/HelloWorld.class",
- IsolatedCfgAdminRuntimeTest.class.getClassLoader().getResourceAsStream(
- "org/apache/aries/isolated/sample/HelloWorld.class"))
- .binary("org/apache/aries/isolated/sample/HelloWorldImpl.class",
- IsolatedCfgAdminRuntimeTest.class.getClassLoader().getResourceAsStream(
- "org/apache/aries/isolated/sample/HelloWorldImpl.class"))
- .binary("OSGI-INF/blueprint/blueprint.xml",
- IsolatedCfgAdminRuntimeTest.class.getClassLoader()
- .getResourceAsStream("isolated/config/blueprint.xml")).end();
+ .binary("META-INF/APPLICATION.MF",
+ IsolatedCfgAdminRuntimeTest.class.getClassLoader()
+ .getResourceAsStream("isolated/config/APPLICATION-BP.MF")
+ )
+ .binary("org.apache.felix.configadmin.jar", configAdminUrl.openStream())
+ .jar("helloworld-bundle.jar")
+ .manifest()
+ .symbolicName("org.apache.aries.isolated.helloworldbp")
+ .attribute("Bundle-Version", "1.0.0")
+ .attribute("Import-Package", "org.osgi.service.cm")
+ .end()
+ .binary("org/apache/aries/isolated/sample/HelloWorld.class",
+ IsolatedCfgAdminRuntimeTest.class.getClassLoader().getResourceAsStream(
+ "org/apache/aries/isolated/sample/HelloWorld.class")
+ )
+ .binary("org/apache/aries/isolated/sample/HelloWorldImpl.class",
+ IsolatedCfgAdminRuntimeTest.class.getClassLoader().getResourceAsStream(
+ "org/apache/aries/isolated/sample/HelloWorldImpl.class")
+ )
+ .binary("OSGI-INF/blueprint/blueprint.xml",
+ IsolatedCfgAdminRuntimeTest.class.getClassLoader()
+ .getResourceAsStream("isolated/config/blueprint.xml")
+ ).end();
ZipFixture helloWorldManualEba = ArchiveFixture
.newZip()
- .binary("META-INF/APPLICATION.MF",
- IsolatedCfgAdminRuntimeTest.class.getClassLoader()
- .getResourceAsStream("isolated/config/APPLICATION-MN.MF"))
- .binary("org.apache.felix.configadmin.jar", configAdminUrl.openStream())
- .jar("helloworld-bundle.jar")
- .manifest()
- .symbolicName("org.apache.aries.isolated.helloworldmn")
- .attribute("Bundle-Version", "1.0.0")
- .attribute("Bundle-Activator", "org.apache.aries.isolated.config.HelloWorldManagedServiceImpl")
- .attribute("Import-Package", "org.osgi.framework,org.osgi.service.cm")
- .end()
- .binary("org/apache/aries/isolated/sample/HelloWorld.class",
- IsolatedCfgAdminRuntimeTest.class.getClassLoader().getResourceAsStream(
- "org/apache/aries/isolated/sample/HelloWorld.class"))
- .binary("org/apache/aries/isolated/sample/HelloWorldImpl.class",
- IsolatedCfgAdminRuntimeTest.class.getClassLoader().getResourceAsStream(
- "org/apache/aries/isolated/sample/HelloWorldImpl.class"))
- .binary("org/apache/aries/isolated/config/HelloWorldManagedServiceImpl.class",
- IsolatedCfgAdminRuntimeTest.class.getClassLoader().getResourceAsStream(
- "org/apache/aries/isolated/config/HelloWorldManagedServiceImpl.class")).end();
+ .binary("META-INF/APPLICATION.MF",
+ IsolatedCfgAdminRuntimeTest.class.getClassLoader()
+ .getResourceAsStream("isolated/config/APPLICATION-MN.MF")
+ )
+ .binary("org.apache.felix.configadmin.jar", configAdminUrl.openStream())
+ .jar("helloworld-bundle.jar")
+ .manifest()
+ .symbolicName("org.apache.aries.isolated.helloworldmn")
+ .attribute("Bundle-Version", "1.0.0")
+ .attribute("Bundle-Activator", "org.apache.aries.isolated.config.HelloWorldManagedServiceImpl")
+ .attribute("Import-Package", "org.osgi.framework,org.osgi.service.cm")
+ .end()
+ .binary("org/apache/aries/isolated/sample/HelloWorld.class",
+ IsolatedCfgAdminRuntimeTest.class.getClassLoader().getResourceAsStream(
+ "org/apache/aries/isolated/sample/HelloWorld.class")
+ )
+ .binary("org/apache/aries/isolated/sample/HelloWorldImpl.class",
+ IsolatedCfgAdminRuntimeTest.class.getClassLoader().getResourceAsStream(
+ "org/apache/aries/isolated/sample/HelloWorldImpl.class")
+ )
+ .binary("org/apache/aries/isolated/config/HelloWorldManagedServiceImpl.class",
+ IsolatedCfgAdminRuntimeTest.class.getClassLoader().getResourceAsStream(
+ "org/apache/aries/isolated/config/HelloWorldManagedServiceImpl.class")
+ ).end();
FileOutputStream fout = new FileOutputStream(APP_HWBP);
helloWorldBluePrintEba.writeOut(fout);
@@ -189,7 +190,7 @@ public class IsolatedCfgAdminRuntimeTest
helloWorldManualEba.writeOut(fout);
fout.close();
}
-
+
/**
* Try and clean up the applications created by {@link #constructApplications()}
*/
@@ -197,7 +198,7 @@ public class IsolatedCfgAdminRuntimeTest
public void deleteApplications() {
for (String application : APPLICATIONS) {
File eba = new File(application);
-
+
if (eba.exists()) {
eba.delete();
}
@@ -207,70 +208,72 @@ public class IsolatedCfgAdminRuntimeTest
/**
* The purpose of this test is to make sure an application that contains an config admin bundle
* can be used by Blueprint. The following steps are performed:
- *
- * - install the application
- * - start the application
- * - assert we have the following services in the isolated service registry (ConfigurationAdmin, ManagedService, HelloWorld)
- * - assert no configuration existed when the CM-PPH was invoked by BP (default message will be the token i.e. ${message})
- * - update the configuration (the message) for the PID (using a primitive boundary proxy), this will cause the blueprint container to reload
- * - check that the re-registered HelloWorld service contains the updated message
- * - clean up
- *
+ * <p/>
+ * - install the application
+ * - start the application
+ * - assert we have the following services in the isolated service registry (ConfigurationAdmin, ManagedService, HelloWorld)
+ * - assert no configuration existed when the CM-PPH was invoked by BP (default message will be the token i.e. ${message})
+ * - update the configuration (the message) for the PID (using a primitive boundary proxy), this will cause the blueprint container to reload
+ * - check that the re-registered HelloWorld service contains the updated message
+ * - clean up
+ *
* @throws Exception
*/
@Test
+ @Ignore
public void testIsolatedCfgAdminBPReload() throws Exception {
validateApplicationConfiguration(
- APP_HWBP,
- "org.apache.aries.helloworldbpapp",
- "helloworld-bp",
- "${message}",
+ APP_HWBP,
+ "org.apache.aries.helloworldbpapp",
+ "helloworld-bp",
+ "${message}",
"blueprint");
}
-
+
/**
* The purpose of this test is to make sure an application that contains an config admin bundle
* can be used by manually. The following steps are performed:
- *
- * - install the application
- * - start the application
- * - assert we have the following services in the isolated service registry (ConfigurationAdmin, ManagedService, HelloWorld)
- * - assert no configuration existed when the CM-PPH was invoked by BP (default message will be the token i.e. ${message})
- * - update the configuration (the message) for the PID (using a primitive boundary proxy), this will cause the HW service to be re-registered ({@link org.apache.aries.isolated.config.HelloWorldManagedServiceImpl}
- * - check that the re-registered HelloWorld service contains the updated message
- * - clean up
- *
+ * <p/>
+ * - install the application
+ * - start the application
+ * - assert we have the following services in the isolated service registry (ConfigurationAdmin, ManagedService, HelloWorld)
+ * - assert no configuration existed when the CM-PPH was invoked by BP (default message will be the token i.e. ${message})
+ * - update the configuration (the message) for the PID (using a primitive boundary proxy), this will cause the HW service to be re-registered ({@link org.apache.aries.isolated.config.HelloWorldManagedServiceImpl}
+ * - check that the re-registered HelloWorld service contains the updated message
+ * - clean up
+ *
* @throws Exception
*/
@Test
- public void testIsolatedCfgAdminManualReload() throws Exception {
+ @Ignore
+ public void testIsolatedCfgAdminManualReload() throws Exception {
validateApplicationConfiguration(
- APP_HWMN,
- "org.apache.aries.helloworldmnapp",
- "helloworld-mn",
- (new HelloWorldImpl()).getMessage(),
+ APP_HWMN,
+ "org.apache.aries.helloworldmnapp",
+ "helloworld-mn",
+ (new HelloWorldImpl()).getMessage(),
"manual");
}
-
+
/**
* Central validation method for verifying configuration can be published and consumed correctly within
* an isolated scope.
- *
- * @param application the application file name
+ *
+ * @param application the application file name
* @param applicationName the application name
- * @param pid the service.pid
- * @param defaultMessage the default message for the HelloWorld service (checked before any configuration updates occur)
- * @param newMessage the new message to set during a configuration update
+ * @param pid the service.pid
+ * @param defaultMessage the default message for the HelloWorld service (checked before any configuration updates occur)
+ * @param newMessage the new message to set during a configuration update
* @throws Exception
*/
private void validateApplicationConfiguration(String application, String applicationName, String pid, String defaultMessage, String newMessage) throws Exception {
-
+
//install and start the application
Context ctx = installApplication(FileSystem.getFSRoot(new File(application)), applicationName);
-
+
//assert we have the services that we're expecting
assertExpectedServices(ctx.getBundleContext(), pid);
-
+
//make sure we have the defaults set
Assert.assertEquals("Invalid message set on the HW service", defaultMessage, IsolationTestUtils.findHelloWorldService(ctx.getBundleContext()).getMessage());
@@ -278,20 +281,20 @@ public class IsolatedCfgAdminRuntimeTest
Dictionary<String, String> dictionary = new Hashtable<String, String>();
dictionary.put("message", newMessage);
Assert.assertTrue("Configuration update failed", executeConfigurationUpdate(ctx.getBundleContext(), pid, dictionary));
-
+
//now make sure we have our new message set in the HW service
Assert.assertEquals("Invalid message set on the HW service", newMessage, IsolationTestUtils.findHelloWorldService(ctx.getBundleContext()).getMessage());
-
+
//clean up
uninstallApplication(ctx);
}
-
+
/**
* Executes a configuration update using the given dictionary. A HelloWorld service will be tracked
* to ensure the configuration was successful (listening for add/remove tracker events).
- *
- * @param ctx the application bundle context
- * @param pid the service-pid to track
+ *
+ * @param ctx the application bundle context
+ * @param pid the service-pid to track
* @param dictionary the dictionary containing updated properties
* @return if the configuration update was successful
* @throws Exception
@@ -299,26 +302,25 @@ public class IsolatedCfgAdminRuntimeTest
private boolean executeConfigurationUpdate(BundleContext ctx, String pid, Dictionary<String, String> dictionary) throws Exception {
boolean result = true;
MonitorTask monitor = new MonitorTask(ctx, "(" + Constants.OBJECTCLASS + "=" + HelloWorld.class.getName() + ")", 2, 1);
-
+
try {
monitor.beginTracking();
result &= (new ConfigurationTask(ctx, pid, dictionary)).execute();
result &= monitor.execute();
- }
- finally {
+ } finally {
monitor.endTracking();
}
-
+
return result;
}
-
+
/**
* Assert that the following services are present in the service registry:
- *
- * - ConfigurationAdmin
- * - ManagedService
- * - HelloWorld
- *
+ * <p/>
+ * - ConfigurationAdmin
+ * - ManagedService
+ * - HelloWorld
+ *
* @param ctx the bundle context
* @param pid the service pid used to register the underlying ManagedService
* @throws Exception
@@ -326,18 +328,18 @@ public class IsolatedCfgAdminRuntimeTest
private void assertExpectedServices(RichBundleContext ctx, String pid) throws Exception {
//assert the CfgAdmin service was registered
Assert.assertNotNull("Missing the ConfigurationAdmin service", ctx.getService(ConfigurationAdmin.class));
-
+
//assert we have the ManagedService exposed
Assert.assertNotNull("Missing the Managed service", ctx.getService(ManagedService.class, "(" + Constants.SERVICE_PID + "=" + pid + ")"));
//now just make sure we can see it through the context of our config admin bundle context (should be in the same scope)
ServiceReference ref = ctx.getServiceReference(ConfigurationAdmin.class.getName());
Assert.assertNotNull("Couldn't find the ManagedService using the ConfigAdmin bundle context", new RichBundleContext(ref.getBundle().getBundleContext()).getService(ManagedService.class, "(" + Constants.SERVICE_PID + "=" + pid + ")"));
-
+
//make sure we have the helloworld service registered
HelloWorld helloWorldBluePrint = IsolationTestUtils.findHelloWorldService(ctx);
- Assert.assertNotNull("Missing the HelloWorld service", helloWorldBluePrint);
+ Assert.assertNotNull("Missing the HelloWorld service", helloWorldBluePrint);
}
-
+
private Context installApplication(IDirectory application, String applicationName) throws Exception {
//install the application and start it
AriesApplicationManager appManager = context().getService(AriesApplicationManager.class);
@@ -347,130 +349,131 @@ public class IsolatedCfgAdminRuntimeTest
return new Context(appCtx, IsolationTestUtils.findIsolatedAppBundleContext(context(), applicationName));
}
-
+
private void uninstallApplication(Context ctx) throws Exception {
AriesApplicationManager appManager = context().getService(AriesApplicationManager.class);
appManager.uninstall(ctx.getApplicationContext());
}
-
+
/**
* Create the configuration for the PAX container
- *
+ *
* @return the various required options
* @throws Exception
*/
- private static Option[] generalConfiguration() throws Exception {
- return testOptions(
+ @org.ops4j.pax.exam.Configuration
+ public static Option[] configuration() throws Exception {
+ return options(
+
+ // framework / core bundles
+ mavenBundle("org.osgi", "org.osgi.core").versionAsInProject(),
+ mavenBundle("org.osgi", "org.osgi.compendium").versionAsInProject(),
+ mavenBundle("org.ops4j.pax.logging", "pax-logging-api").versionAsInProject(),
+ mavenBundle("org.ops4j.pax.logging", "pax-logging-service").versionAsInProject(),
+
+ // Repository
repository("http://repository.ops4j.org/maven2"),
- paxLogging("DEBUG"),
- mavenBundle("org.apache.aries.blueprint", "org.apache.aries.blueprint"),
- mavenBundle("org.ow2.asm", "asm-all"),
- mavenBundle("org.apache.aries.proxy", "org.apache.aries.proxy"),
- mavenBundle("org.apache.aries.transaction", "org.apache.aries.transaction.blueprint"),
- mavenBundle("org.apache.aries", "org.apache.aries.util"),
- mavenBundle("org.apache.aries.application", "org.apache.aries.application.api"),
- mavenBundle("org.apache.aries.application", "org.apache.aries.application.utils"),
- mavenBundle("org.apache.aries.application", "org.apache.aries.application.default.local.platform"),
- mavenBundle("org.apache.aries.application", "org.apache.aries.application.modeller"),
- mavenBundle("org.apache.felix", "org.apache.felix.bundlerepository"),
- mavenBundle("org.apache.aries.application", "org.apache.aries.application.resolver.obr"),
- mavenBundle("org.apache.aries.application", "org.apache.aries.application.resolve.transform.cm"),
- mavenBundle("org.apache.aries.application", "org.apache.aries.application.deployment.management"),
- mavenBundle("org.apache.aries.application", "org.apache.aries.application.management"),
- mavenBundle("org.apache.aries.application", "org.apache.aries.application.runtime.isolated"),
- mavenBundle("org.apache.aries.application", "org.apache.aries.application.runtime.framework"),
- mavenBundle("org.apache.aries.application", "org.apache.aries.application.runtime.framework.management"),
- mavenBundle("org.apache.aries.application", "org.apache.aries.application.runtime.repository"),
- mavenBundle("org.apache.felix", "org.apache.felix.configadmin"),
- mavenBundle("org.apache.geronimo.specs", "geronimo-jta_1.1_spec"),
- mavenBundle("org.ops4j.pax.url", "pax-url-mvn"));
- //vmOption("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5006"),
- }
-
- @org.ops4j.pax.exam.junit.Configuration
- public static Option[] configuration() throws Exception
- {
- return testOptions(
- generalConfiguration(),
- PaxRunnerOptions.rawPaxRunnerOption("config", "classpath:ss-runner.properties")
- );
+
+ // Logging
+ systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("INFO"),
+
+ // Bundles
+ junitBundles(),
+ mavenBundle("org.apache.aries.testsupport", "org.apache.aries.testsupport.unit").versionAsInProject(),
+
+ // Bundles
+ mavenBundle("org.apache.aries.blueprint", "org.apache.aries.blueprint").versionAsInProject(),
+ mavenBundle("org.ow2.asm", "asm-all").versionAsInProject(),
+ mavenBundle("org.apache.aries.proxy", "org.apache.aries.proxy").versionAsInProject(),
+ mavenBundle("org.apache.aries.transaction", "org.apache.aries.transaction.blueprint").versionAsInProject(),
+ 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.utils").versionAsInProject(),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.default.local.platform").versionAsInProject(),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.modeller").versionAsInProject(),
+ mavenBundle("org.apache.felix", "org.apache.felix.bundlerepository").versionAsInProject(),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.resolver.obr").versionAsInProject(),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.resolve.transform.cm").versionAsInProject(),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.deployment.management").versionAsInProject(),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.management").versionAsInProject(),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.runtime.isolated").versionAsInProject(),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.runtime.framework").versionAsInProject(),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.runtime.framework.management").versionAsInProject(),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.runtime.repository").versionAsInProject(),
+ mavenBundle("org.apache.felix", "org.apache.felix.configadmin").versionAsInProject(),
+ mavenBundle("org.apache.geronimo.specs", "geronimo-jta_1.1_spec").versionAsInProject(),
+ mavenBundle("org.ops4j.pax.url", "pax-url-aether").versionAsInProject());
}
/**
* High level interface for executing a unit of work
- *
*
* @version $Rev$ $Date$
*/
- private static interface Task
- {
+ private static interface Task {
/**
* Executes the task logic
- *
+ *
* @return if the task was successful
* @throws Exception
*/
public boolean execute() throws Exception;
}
-
+
/**
* Base class for a task implementation
- *
*
* @version $Rev$ $Date$
*/
- private static abstract class BaseTask implements Task
- {
+ private static abstract class BaseTask implements Task {
private BundleContext ctx;
-
+
public BaseTask(BundleContext ctx) {
this.ctx = ctx;
}
-
+
protected BundleContext getBundleContext() {
return ctx;
}
}
-
+
/**
* Trackable task that allows a service tracker to pickup service registration/un-registration events using the
* supplied filter. Remember that if a service exists matching a filter while opening the underlying tracker
* it will cause a addedService event to be fired, this must be taken into account when instantiating this type
* task. For example if you had a ManagedService present in the container matching the given filter, you should
* set the expected registerCount as 2 if you expect a re-register to occur due to a container reload etc.
- *
*
* @version $Rev$ $Date$
*/
- public static abstract class TrackableTask extends BaseTask implements Task, ServiceTrackerCustomizer
- {
+ public static abstract class TrackableTask extends BaseTask implements Task, ServiceTrackerCustomizer {
private static final long DEFAULT_TIMEOUT = 5000;
-
+
private String filter;
private ServiceTracker tracker;
private CountDownLatch addedLatch;
private CountDownLatch removedLatch;
-
+
public TrackableTask(BundleContext ctx, String filter) {
this(ctx, filter, 1, 1);
}
-
+
public TrackableTask(BundleContext ctx, String filter, int registerCount) {
this(ctx, filter, registerCount, 0);
}
-
+
public TrackableTask(BundleContext ctx, String filter, int registerCount, int unregisterCount) {
super(ctx);
-
+
this.filter = filter;
this.addedLatch = new CountDownLatch(registerCount);
this.removedLatch = new CountDownLatch(unregisterCount);
this.tracker = null;
}
-
+
/**
* Initiates the underlying service tracker
- *
+ *
* @throws InvalidSyntaxException
*/
protected synchronized void beginTracking() throws InvalidSyntaxException {
@@ -479,7 +482,7 @@ public class IsolatedCfgAdminRuntimeTest
tracker.open();
}
}
-
+
/**
* Stops and clears the underlying service tracker
*/
@@ -489,28 +492,27 @@ public class IsolatedCfgAdminRuntimeTest
tracker = null;
}
}
-
+
/*
* (non-Javadoc)
* @see org.apache.aries.application.runtime.itests.IsolatedCfgAdminRuntimeTest.Task#execute()
*/
public boolean execute() throws Exception {
boolean result = true;
-
+
try {
beginTracking();
doExecute();
result &= addedLatch.await(DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS);
result &= removedLatch.await(DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS);
- }
- finally {
+ } finally {
endTracking();
}
-
+
return result;
}
-
+
/*
* (non-Javadoc)
* @see org.osgi.util.tracker.ServiceTrackerCustomizer#addingService(org.osgi.framework.ServiceReference)
@@ -524,7 +526,7 @@ public class IsolatedCfgAdminRuntimeTest
* (non-Javadoc)
* @see org.osgi.util.tracker.ServiceTrackerCustomizer#modifiedService(org.osgi.framework.ServiceReference, java.lang.Object)
*/
- public void modifiedService(ServiceReference serviceRef, Object service) {
+ public void modifiedService(ServiceReference serviceRef, Object service) {
}
/*
@@ -534,10 +536,10 @@ public class IsolatedCfgAdminRuntimeTest
public synchronized void removedService(ServiceReference serviceRef, Object service) {
removedLatch.countDown();
}
-
+
/**
* Performs the task logic
- *
+ *
* @throws Exception
*/
protected abstract void doExecute() throws Exception;
@@ -547,17 +549,16 @@ public class IsolatedCfgAdminRuntimeTest
* The configuration task is responsible for executing a configuration update within the scope
* of the given context. Note, this task assumes the class space is inconsistent will not try
* casting to classes that may exist in the test world and also in the application.
- *
+ *
* @version $Rev$ $Date$
*/
- private static class ConfigurationTask extends BaseTask
- {
+ private static class ConfigurationTask extends BaseTask {
private String pid;
private Dictionary<String, String> dictionary;
-
- public ConfigurationTask(BundleContext ctx, String pid, Dictionary<String, String> dictionary) {
+
+ public ConfigurationTask(BundleContext ctx, String pid, Dictionary<String, String> dictionary) {
super(ctx);
-
+
this.pid = pid;
this.dictionary = dictionary;
}
@@ -568,42 +569,39 @@ public class IsolatedCfgAdminRuntimeTest
*/
public boolean execute() throws Exception {
boolean result = false;
- ServiceTracker tracker = new ServiceTracker(getBundleContext(), getBundleContext().createFilter("(" + Constants.OBJECTCLASS + "=" + ConfigurationAdmin.class.getName() + ")"), null);
-
+ ServiceTracker tracker = new ServiceTracker(getBundleContext(), getBundleContext().createFilter("(" + Constants.OBJECTCLASS + "=" + ConfigurationAdmin.class.getName() + ")"), null);
+
try {
tracker.open();
Object cfgAdminService = tracker.waitForService(5000);
-
+
if (cfgAdminService != null) {
-
+
ConfigurationAdmin proxy = Skeleton.newMock(cfgAdminService, ConfigurationAdmin.class);
Configuration configuration = proxy.getConfiguration(pid);
configuration.setBundleLocation(null);
configuration.update(dictionary);
result = true;
}
- }
- finally {
+ } finally {
tracker.close();
}
-
+
return result;
}
}
-
+
/**
* Simple monitor class to keep track of services using the supplied filter, acts as a wrapper
* so that it can be placed in side a composite task.
- *
*
* @version $Rev$ $Date$
*/
- private static final class MonitorTask extends TrackableTask
- {
+ private static final class MonitorTask extends TrackableTask {
public MonitorTask(BundleContext ctx, String filter, int registerCount, int unregisterCount) {
super(ctx, filter, registerCount, unregisterCount);
}
-
+
/*
* (non-Javadoc)
* @see org.apache.aries.application.runtime.itests.IsolatedCfgAdminRuntimeTest.TrackableTask#doExecute()
@@ -612,31 +610,74 @@ public class IsolatedCfgAdminRuntimeTest
protected void doExecute() throws Exception {
//do nothing, we just care about tracking
}
-
+
}
-
+
/**
* Simple wrapper for the various contexts required in this test suite
- *
*
* @version $Rev$ $Date$
*/
- private static class Context
- {
+ private static class Context {
private AriesApplicationContext applicationContext;
private RichBundleContext bundleContext;
-
+
public Context(AriesApplicationContext applicationContext, BundleContext bundleContext) {
this.applicationContext = applicationContext;
this.bundleContext = new RichBundleContext(bundleContext);
}
-
+
public AriesApplicationContext getApplicationContext() {
return applicationContext;
}
-
+
public RichBundleContext getBundleContext() {
return bundleContext;
}
}
+
+ public static MavenArtifactProvisionOption mavenBundleInTest(ClassLoader loader, String groupId, String artifactId) {
+ return mavenBundle().groupId(groupId).artifactId(artifactId)
+ .version(getArtifactVersion(loader, groupId, artifactId));
+ }
+
+ //TODO getArtifactVersion and getFileFromClasspath are borrowed and modified from pax-exam. They should be moved back ASAP.
+ private static String getArtifactVersion(ClassLoader loader, final String groupId, final String artifactId) {
+ final Properties dependencies = new Properties();
+ try {
+ InputStream in = getFileFromClasspath(loader, "META-INF/maven/dependencies.properties");
+ try {
+ dependencies.load(in);
+ } finally {
+ in.close();
+ }
+ final String version = dependencies.getProperty(groupId + "/" + artifactId + "/version");
+ if (version == null) {
+ throw new RuntimeException(
+ "Could not resolve version. Do you have a dependency for " + groupId + "/" + artifactId
+ + " in your maven project?"
+ );
+ }
+ return version;
+ } catch (IOException e) {
+ // TODO throw a better exception
+ throw new RuntimeException(
+ "Could not resolve version. Did you configured the plugin in your maven project?"
+ + "Or maybe you did not run the maven build and you are using an IDE?"
+ );
+ }
+ }
+
+ private static InputStream getFileFromClasspath(ClassLoader loader, final String filePath)
+ throws FileNotFoundException {
+ try {
+ URL fileURL = loader.getResource(filePath);
+ if (fileURL == null) {
+ throw new FileNotFoundException("File [" + filePath + "] could not be found in classpath");
+ }
+ return fileURL.openStream();
+ } catch (IOException e) {
+ throw new FileNotFoundException("File [" + filePath + "] could not be found: " + e.getMessage());
+ }
+ }
}
Modified: aries/branches/subsystemsR6/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/IsolatedRuntimeTest.java
URL: http://svn.apache.org/viewvc/aries/branches/subsystemsR6/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/IsolatedRuntimeTest.java?rev=1606837&r1=1606836&r2=1606837&view=diff
==============================================================================
--- aries/branches/subsystemsR6/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/IsolatedRuntimeTest.java (original)
+++ aries/branches/subsystemsR6/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/IsolatedRuntimeTest.java Mon Jun 30 16:54:57 2014
@@ -18,15 +18,11 @@
*/
package org.apache.aries.application.runtime.itests;
-import static org.apache.aries.itest.ExtraOptions.flatOptions;
-import static org.apache.aries.itest.ExtraOptions.mavenBundle;
-import static org.apache.aries.itest.ExtraOptions.paxLogging;
-import static org.apache.aries.itest.ExtraOptions.testOptions;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
-import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.repository;
+import static org.ops4j.pax.exam.CoreOptions.*;
import java.io.File;
import java.io.FileOutputStream;
@@ -48,312 +44,310 @@ import org.apache.aries.util.filesystem.
import org.apache.aries.util.manifest.ManifestHeaderProcessor;
import org.apache.felix.bundlerepository.RepositoryAdmin;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
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.MavenConfiguredJUnit4TestRunner;
+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.BundleEvent;
import org.osgi.framework.SynchronousBundleListener;
import org.osgi.service.framework.CompositeBundle;
-@RunWith(MavenConfiguredJUnit4TestRunner.class)
+@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerClass.class)
public class IsolatedRuntimeTest extends AbstractIntegrationTest {
-
- /* Use @Before not @BeforeClass so as to ensure that these resources
- * are created in the paxweb temp directory, and not in the svn tree
- */
- static boolean createdApplications = false;
- @Before
- public static void createApplications() throws Exception {
-
- if (createdApplications) {
- return;
+
+ /* Use @Before not @BeforeClass so as to ensure that these resources
+ * are created in the paxweb temp directory, and not in the svn tree
+ */
+ static boolean createdApplications = false;
+
+ @Before
+ public void createApplications() throws Exception {
+
+ if (createdApplications) {
+ return;
+ }
+ ZipFixture testEba = ArchiveFixture.newZip()
+ .jar("sample.jar")
+ .manifest().symbolicName("org.apache.aries.isolated.sample")
+ .attribute("Bundle-Version", "1.0.0")
+ .attribute("Import-Package", "org.osgi.service.blueprint, org.apache.aries.isolated.shared")
+ // needed for testFrameworkResolvedBeforeInnerBundlesStart()
+ .attribute("Bundle-ActivationPolicy", "lazy")
+ .end()
+ .binary("org/apache/aries/isolated/sample/HelloWorld.class",
+ IsolatedRuntimeTest.class.getClassLoader().getResourceAsStream("org/apache/aries/isolated/sample/HelloWorld.class"))
+ .binary("org/apache/aries/isolated/sample/HelloWorldImpl.class",
+ IsolatedRuntimeTest.class.getClassLoader().getResourceAsStream("org/apache/aries/isolated/sample/HelloWorldImpl.class"))
+ .binary("org/apache/aries/isolated/sample/SharedImpl.class",
+ IsolatedRuntimeTest.class.getClassLoader().getResourceAsStream("org/apache/aries/isolated/sample/SharedImpl.class"))
+ .binary("OSGI-INF/blueprint/sample-blueprint.xml",
+ IsolatedRuntimeTest.class.getClassLoader().getResourceAsStream("isolated/sample-blueprint.xml"))
+ .end()
+ .jar("shared.jar")
+ .manifest().symbolicName("org.apache.aries.isolated.shared")
+ .attribute("Bundle-Version", "1.0.0")
+ .attribute("Export-Package", "org.apache.aries.isolated.shared")
+ .end()
+ .binary("org/apache/aries/isolated/shared/Shared.class",
+ IsolatedRuntimeTest.class.getClassLoader().getResourceAsStream("org/apache/aries/isolated/shared/Shared.class"))
+ .end();
+
+ FileOutputStream fout = new FileOutputStream("test.eba");
+ testEba.writeOut(fout);
+ fout.close();
+
+ ZipFixture testEba2 = testEba.binary("META-INF/APPLICATION.MF",
+ IsolatedRuntimeTest.class.getClassLoader().getResourceAsStream("isolated/APPLICATION.MF"))
+ .end();
+ fout = new FileOutputStream("test2.eba");
+ testEba2.writeOut(fout);
+ fout.close();
+
+ ZipFixture sampleJar2 = ArchiveFixture.newJar()
+ .manifest().symbolicName("org.apache.aries.isolated.sample")
+ .attribute("Bundle-Version", "2.0.0")
+ .end()
+ .binary("org/apache/aries/isolated/sample/HelloWorld.class",
+ IsolatedRuntimeTest.class.getClassLoader().getResourceAsStream("org/apache/aries/isolated/sample/HelloWorld.class"))
+ .binary("org/apache/aries/isolated/sample/HelloWorldImpl.class",
+ IsolatedRuntimeTest.class.getClassLoader().getResourceAsStream("org/apache/aries/isolated/sample/HelloWorldImpl.class"))
+ .binary("OSGI-INF/blueprint/aries.xml",
+ IsolatedRuntimeTest.class.getClassLoader().getResourceAsStream("isolated/sample2-blueprint.xml"))
+ .end();
+
+ fout = new FileOutputStream("sample_2.0.0.jar");
+ sampleJar2.writeOut(fout);
+ fout.close();
+
+ ZipFixture ebaWithFragment = ArchiveFixture.newZip()
+ .jar("sample.jar")
+ .manifest().symbolicName("org.apache.aries.isolated.sample")
+ .attribute("Bundle-Version", "1.0.0")
+ .end()
+ .end()
+ .jar("fragment.jar")
+ .manifest().symbolicName("org.apache.aries.isolated.fragment")
+ .attribute("Bundle-Version", "1.0.0")
+ .attribute("Fragment-Host", "org.apache.aries.isolated.sample")
+ .end()
+ .binary("org/apache/aries/isolated/sample/HelloWorld.class",
+ IsolatedRuntimeTest.class.getClassLoader().getResourceAsStream("org/apache/aries/isolated/sample/HelloWorld.class"))
+ .binary("org/apache/aries/isolated/sample/HelloWorldImpl.class",
+ IsolatedRuntimeTest.class.getClassLoader().getResourceAsStream("org/apache/aries/isolated/sample/HelloWorldImpl.class"))
+ .binary("OSGI-INF/blueprint/sample-blueprint.xml",
+ IsolatedRuntimeTest.class.getClassLoader().getResourceAsStream("isolated/sample-blueprint.xml"))
+ .end();
+
+ fout = new FileOutputStream("withFragment.eba");
+ ebaWithFragment.writeOut(fout);
+ fout.close();
+
+ createdApplications = true;
+ }
+
+ @Test
+ @Ignore
+ public void testAppWithoutApplicationManifest() throws Exception {
+
+ AriesApplicationManager manager = context().getService(AriesApplicationManager.class);
+ AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("test.eba")));
+ AriesApplicationContext ctx = manager.install(app);
+
+ ctx.start();
+ assertHelloWorldService("test.eba");
+
+ manager.uninstall(ctx);
+ }
+
+ @Test
+ @Ignore
+ public void testAppWithApplicationManifest() throws Exception {
+
+ AriesApplicationManager manager = context().getService(AriesApplicationManager.class);
+ AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("test2.eba")));
+ AriesApplicationContext ctx = manager.install(app);
+
+ ctx.start();
+ assertHelloWorldService("org.apache.aries.sample2");
+
+ manager.uninstall(ctx);
+ }
+
+ @Test
+ @Ignore
+ public void testUninstallReinstall() throws Exception {
+
+ AriesApplicationManager manager = context().getService(AriesApplicationManager.class);
+ AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("test2.eba")));
+ AriesApplicationContext ctx = manager.install(app);
+
+ app = ctx.getApplication();
+
+ ctx.start();
+
+ assertHelloWorldService("org.apache.aries.sample2");
+
+ ctx.stop();
+ manager.uninstall(ctx);
+
+ assertNull(IsolationTestUtils.findIsolatedAppBundleContext(bundleContext, "org.apache.aries.sample2"));
+
+ ctx = manager.install(app);
+ ctx.start();
+
+ assertHelloWorldService("org.apache.aries.sample2");
+
+ manager.uninstall(ctx);
+ }
+
+ @Test
+ @Ignore
+ public void testAppWithFragment() throws Exception {
+ AriesApplicationManager manager = context().getService(AriesApplicationManager.class);
+ AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("withFragment.eba")));
+ AriesApplicationContext ctx = manager.install(app);
+
+ ctx.start();
+
+ assertHelloWorldService("withFragment.eba");
+
+ manager.uninstall(ctx);
}
- ZipFixture testEba = ArchiveFixture.newZip()
- .jar("sample.jar")
- .manifest().symbolicName("org.apache.aries.isolated.sample")
- .attribute("Bundle-Version", "1.0.0")
- .attribute("Import-Package", "org.osgi.service.blueprint, org.apache.aries.isolated.shared")
- // needed for testFrameworkResolvedBeforeInnerBundlesStart()
- .attribute("Bundle-ActivationPolicy", "lazy")
- .end()
- .binary("org/apache/aries/isolated/sample/HelloWorld.class",
- IsolatedRuntimeTest.class.getClassLoader().getResourceAsStream("org/apache/aries/isolated/sample/HelloWorld.class"))
- .binary("org/apache/aries/isolated/sample/HelloWorldImpl.class",
- IsolatedRuntimeTest.class.getClassLoader().getResourceAsStream("org/apache/aries/isolated/sample/HelloWorldImpl.class"))
- .binary("org/apache/aries/isolated/sample/SharedImpl.class",
- IsolatedRuntimeTest.class.getClassLoader().getResourceAsStream("org/apache/aries/isolated/sample/SharedImpl.class"))
- .binary("OSGI-INF/blueprint/sample-blueprint.xml",
- IsolatedRuntimeTest.class.getClassLoader().getResourceAsStream("isolated/sample-blueprint.xml"))
- .end()
- .jar("shared.jar")
- .manifest().symbolicName("org.apache.aries.isolated.shared")
- .attribute("Bundle-Version", "1.0.0")
- .attribute("Export-Package", "org.apache.aries.isolated.shared")
- .end()
- .binary("org/apache/aries/isolated/shared/Shared.class",
- IsolatedRuntimeTest.class.getClassLoader().getResourceAsStream("org/apache/aries/isolated/shared/Shared.class"))
- .end();
-
- FileOutputStream fout = new FileOutputStream("test.eba");
- testEba.writeOut(fout);
- fout.close();
-
- ZipFixture testEba2 = testEba.binary("META-INF/APPLICATION.MF",
- IsolatedRuntimeTest.class.getClassLoader().getResourceAsStream("isolated/APPLICATION.MF"))
- .end();
- fout = new FileOutputStream("test2.eba");
- testEba2.writeOut(fout);
- fout.close();
-
- ZipFixture sampleJar2 = ArchiveFixture.newJar()
- .manifest().symbolicName("org.apache.aries.isolated.sample")
- .attribute("Bundle-Version", "2.0.0")
- .end()
- .binary("org/apache/aries/isolated/sample/HelloWorld.class",
- IsolatedRuntimeTest.class.getClassLoader().getResourceAsStream("org/apache/aries/isolated/sample/HelloWorld.class"))
- .binary("org/apache/aries/isolated/sample/HelloWorldImpl.class",
- IsolatedRuntimeTest.class.getClassLoader().getResourceAsStream("org/apache/aries/isolated/sample/HelloWorldImpl.class"))
- .binary("OSGI-INF/blueprint/aries.xml",
- IsolatedRuntimeTest.class.getClassLoader().getResourceAsStream("isolated/sample2-blueprint.xml"))
- .end();
-
- fout = new FileOutputStream("sample_2.0.0.jar");
- sampleJar2.writeOut(fout);
- fout.close();
-
- ZipFixture ebaWithFragment = ArchiveFixture.newZip()
- .jar("sample.jar")
- .manifest().symbolicName("org.apache.aries.isolated.sample")
- .attribute("Bundle-Version", "1.0.0")
- .end()
- .end()
- .jar("fragment.jar")
- .manifest().symbolicName("org.apache.aries.isolated.fragment")
- .attribute("Bundle-Version", "1.0.0")
- .attribute("Fragment-Host", "org.apache.aries.isolated.sample")
- .end()
- .binary("org/apache/aries/isolated/sample/HelloWorld.class",
- IsolatedRuntimeTest.class.getClassLoader().getResourceAsStream("org/apache/aries/isolated/sample/HelloWorld.class"))
- .binary("org/apache/aries/isolated/sample/HelloWorldImpl.class",
- IsolatedRuntimeTest.class.getClassLoader().getResourceAsStream("org/apache/aries/isolated/sample/HelloWorldImpl.class"))
- .binary("OSGI-INF/blueprint/sample-blueprint.xml",
- IsolatedRuntimeTest.class.getClassLoader().getResourceAsStream("isolated/sample-blueprint.xml"))
- .end();
-
- fout = new FileOutputStream("withFragment.eba");
- ebaWithFragment.writeOut(fout);
- fout.close();
-
- createdApplications = true;
- }
-
- @Test
- public void testAppWithoutApplicationManifest() throws Exception {
-
- AriesApplicationManager manager = context().getService(AriesApplicationManager.class);
- AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("test.eba")));
- AriesApplicationContext ctx = manager.install(app);
-
- ctx.start();
- assertHelloWorldService("test.eba");
-
- manager.uninstall(ctx);
- }
-
- @Test
- public void testAppWithApplicationManifest() throws Exception {
-
- AriesApplicationManager manager = context().getService(AriesApplicationManager.class);
- AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("test2.eba")));
- AriesApplicationContext ctx = manager.install(app);
-
- ctx.start();
- assertHelloWorldService("org.apache.aries.sample2");
-
- manager.uninstall(ctx);
- }
-
- @Test
- public void testUninstallReinstall() throws Exception {
-
- AriesApplicationManager manager = context().getService(AriesApplicationManager.class);
- AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("test2.eba")));
- AriesApplicationContext ctx = manager.install(app);
-
- app = ctx.getApplication();
-
- ctx.start();
-
- assertHelloWorldService("org.apache.aries.sample2");
-
- ctx.stop();
- manager.uninstall(ctx);
-
- assertNull(IsolationTestUtils.findIsolatedAppBundleContext(bundleContext, "org.apache.aries.sample2"));
-
- ctx = manager.install(app);
- ctx.start();
-
- assertHelloWorldService("org.apache.aries.sample2");
-
- manager.uninstall(ctx);
- }
-
- @Test
- public void testAppWithFragment() throws Exception
- {
- AriesApplicationManager manager = context().getService(AriesApplicationManager.class);
- AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("withFragment.eba")));
- AriesApplicationContext ctx = manager.install(app);
-
- ctx.start();
-
- assertHelloWorldService("withFragment.eba");
-
- manager.uninstall(ctx);
- }
-
- @Test
- public void testAppWithGlobalRepositoryBundle() throws Exception
- {
- AriesApplicationManager manager = context().getService(AriesApplicationManager.class);
- AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("test2.eba")));
-
- IsolationTestUtils.prepareSampleBundleV2(bundleContext,
- context().getService(RepositoryGenerator.class),
- context().getService(RepositoryAdmin.class),
- context().getService(ModellingManager.class));
-
- AriesApplication newApp = manager.resolve(app, new ResolveConstraint() {
- @Override
- public String getBundleName() {
- return "org.apache.aries.isolated.sample";
- }
-
- @Override
- public VersionRange getVersionRange() {
- return ManifestHeaderProcessor.parseVersionRange("[2.0.0,2.0.0]", true);
- }
- });
-
- AriesApplicationContext ctx = manager.install(newApp);
- ctx.start();
-
- assertHelloWorldService("org.apache.aries.sample2", "hello brave new world");
-
- manager.uninstall(ctx);
- }
-
- @Test
- public void testFrameworkResolvedBeforeInnerBundlesStart() throws Exception {
+
+ @Test
+ @Ignore
+ public void testAppWithGlobalRepositoryBundle() throws Exception {
+ AriesApplicationManager manager = context().getService(AriesApplicationManager.class);
+ AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("test2.eba")));
+
+ IsolationTestUtils.prepareSampleBundleV2(bundleContext,
+ context().getService(RepositoryGenerator.class),
+ context().getService(RepositoryAdmin.class),
+ context().getService(ModellingManager.class));
+
+ AriesApplication newApp = manager.resolve(app, new ResolveConstraint() {
+ @Override
+ public String getBundleName() {
+ return "org.apache.aries.isolated.sample";
+ }
+
+ @Override
+ public VersionRange getVersionRange() {
+ return ManifestHeaderProcessor.parseVersionRange("[2.0.0,2.0.0]", true);
+ }
+ });
+
+ AriesApplicationContext ctx = manager.install(newApp);
+ ctx.start();
+
+ assertHelloWorldService("org.apache.aries.sample2", "hello brave new world");
+
+ manager.uninstall(ctx);
+ }
+
+ @Test
+ @Ignore
+ public void testFrameworkResolvedBeforeInnerBundlesStart() throws Exception {
/*
* Lazy bundles have in the past triggered recursive bundle trackers to handle them before
* the composite bundle framework was even resolved. In such a case the below loadClass
* operation on a class that depends on a class imported from the outside of the composite
* will fail with an NPE.
*/
-
- final AtomicBoolean loadedClass = new AtomicBoolean(false);
-
- context().addBundleListener(new SynchronousBundleListener() {
- public void bundleChanged(BundleEvent event) {
- Bundle b = event.getBundle();
- if (event.getType() == BundleEvent.STARTING || event.getType() == BundleEvent.LAZY_ACTIVATION) {
- if (b.getEntry("org/apache/aries/isolated/sample/SharedImpl.class") != null) {
- try {
- Class<?> cl = b.loadClass("org.apache.aries.isolated.sample.SharedImpl");
- cl.newInstance();
- loadedClass.set(true);
- } catch (Exception e) {
- e.printStackTrace();
- throw new RuntimeException(e);
+
+ final AtomicBoolean loadedClass = new AtomicBoolean(false);
+
+ context().addBundleListener(new SynchronousBundleListener() {
+ public void bundleChanged(BundleEvent event) {
+ Bundle b = event.getBundle();
+ if (event.getType() == BundleEvent.STARTING || event.getType() == BundleEvent.LAZY_ACTIVATION) {
+ if (b.getEntry("org/apache/aries/isolated/sample/SharedImpl.class") != null) {
+ try {
+ Class<?> cl = b.loadClass("org.apache.aries.isolated.sample.SharedImpl");
+ cl.newInstance();
+ loadedClass.set(true);
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new RuntimeException(e);
+ }
}
+ } else if (event.getType() == BundleEvent.INSTALLED && b instanceof CompositeBundle) {
+ ((CompositeBundle) b).getCompositeFramework().getBundleContext().addBundleListener(this);
}
- } else if (event.getType() == BundleEvent.INSTALLED && b instanceof CompositeBundle) {
- ((CompositeBundle) b).getCompositeFramework().getBundleContext().addBundleListener(this);
}
+ });
+
+ AriesApplicationManager manager = context().getService(AriesApplicationManager.class);
+ AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("test2.eba")));
+ AriesApplicationContext ctx = manager.install(app);
+
+ try {
+ ctx.start();
+
+ app = ctx.getApplication();
+ assertEquals(1, app.getDeploymentMetadata().getApplicationDeploymentContents().size());
+ assertEquals(1, app.getDeploymentMetadata().getApplicationProvisionBundles().size());
+ assertTrue(loadedClass.get());
+ } finally {
+ manager.uninstall(ctx);
}
- });
-
- AriesApplicationManager manager = context().getService(AriesApplicationManager.class);
- AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("test2.eba")));
- AriesApplicationContext ctx = manager.install(app);
-
- try {
- ctx.start();
-
- app = ctx.getApplication();
- assertEquals(1, app.getDeploymentMetadata().getApplicationDeploymentContents().size());
- assertEquals(1, app.getDeploymentMetadata().getApplicationProvisionBundles().size());
- assertTrue(loadedClass.get());
- } finally {
- manager.uninstall(ctx);
}
- }
-
- private void assertHelloWorldService(String appName) throws Exception
- {
- assertHelloWorldService(appName, "hello world");
- }
-
- private void assertHelloWorldService(String appName, String message) throws Exception
- {
- HelloWorld hw = IsolationTestUtils.findHelloWorldService(bundleContext, appName);
- assertNotNull("The Hello World service could not be found.", hw);
- assertEquals(message, hw.getMessage());
- }
-
- private static Option[] generalConfiguration() {
- return flatOptions(
- repository( "http://repository.ops4j.org/maven2" ),
-
- paxLogging("DEBUG"),
-
- // do not provision against the local runtime
- // Bundles
- mavenBundle("org.apache.aries.blueprint", "org.apache.aries.blueprint"),
- mavenBundle("org.ow2.asm", "asm-all"),
- mavenBundle("org.apache.aries.proxy", "org.apache.aries.proxy"),
- mavenBundle("org.apache.aries.transaction", "org.apache.aries.transaction.blueprint"),
- mavenBundle("org.apache.aries", "org.apache.aries.util"),
- mavenBundle("org.apache.aries.application", "org.apache.aries.application.api"),
- mavenBundle("org.apache.aries.application", "org.apache.aries.application.utils"),
- mavenBundle("org.apache.aries.application", "org.apache.aries.application.default.local.platform"),
- mavenBundle("org.apache.aries.application", "org.apache.aries.application.modeller"),
- mavenBundle("org.apache.felix", "org.apache.felix.bundlerepository"),
- mavenBundle("org.apache.aries.application", "org.apache.aries.application.resolver.obr"),
- mavenBundle("org.apache.aries.application", "org.apache.aries.application.deployment.management"),
- mavenBundle("org.apache.aries.application", "org.apache.aries.application.management"),
- mavenBundle("org.apache.aries.application", "org.apache.aries.application.runtime.isolated"),
- mavenBundle("org.apache.aries.application", "org.apache.aries.application.runtime.framework"),
- mavenBundle("org.apache.aries.application", "org.apache.aries.application.runtime.framework.management"),
- mavenBundle("org.apache.aries.application", "org.apache.aries.application.runtime.repository"),
- mavenBundle("org.osgi", "org.osgi.compendium"),
- mavenBundle("org.apache.geronimo.specs","geronimo-jta_1.1_spec")
-
- /* For debugging, uncommenting the following two lines and add the imports */
- /*
- * vmOption ("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5011"),
- waitForFrameworkStartup(),*/
-// vmOption ("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5011"),
- /*
- * and add these imports:
- import static org.ops4j.pax.exam.CoreOptions.waitForFrameworkStartup;
- import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.vmOption;
- */
- );
- }
-
- @org.ops4j.pax.exam.junit.Configuration
- public static Option[] configuration()
- {
- return testOptions(
- generalConfiguration(),
- PaxRunnerOptions.rawPaxRunnerOption("config", "classpath:ss-runner.properties")
- );
- }
+
+ private void assertHelloWorldService(String appName) throws Exception {
+ assertHelloWorldService(appName, "hello world");
+ }
+
+ private void assertHelloWorldService(String appName, String message) throws Exception {
+ HelloWorld hw = IsolationTestUtils.findHelloWorldService(bundleContext, appName);
+ assertNotNull("The Hello World service could not be found.", hw);
+ assertEquals(message, hw.getMessage());
+ }
+
+ @Configuration
+ public static Option[] configuration() {
+ return options(
+
+ // framework / core bundles
+ mavenBundle("org.osgi", "org.osgi.core").versionAsInProject(),
+ mavenBundle("org.osgi", "org.osgi.compendium").versionAsInProject(),
+ mavenBundle("org.ops4j.pax.logging", "pax-logging-api").versionAsInProject(),
+ mavenBundle("org.ops4j.pax.logging", "pax-logging-service").versionAsInProject(),
+
+ // Repository
+ repository("http://repository.ops4j.org/maven2"),
+
+ // Logging
+ systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("INFO"),
+
+ // Bundles
+ junitBundles(),
+ mavenBundle("org.apache.aries.testsupport", "org.apache.aries.testsupport.unit").versionAsInProject(),
+
+ // Bundles
+ mavenBundle("org.apache.aries.blueprint", "org.apache.aries.blueprint").versionAsInProject(),
+ mavenBundle("org.ow2.asm", "asm-all").versionAsInProject(),
+ mavenBundle("org.apache.aries.proxy", "org.apache.aries.proxy").versionAsInProject(),
+ mavenBundle("org.apache.aries.transaction", "org.apache.aries.transaction.blueprint").versionAsInProject(),
+ 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.utils").versionAsInProject(),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.default.local.platform").versionAsInProject(),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.modeller").versionAsInProject(),
+ mavenBundle("org.apache.felix", "org.apache.felix.bundlerepository").versionAsInProject(),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.resolver.obr").versionAsInProject(),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.deployment.management").versionAsInProject(),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.management").versionAsInProject(),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.runtime.isolated").versionAsInProject(),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.runtime.framework").versionAsInProject(),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.runtime.framework.management").versionAsInProject(),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.runtime.repository").versionAsInProject(),
+ mavenBundle("org.apache.geronimo.specs", "geronimo-jta_1.1_spec").versionAsInProject());
+ }
}
Modified: aries/branches/subsystemsR6/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/MinimumImportsTest.java
URL: http://svn.apache.org/viewvc/aries/branches/subsystemsR6/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/MinimumImportsTest.java?rev=1606837&r1=1606836&r2=1606837&view=diff
==============================================================================
--- aries/branches/subsystemsR6/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/MinimumImportsTest.java (original)
+++ aries/branches/subsystemsR6/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/MinimumImportsTest.java Mon Jun 30 16:54:57 2014
@@ -18,11 +18,9 @@
*/
package org.apache.aries.application.runtime.itests;
-import static org.apache.aries.itest.ExtraOptions.mavenBundle;
-import static org.apache.aries.itest.ExtraOptions.paxLogging;
-import static org.apache.aries.itest.ExtraOptions.testOptions;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+import static org.ops4j.pax.exam.CoreOptions.*;
import java.io.BufferedReader;
import java.io.File;
@@ -43,169 +41,165 @@ import org.apache.felix.bundlerepository
import org.junit.Before;
import org.junit.Test;
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.MavenConfiguredJUnit4TestRunner;
+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.Constants;
import org.osgi.framework.ServiceRegistration;
import org.osgi.service.blueprint.container.BlueprintEvent;
import org.osgi.service.blueprint.container.BlueprintListener;
-@RunWith(MavenConfiguredJUnit4TestRunner.class)
+@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerClass.class)
public class MinimumImportsTest extends AbstractIntegrationTest {
- /* Use @Before not @BeforeClass so as to ensure that these resources
- * are created in the paxweb temp directory, and not in the svn tree
- */
- static boolean createdApplications = false;
- static String fake_app_management = "application.management.fake";
- @Before
- public static void createApplications() throws Exception {
+ /* Use @Before not @BeforeClass so as to ensure that these resources
+ * are created in the paxweb temp directory, and not in the svn tree
+ */
+ static boolean createdApplications = false;
+ static String fake_app_management = "application.management.fake";
- if (createdApplications) {
- return;
- }
+ @Before
+ public void createApplications() throws Exception {
- // need to fake a application manager to export the service in order to pass the resolving for the client
- // In the real situation, we don't allow customers' bundles to explicitly import the runtime services.
- ZipFixture bundle = ArchiveFixture.newJar().manifest()
- .attribute(Constants.BUNDLE_SYMBOLICNAME, fake_app_management)
- .attribute(Constants.BUNDLE_MANIFESTVERSION, "2")
- .attribute(Constants.BUNDLE_VERSION, "1.0.0").end();
-
- OutputStream out = new FileOutputStream(fake_app_management + ".jar");
- bundle.writeOut(out);
- out.close();
-
-
- ZipFixture testEba = ArchiveFixture.newZip()
- .jar("org.apache.aries.application.itests.minimports.jar")
- .manifest().symbolicName("org.apache.aries.application.itests.minimports")
- .attribute("Bundle-Version", "1.0.0")
- .attribute("Import-Package", "org.apache.aries.application.management")
- .end()
- .binary("org/apache/aries/application/sample/appmgrclient/AppMgrClient.class",
- MinimumImportsTest.class.getClassLoader().getResourceAsStream("org/apache/aries/application/sample/appmgrclient/AppMgrClient.class"))
- .binary("OSGI-INF/blueprint/app-mgr-client.xml",
- MinimumImportsTest.class.getClassLoader().getResourceAsStream("app-mgr-client.xml"))
- .end();
-
- FileOutputStream fout = new FileOutputStream("appmgrclienttest.eba");
- testEba.writeOut(fout);
- fout.close();
-
- StringBuilder repositoryXML = new StringBuilder();
-
- BufferedReader reader = new BufferedReader(new InputStreamReader(MinimumImportsTest.class.getResourceAsStream("/basic/fakeAppMgrServiceRepo.xml")));
- String line;
-
- while ((line = reader.readLine()) != null) {
- repositoryXML.append(line);
- repositoryXML.append("\r\n");
- }
+ if (createdApplications) {
+ return;
+ }
- String repo = repositoryXML.toString().replaceAll("bundle_location", new File(fake_app_management + ".jar").toURI().toString());
+ // need to fake a application manager to export the service in order to pass the resolving for the client
+ // In the real situation, we don't allow customers' bundles to explicitly import the runtime services.
+ ZipFixture bundle = ArchiveFixture.newJar().manifest()
+ .attribute(Constants.BUNDLE_SYMBOLICNAME, fake_app_management)
+ .attribute(Constants.BUNDLE_MANIFESTVERSION, "2")
+ .attribute(Constants.BUNDLE_VERSION, "1.0.0").end();
+
+ OutputStream out = new FileOutputStream(fake_app_management + ".jar");
+ bundle.writeOut(out);
+ out.close();
+
+
+ ZipFixture testEba = ArchiveFixture.newZip()
+ .jar("org.apache.aries.application.itests.minimports.jar")
+ .manifest().symbolicName("org.apache.aries.application.itests.minimports")
+ .attribute("Bundle-Version", "1.0.0")
+ .attribute("Import-Package", "org.apache.aries.application.management")
+ .end()
+ .binary("org/apache/aries/application/sample/appmgrclient/AppMgrClient.class",
+ MinimumImportsTest.class.getClassLoader().getResourceAsStream("org/apache/aries/application/sample/appmgrclient/AppMgrClient.class"))
+ .binary("OSGI-INF/blueprint/app-mgr-client.xml",
+ MinimumImportsTest.class.getClassLoader().getResourceAsStream("app-mgr-client.xml"))
+ .end();
+
+ FileOutputStream fout = new FileOutputStream("appmgrclienttest.eba");
+ testEba.writeOut(fout);
+ fout.close();
+
+ StringBuilder repositoryXML = new StringBuilder();
+
+ BufferedReader reader = new BufferedReader(new InputStreamReader(MinimumImportsTest.class.getResourceAsStream("/basic/fakeAppMgrServiceRepo.xml")));
+ String line;
+
+ while ((line = reader.readLine()) != null) {
+ repositoryXML.append(line);
+ repositoryXML.append("\r\n");
+ }
- System.out.println(repo);
+ String repo = repositoryXML.toString().replaceAll("bundle_location", new File(fake_app_management + ".jar").toURI().toString());
- FileWriter writer = new FileWriter("repository.xml");
- writer.write(repo);
- writer.close();
- createdApplications = true;
- }
+ System.out.println(repo);
- public static class AppMgrClientBlueprintListener implements BlueprintListener {
+ FileWriter writer = new FileWriter("repository.xml");
+ writer.write(repo);
+ writer.close();
+ createdApplications = true;
+ }
- Boolean success = null;
+ public static class AppMgrClientBlueprintListener implements BlueprintListener {
- public void blueprintEvent(BlueprintEvent event) {
- if (event.getBundle().getSymbolicName().equals(
- "org.apache.aries.application.itests.minimports")) {
- if (event.getType() == event.FAILURE) {
- success = Boolean.FALSE;
- }
- if (event.getType() == event.CREATED) {
- success = Boolean.TRUE;
+ Boolean success = null;
+
+ public void blueprintEvent(BlueprintEvent event) {
+ if (event.getBundle().getSymbolicName().equals(
+ "org.apache.aries.application.itests.minimports")) {
+ if (event.getType() == event.FAILURE) {
+ success = Boolean.FALSE;
+ }
+ if (event.getType() == event.CREATED) {
+ success = Boolean.TRUE;
+ }
+ }
}
- }
}
- }
- @Test
- public void testAppUsingAriesApplicationManager() throws Exception {
+ @Test
+ public void testAppUsingAriesApplicationManager() throws Exception {
- // Register a BlueprintListener to listen for the events from the BlueprintContainer for the bundle in the appmgrclienttest.eba
+ // Register a BlueprintListener to listen for the events from the BlueprintContainer for the bundle in the appmgrclienttest.eba
- AppMgrClientBlueprintListener acbl = new AppMgrClientBlueprintListener();
- ServiceRegistration sr = bundleContext.registerService("org.osgi.service.blueprint.container.BlueprintListener", acbl, null);
+ AppMgrClientBlueprintListener acbl = new AppMgrClientBlueprintListener();
+ ServiceRegistration sr = bundleContext.registerService("org.osgi.service.blueprint.container.BlueprintListener", acbl, null);
- AriesApplicationManager manager = context().getService(AriesApplicationManager.class);
- AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("appmgrclienttest.eba")));
- RepositoryAdmin repositoryAdmin = context().getService(RepositoryAdmin.class);
+ AriesApplicationManager manager = context().getService(AriesApplicationManager.class);
+ AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("appmgrclienttest.eba")));
+ RepositoryAdmin repositoryAdmin = context().getService(RepositoryAdmin.class);
- Repository[] repos = repositoryAdmin.listRepositories();
- for (Repository repo : repos) {
- repositoryAdmin.removeRepository(repo.getURI());
- }
+ Repository[] repos = repositoryAdmin.listRepositories();
+ for (Repository repo : repos) {
+ repositoryAdmin.removeRepository(repo.getURI());
+ }
- repositoryAdmin.addRepository(new File("repository.xml").toURI().toURL());
+ repositoryAdmin.addRepository(new File("repository.xml").toURI().toURL());
- AriesApplicationContext ctx = manager.install(app);
- ctx.start();
+ AriesApplicationContext ctx = manager.install(app);
+ ctx.start();
- int sleepfor = 3000;
- while ((acbl.success == null || acbl.success == false) && sleepfor > 0) {
- Thread.sleep(100);
- sleepfor-=100;
+ int sleepfor = 3000;
+ while ((acbl.success == null || acbl.success == false) && sleepfor > 0) {
+ Thread.sleep(100);
+ sleepfor -= 100;
+ }
+ assertNotNull("Timed out - didn't receive Blueprint CREATED or FAILURE event", acbl.success);
+ assertTrue("Received Blueprint FAILURE event", acbl.success);
+
+ ctx.stop();
+ manager.uninstall(ctx);
+ sr.unregister();
}
- assertNotNull("Timed out - didn't receive Blueprint CREATED or FAILURE event", acbl.success);
- assertTrue("Received Blueprint FAILURE event", acbl.success);
- ctx.stop();
- manager.uninstall(ctx);
- sr.unregister();
- }
-
- public static Option[] generalConfiguration() {
- return testOptions(
- paxLogging("DEBUG"),
-
- // Bundles
- mavenBundle("org.apache.aries.application", "org.apache.aries.application.api"),
- mavenBundle("org.apache.aries.application", "org.apache.aries.application.utils"),
- mavenBundle("org.apache.aries.application", "org.apache.aries.application.management"),
- mavenBundle("org.apache.aries.application", "org.apache.aries.application.runtime"),
- mavenBundle("org.apache.aries.application", "org.apache.aries.application.runtime.itest.interfaces"),
- mavenBundle("org.apache.aries.application", "org.apache.aries.application.default.local.platform"),
- mavenBundle("org.apache.aries", "org.apache.aries.util"),
- mavenBundle("org.apache.felix", "org.apache.felix.bundlerepository"),
- mavenBundle("org.apache.aries.application", "org.apache.aries.application.resolver.obr"),
- mavenBundle("org.apache.aries.application", "org.apache.aries.application.modeller"),
- mavenBundle("org.apache.aries.application", "org.apache.aries.application.deployment.management"),
- mavenBundle("org.apache.aries.blueprint", "org.apache.aries.blueprint"),
- mavenBundle("org.ow2.asm", "asm-all"),
- mavenBundle("org.apache.aries.proxy", "org.apache.aries.proxy"),
- mavenBundle("org.osgi", "org.osgi.compendium")
-
- /* For debugging, uncomment the next two lines*/
- /*vmOption ("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5007"),
- waitForFrameworkStartup(),*/
-
- /*and add these imports:
- import static org.ops4j.pax.exam.CoreOptions.waitForFrameworkStartup;
- import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.vmOption;*/
-
-
- );
- }
-
- @org.ops4j.pax.exam.junit.Configuration
- public static Option[] configuration()
- {
- return testOptions(
- generalConfiguration(),
- PaxRunnerOptions.rawPaxRunnerOption("config", "classpath:ss-runner.properties")
- );
- }
+ @Configuration
+ public static Option[] configuration() {
+ return options(
+
+ // framework / core bundles
+ mavenBundle("org.osgi", "org.osgi.core").versionAsInProject(),
+ mavenBundle("org.osgi", "org.osgi.compendium").versionAsInProject(),
+ mavenBundle("org.ops4j.pax.logging", "pax-logging-api").versionAsInProject(),
+ mavenBundle("org.ops4j.pax.logging", "pax-logging-service").versionAsInProject(),
+
+ // Logging
+ systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("INFO"),
+
+ // Bundles
+ junitBundles(),
+ mavenBundle("org.apache.aries.testsupport", "org.apache.aries.testsupport.unit").versionAsInProject(),
+
+ // Bundles
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.api").versionAsInProject(),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.utils").versionAsInProject(),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.management").versionAsInProject(),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.runtime").versionAsInProject(),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.runtime.itest.interfaces").versionAsInProject(),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.default.local.platform").versionAsInProject(),
+ mavenBundle("org.apache.aries", "org.apache.aries.util").versionAsInProject(),
+ mavenBundle("org.apache.felix", "org.apache.felix.bundlerepository").versionAsInProject(),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.resolver.obr").versionAsInProject(),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.modeller").versionAsInProject(),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.deployment.management").versionAsInProject(),
+ mavenBundle("org.apache.aries.blueprint", "org.apache.aries.blueprint").versionAsInProject(),
+ mavenBundle("org.ow2.asm", "asm-all").versionAsInProject(),
+ mavenBundle("org.apache.aries.proxy", "org.apache.aries.proxy").versionAsInProject());
+ }
}