Repository: geode
Updated Branches:
  refs/heads/develop 755f63624 -> c5b121175


http://git-wip-us.apache.org/repos/asf/geode/blob/c5b12117/geode-assembly/src/test/java/org/apache/geode/session/tests/GenericAppServerClientServerTest.java
----------------------------------------------------------------------
diff --git 
a/geode-assembly/src/test/java/org/apache/geode/session/tests/GenericAppServerClientServerTest.java
 
b/geode-assembly/src/test/java/org/apache/geode/session/tests/GenericAppServerClientServerTest.java
index ea4022b..413f9e3 100644
--- 
a/geode-assembly/src/test/java/org/apache/geode/session/tests/GenericAppServerClientServerTest.java
+++ 
b/geode-assembly/src/test/java/org/apache/geode/session/tests/GenericAppServerClientServerTest.java
@@ -15,18 +15,36 @@
 package org.apache.geode.session.tests;
 
 import org.junit.Before;
+import static org.junit.Assert.assertEquals;
 
 import org.apache.geode.cache.Cache;
+import org.apache.geode.cache.Region;
+import org.apache.geode.cache.RegionShortcut;
 import org.apache.geode.cache.server.CacheServer;
+import org.apache.geode.modules.session.functions.GetSessionCount;
+import org.apache.geode.modules.util.RegionHelper;
 import org.apache.geode.test.dunit.Host;
 import org.apache.geode.test.dunit.VM;
 
