Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Waibel2011-12-28 06:07:01 -0500
committerFlorian Waibel2011-12-28 06:07:01 -0500
commite8a2f81af05d0498f9f339261ab2f3d9e9a86e23 (patch)
tree843904014a5af6c8ed90a83303cc9cf7d5c901b6 /org.eclipse.virgo.kernel.deployer.test/src/test/java
parent150941f06c809c3ac560d3623fe8d0ab8db3dcc9 (diff)
downloadorg.eclipse.virgo.kernel-e8a2f81af05d0498f9f339261ab2f3d9e9a86e23.tar.gz
org.eclipse.virgo.kernel-e8a2f81af05d0498f9f339261ab2f3d9e9a86e23.tar.xz
org.eclipse.virgo.kernel-e8a2f81af05d0498f9f339261ab2f3d9e9a86e23.zip
#365034 - Added (failing) integration tests for 1a,1b,2(1a,1b).
Diffstat (limited to 'org.eclipse.virgo.kernel.deployer.test/src/test/java')
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/PlanDeploymentWithDAGTests.java118
1 files changed, 118 insertions, 0 deletions
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/PlanDeploymentWithDAGTests.java b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/PlanDeploymentWithDAGTests.java
new file mode 100644
index 00000000..a5206a16
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/PlanDeploymentWithDAGTests.java
@@ -0,0 +1,118 @@
+/*******************************************************************************
+ * Copyright (c) 2011 EclipseSource
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * EclipseSource - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.kernel.deployer.test;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.virgo.kernel.deployer.core.DeploymentIdentity;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+
+// TODO 1c. (transitive dependencies) (@see https://bugs.eclipse.org/bugs/show_bug.cgi?id=365034)
+public class PlanDeploymentWithDAGTests extends AbstractDeployerIntegrationTest {
+
+ private static final String BUNDLE_ONE_SYMBOLIC_NAME = "simple.bundle.one";
+
+ @Test
+ // 1a. (@see https://bugs.eclipse.org/bugs/show_bug.cgi?id=365034)
+ public void planReferencingAnAlreadyInstalledBundle() throws Exception {
+
+ File file = new File("src/test/resources/plan-deployment/simple.bundle.one.jar");
+ DeploymentIdentity deploymentId = this.deployer.deploy(file.toURI());
+ assertBundlesInstalled(this.context.getBundles(), BUNDLE_ONE_SYMBOLIC_NAME);
+
+ DeploymentIdentity deploymentIdentity = this.deployer.deploy(new File("src/test/resources/testunscopednonatomicA.plan").toURI());
+ assertBundlesInstalled(this.context.getBundles(), BUNDLE_ONE_SYMBOLIC_NAME);
+
+ this.deployer.undeploy(deploymentIdentity);
+ assertBundlesInstalled(this.context.getBundles(), BUNDLE_ONE_SYMBOLIC_NAME);
+
+ this.deployer.undeploy(deploymentId.getType(), deploymentId.getSymbolicName(), deploymentId.getVersion());
+ assertBundlesNotInstalled(this.context.getBundles(), BUNDLE_ONE_SYMBOLIC_NAME);
+ }
+
+ @Test
+ // 1b. (@see https://bugs.eclipse.org/bugs/show_bug.cgi?id=365034)
+ public void twoPlansReferencingASharedBundle() throws Exception {
+
+ DeploymentIdentity deploymentIdentityPlanA = this.deployer.deploy(new File("src/test/resources/testunscopednonatomicA.plan").toURI());
+ assertBundlesInstalled(this.context.getBundles(), BUNDLE_ONE_SYMBOLIC_NAME);
+
+ DeploymentIdentity deploymentIdentityPlanB = this.deployer.deploy(new File("src/test/resources/testunscopednonatomicB.plan").toURI());
+ assertBundlesInstalled(this.context.getBundles(), BUNDLE_ONE_SYMBOLIC_NAME);
+
+ this.deployer.undeploy(deploymentIdentityPlanB);
+
+ assertBundlesInstalled(this.context.getBundles(), BUNDLE_ONE_SYMBOLIC_NAME);
+
+ this.deployer.undeploy(deploymentIdentityPlanA);
+ assertBundlesNotInstalled(this.context.getBundles(), BUNDLE_ONE_SYMBOLIC_NAME);
+ }
+
+ @Test
+ // 2. (1a. / 1b) (@see https://bugs.eclipse.org/bugs/show_bug.cgi?id=365034)
+ public void bundleAlreadyInstalledAsPartOfAPlan() throws Exception {
+
+ DeploymentIdentity deploymentIdentity = this.deployer.deploy(new File("src/test/resources/testunscopednonatomicA.plan").toURI());
+ assertBundlesInstalled(this.context.getBundles(), BUNDLE_ONE_SYMBOLIC_NAME);
+
+ File file = new File("src/test/resources/plan-deployment/simple.bundle.one.jar");
+ DeploymentIdentity deploymentId = this.deployer.deploy(file.toURI());
+ assertBundlesInstalled(this.context.getBundles(), BUNDLE_ONE_SYMBOLIC_NAME);
+
+ this.deployer.undeploy(deploymentId.getType(), deploymentId.getSymbolicName(), deploymentId.getVersion());
+ assertBundlesInstalled(this.context.getBundles(), BUNDLE_ONE_SYMBOLIC_NAME);
+
+ this.deployer.undeploy(deploymentIdentity);
+ assertBundlesNotInstalled(this.context.getBundles(), BUNDLE_ONE_SYMBOLIC_NAME);
+ }
+
+ // TODO - copy from PlanDeploymentTests
+ private void assertBundlesNotInstalled(Bundle[] bundles, String... candidateBsns) {
+ List<String> installedBsns = getInstalledBsns(bundles);
+ for (String candidateBsn : candidateBsns) {
+ for (String installedBsn : installedBsns) {
+ if (installedBsn.contains(candidateBsn)) {
+ fail(candidateBsn + " was installed");
+ }
+ }
+ }
+ }
+
+ private void assertBundlesInstalled(Bundle[] bundles, String... candidateBsns) {
+ List<String> installedBsns = getInstalledBsns(bundles);
+ for (String candidateBsn : candidateBsns) {
+ boolean found = false;
+ for (String installedBsn : installedBsns) {
+ if (installedBsn.contains(candidateBsn)) {
+ found = true;
+ }
+ }
+ assertTrue(candidateBsn + " was not installed", found);
+ }
+ }
+
+ private List<String> getInstalledBsns(Bundle[] bundles) {
+ List<String> installedBsns = new ArrayList<String>(bundles.length);
+ for (Bundle bundle : bundles) {
+ installedBsns.add(bundle.getSymbolicName());
+ }
+
+ return installedBsns;
+ }
+
+}

Back to the top