geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jensde...@apache.org
Subject incubator-geode git commit: GEODE-1324: Convert SessionReplicationIntegrationJUnitTest to use TemporaryFolder
Date Fri, 29 Apr 2016 17:49:01 GMT
Repository: incubator-geode
Updated Branches:
  refs/heads/develop a20efb927 -> b2f8e594c


GEODE-1324: Convert SessionReplicationIntegrationJUnitTest to use TemporaryFolder


Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/b2f8e594
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/b2f8e594
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/b2f8e594

Branch: refs/heads/develop
Commit: b2f8e594cab721755c7c47cf1e609775a81c3340
Parents: a20efb9
Author: Jens Deppe <jdeppe@pivotal.io>
Authored: Fri Apr 29 09:34:07 2016 -0700
Committer: Jens Deppe <jdeppe@pivotal.io>
Committed: Fri Apr 29 10:47:20 2016 -0700

----------------------------------------------------------------------
 .../SessionReplicationIntegrationJUnitTest.java | 30 +++++++-------------
 1 file changed, 10 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b2f8e594/extensions/geode-modules-session/src/test/java/com/gemstone/gemfire/modules/session/internal/filter/SessionReplicationIntegrationJUnitTest.java
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-session/src/test/java/com/gemstone/gemfire/modules/session/internal/filter/SessionReplicationIntegrationJUnitTest.java
b/extensions/geode-modules-session/src/test/java/com/gemstone/gemfire/modules/session/internal/filter/SessionReplicationIntegrationJUnitTest.java
index 004f9fe..ef89a37 100644
--- a/extensions/geode-modules-session/src/test/java/com/gemstone/gemfire/modules/session/internal/filter/SessionReplicationIntegrationJUnitTest.java
+++ b/extensions/geode-modules-session/src/test/java/com/gemstone/gemfire/modules/session/internal/filter/SessionReplicationIntegrationJUnitTest.java
@@ -41,8 +41,12 @@ import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
 import org.apache.jasper.servlet.JspServlet;
 import org.junit.After;
 import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
+import org.junit.Rule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
+import org.junit.rules.TemporaryFolder;
 import org.junit.runner.RunWith;
 import org.eclipse.jetty.servlet.FilterHolder;
 import org.eclipse.jetty.servlet.ServletHolder;
@@ -68,23 +72,13 @@ public class SessionReplicationIntegrationJUnitTest {
 
   private FilterHolder filterHolder;
 
-  private static final File tmpdir;
-
-  private static final String gemfire_log;
-
-  static {
-    // Create a per-user scratch directory
-    tmpdir = new File(System.getProperty("java.io.tmpdir"), // TODO: use junit rule TemporaryFolder
-        "gemfire_modules-" + System.getProperty("user.name"));
-    tmpdir.mkdirs();
-    tmpdir.deleteOnExit();
-
-    gemfire_log = tmpdir.getPath() +
-        System.getProperty("file.separator") + "gemfire_modules.log";
-  }
+  @Rule
+  public TemporaryFolder tmpdir = new TemporaryFolder();
 
   @Before
   public void setUp() throws Exception {
+    File gemfireLogFile = new File(tmpdir.newFolder(), "gemfire_modules.log");
+
     request = HttpTester.newRequest();
 
     tester = new MyServletTester();
@@ -92,7 +86,7 @@ public class SessionReplicationIntegrationJUnitTest {
 
     filterHolder = tester.addFilter(SessionCachingFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));
     filterHolder.setInitParameter("gemfire.property.mcast-port", "0");
-    filterHolder.setInitParameter("gemfire.property.log-file", gemfire_log);
+    filterHolder.setInitParameter("gemfire.property.log-file", gemfireLogFile.getAbsolutePath());
     filterHolder.setInitParameter("cache-type", "peer-to-peer");
 
     servletHolder = tester.addServlet(BasicServlet.class, "/hello");
@@ -107,10 +101,6 @@ public class SessionReplicationIntegrationJUnitTest {
 
   @After
   public void tearDown() throws Exception {
-//    if (tester.isStarted()) {
-//      ContextManager.getInstance().removeContext(
-//          servletHolder.getServlet().getServletConfig().getServletContext());
-//    }
     tester.stop();
   }
 
@@ -1467,7 +1457,7 @@ public class SessionReplicationIntegrationJUnitTest {
     ServletHolder jspHolder = tester.addServlet(JspServlet.class, "/test/*");
     jspHolder.setInitOrder(1);
 
-    jspHolder.setInitParameter("scratchdir", tmpdir.getPath());
+    jspHolder.setInitParameter("scratchdir", tmpdir.toString());
 
     Callback c_1 = new Callback() {
       @Override


Mime
View raw message