Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlyn Normington2012-07-18 15:17:48 +0000
committerGlyn Normington2012-07-18 15:17:48 +0000
commit9cc2a8197824d3ad2eead1633a8816ecbc3fab5f (patch)
tree461b85dc00ad881919a812a3a1bccdecb4ca690b /org.eclipse.virgo.kernel.artifact
parent300514a6d82cf23bba3226babc775849c9de937a (diff)
downloadorg.eclipse.virgo.kernel-9cc2a8197824d3ad2eead1633a8816ecbc3fab5f.tar.gz
org.eclipse.virgo.kernel-9cc2a8197824d3ad2eead1633a8816ecbc3fab5f.tar.xz
org.eclipse.virgo.kernel-9cc2a8197824d3ad2eead1633a8816ecbc3fab5f.zip
add unit test
Diffstat (limited to 'org.eclipse.virgo.kernel.artifact')
-rw-r--r--org.eclipse.virgo.kernel.artifact/src/test/java/org/eclipse/virgo/kernel/artifact/fs/internal/JarFileArtifactFSRefreshTests.java67
-rw-r--r--org.eclipse.virgo.kernel.artifact/src/test/resources/refresh/simple.module.jarbin0 -> 377 bytes
-rw-r--r--org.eclipse.virgo.kernel.artifact/src/test/resources/refresh/simple2.module.jarbin0 -> 378 bytes
3 files changed, 67 insertions, 0 deletions
diff --git a/org.eclipse.virgo.kernel.artifact/src/test/java/org/eclipse/virgo/kernel/artifact/fs/internal/JarFileArtifactFSRefreshTests.java b/org.eclipse.virgo.kernel.artifact/src/test/java/org/eclipse/virgo/kernel/artifact/fs/internal/JarFileArtifactFSRefreshTests.java
new file mode 100644
index 00000000..b96d2f00
--- /dev/null
+++ b/org.eclipse.virgo.kernel.artifact/src/test/java/org/eclipse/virgo/kernel/artifact/fs/internal/JarFileArtifactFSRefreshTests.java
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 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.artifact.fs.internal;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Scanner;
+
+import org.eclipse.virgo.kernel.artifact.fs.ArtifactFS;
+import org.eclipse.virgo.kernel.artifact.fs.ArtifactFSEntry;
+import org.eclipse.virgo.util.io.PathReference;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Emulate the file manipulations when refreshing a bundle and test that JarFileArtifactFS does not perform
+ * inappropriate caching.
+ */
+public class JarFileArtifactFSRefreshTests {
+
+ private PathReference testModule;
+
+ @Before
+ public void setUp() throws Exception {
+ PathReference pr = new PathReference("./target/redeploy-refresh");
+ pr.delete(true);
+ pr.createDirectory();
+ this.testModule = pr.newChild("simple.module.jar");
+ }
+
+ @Test
+ public void testRefresh() throws Exception {
+ PathReference simpleModule = new PathReference("src/test/resources/refresh/simple.module.jar");
+ simpleModule.copy(this.testModule);
+
+ ArtifactFS artifactFS = new JarFileArtifactFS(new PathReference("./target/redeploy-refresh/simple.module.jar").toFile());
+
+ checkBsn(artifactFS, "simple.module");
+
+ this.testModule.delete();
+ new PathReference("src/test/resources/refresh/simple2.module.jar").copy(this.testModule);
+
+ JarFileArtifactFS fs = new JarFileArtifactFS(new PathReference("./target/redeploy-refresh/simple.module.jar").toFile());
+
+ checkBsn(fs, "simple2.module");
+ }
+
+ public void checkBsn(ArtifactFS artifactFS, String bsn) throws IOException {
+ ArtifactFSEntry entry = artifactFS.getEntry("META-INF/MANIFEST.MF");
+ InputStream inputStream = entry.getInputStream();
+ String manifest = new Scanner(inputStream).useDelimiter("\\A").next();
+ assertTrue(manifest.contains(bsn));
+ inputStream.close();
+ }
+
+}
diff --git a/org.eclipse.virgo.kernel.artifact/src/test/resources/refresh/simple.module.jar b/org.eclipse.virgo.kernel.artifact/src/test/resources/refresh/simple.module.jar
new file mode 100644
index 00000000..a1738c44
--- /dev/null
+++ b/org.eclipse.virgo.kernel.artifact/src/test/resources/refresh/simple.module.jar
Binary files differ
diff --git a/org.eclipse.virgo.kernel.artifact/src/test/resources/refresh/simple2.module.jar b/org.eclipse.virgo.kernel.artifact/src/test/resources/refresh/simple2.module.jar
new file mode 100644
index 00000000..cefbadbf
--- /dev/null
+++ b/org.eclipse.virgo.kernel.artifact/src/test/resources/refresh/simple2.module.jar
Binary files differ

Back to the top