Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Frost2011-03-15 12:45:42 -0400
committerChristopher Frost2011-03-15 12:45:42 -0400
commitbcc2da9092984f181a6581356fc8f9b9a16f1ef5 (patch)
tree659cf1320e181e88e1fe4534000a384157a52a6e /org.eclipse.virgo.kernel.deployer.test
parent474c3221807029f103107074412f2e85d419cbcf (diff)
downloadorg.eclipse.virgo.kernel-bcc2da9092984f181a6581356fc8f9b9a16f1ef5.tar.gz
org.eclipse.virgo.kernel-bcc2da9092984f181a6581356fc8f9b9a16f1ef5.tar.xz
org.eclipse.virgo.kernel-bcc2da9092984f181a6581356fc8f9b9a16f1ef5.zip
337846 Adding tests and updating deployer context to reference repository type in correct package
Diffstat (limited to 'org.eclipse.virgo.kernel.deployer.test')
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/PipelinedDeployerIntegrationTests.java22
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/StubWatchableRepository.java31
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/META-INF/MANIFEST.MF1
3 files changed, 53 insertions, 1 deletions
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/PipelinedDeployerIntegrationTests.java b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/PipelinedDeployerIntegrationTests.java
index 03de2e6f..882c42c7 100644
--- a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/PipelinedDeployerIntegrationTests.java
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/PipelinedDeployerIntegrationTests.java
@@ -13,6 +13,7 @@ package org.eclipse.virgo.kernel.deployer.test;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertEquals;
import java.io.File;
import java.lang.management.ManagementFactory;
@@ -30,6 +31,7 @@ import org.eclipse.virgo.kernel.install.artifact.InstallArtifactLifecycleListene
import org.eclipse.virgo.kernel.deployer.core.DeploymentException;
import org.eclipse.virgo.kernel.deployer.core.DeploymentIdentity;
import org.eclipse.virgo.kernel.deployer.core.DeploymentOptions;
+import org.eclipse.virgo.repository.WatchableRepository;
import org.eclipse.virgo.util.io.FileCopyUtils;
import org.eclipse.virgo.util.io.FileSystemUtils;
import org.eclipse.virgo.util.io.PathReference;
@@ -51,8 +53,12 @@ public class PipelinedDeployerIntegrationTests extends AbstractDeployerIntegrati
private ServiceRegistration<InstallArtifactLifecycleListener> lifecycleListenerRegistration;
- private DeploymentIdentity deploymentIdentity;
+ private StubWatchableRepository watchableRepository;
+
+ private ServiceRegistration<WatchableRepository> watchableRepositoryRegistration;
+ private DeploymentIdentity deploymentIdentity;
+
@Before
public void setUp() throws Exception {
PathReference pr = new PathReference("./target/deployer");
@@ -63,6 +69,9 @@ public class PipelinedDeployerIntegrationTests extends AbstractDeployerIntegrati
this.lifecycleListener = new StubInstallArtifactLifecycleListener();
this.lifecycleListenerRegistration = this.kernelContext.registerService(InstallArtifactLifecycleListener.class, this.lifecycleListener, null);
+
+ this.watchableRepository = new StubWatchableRepository();
+ this.watchableRepositoryRegistration = this.kernelContext.registerService(WatchableRepository.class, this.watchableRepository, null);
}
private void clearPickup() {
@@ -78,6 +87,9 @@ public class PipelinedDeployerIntegrationTests extends AbstractDeployerIntegrati
if (this.lifecycleListenerRegistration != null) {
this.lifecycleListenerRegistration.unregister();
}
+ if (this.watchableRepository != null) {
+ this.watchableRepositoryRegistration.unregister();
+ }
}
private void undeploy() throws DeploymentException {
@@ -103,6 +115,7 @@ public class PipelinedDeployerIntegrationTests extends AbstractDeployerIntegrati
this.deployer.undeploy(this.deploymentIdentity);
this.deploymentIdentity = null;
this.lifecycleListener.assertLifecycleCounts(1, 1, 1, 1);
+ assertEquals(1, this.watchableRepository.getCheckCount());
}
@Test
@@ -116,6 +129,7 @@ public class PipelinedDeployerIntegrationTests extends AbstractDeployerIntegrati
File workDir = new File("target/work/org.eclipse.virgo.kernel/Module/dummy.jar-0");
assertFalse(workDir.exists());
+ assertEquals(1, this.watchableRepository.getCheckCount());
}
@Test
@@ -124,6 +138,7 @@ public class PipelinedDeployerIntegrationTests extends AbstractDeployerIntegrati
ObjectName objectName = ObjectName.getInstance("org.eclipse.virgo.kernel:category=Control,type=RecoveryMonitor");
assertTrue(server.isRegistered(objectName));
assertTrue((Boolean) server.getAttribute(objectName, "RecoveryComplete"));
+ assertEquals(0, this.watchableRepository.getCheckCount());
}
@Test
@@ -138,6 +153,7 @@ public class PipelinedDeployerIntegrationTests extends AbstractDeployerIntegrati
this.lifecycleListener.assertLifecycleCounts(2, 2, 1, 1);
undeploy();
this.lifecycleListener.assertLifecycleCounts(2, 2, 2, 2);
+ assertEquals(2, this.watchableRepository.getCheckCount());
}
@Test
@@ -150,6 +166,7 @@ public class PipelinedDeployerIntegrationTests extends AbstractDeployerIntegrati
this.lifecycleListener.assertLifecycleCounts(2, 2, 1, 1);
undeploy();
this.lifecycleListener.assertLifecycleCounts(2, 2, 2, 2);
+ assertEquals(1, this.watchableRepository.getCheckCount());
}
@Test
@@ -160,6 +177,7 @@ public class PipelinedDeployerIntegrationTests extends AbstractDeployerIntegrati
assertLifecycleCountsAfterWait(1, 1, 0, 0, 10000);
deployed.delete();
assertLifecycleCountsAfterWait(1, 1, 1, 1, 6000);
+ assertEquals(1, this.watchableRepository.getCheckCount());
}
private void assertLifecycleCountsAfterWait(int starting, int started, int stopping, int stopped, long waitMillis) throws InterruptedException {
@@ -200,6 +218,7 @@ public class PipelinedDeployerIntegrationTests extends AbstractDeployerIntegrati
undeploy(true);
assertTrue(copy.exists());
copy.delete();
+ assertEquals(3, this.watchableRepository.getCheckCount());
}
@Test
@@ -228,5 +247,6 @@ public class PipelinedDeployerIntegrationTests extends AbstractDeployerIntegrati
undeploy();
this.lifecycleListener.assertLifecycleCounts(2, 2, 2, 2);
assertFalse(copy.exists());
+ assertEquals(2, this.watchableRepository.getCheckCount());
}
}
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/StubWatchableRepository.java b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/StubWatchableRepository.java
new file mode 100644
index 00000000..179643be
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/StubWatchableRepository.java
@@ -0,0 +1,31 @@
+package org.eclipse.virgo.kernel.deployer.test;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.virgo.repository.WatchableRepository;
+
+
+public class StubWatchableRepository implements WatchableRepository {
+
+ private int checkCount = 0;
+
+ @Override
+ public Set<String> getArtifactLocations(String filename) {
+ return new HashSet<String>();
+ }
+
+ @Override
+ public void forceCheck() throws Exception {
+ this.checkCount++;
+ }
+
+ public void resetCheckCount(){
+ this.checkCount = 0;
+ }
+
+ public int getCheckCount(){
+ return this.checkCount;
+ }
+
+}
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/META-INF/MANIFEST.MF b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/META-INF/MANIFEST.MF
index 326a811f..0b1fae6b 100644
--- a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/META-INF/MANIFEST.MF
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/META-INF/MANIFEST.MF
@@ -16,6 +16,7 @@ Import-Package: org.eclipse.virgo.kernel.core,
org.eclipse.virgo.kernel.services.work,
org.eclipse.virgo.util.io,
org.eclipse.virgo.util.math,
+ org.eclipse.virgo.repository,
javax.management,
org.eclipse.osgi.service.resolver,
org.junit,

Back to the top