changeset 1165:7e1a098d6335

Use temporary cache in PluginBridge unit tests 2015-03-02 Jie Kang <jkang@redhat.com> Use temporary cache in PluginBridge unit tests * tests/netx/unit/net/sourceforge/jnlp/PluginBridgeTest.java: sets temporary cache in @BeforeClass and unsets in @AfterClass
author Jie Kang <jkang@redhat.com>
date Mon, 02 Mar 2015 10:02:35 -0500
parents 85fe0274f4a8
children 11b46740b094
files ChangeLog tests/netx/unit/net/sourceforge/jnlp/PluginBridgeTest.java
diffstat 2 files changed, 27 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Mon Mar 02 14:23:39 2015 +0100
+++ b/ChangeLog	Mon Mar 02 10:02:35 2015 -0500
@@ -1,3 +1,9 @@
+2015-03-02  Jie Kang  <jkang@redhat.com>
+
+	Use temporary cache in PluginBridge unit tests
+	* tests/netx/unit/net/sourceforge/jnlp/PluginBridgeTest.java: sets
+	temporary cache in @BeforeClass and unsets in @AfterClass
+
 2015-02-27  Jiri Vanek  <jvanek@redhat.com>
 
 	Silenced to verbose unittests
--- a/tests/netx/unit/net/sourceforge/jnlp/PluginBridgeTest.java	Mon Mar 02 14:23:39 2015 +0100
+++ b/tests/netx/unit/net/sourceforge/jnlp/PluginBridgeTest.java	Mon Mar 02 10:02:35 2015 -0500
@@ -24,6 +24,7 @@
 
 import static org.junit.Assert.assertEquals;
 
+import java.io.File;
 import java.io.IOException;
 import java.net.MalformedURLException;
 import java.net.URL;
@@ -32,11 +33,17 @@
 import java.util.Map;
 import java.util.List;
 
+import net.sourceforge.jnlp.cache.CacheUtil;
 import net.sourceforge.jnlp.cache.UpdatePolicy;
+import net.sourceforge.jnlp.config.DeploymentConfiguration;
+import net.sourceforge.jnlp.runtime.JNLPRuntime;
 import net.sourceforge.jnlp.util.logging.NoStdOutErrTest;
 import net.sourceforge.jnlp.util.replacements.BASE64Encoder;
+
+import org.junit.AfterClass;
 import org.junit.Assert;
 
+import org.junit.BeforeClass;
 import org.junit.Test;
 
 public class PluginBridgeTest extends NoStdOutErrTest{
@@ -74,6 +81,20 @@
         return new PluginParameters(params);
     }
 
+    private static String originalCacheDir;
+
+    @BeforeClass
+    public static void setup() {
+        originalCacheDir = JNLPRuntime.getConfiguration().getProperty(DeploymentConfiguration.KEY_USER_CACHE_DIR);
+        JNLPRuntime.getConfiguration().setProperty(DeploymentConfiguration.KEY_USER_CACHE_DIR, System.getProperty("java.io.tmpdir") + File.separator + "tempcache");
+    }
+
+    @AfterClass
+    public static void teardown() {
+        CacheUtil.clearCache();
+        JNLPRuntime.getConfiguration().setProperty(DeploymentConfiguration.KEY_USER_CACHE_DIR, originalCacheDir);
+    }
+
     @Test
     public void testAbsoluteJNLPHref() throws MalformedURLException, Exception {
         URL codeBase = new URL("http://undesired.absolute.codebase.com");