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-12: Switch to AvailablePortHelper for ephemeral ports
Date Mon, 08 Feb 2016 19:58:02 GMT
Repository: incubator-geode
Updated Branches:
  refs/heads/develop 0089b8569 -> 41192cc93


GEODE-12: Switch to AvailablePortHelper for ephemeral ports


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

Branch: refs/heads/develop
Commit: 41192cc93f9ba8138383e026b2f045935cb8658d
Parents: 0089b85
Author: Jens Deppe <jdeppe@pivotal.io>
Authored: Mon Feb 8 11:57:56 2016 -0800
Committer: Jens Deppe <jdeppe@pivotal.io>
Committed: Mon Feb 8 11:57:56 2016 -0800

----------------------------------------------------------------------
 extensions/gemfire-modules/build.gradle         |  1 +
 .../gemfire/modules/session/DualCacheTest.java  | 72 --------------------
 .../modules/session/TestSessionsBase.java       | 32 +++++----
 3 files changed, 19 insertions(+), 86 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/41192cc9/extensions/gemfire-modules/build.gradle
----------------------------------------------------------------------
diff --git a/extensions/gemfire-modules/build.gradle b/extensions/gemfire-modules/build.gradle
index 68197bf..cf22f2c 100644
--- a/extensions/gemfire-modules/build.gradle
+++ b/extensions/gemfire-modules/build.gradle
@@ -35,4 +35,5 @@ dependencies {
   testRuntime 'org.apache.tomcat:coyote:' + project.'tomcat6.version'
 
   provided project(path: ':gemfire-junit')
+  provided project(path: ':gemfire-core', configuration: 'testOutput')
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/41192cc9/extensions/gemfire-modules/src/test/java/com/gemstone/gemfire/modules/session/DualCacheTest.java
----------------------------------------------------------------------
diff --git a/extensions/gemfire-modules/src/test/java/com/gemstone/gemfire/modules/session/DualCacheTest.java
b/extensions/gemfire-modules/src/test/java/com/gemstone/gemfire/modules/session/DualCacheTest.java
deleted file mode 100644
index dbe4b54..0000000
--- a/extensions/gemfire-modules/src/test/java/com/gemstone/gemfire/modules/session/DualCacheTest.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements.  See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License.  You may obtain a copy of the License at
-*
-*      http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-
-package com.gemstone.gemfire.modules.session;
-
-import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
-import com.meterware.httpunit.GetMethodWebRequest;
-import com.meterware.httpunit.WebConversation;
-import com.meterware.httpunit.WebRequest;
-import com.meterware.httpunit.WebResponse;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-/**
- *
- */
-@Category(IntegrationTest.class)
-public class DualCacheTest {
-
-  /**
-   * Check that our session persists. The values we pass in as query params are used to set
attributes on the session.
-   */
-  @Ignore("Ignored while refactoring")
-  @Test
-  public void testSessionFailover() throws Exception {
-    String key = "value_testSessionFailover";
-    String value = "Foo";
-
-    WebConversation wc = new WebConversation();
-    WebRequest req1 = new GetMethodWebRequest("http://localhost:7890/test");
-    req1.setParameter("cmd", QueryCommand.SET.name());
-    req1.setParameter("param", key);
-    req1.setParameter("value", value);
-    WebResponse response = wc.getResponse(req1);
-    String sessionId = response.getNewCookieValue("JSESSIONID");
-
-    assertNotNull("No apparent session cookie", sessionId);
-
-    WebRequest req2 = new GetMethodWebRequest("http://localhost:7891/test");
-    req2.setHeaderField("Cookie", "JSESSIONID=" + sessionId);
-    req2.setParameter("cmd", QueryCommand.GET.name());
-    req2.setParameter("param", key);
-    response = wc.getResponse(req2);
-    sessionId = response.getNewCookieValue("JSESSIONID");
-
-    assertEquals(value, response.getText());
-    assertTrue("The sessionId does not contain the correct JVM route value", sessionId.contains("JVM-2"));
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/41192cc9/extensions/gemfire-modules/src/test/java/com/gemstone/gemfire/modules/session/TestSessionsBase.java
----------------------------------------------------------------------
diff --git a/extensions/gemfire-modules/src/test/java/com/gemstone/gemfire/modules/session/TestSessionsBase.java
b/extensions/gemfire-modules/src/test/java/com/gemstone/gemfire/modules/session/TestSessionsBase.java
index 4b7ab87..544658e 100644
--- a/extensions/gemfire-modules/src/test/java/com/gemstone/gemfire/modules/session/TestSessionsBase.java
+++ b/extensions/gemfire-modules/src/test/java/com/gemstone/gemfire/modules/session/TestSessionsBase.java
@@ -17,6 +17,7 @@
 package com.gemstone.gemfire.modules.session;
 
 import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.internal.AvailablePortHelper;
 import com.gemstone.gemfire.modules.session.catalina.DeltaSessionManager;
 import com.gemstone.gemfire.modules.session.catalina.PeerToPeerCacheLifecycleListener;
 import com.meterware.httpunit.GetMethodWebRequest;
@@ -49,9 +50,12 @@ public abstract class TestSessionsBase {
 
   private static DeltaSessionManager sessionManager;
 
+  private static int port;
+
   // Set up the servers we need
   public static void setupServer(DeltaSessionManager manager) throws Exception {
-    server = new EmbeddedTomcat("/test", 7890, "JVM-1");
+    port = AvailablePortHelper.getRandomAvailableTCPPort();
+    server = new EmbeddedTomcat("/test", port, "JVM-1");
 
     PeerToPeerCacheLifecycleListener p2pListener = new PeerToPeerCacheLifecycleListener();
     p2pListener.setProperty("mcast-port", "0");
@@ -91,7 +95,7 @@ public abstract class TestSessionsBase {
   @Test
   public void testSanity() throws Exception {
     WebConversation wc = new WebConversation();
-    WebRequest req = new GetMethodWebRequest("http://localhost:7890/test");
+    WebRequest req = new GetMethodWebRequest(String.format("http://localhost:%d/test", port));
     req.setParameter("cmd", QueryCommand.GET.name());
     req.setParameter("param", "null");
     WebResponse response = wc.getResponse(req);
@@ -117,7 +121,7 @@ public abstract class TestSessionsBase {
     servlet.getServletContext().setAttribute("callback", c);
 
     WebConversation wc = new WebConversation();
-    WebRequest req = new GetMethodWebRequest("http://localhost:7890/test");
+    WebRequest req = new GetMethodWebRequest(String.format("http://localhost:%d/test", port));
 
     req.setParameter("cmd", QueryCommand.CALLBACK.name());
     req.setParameter("param", "callback");
@@ -142,7 +146,7 @@ public abstract class TestSessionsBase {
     servlet.getServletContext().setAttribute("callback", c);
 
     WebConversation wc = new WebConversation();
-    WebRequest req = new GetMethodWebRequest("http://localhost:7890/test");
+    WebRequest req = new GetMethodWebRequest(String.format("http://localhost:%d/test", port));
 
     req.setParameter("cmd", QueryCommand.CALLBACK.name());
     req.setParameter("param", "callback");
@@ -163,7 +167,7 @@ public abstract class TestSessionsBase {
     String value = "Foo";
 
     WebConversation wc = new WebConversation();
-    WebRequest req = new GetMethodWebRequest("http://localhost:7890/test");
+    WebRequest req = new GetMethodWebRequest(String.format("http://localhost:%d/test", port));
     req.setParameter("cmd", QueryCommand.SET.name());
     req.setParameter("param", key);
     req.setParameter("value", value);
@@ -220,7 +224,7 @@ public abstract class TestSessionsBase {
     String value = "Foo";
 
     WebConversation wc = new WebConversation();
-    WebRequest req = new GetMethodWebRequest("http://localhost:7890/test");
+    WebRequest req = new GetMethodWebRequest(String.format("http://localhost:%d/test", port));
 
     // Set an attribute
     req.setParameter("cmd", QueryCommand.SET.name());
@@ -254,7 +258,7 @@ public abstract class TestSessionsBase {
     String value = "Foo";
 
     WebConversation wc = new WebConversation();
-    WebRequest req = new GetMethodWebRequest("http://localhost:7890/test");
+    WebRequest req = new GetMethodWebRequest(String.format("http://localhost:%d/test", port));
 
     // Set an attribute
     req.setParameter("cmd", QueryCommand.SET.name());
@@ -295,7 +299,7 @@ public abstract class TestSessionsBase {
     String value = "Foo";
 
     WebConversation wc = new WebConversation();
-    WebRequest req = new GetMethodWebRequest("http://localhost:7890/test");
+    WebRequest req = new GetMethodWebRequest(String.format("http://localhost:%d/test", port));
 
     // Set an attribute
     req.setParameter("cmd", QueryCommand.SET.name());
@@ -326,7 +330,7 @@ public abstract class TestSessionsBase {
     String value = "Foo";
 
     WebConversation wc = new WebConversation();
-    WebRequest req = new GetMethodWebRequest("http://localhost:7890/test");
+    WebRequest req = new GetMethodWebRequest(String.format("http://localhost:%d/test", port));
 
     // Set an attribute
     req.setParameter("cmd", QueryCommand.SET.name());
@@ -347,7 +351,7 @@ public abstract class TestSessionsBase {
     String value = "Foo";
 
     WebConversation wc = new WebConversation();
-    WebRequest req = new GetMethodWebRequest("http://localhost:7890/test");
+    WebRequest req = new GetMethodWebRequest(String.format("http://localhost:%d/test", port));
 
     // Set an attribute
     req.setParameter("cmd", QueryCommand.SET.name());
@@ -384,7 +388,7 @@ public abstract class TestSessionsBase {
     servlet.getServletContext().setAttribute("callback", c);
 
     WebConversation wc = new WebConversation();
-    WebRequest req = new GetMethodWebRequest("http://localhost:7890/test");
+    WebRequest req = new GetMethodWebRequest(String.format("http://localhost:%d/test", port));
 
     // Execute the callback
     req.setParameter("cmd", QueryCommand.CALLBACK.name());
@@ -412,7 +416,7 @@ public abstract class TestSessionsBase {
     servlet.getServletContext().setAttribute("callback", c);
 
     WebConversation wc = new WebConversation();
-    WebRequest req = new GetMethodWebRequest("http://localhost:7890/test");
+    WebRequest req = new GetMethodWebRequest(String.format("http://localhost:%d/test", port));
 
     // Execute the callback
     req.setParameter("cmd", QueryCommand.CALLBACK.name());
@@ -437,7 +441,7 @@ public abstract class TestSessionsBase {
     servlet.getServletContext().setAttribute("callback", c);
 
     WebConversation wc = new WebConversation();
-    WebRequest req = new GetMethodWebRequest("http://localhost:7890/test");
+    WebRequest req = new GetMethodWebRequest(String.format("http://localhost:%d/test", port));
 
     // Execute the callback
     req.setParameter("cmd", QueryCommand.CALLBACK.name());
@@ -472,7 +476,7 @@ public abstract class TestSessionsBase {
     servlet.getServletContext().setAttribute("callback", c);
 
     WebConversation wc = new WebConversation();
-    WebRequest req = new GetMethodWebRequest("http://localhost:7890/test");
+    WebRequest req = new GetMethodWebRequest(String.format("http://localhost:%d/test", port));
 
     // Execute the callback
     req.setParameter("cmd", QueryCommand.CALLBACK.name());


Mime
View raw message