Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlyn Normington2012-07-27 07:46:59 -0400
committerGlyn Normington2012-07-27 07:46:59 -0400
commit1726d85ca80c477253c02b0965bfcff7c3958eea (patch)
tree6ff245789d92b4e7a9b0ebaf271067e80822e499
parentdcb10440e8d4e991eec86a8d3d5d0a0f49b6bc28 (diff)
downloadorg.eclipse.virgo.kernel-1726d85ca80c477253c02b0965bfcff7c3958eea.tar.gz
org.eclipse.virgo.kernel-1726d85ca80c477253c02b0965bfcff7c3958eea.tar.xz
org.eclipse.virgo.kernel-1726d85ca80c477253c02b0965bfcff7c3958eea.zip
385743: improve naming and document interface
-rw-r--r--org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/AbstractArtifactStore.java (renamed from org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/AbstractPathGenerator.java)20
-rw-r--r--org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/ArtifactStore.java49
-rw-r--r--org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/ConstantPathGenerator.java71
-rw-r--r--org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/FileMovingArtifactStore.java83
-rw-r--r--org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/GenerationalArtifactStore.java94
-rw-r--r--org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/GenerationalPathGenerator.java70
-rw-r--r--org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/PathGenerator.java20
-rw-r--r--org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/StandardArtifactStorage.java12
-rw-r--r--org.eclipse.virgo.kernel.deployer/src/test/java/org/eclipse/virgo/kernel/install/artifact/internal/FileMovingArtifactStoreTests.java (renamed from org.eclipse.virgo.kernel.deployer/src/test/java/org/eclipse/virgo/kernel/install/artifact/internal/ConstantPathGeneratorTests.java)50
-rw-r--r--org.eclipse.virgo.kernel.deployer/src/test/java/org/eclipse/virgo/kernel/install/artifact/internal/GenerationalArtifactStoreTests.java (renamed from org.eclipse.virgo.kernel.deployer/src/test/java/org/eclipse/virgo/kernel/install/artifact/internal/GenerationalPathGeneratorTests.java)48
10 files changed, 291 insertions, 226 deletions
diff --git a/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/AbstractPathGenerator.java b/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/AbstractArtifactStore.java
index 8a8b7e59..2db44d82 100644
--- a/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/AbstractPathGenerator.java
+++ b/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/AbstractArtifactStore.java
@@ -3,13 +3,13 @@ package org.eclipse.virgo.kernel.install.artifact.internal;
import org.eclipse.virgo.util.io.PathReference;
-public abstract class AbstractPathGenerator {
+public abstract class AbstractArtifactStore implements ArtifactStore {
- private boolean hasPrevious = false;
+ private boolean saved = false;
protected final Object monitor = new Object();
- public AbstractPathGenerator(PathReference basePathReference) {
+ public AbstractArtifactStore(PathReference basePathReference) {
if (basePathReference == null) {
throw new IllegalArgumentException("Null path");
}
@@ -20,25 +20,25 @@ public abstract class AbstractPathGenerator {
public abstract PathReference getCurrentPath();
- public void next() {
+ public void save() {
synchronized (this.monitor) {
- this.hasPrevious = true;
+ this.saved = true;
PathReference currentPathReference = getCurrentPath();
currentPathReference.getParent().createDirectory();
currentPathReference.delete(true);
}
}
- public void previous() {
+ public void restore() {
synchronized (this.monitor) {
- if (!this.hasPrevious) {
- throw new IllegalStateException("No previous path available");
+ if (!this.saved) {
+ throw new IllegalStateException("No saved artifact available");
}
getCurrentPath().delete(true);
- this.hasPrevious = false;
+ this.saved = false;
}
}
- protected abstract PathReference getPreviousPath();
+ protected abstract PathReference getSavedPath();
} \ No newline at end of file
diff --git a/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/ArtifactStore.java b/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/ArtifactStore.java
new file mode 100644
index 00000000..711f6c0e
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/ArtifactStore.java
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2012 VMware Inc.
+ * 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:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.kernel.install.artifact.internal;
+
+import org.eclipse.virgo.util.io.PathReference;
+
+/**
+ * {@link ArtifactStore} manages the disk storage used to hold a working copy of an artifact. When updating the
+ * artifact, the old version of the artifact is saved in case the update operation fails and the artifact needs to be
+ * restored to the old version (in which case the new version is deleted). At most one saved version is maintained to
+ * conserve disk space if the artifact is updated multiple times.
+ * <p />
+ * An implementation of this interface may expose a single current path and save the artifact by moving it, it may
+ * create a series of paths without moving the artifact, or it may use another approach.
+ * <p />
+ * <strong>Concurrent Semantics</strong><br />
+ * Implementations of this interface need not be thread safe.
+ */
+interface ArtifactStore {
+
+ /**
+ * Gets the current artifact path.
+ *
+ * @return a {@link PathReference} to the current artifact path.
+ */
+ public PathReference getCurrentPath();
+
+ /**
+ * Saves the current artifact and prepares the current artifact path storage ready for the new artifact. Only one
+ * saved version is kept: any previously saved version is deleted.
+ */
+ public void save();
+
+ /**
+ * Deletes the current artifact and restores the saved version. The new current artifact has the same path as when
+ * it was last current.
+ */
+ public void restore();
+
+} \ No newline at end of file
diff --git a/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/ConstantPathGenerator.java b/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/ConstantPathGenerator.java
deleted file mode 100644
index 57043fc2..00000000
--- a/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/ConstantPathGenerator.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 VMware Inc.
- * 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:
- * VMware Inc. - initial contribution
- *******************************************************************************/
-
-package org.eclipse.virgo.kernel.install.artifact.internal;
-
-import org.eclipse.virgo.util.io.PathReference;
-
-final class ConstantPathGenerator extends AbstractPathGenerator implements PathGenerator {
-
- private final PathReference basePathReference;
-
- private final PathReference previousPathReference;
-
- public ConstantPathGenerator(PathReference basePathReference) {
- super(basePathReference);
- this.basePathReference = basePathReference;
- this.previousPathReference = new PathReference(String.format("%s-past", this.basePathReference.getAbsolutePath()));
-
- this.basePathReference.getParent().createDirectory();
- this.basePathReference.delete(true);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void next() {
- if (this.basePathReference.exists()) {
- this.previousPathReference.delete(true);
- this.basePathReference.moveTo(this.previousPathReference);
- }
- super.next();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void previous() {
- super.previous();
- if (this.previousPathReference.exists()) {
- this.previousPathReference.moveTo(this.basePathReference);
- }
-
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public PathReference getCurrentPath() {
- return this.basePathReference;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected PathReference getPreviousPath() {
- return this.previousPathReference;
- }
-
-}
diff --git a/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/FileMovingArtifactStore.java b/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/FileMovingArtifactStore.java
new file mode 100644
index 00000000..5e17bb75
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/FileMovingArtifactStore.java
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * Copyright (c) 2012 VMware Inc.
+ * 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:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.kernel.install.artifact.internal;
+
+import org.eclipse.virgo.util.io.PathReference;
+
+/**
+ * {@link FileMovingArtifactStore} implements {@link ArtifactStore} and saves its artifact by moving it to another
+ * location on disk.
+ * <p />
+ *
+ * <strong>Concurrent Semantics</strong><br />
+ * Thread safe.
+ */
+final class FileMovingArtifactStore extends AbstractArtifactStore implements ArtifactStore {
+
+ private final PathReference currentPath;
+
+ private final PathReference savedPath;
+
+ /**
+ * Constructs a {@link FileMovingArtifactStore} at the specified path and prepares the path storage ready for the
+ * new artifact.
+ */
+ FileMovingArtifactStore(PathReference basePathReference) {
+ super(basePathReference);
+ this.currentPath = basePathReference;
+ this.savedPath = new PathReference(String.format("%s-saved", this.currentPath.getAbsolutePath()));
+
+ this.currentPath.getParent().createDirectory();
+ this.currentPath.delete(true);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void save() {
+ if (this.currentPath.exists()) {
+ this.savedPath.delete(true);
+ this.currentPath.moveTo(this.savedPath);
+ }
+ super.save();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void restore() {
+ super.restore();
+ if (this.savedPath.exists()) {
+ this.savedPath.moveTo(this.currentPath);
+ }
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public PathReference getCurrentPath() {
+ return this.currentPath;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected PathReference getSavedPath() {
+ return this.savedPath;
+ }
+
+}
diff --git a/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/GenerationalArtifactStore.java b/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/GenerationalArtifactStore.java
new file mode 100644
index 00000000..c74b5567
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/GenerationalArtifactStore.java
@@ -0,0 +1,94 @@
+/*******************************************************************************
+ * Copyright (c) 2012 VMware Inc.
+ * 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:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.kernel.install.artifact.internal;
+
+import org.eclipse.virgo.util.io.PathReference;
+
+/**
+ * {@link GenerationalArtifactStore} implements {@link ArtifactStore} by creating a series of paths so that each version
+ * of the artifact has a fresh path (unless the series wraps which is extremely unlikely in practice). This is designed
+ * for storing a bundle which will be installed by reference into the OSGi framework since, when the bundle is updated,
+ * the current version of the bundle may be in use until the bundle becomes unresolved.
+ * <p />
+ *
+ * <strong>Concurrent Semantics</strong><br />
+ * TODO Document concurrent semantics of GenerationalArtifactStore
+ */
+final class GenerationalArtifactStore extends AbstractArtifactStore implements ArtifactStore {
+
+ private final PathReference baseDirectory;
+
+ private long generation = 0;
+
+ private final String baseName;
+
+ /**
+ * Constructs a {@link GenerationalArtifactStore} in the directory of the specified path and prepares the path
+ * storage ready for the new artifact. Each path produced by this store has the same filename as the specified path.
+ */
+ GenerationalArtifactStore(PathReference basePathReference) {
+ super(basePathReference);
+ this.baseDirectory = basePathReference.getParent();
+ this.baseName = basePathReference.getName();
+
+ PathReference currentPathReference = getGenerationPath(this.generation, this.baseDirectory, this.baseName);
+ currentPathReference.getParent().createDirectory();
+ currentPathReference.delete(true);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public PathReference getCurrentPath() {
+ synchronized (this.monitor) {
+ return getGenerationPath(this.generation);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void save() {
+ synchronized (this.monitor) {
+ if (this.generation != 0) {
+ getSavedPath().delete(true);
+ }
+ this.generation++;
+ super.save();
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void restore() {
+ synchronized (this.monitor) {
+ super.restore();
+ this.generation--;
+ }
+ }
+
+ protected PathReference getSavedPath() {
+ return getGenerationPath(this.generation - 1);
+ }
+
+ private PathReference getGenerationPath(long generation) {
+ return getGenerationPath(generation, this.baseDirectory, this.baseName);
+ }
+
+ private static PathReference getGenerationPath(long generation, PathReference baseDirectory, String baseName) {
+ return baseDirectory.newChild(Long.toString(generation)).newChild(baseName);
+ }
+
+}
diff --git a/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/GenerationalPathGenerator.java b/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/GenerationalPathGenerator.java
deleted file mode 100644
index 173e3121..00000000
--- a/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/GenerationalPathGenerator.java
+++ /dev/null
@@ -1,70 +0,0 @@
-
-package org.eclipse.virgo.kernel.install.artifact.internal;
-
-import org.eclipse.virgo.util.io.PathReference;
-
-final class GenerationalPathGenerator extends AbstractPathGenerator implements PathGenerator {
-
- private final PathReference baseDirectory;
-
- private long generation = 0;
-
- private final String baseName;
-
- GenerationalPathGenerator(PathReference basePathReference) {
- super(basePathReference);
- this.baseDirectory = basePathReference.getParent();
- this.baseName = basePathReference.getName();
-
- PathReference currentPathReference = getGenerationPath(this.generation, this.baseDirectory, this.baseName);
- currentPathReference.getParent().createDirectory();
- currentPathReference.delete(true);
- }
-
- /**
- * {@inheritDoc}
- */
- public PathReference getCurrentPath() {
- synchronized (this.monitor) {
- return getGenerationPath(this.generation);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void next() {
- synchronized (this.monitor) {
- if (this.generation != 0) {
- getPreviousPath().delete(true);
- }
- this.generation++;
- super.next();
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void previous() {
- synchronized (this.monitor) {
- super.previous();
- this.generation--;
- }
- }
-
- protected PathReference getPreviousPath() {
- return getGenerationPath(this.generation - 1);
- }
-
- private PathReference getGenerationPath(long generation) {
- return getGenerationPath(generation, this.baseDirectory, this.baseName);
- }
-
- private static PathReference getGenerationPath(long generation, PathReference baseDirectory, String baseName) {
- return baseDirectory.newChild(Long.toString(generation)).newChild(baseName);
- }
-
-}
diff --git a/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/PathGenerator.java b/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/PathGenerator.java
deleted file mode 100644
index d9f0f970..00000000
--- a/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/PathGenerator.java
+++ /dev/null
@@ -1,20 +0,0 @@
-
-package org.eclipse.virgo.kernel.install.artifact.internal;
-
-import org.eclipse.virgo.util.io.PathReference;
-
-interface PathGenerator {
-
- public abstract PathReference getCurrentPath();
-
- /**
- * Note that the history is only one level deep.
- */
- public abstract void next();
-
- /**
- * This may only be called if the current generation has not been used.
- */
- public abstract void previous();
-
-} \ No newline at end of file
diff --git a/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/StandardArtifactStorage.java b/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/StandardArtifactStorage.java
index 2ecb58ec..0a072581 100644
--- a/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/StandardArtifactStorage.java
+++ b/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/StandardArtifactStorage.java
@@ -43,7 +43,7 @@ final class StandardArtifactStorage implements ArtifactStorage {
private final boolean unpackBundles;
- private final PathGenerator pathGenerator;
+ private final ArtifactStore pathGenerator;
public StandardArtifactStorage(PathReference sourcePathReference, PathReference baseStagingPathReference, ArtifactFSFactory artifactFSFactory,
EventLogger eventLogger, String unpackBundlesOption) {
@@ -55,15 +55,15 @@ final class StandardArtifactStorage implements ArtifactStorage {
this.unpackBundles = unpackBundlesOption == null || DEPLOYER_UNPACK_BUNDLES_TRUE.equalsIgnoreCase(unpackBundlesOption);
- this.pathGenerator = CONSTANT_PATH_EXTENSIONS.contains(getFileExtension(sourcePathReference)) ? new ConstantPathGenerator(
- baseStagingPathReference) : new GenerationalPathGenerator(baseStagingPathReference);
+ this.pathGenerator = CONSTANT_PATH_EXTENSIONS.contains(getFileExtension(sourcePathReference)) ? new FileMovingArtifactStore(
+ baseStagingPathReference) : new GenerationalArtifactStore(baseStagingPathReference);
synchronize(this.sourcePathReference);
}
@Override
public void synchronize() {
- this.pathGenerator.next();
+ this.pathGenerator.save();
synchronize(this.sourcePathReference);
}
@@ -74,13 +74,13 @@ final class StandardArtifactStorage implements ArtifactStorage {
@Override
public void synchronize(URI sourceUri) {
- this.pathGenerator.next();
+ this.pathGenerator.save();
synchronize(new PathReference(sourceUri));
}
@Override
public void rollBack() {
- this.pathGenerator.previous();
+ this.pathGenerator.restore();
}
@Override
diff --git a/org.eclipse.virgo.kernel.deployer/src/test/java/org/eclipse/virgo/kernel/install/artifact/internal/ConstantPathGeneratorTests.java b/org.eclipse.virgo.kernel.deployer/src/test/java/org/eclipse/virgo/kernel/install/artifact/internal/FileMovingArtifactStoreTests.java
index 97933ae5..fbb80566 100644
--- a/org.eclipse.virgo.kernel.deployer/src/test/java/org/eclipse/virgo/kernel/install/artifact/internal/ConstantPathGeneratorTests.java
+++ b/org.eclipse.virgo.kernel.deployer/src/test/java/org/eclipse/virgo/kernel/install/artifact/internal/FileMovingArtifactStoreTests.java
@@ -21,19 +21,19 @@ import org.eclipse.virgo.util.io.PathReference;
import org.junit.Before;
import org.junit.Test;
-public class ConstantPathGeneratorTests {
+public class FileMovingArtifactStoreTests {
- private static final String TEST_PATH = "target/pathGeneratorTests/";
+ private static final String TEST_PATH = "target/fileMovingArtifactStoreTests/";
private static final String TEST_FILENAME = "some.jar";
- private PathGenerator artifactHistory;
+ private ArtifactStore artifactHistory;
@Before
public void setUp() throws Exception {
PathReference basePathReference = new PathReference(TEST_PATH + TEST_FILENAME);
basePathReference.delete(true);
- this.artifactHistory = new ConstantPathGenerator(basePathReference);
+ this.artifactHistory = new FileMovingArtifactStore(basePathReference);
}
@Test
@@ -45,7 +45,7 @@ public class ConstantPathGeneratorTests {
@Test
public void testStash() {
PathReference original = this.artifactHistory.getCurrentPath();
- this.artifactHistory.next();
+ this.artifactHistory.save();
PathReference c = this.artifactHistory.getCurrentPath();
checkPath(c);
assertTrue(original.equals(c));
@@ -54,8 +54,8 @@ public class ConstantPathGeneratorTests {
@Test
public void testUnstash() {
PathReference original = this.artifactHistory.getCurrentPath();
- this.artifactHistory.next();
- this.artifactHistory.previous();
+ this.artifactHistory.save();
+ this.artifactHistory.restore();
PathReference c = this.artifactHistory.getCurrentPath();
checkPath(c);
assertTrue(original.equals(c));
@@ -65,9 +65,9 @@ public class ConstantPathGeneratorTests {
@Test
public void testRepeatedStash() {
PathReference original = this.artifactHistory.getCurrentPath();
- this.artifactHistory.next();
+ this.artifactHistory.save();
PathReference next = this.artifactHistory.getCurrentPath();
- this.artifactHistory.next();
+ this.artifactHistory.save();
PathReference last = this.artifactHistory.getCurrentPath();
checkPath(last);
assertTrue(original.equals(next));
@@ -76,21 +76,21 @@ public class ConstantPathGeneratorTests {
@Test
public void testFileDeletionOnUnstash() {
- this.artifactHistory.next();
+ this.artifactHistory.save();
PathReference c = this.artifactHistory.getCurrentPath();
c.createFile();
assertTrue(c.exists());
- this.artifactHistory.previous();
+ this.artifactHistory.restore();
assertFalse(c.exists());
}
@Test
public void testDirectoryDeletionOnUnstash() {
- this.artifactHistory.next();
+ this.artifactHistory.save();
PathReference c = this.artifactHistory.getCurrentPath();
c.createDirectory();
assertTrue(c.exists());
- this.artifactHistory.previous();
+ this.artifactHistory.restore();
assertFalse(c.exists());
}
@@ -99,9 +99,9 @@ public class ConstantPathGeneratorTests {
PathReference c = this.artifactHistory.getCurrentPath();
c.createFile();
assertTrue(c.exists());
- this.artifactHistory.next();
+ this.artifactHistory.save();
assertFalse(c.exists());
- this.artifactHistory.next();
+ this.artifactHistory.save();
assertFalse(c.exists());
}
@@ -110,37 +110,37 @@ public class ConstantPathGeneratorTests {
PathReference c = this.artifactHistory.getCurrentPath();
c.createDirectory();
assertTrue(c.exists());
- this.artifactHistory.next();
+ this.artifactHistory.save();
assertFalse(c.exists());
- this.artifactHistory.next();
+ this.artifactHistory.save();
assertFalse(c.exists());
}
@Test(expected=IllegalStateException.class)
public void testBadUnstash() {
- this.artifactHistory.previous();
+ this.artifactHistory.restore();
}
@Test(expected=IllegalStateException.class)
public void testDoubleUnstash() {
- this.artifactHistory.next();
- this.artifactHistory.next();
- this.artifactHistory.previous();
- this.artifactHistory.previous();
+ this.artifactHistory.save();
+ this.artifactHistory.save();
+ this.artifactHistory.restore();
+ this.artifactHistory.restore();
}
@Test(expected=IllegalArgumentException.class)
public void testNullConstructorPath() {
- new ConstantPathGenerator(null);
+ new FileMovingArtifactStore(null);
}
@Test(expected=IllegalArgumentException.class)
public void testEmptyConstructorPath() {
- new ConstantPathGenerator(new PathReference(""));
+ new FileMovingArtifactStore(new PathReference(""));
}
public void testDirectorylessConstructorPath() {
- PathGenerator ph = new ConstantPathGenerator(new PathReference("a"));
+ ArtifactStore ph = new FileMovingArtifactStore(new PathReference("a"));
assertEquals("a", ph.getCurrentPath().getName());
}
diff --git a/org.eclipse.virgo.kernel.deployer/src/test/java/org/eclipse/virgo/kernel/install/artifact/internal/GenerationalPathGeneratorTests.java b/org.eclipse.virgo.kernel.deployer/src/test/java/org/eclipse/virgo/kernel/install/artifact/internal/GenerationalArtifactStoreTests.java
index 6d493fb7..abeecd4c 100644
--- a/org.eclipse.virgo.kernel.deployer/src/test/java/org/eclipse/virgo/kernel/install/artifact/internal/GenerationalPathGeneratorTests.java
+++ b/org.eclipse.virgo.kernel.deployer/src/test/java/org/eclipse/virgo/kernel/install/artifact/internal/GenerationalArtifactStoreTests.java
@@ -21,17 +21,17 @@ import org.eclipse.virgo.util.io.PathReference;
import org.junit.Before;
import org.junit.Test;
-public class GenerationalPathGeneratorTests {
+public class GenerationalArtifactStoreTests {
private static final String TEST_PATH = "target/pathGeneratorTests/";
private static final String TEST_FILENAME = "some.jar";
- private PathGenerator artifactHistory;
+ private ArtifactStore artifactHistory;
@Before
public void setUp() throws Exception {
- this.artifactHistory = new GenerationalPathGenerator(new PathReference(TEST_PATH + TEST_FILENAME));
+ this.artifactHistory = new GenerationalArtifactStore(new PathReference(TEST_PATH + TEST_FILENAME));
}
@Test
@@ -43,7 +43,7 @@ public class GenerationalPathGeneratorTests {
@Test
public void testStash() {
PathReference original = this.artifactHistory.getCurrentPath();
- this.artifactHistory.next();
+ this.artifactHistory.save();
PathReference c = this.artifactHistory.getCurrentPath();
checkPath(c);
assertFalse(original.equals(c));
@@ -52,8 +52,8 @@ public class GenerationalPathGeneratorTests {
@Test
public void testUnstash() {
PathReference original = this.artifactHistory.getCurrentPath();
- this.artifactHistory.next();
- this.artifactHistory.previous();
+ this.artifactHistory.save();
+ this.artifactHistory.restore();
PathReference c = this.artifactHistory.getCurrentPath();
checkPath(c);
assertTrue(original.equals(c));
@@ -63,9 +63,9 @@ public class GenerationalPathGeneratorTests {
@Test
public void testRepeatedStash() {
PathReference original = this.artifactHistory.getCurrentPath();
- this.artifactHistory.next();
+ this.artifactHistory.save();
PathReference next = this.artifactHistory.getCurrentPath();
- this.artifactHistory.next();
+ this.artifactHistory.save();
PathReference last = this.artifactHistory.getCurrentPath();
checkPath(last);
assertFalse(original.equals(next));
@@ -74,21 +74,21 @@ public class GenerationalPathGeneratorTests {
@Test
public void testFileDeletionOnUnstash() {
- this.artifactHistory.next();
+ this.artifactHistory.save();
PathReference c = this.artifactHistory.getCurrentPath();
c.createFile();
assertTrue(c.exists());
- this.artifactHistory.previous();
+ this.artifactHistory.restore();
assertFalse(c.exists());
}
@Test
public void testDirectoryDeletionOnUnstash() {
- this.artifactHistory.next();
+ this.artifactHistory.save();
PathReference c = this.artifactHistory.getCurrentPath();
c.createDirectory();
assertTrue(c.exists());
- this.artifactHistory.previous();
+ this.artifactHistory.restore();
assertFalse(c.exists());
}
@@ -97,9 +97,9 @@ public class GenerationalPathGeneratorTests {
PathReference c = this.artifactHistory.getCurrentPath();
c.createFile();
assertTrue(c.exists());
- this.artifactHistory.next();
+ this.artifactHistory.save();
assertTrue(c.exists());
- this.artifactHistory.next();
+ this.artifactHistory.save();
assertFalse(c.exists());
}
@@ -108,37 +108,37 @@ public class GenerationalPathGeneratorTests {
PathReference c = this.artifactHistory.getCurrentPath();
c.createDirectory();
assertTrue(c.exists());
- this.artifactHistory.next();
+ this.artifactHistory.save();
assertTrue(c.exists());
- this.artifactHistory.next();
+ this.artifactHistory.save();
assertFalse(c.exists());
}
@Test(expected=IllegalStateException.class)
public void testBadUnstash() {
- this.artifactHistory.previous();
+ this.artifactHistory.restore();
}
@Test(expected=IllegalStateException.class)
public void testDoubleUnstash() {
- this.artifactHistory.next();
- this.artifactHistory.next();
- this.artifactHistory.previous();
- this.artifactHistory.previous();
+ this.artifactHistory.save();
+ this.artifactHistory.save();
+ this.artifactHistory.restore();
+ this.artifactHistory.restore();
}
@Test(expected=IllegalArgumentException.class)
public void testNullConstructorPath() {
- new GenerationalPathGenerator(null);
+ new GenerationalArtifactStore(null);
}
@Test(expected=IllegalArgumentException.class)
public void testEmptyConstructorPath() {
- new GenerationalPathGenerator(new PathReference(""));
+ new GenerationalArtifactStore(new PathReference(""));
}
public void testDirectorylessConstructorPath() {
- PathGenerator ph = new GenerationalPathGenerator(new PathReference("a"));
+ ArtifactStore ph = new GenerationalArtifactStore(new PathReference("a"));
assertEquals("a", ph.getCurrentPath().getName());
}

Back to the top