+import org.awaitility.Awaitility;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.io.IOException;
+import java.net.URISyntaxException;
+import java.util.concurrent.TimeUnit;
+
+import javax.servlet.http.HttpSession;
+
 /**
  * Extends the {@link CargoTestBase} class to support client server tests of 
generic app servers
  *
  * Currently being used to test Jetty 9 containers in client server mode.
  */
 public abstract class GenericAppServerClientServerTest extends CargoTestBase {
+
+  protected VM serverVM;
+
   /**
    * Starts the server for the client containers to connect to while testing.
    */
@@ -34,9 +52,8 @@ public abstract class GenericAppServerClientServerTest 
extends CargoTestBase {
   public void startServers() throws InterruptedException {
     // Setup host
     Host host = Host.getHost(0);
-    VM vm0 = host.getVM(0);
-    // Start server in VM
-    vm0.invoke(() -> {
+    serverVM = host.getVM(0);
+    serverVM.invoke(() -> {
       Cache cache = getCache();
       // Add cache server
       CacheServer server = cache.addCacheServer();
@@ -45,4 +62,55 @@ public abstract class GenericAppServerClientServerTest 
extends CargoTestBase {
       server.start();
     });
   }
+
+  /**
+   * Test that we don't leave native sessions in the container, wasting memory
+   */
+  @Test
+  public void shouldNotLeaveNativeSessionInContainer()
+      throws IOException, URISyntaxException, InterruptedException {
+    manager.startAllInactiveContainers();
+
+    String key = "value_testSessionExpiration";
+    String value = "Foo";
+
+    client.setPort(Integer.parseInt(manager.getContainerPort(0)));
+    Client.Response resp = client.set(key, value);
+    String cookie = resp.getSessionCookie();
+
+    for (int i = 0; i < manager.numContainers(); i++) {
+      client.setPort(Integer.parseInt(manager.getContainerPort(i)));
+      resp = client.get(key);
+
+      assertEquals("Sessions are not replicating properly", cookie, 
resp.getSessionCookie());
+      assertEquals(value, resp.getResponse());
+    }
+
+    for (int i = 0; i < manager.numContainers(); i++) {
+      client.setPort(Integer.parseInt(manager.getContainerPort(i)));
+      resp = client.executionFunction(GetSessionCount.class);
+      assertEquals("Should have 0 native sessions", "0", resp.getResponse());
+    }
+  }
+
+  @Override
+  protected void verifySessionIsRemoved(String key) throws IOException, 
URISyntaxException {
+    serverVM.invoke(() -> {
+      Cache cache = getCache();
+      Region region = cache.getRegion("gemfire_modules_sessions");
+      Awaitility.await().atMost(1, TimeUnit.MINUTES).until(() -> 
assertEquals(0, region.size()));
+    });
+    super.verifySessionIsRemoved(key);
+  }
+
+  @Override
+  protected void verifyMaxInactiveInterval(int expected) throws IOException, 
URISyntaxException {
+    super.verifyMaxInactiveInterval(expected);
+    serverVM.invoke(() -> {
+      Cache cache = getCache();
+      Region<Object, HttpSession> region =
+          cache.<Object, HttpSession>getRegion("gemfire_modules_sessions");
+      region.values().forEach(session -> assertEquals(expected, 
session.getMaxInactiveInterval()));
+    });
+  }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/c5b12117/geode-assembly/src/test/java/org/apache/geode/session/tests/GenericAppServerContainer.java
----------------------------------------------------------------------
diff --git 
a/geode-assembly/src/test/java/org/apache/geode/session/tests/GenericAppServerContainer.java
 
b/geode-assembly/src/test/java/org/apache/geode/session/tests/GenericAppServerContainer.java
index 11c76fc..fbd9593 100644
--- 
a/geode-assembly/src/test/java/org/apache/geode/session/tests/GenericAppServerContainer.java
+++ 
b/geode-assembly/src/test/java/org/apache/geode/session/tests/GenericAppServerContainer.java
@@ -77,7 +77,8 @@ public class GenericAppServerContainer extends 
ServerContainer {
     setLocator(install.getDefaultLocatorAddress(), 
install.getDefaultLocatorPort());
 
     // Make sure that local caches are disabled by default
-    setCacheProperty("enable_local_cache", "false");
+    setCacheProperty("enable_local_cache",
+        Boolean.toString(install.getConnectionType().enableLocalCache()));
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/geode/blob/c5b12117/geode-assembly/src/test/java/org/apache/geode/session/tests/Jetty9CachingClientServerTest.java
----------------------------------------------------------------------
diff --git 
a/geode-assembly/src/test/java/org/apache/geode/session/tests/Jetty9CachingClientServerTest.java
 
b/geode-assembly/src/test/java/org/apache/geode/session/tests/Jetty9CachingClientServerTest.java
new file mode 100644
index 0000000..bcad0cc
--- /dev/null
+++ 
b/geode-assembly/src/test/java/org/apache/geode/session/tests/Jetty9CachingClientServerTest.java
@@ -0,0 +1,83 @@
+/*
+ * 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.
+ */
+package org.apache.geode.session.tests;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
+import java.net.URISyntaxException;
+import java.util.concurrent.TimeUnit;
+
+import javax.servlet.http.HttpSession;
+
+import org.awaitility.Awaitility;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import org.apache.geode.cache.Cache;
+import org.apache.geode.cache.Region;
+import org.apache.geode.modules.session.functions.GetSessionCount;
+import org.apache.geode.test.dunit.DUnitEnv;
+
+/**
+ * Jetty 9 Client Server tests
+ *
+ * Runs all the tests in {@link CargoTestBase} on the Jetty 9 install, setup 
in the
+ * {@link #setupJettyInstall()} method before tests are run.
+ */
+public class Jetty9CachingClientServerTest extends 
GenericAppServerClientServerTest {
+  private static ContainerInstall install;
+
+  @BeforeClass
+  public static void setupJettyInstall() throws Exception {
+    install = new 
GenericAppServerInstall(GenericAppServerInstall.GenericAppServerVersion.JETTY9,
+        ContainerInstall.ConnectionType.CACHING_CLIENT_SERVER,
+        ContainerInstall.DEFAULT_INSTALL_DIR + 
"Jetty9CachingClientServerTest");
+    install.setDefaultLocator(DUnitEnv.get().getLocatorAddress(), 
DUnitEnv.get().getLocatorPort());
+  }
+
+  @Override
+  public ContainerInstall getInstall() {
+    return install;
+  }
+
+  /**
+   * Test that we cache the user's session on the client, rather than going to 
the server for each
+   * request
+   */
+  @Test
+  public void shouldCacheSessionOnClient()
+      throws IOException, URISyntaxException, InterruptedException {
+    manager.startAllInactiveContainers();
+
+    String key = "value_testSessionExpiration";
+    String value = "Foo";
+
+    client.setPort(Integer.parseInt(manager.getContainerPort(0)));
+    Client.Response resp = client.set(key, value);
+    String cookie = resp.getSessionCookie();
+
+    // Modify the values on the server
+    serverVM.invoke(() -> {
+      Cache cache = getCache();
+      Region<String, HttpSession> region = 
cache.getRegion("gemfire_modules_sessions");
+      region.values().forEach(session -> session.setAttribute(key, "bogus"));
+    });
+
+    // Make sure the client still sees it's original cached value
+    resp = client.get(key);
+    assertEquals(value, resp.getResponse());
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/c5b12117/geode-assembly/src/test/java/org/apache/geode/session/tests/ServerContainer.java
----------------------------------------------------------------------
diff --git 
a/geode-assembly/src/test/java/org/apache/geode/session/tests/ServerContainer.java
 
b/geode-assembly/src/test/java/org/apache/geode/session/tests/ServerContainer.java
index 39ec42c..3434180 100644
--- 
a/geode-assembly/src/test/java/org/apache/geode/session/tests/ServerContainer.java
+++ 
b/geode-assembly/src/test/java/org/apache/geode/session/tests/ServerContainer.java
@@ -174,17 +174,19 @@ public abstract class ServerContainer {
           + " failed to start because it is currently " + 
container.getState());
 
     LocalConfiguration config = getConfiguration();
-    int[] ports = AvailablePortHelper.getRandomAvailableTCPPorts(3);
+    int[] ports = AvailablePortHelper.getRandomAvailableTCPPorts(4);
     // Set container ports from available ports
     config.setProperty(ServletPropertySet.PORT, Integer.toString(ports[0]));
     config.setProperty(GeneralPropertySet.RMI_PORT, 
Integer.toString(ports[1]));
     config.setProperty(TomcatPropertySet.AJP_PORT, Integer.toString(ports[2]));
     config.setProperty(GeneralPropertySet.PORT_OFFSET, "0");
+    config.setProperty(GeneralPropertySet.START_JVMARGS,
+        "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=" + 
ports[3]);
     container.setConfiguration(config);
 
-    try {
-      logger.info("Starting container " + description);
 
+    try {
+      logger.info("Starting container " + description + "RMI Port: " + 
ports[3]);
       // Writes settings to the expected form (either XML or WAR file)
       writeSettings();
       // Start the container through cargo

http://git-wip-us.apache.org/repos/asf/geode/blob/c5b12117/geode-docs/tools_modules/http_session_mgmt/weblogic_setting_up_the_module.html.md.erb
----------------------------------------------------------------------
diff --git 
a/geode-docs/tools_modules/http_session_mgmt/weblogic_setting_up_the_module.html.md.erb
 
b/geode-docs/tools_modules/http_session_mgmt/weblogic_setting_up_the_module.html.md.erb
index 1f12d54..27dc1df 100644
--- 
a/geode-docs/tools_modules/http_session_mgmt/weblogic_setting_up_the_module.html.md.erb
+++ 
b/geode-docs/tools_modules/http_session_mgmt/weblogic_setting_up_the_module.html.md.erb
@@ -31,7 +31,7 @@ $ modify_war -h
 
 To modify your war or ear file manually, make the following updates:
 
--   **web.xml** needs a filter and listener added as follows. If you have your 
own filters, the <%=vars.product_name%> Module filter **must** be the first one.
+-   **web.xml** needs a filter added as follows. If you have your own filters, 
the <%=vars.product_name%> Module filter **must** be the first one.
 
     ``` pre
     <filter>
@@ -52,9 +52,6 @@ To modify your war or ear file manually, make the following 
updates:
         <filter-name>gemfire-session-filter</filter-name>
         <url-pattern>/*</url-pattern>
     </filter-mapping>
-    <listener>
-        
<listener-class>org.apache.geode.modules.session.filter.SessionListener</listener-class>
-    </listener>
     ```
 
 -   Add the following jar files from the AppServer.zip to the `WEB-INF/lib` 
directory of the war:

Reply via email to