Author: jawi
Date: Sun Jan 18 19:58:33 2015
New Revision: 1652841
URL: http://svn.apache.org/r1652841
Log:
Updated used Felix DA:
- fixes a small logical error causing the "stop unaffected bundles"
setting not to work properly;
- added a test case for the default "stop the world" scenario, and
the custom Felix DA setting in which only affected bundles are
stopped.
Modified:
ace/trunk/cnf/localrepo/index.xml
ace/trunk/cnf/localrepo/org.apache.felix.deploymentadmin/org.apache.felix.deploymentadmin-0.9.8.jar
ace/trunk/org.apache.ace.deployment.itest/src/org/apache/ace/it/deployment/DeploymentIntegrationTest.java
Modified: ace/trunk/cnf/localrepo/index.xml
URL:
http://svn.apache.org/viewvc/ace/trunk/cnf/localrepo/index.xml?rev=1652841&r1=1652840&r2=1652841&view=diff
==============================================================================
--- ace/trunk/cnf/localrepo/index.xml (original)
+++ ace/trunk/cnf/localrepo/index.xml Sun Jan 18 19:58:33 2015
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='utf-8'?>
-<repository increment='1421330042658' name='Local'
xmlns='http://www.osgi.org/xmlns/repository/v1.0.0'>
+<repository increment='1421609627484' name='Local'
xmlns='http://www.osgi.org/xmlns/repository/v1.0.0'>
<resource>
<capability namespace='osgi.identity'>
<attribute name='osgi.identity' value='biz.aQute.bnd'/>
@@ -7099,9 +7099,9 @@
<attribute name='version' type='Version' value='0.9.8.SNAPSHOT'/>
</capability>
<capability namespace='osgi.content'>
- <attribute name='osgi.content'
value='d491d3dcd4aa4fc5dded0648d169393cabaf23883ea4775818ed43f306de8b24'/>
+ <attribute name='osgi.content'
value='737e67d9a28131f89fadcf36a3f5c3d46703b569883954275270bb1239c85412'/>
<attribute name='url'
value='org.apache.felix.deploymentadmin/org.apache.felix.deploymentadmin-0.9.8.jar'/>
- <attribute name='size' type='Long' value='100254'/>
+ <attribute name='size' type='Long' value='100235'/>
<attribute name='mime' value='application/vnd.osgi.bundle'/>
</capability>
<capability namespace='osgi.wiring.bundle'>
Modified:
ace/trunk/cnf/localrepo/org.apache.felix.deploymentadmin/org.apache.felix.deploymentadmin-0.9.8.jar
URL:
http://svn.apache.org/viewvc/ace/trunk/cnf/localrepo/org.apache.felix.deploymentadmin/org.apache.felix.deploymentadmin-0.9.8.jar?rev=1652841&r1=1652840&r2=1652841&view=diff
==============================================================================
Binary files - no diff available.
Modified:
ace/trunk/org.apache.ace.deployment.itest/src/org/apache/ace/it/deployment/DeploymentIntegrationTest.java
URL:
http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.deployment.itest/src/org/apache/ace/it/deployment/DeploymentIntegrationTest.java?rev=1652841&r1=1652840&r2=1652841&view=diff
==============================================================================
---
ace/trunk/org.apache.ace.deployment.itest/src/org/apache/ace/it/deployment/DeploymentIntegrationTest.java
(original)
+++
ace/trunk/org.apache.ace.deployment.itest/src/org/apache/ace/it/deployment/DeploymentIntegrationTest.java
Sun Jan 18 19:58:33 2015
@@ -21,12 +21,12 @@ package org.apache.ace.it.deployment;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
-import java.util.ArrayList;
import java.util.Arrays;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
import java.util.Properties;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
@@ -53,50 +53,161 @@ import org.osgi.service.event.EventConst
import org.osgi.service.event.EventHandler;
import org.osgi.service.http.HttpService;
-@SuppressWarnings("restriction")
public class DeploymentIntegrationTest extends IntegrationTestBase implements
BundleListener, EventHandler {
- protected void configureProvisionedServices() throws IOException {
- m_tempDir = File.createTempFile("test", "");
- m_tempDir.delete();
- m_tempDir.mkdir();
+ /**
+ * Input stream wrapper that creates an input stream that breaks after N
bytes. When it breaks, it will throw an IO
+ * exception and sends a notification to the semaphore that allows the
overall test to continue.
+ */
+ private class BrokenInputStream extends InputStream {
+ private final InputStream m_normalStream;
+ private int m_bytesUntilBreakdown;
+ private boolean m_isBroken;
+
+ public BrokenInputStream(InputStream normalStream, int
bytesUntilBreakdown) {
+ m_normalStream = normalStream;
+ m_bytesUntilBreakdown = bytesUntilBreakdown;
+ }
+
+ @Override
+ public void close() throws IOException {
+ m_normalStream.close();
+ breakStream();
+ }
+
+ @Override
+ public int read() throws IOException {
+ if (m_bytesUntilBreakdown-- < 1) {
+ breakStream();
+ }
+ return m_normalStream.read();
+ }
+
+ private synchronized void breakStream() throws IOException {
+ if (!m_isBroken) {
+ m_isBroken = true;
+
+ // release the semaphore to continue the test
+ m_semaphore.release();
+ }
+ throw new IOException("Stream broken.");
+ }
+
}
- protected Component[] getDependencies() {
- return new Component[] {
- createComponent()
- .setImplementation(this)
-
.add(createServiceDependency().setService(HttpService.class).setRequired(true))
-
.add(createServiceDependency().setService(ConfigurationAdmin.class).setRequired(true))
-
.add(createServiceDependency().setService(DeploymentAdmin.class).setRequired(true)),
- };
+ /**
+ * Wrapper around the deployment admin that will fail once, after N bytes.
+ */
+ private class FailingDeploymentAdmin implements DeploymentAdmin {
+ private final DeploymentAdmin m_deploymentAdmin;
+ private boolean m_wasBroken;
+ private final int m_failAfterBytes;
+
+ public FailingDeploymentAdmin(DeploymentAdmin deploymentAdmin, int
failAfterBytes) {
+ m_deploymentAdmin = deploymentAdmin;
+ m_failAfterBytes = failAfterBytes;
+ }
+
+ public boolean cancel() {
+ return m_deploymentAdmin.cancel();
+ }
+
+ public DeploymentPackage getDeploymentPackage(Bundle bundle) {
+ return m_deploymentAdmin.getDeploymentPackage(bundle);
+ }
+
+ public DeploymentPackage getDeploymentPackage(String symbName) {
+ return m_deploymentAdmin.getDeploymentPackage(symbName);
+ }
+
+ public DeploymentPackage installDeploymentPackage(InputStream in)
throws DeploymentException {
+ synchronized (this) {
+ if (!m_wasBroken) {
+ m_wasBroken = true;
+ in = new BrokenInputStream(in, m_failAfterBytes);
+ }
+ }
+ return m_deploymentAdmin.installDeploymentPackage(in);
+ }
+
+ public DeploymentPackage[] listDeploymentPackages() {
+ return m_deploymentAdmin.listDeploymentPackages();
+ }
}
public static final String HOST = "localhost";
- public static final String GWID = "gw-id";
+ public static final String TARGET_ID = "test-target";
public static final String POLL_INTERVAL = "1000";
+ public static final String STOP_UNAFFECTED_BUNDLES =
"org.apache.felix.deploymentadmin.stopUnaffectedBundles";
+
+ private final Semaphore m_semaphore = new Semaphore(0);
+ private final ConcurrentMap<Integer, CopyOnWriteArrayList<Bundle>>
m_events = new ConcurrentHashMap<Integer, CopyOnWriteArrayList<Bundle>>();
+
private volatile ConfigurationAdmin m_config;
private volatile DeploymentAdmin m_deployment;
private volatile File m_tempDir;
- private final Semaphore m_semaphore = new Semaphore(0);
- Map<Integer, List<Bundle>> m_events = new HashMap<Integer, List<Bundle>>();
- private ServiceRegistration m_deploymentAdminProxyRegistration;
+ private volatile ServiceRegistration m_deploymentAdminProxyReg;
+
+ @Override
+ public void bundleChanged(BundleEvent event) {
+ System.out.println("Bundle Event: " + event);
+ Integer eventType = Integer.valueOf(event.getType());
+ CopyOnWriteArrayList<Bundle> bundles = new
CopyOnWriteArrayList<Bundle>();
+ CopyOnWriteArrayList<Bundle> oldBundles =
m_events.putIfAbsent(eventType, bundles);
+ if (oldBundles != null) {
+ bundles = oldBundles;
+ }
+ bundles.addIfAbsent(event.getBundle());
+ }
+
+ @Override
+ public void handleEvent(Event event) {
+ System.out.println("Event: " + event);
+ m_semaphore.release();
+ }
+
+ /**
+ * Tests that we can deploy various versions of bundles stopping only
affected bundles, which is a custom exension
+ * in Felix DeploymentAdmin.
+ */
+ public void testDeployVersionSeriesStopAffectedBundlesOnlyOk() throws
Exception {
+ System.setProperty(STOP_UNAFFECTED_BUNDLES, "false");
+ try {
+ doTestDeployVersionSeriesOk();
+ }
+ finally {
+ System.clearProperty(STOP_UNAFFECTED_BUNDLES);
+ }
+ }
+
+ /**
+ * Tests that we can deploy various versions of bundles using a "stop the
world" scenario, which is the default
+ * behavior in DeploymentAdmin.
+ */
+ public void testDeployVersionSeriesStopTheWorldOk() throws Exception {
+ doTestDeployVersionSeriesOk();
+ }
@Override
protected void configureAdditionalServices() throws Exception {
deleteDirOrFile(m_tempDir);
}
+
+ @Override
+ protected void configureProvisionedServices() throws IOException {
+ m_tempDir = File.createTempFile("test", "");
+ m_tempDir.delete();
+ m_tempDir.mkdir();
+ }
- private void deleteDirOrFile(File root) {
- if (root.isDirectory()) {
- for (File file : root.listFiles()) {
- deleteDirOrFile(file);
- }
+ @Override
+ protected void doTearDown() throws Exception {
+ for (DeploymentPackage dp : m_deployment.listDeploymentPackages()) {
+ dp.uninstallForced();
}
- root.delete();
}
- public void testDeployVersionSeries() throws Exception {
+ protected void doTestDeployVersionSeriesOk() throws Exception {
Bundle[] start = m_bundleContext.getBundles();
// Test deploy initial version 1.0.0 with 3 bundles in version 1.0.0
@@ -105,13 +216,16 @@ public class DeploymentIntegrationTest e
executeTest();
// start + versions bundles may be present
assertState(start, m_bundleContext.getBundles(), versions);
- assert m_events.get(BundleEvent.STARTED).size() == versions.length :
"Received unexpected amount of starting events.";
- assert m_events.get(BundleEvent.STOPPED) == null : "Received
unexpected amount of stopping events";
+
+ assertEquals("Received unexpected amount of starting events.",
versions.length, m_events.get(BundleEvent.STARTED).size());
+ assertNull("Received unexpected amount of stopping events",
m_events.get(BundleEvent.STOPPED));
+
m_events.clear();
// Test correct presence of deployment packages in deployment admin
- assert m_deployment.listDeploymentPackages().length == 1 : "Deployment
admin reports unexpected number of deployment packages";
- assert m_deployment.getDeploymentPackage(GWID) != null : "Deployment
admin did not return the expected deployment package";
+ assertEquals("Deployment admin reports unexpected number of deployment
packages", 1, m_deployment.listDeploymentPackages().length);
+ assertNotNull("Deployment admin did not return the expected deployment
package", m_deployment.getDeploymentPackage(TARGET_ID));
+
Bundle[] bundles = m_bundleContext.getBundles();
Bundle bundle = null;
for (int i = 0; i < bundles.length; i++) {
@@ -120,7 +234,7 @@ public class DeploymentIntegrationTest e
break;
}
}
- assert m_deployment.getDeploymentPackage(bundle) != null : "Deployment
admin did not return the expected deployment package";
+ assertNotNull("Deployment admin did not return the expected deployment
package", m_deployment.getDeploymentPackage(bundle));
// Test deploy a version 1.1.0 on top of the previous 1.0.0 with one
new bundle and one updated to version 1.1.0
// (i.e., two fix-package bundles)
@@ -129,12 +243,20 @@ public class DeploymentIntegrationTest e
generateBundle(new File(version, "0.jar"), versions[0], "1.1.0");
generateBundles(version, versions, 1, versions.length, "1.0.0");
executeTest();
+
+ int expectedStopEvents = versions.length - 1;
+ int expectedStartedEvents = versions.length;
+ if ("false".equals(System.getProperty(STOP_UNAFFECTED_BUNDLES))) {
+ expectedStopEvents = 1;
+ expectedStartedEvents = 2;
+ }
+
// start + versions bundles may be present
assertState(start, m_bundleContext.getBundles(), versions);
- assert m_events.get(BundleEvent.UPDATED).size() == 1 : "Received
unexpected amount of updated events.";
- assert
m_events.get(BundleEvent.UPDATED).get(0).getSymbolicName().equals(versions[0])
: "Received unexpected update event.";
- assert m_events.get(BundleEvent.STOPPED).size() == versions.length - 1
: "Received unexpected amount of stopped events.";
- assert m_events.get(BundleEvent.STARTED).size() == versions.length :
"Received unexpected amount of started events: expected " + versions.length +
", received " + m_events.get(BundleEvent.STARTED).size() + ".";
+ assertEquals("Received unexpected amount of updated events.", 1,
m_events.get(BundleEvent.UPDATED).size());
+ assertEquals("Received unexpected update event.", versions[0],
m_events.get(BundleEvent.UPDATED).get(0).getSymbolicName());
+ assertEquals("Received unexpected amount of stopped events.",
expectedStopEvents, m_events.get(BundleEvent.STOPPED).size());
+ assertEquals("Received unexpected amount of started events.",
expectedStartedEvents, m_events.get(BundleEvent.STARTED).size());
m_events.clear();
// Test to deploy an empty version 2.0.0, but break the stream which
should cancel the deployment
@@ -147,32 +269,22 @@ public class DeploymentIntegrationTest e
// only start bundles may be present
assertState(start, m_bundleContext.getBundles(), new String[0]);
- assert m_events.get(BundleEvent.INSTALLED) == null : "Received
unexpected amount of installed events.";
- assert m_events.get(BundleEvent.STARTED) == null : "Received
unexpected amount of starting events.";
- assert m_events.get(BundleEvent.UNINSTALLED).size() == versions.length
: "Received unexpected amount of uninstalled events: " +
m_events.get(BundleEvent.UNINSTALLED).size() + " instead of " + versions.length;
- assert m_events.get(BundleEvent.STOPPED).size() == versions.length :
"Received unexpected amount of stopped events: " +
m_events.get(BundleEvent.STOPPED).size() + " instead of " + versions.length;
+ assertNull("Received unexpected amount of installed events.",
m_events.get(BundleEvent.INSTALLED));
+ assertNull("Received unexpected amount of starting events.",
m_events.get(BundleEvent.STARTED));
+ assertEquals("Received unexpected amount of uninstalled events.",
versions.length, m_events.get(BundleEvent.UNINSTALLED).size());
+ assertEquals("Received unexpected amount of stopped events.",
versions.length, m_events.get(BundleEvent.STOPPED).size());
m_events.clear();
-
}
- public void bundleChanged(BundleEvent event) {
- synchronized (m_events) {
- if (!m_events.containsKey(Integer.valueOf(event.getType()))) {
- m_events.put(Integer.valueOf(event.getType()), new
ArrayList<Bundle>());
- }
-
m_events.get(Integer.valueOf(event.getType())).add(event.getBundle());
- }
- }
-
- public void handleEvent(Event event) {
- System.out.println("Event: " + event);
- m_semaphore.release();
- }
-
- private void generateBundles(File dir, String[] versions, int off, int
len, String version) throws Exception {
- for (int i = off; i < len; i++) {
- generateBundle(new File(dir, i + ".jar"), versions[i], version);
- }
+ @Override
+ protected Component[] getDependencies() {
+ return new Component[] {
+ createComponent()
+ .setImplementation(this)
+
.add(createServiceDependency().setService(HttpService.class).setRequired(true))
+
.add(createServiceDependency().setService(ConfigurationAdmin.class).setRequired(true))
+
.add(createServiceDependency().setService(DeploymentAdmin.class).setRequired(true)),
+ };
}
private void assertState(Bundle[] start, Bundle[] current, String[]
versions) {
@@ -187,149 +299,79 @@ public class DeploymentIntegrationTest e
}
}
- private File createVersion(String version) {
- File versionFile = new File(new File(m_tempDir, GWID), version);
- versionFile.mkdirs();
- return versionFile;
+ private void configureServer() throws IOException {
+ // configure data bundle
+ configure("org.apache.ace.deployment.servlet", HttpConstants.ENDPOINT,
"/deployment", "authentication.enabled", "false");
+ // configure file based backend
+ configure("org.apache.ace.deployment.provider.filebased",
"BaseDirectoryName", m_tempDir.getAbsolutePath());
}
- @SuppressWarnings("serial")
- private void executeTest() throws IOException, InterruptedException {
- m_bundleContext.addBundleListener(this);
- ServiceRegistration reg =
m_bundleContext.registerService(EventHandler.class.getName(), this, new
Properties() {
- {
- put(EventConstants.EVENT_TOPIC,
"org/osgi/service/deployment/COMPLETE");
- put(EventConstants.EVENT_FILTER, "(successful=true)");
- }
- });
- configureTarget();
- configureServer();
- assert m_semaphore.tryAcquire(8, TimeUnit.SECONDS) : "Timed out while
waiting for deployment to complete.";
- unconfigureServer();
- unconfigureTarget();
- reg.unregister();
- m_bundleContext.removeBundleListener(this);
+ private void configureTarget() throws IOException {
+ // configure discovery bundle
+ configure(DiscoveryConstants.DISCOVERY_PID,
DiscoveryConstants.DISCOVERY_URL_KEY, "http://" + HOST + ":" +
TestConstants.PORT);
+ // configure identification bundle
+ configure(IdentificationConstants.IDENTIFICATION_PID,
IdentificationConstants.IDENTIFICATION_TARGETID_KEY, TARGET_ID);
+ // configure scheduler
+ configure(SchedulerConstants.SCHEDULER_PID,
+ "org.apache.ace.target.auditlog.task.AuditLogSyncTask",
POLL_INTERVAL,
+ "org.apache.ace.deployment.task.DeploymentUpdateTask",
POLL_INTERVAL);
}
- private void executeTestWithFailingStream() throws IOException,
InterruptedException {
- m_bundleContext.addBundleListener(this);
- registerDeploymentAdminProxy(new FailingDeploymentAdmin(m_deployment,
50));
- configureTarget();
- configureServer();
- assert m_semaphore.tryAcquire(8, TimeUnit.SECONDS) : "Timed out while
waiting for deployment to abort.";
- unconfigureServer();
- unconfigureTarget();
- unregisterDeploymentAdminProxy();
- m_bundleContext.removeBundleListener(this);
+ private File createVersion(String version) {
+ File versionFile = new File(new File(m_tempDir, TARGET_ID), version);
+ versionFile.mkdirs();
+ return versionFile;
}
- /**
- * Input stream wrapper that creates an input stream that breaks after N
bytes. When it breaks, it will throw an IO
- * exception and sends a notification to the semaphore that allows the
overall test to continue.
- */
- private class BrokenInputStream extends InputStream {
- private final InputStream m_normalStream;
- private int m_bytesUntilBreakdown;
- private boolean m_isBroken;
-
- public BrokenInputStream(InputStream normalStream, int
bytesUntilBreakdown) {
- m_normalStream = normalStream;
- m_bytesUntilBreakdown = bytesUntilBreakdown;
- }
-
- private synchronized void breakStream() throws IOException {
- if (!m_isBroken) {
- m_isBroken = true;
-
- // release the semaphore to continue the test
- m_semaphore.release();
- }
- throw new IOException("Stream broken.");
- }
-
- @Override
- public int read() throws IOException {
- if (m_bytesUntilBreakdown-- < 1) {
- breakStream();
+ private void deleteDirOrFile(File root) {
+ if (root.isDirectory()) {
+ for (File file : root.listFiles()) {
+ deleteDirOrFile(file);
}
- return m_normalStream.read();
}
-
- @Override
- public void close() throws IOException {
- m_normalStream.close();
- breakStream();
- }
-
+ root.delete();
}
- /**
- * Wrapper around the deployment admin that will fail once, after N bytes.
- */
- private class FailingDeploymentAdmin implements DeploymentAdmin {
- private final DeploymentAdmin m_deploymentAdmin;
- private boolean m_wasBroken;
- private final int m_failAfterBytes;
-
- public FailingDeploymentAdmin(DeploymentAdmin deploymentAdmin, int
failAfterBytes) {
- m_deploymentAdmin = deploymentAdmin;
- m_failAfterBytes = failAfterBytes;
- }
+ private void executeTest() throws IOException, InterruptedException {
+ Properties props = new Properties();
+ props.put(EventConstants.EVENT_TOPIC,
"org/osgi/service/deployment/COMPLETE");
+ props.put(EventConstants.EVENT_FILTER, "(successful=true)");
- public boolean cancel() {
- return m_deploymentAdmin.cancel();
- }
+ m_bundleContext.addBundleListener(this);
+ ServiceRegistration reg =
m_bundleContext.registerService(EventHandler.class.getName(), this, props);
- public DeploymentPackage getDeploymentPackage(String symbName) {
- return m_deploymentAdmin.getDeploymentPackage(symbName);
- }
+ try {
+ configureTarget();
+ configureServer();
- public DeploymentPackage getDeploymentPackage(Bundle bundle) {
- return m_deploymentAdmin.getDeploymentPackage(bundle);
- }
+ assertTrue("Timed out while waiting for deployment to complete.",
m_semaphore.tryAcquire(8, TimeUnit.SECONDS));
- public DeploymentPackage installDeploymentPackage(InputStream in)
throws DeploymentException {
- synchronized (this) {
- if (!m_wasBroken) {
- m_wasBroken = true;
- in = new BrokenInputStream(in, m_failAfterBytes);
- }
- }
- return m_deploymentAdmin.installDeploymentPackage(in);
+ unconfigureServer();
+ unconfigureTarget();
}
-
- public DeploymentPackage[] listDeploymentPackages() {
- return m_deploymentAdmin.listDeploymentPackages();
+ finally {
+ reg.unregister();
+ m_bundleContext.removeBundleListener(this);
}
}
- private void configureTarget() throws IOException {
- // configure discovery bundle
- configure(DiscoveryConstants.DISCOVERY_PID,
DiscoveryConstants.DISCOVERY_URL_KEY, "http://" + HOST + ":" +
TestConstants.PORT);
- // configure identification bundle
- configure(IdentificationConstants.IDENTIFICATION_PID,
IdentificationConstants.IDENTIFICATION_TARGETID_KEY, GWID);
- // configure scheduler
- configure(SchedulerConstants.SCHEDULER_PID,
- "org.apache.ace.target.auditlog.task.AuditLogSyncTask",
POLL_INTERVAL,
- "org.apache.ace.deployment.task.DeploymentUpdateTask",
POLL_INTERVAL);
- }
-
- private void unconfigureTarget() throws IOException {
- m_config.getConfiguration(DiscoveryConstants.DISCOVERY_PID,
null).delete();
- m_config.getConfiguration(IdentificationConstants.IDENTIFICATION_PID,
null).delete();
- m_config.getConfiguration(SchedulerConstants.SCHEDULER_PID,
null).delete();
- }
-
- private void unconfigureServer() throws IOException {
- m_config.getConfiguration("org.apache.ace.deployment.servlet",
null).delete();
-
m_config.getConfiguration("org.apache.ace.deployment.provider.filebased",
null).delete();
- }
+ private void executeTestWithFailingStream() throws IOException,
InterruptedException {
+ m_bundleContext.addBundleListener(this);
+ registerDeploymentAdminProxy(new FailingDeploymentAdmin(m_deployment,
50));
- private void configureServer() throws IOException {
- // configure data bundle
- configure("org.apache.ace.deployment.servlet", HttpConstants.ENDPOINT,
"/deployment", "authentication.enabled", "false");
- // configure file based backend
- configure("org.apache.ace.deployment.provider.filebased",
"BaseDirectoryName", m_tempDir.getAbsolutePath());
+ try {
+ configureTarget();
+ configureServer();
+
+ assertTrue("Timed out while waiting for deployment to abort.",
m_semaphore.tryAcquire(8, TimeUnit.SECONDS));
+
+ unconfigureServer();
+ unconfigureTarget();
+ }
+ finally {
+ unregisterDeploymentAdminProxy();
+ m_bundleContext.removeBundleListener(this);
+ }
}
private ArtifactData generateBundle(File file, String symbolicName, String
version) throws Exception {
@@ -338,13 +380,30 @@ public class DeploymentIntegrationTest e
return bundle;
}
+ private void generateBundles(File dir, String[] versions, int off, int
len, String version) throws Exception {
+ for (int i = off; i < len; i++) {
+ generateBundle(new File(dir, i + ".jar"), versions[i], version);
+ }
+ }
+
private void registerDeploymentAdminProxy(DeploymentAdmin proxy) {
Properties props = new Properties();
props.put(org.osgi.framework.Constants.SERVICE_RANKING, 1);
- m_deploymentAdminProxyRegistration =
m_bundleContext.registerService(DeploymentAdmin.class.getName(), proxy, props);
+ m_deploymentAdminProxyReg =
m_bundleContext.registerService(DeploymentAdmin.class.getName(), proxy, props);
+ }
+
+ private void unconfigureServer() throws IOException {
+ m_config.getConfiguration("org.apache.ace.deployment.servlet",
null).delete();
+
m_config.getConfiguration("org.apache.ace.deployment.provider.filebased",
null).delete();
+ }
+
+ private void unconfigureTarget() throws IOException {
+ m_config.getConfiguration(DiscoveryConstants.DISCOVERY_PID,
null).delete();
+ m_config.getConfiguration(IdentificationConstants.IDENTIFICATION_PID,
null).delete();
+ m_config.getConfiguration(SchedulerConstants.SCHEDULER_PID,
null).delete();
}
private void unregisterDeploymentAdminProxy() {
- m_deploymentAdminProxyRegistration.unregister();
+ m_deploymentAdminProxyReg.unregister();
}
}