You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by je...@apache.org on 2015/12/29 22:11:00 UTC
[06/24] incubator-geode git commit: GEODE-14: Move GemFire Sessions
module and relocate all packages to 'internal'
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/92ee6a79/modules/gemfire-modules-session-external/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/SessionCachingFilter.java
----------------------------------------------------------------------
diff --git a/modules/gemfire-modules-session-external/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/SessionCachingFilter.java b/modules/gemfire-modules-session-external/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/SessionCachingFilter.java
new file mode 100644
index 0000000..b3dada5
--- /dev/null
+++ b/modules/gemfire-modules-session-external/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/SessionCachingFilter.java
@@ -0,0 +1,639 @@
+/*=========================================================================
+ * Copyright (c) 2010-2014 Pivotal Software, Inc. All Rights Reserved.
+ * This product is protected by U.S. and international copyright
+ * and intellectual property laws. Pivotal products are covered by
+ * one or more patents listed at http://www.pivotal.io/patents.
+ *=========================================================================
+ */
+package com.gemstone.gemfire.modules.session.internal.filter;
+
+import com.gemstone.gemfire.modules.session.internal.filter.util.ThreadLocalSession;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletRequestWrapper;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpServletResponseWrapper;
+import javax.servlet.http.HttpSession;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.security.Principal;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.atomic.AtomicInteger;
+
+/**
+ * Primary class which orchestrates everything. This is the class which gets
+ * configured in the web.xml.
+ */
+public class SessionCachingFilter implements Filter {
+
+ /**
+ * Logger instance
+ */
+ private static final Logger LOG =
+ LoggerFactory.getLogger(SessionCachingFilter.class.getName());
+
+ /**
+ * The filter configuration object we are associated with. If this value is
+ * null, this filter instance is not currently configured.
+ */
+ private FilterConfig filterConfig = null;
+
+ /**
+ * Some containers will want to instantiate multiple instances of this filter,
+ * but we only need one SessionManager
+ */
+ private static SessionManager manager = null;
+
+ /**
+ * Can be overridden during testing.
+ */
+ private static AtomicInteger started =
+ new AtomicInteger(
+ Integer.getInteger("gemfire.override.session.manager.count", 1));
+
+ private static int percentInactiveTimeTriggerRebuild =
+ Integer.getInteger("gemfire.session.inactive.trigger.rebuild", 80);
+
+ /**
+ * This latch ensures that at least one thread/instance has fired up the
+ * session manager before any other threads complete the init method.
+ */
+ private static CountDownLatch startingLatch = new CountDownLatch(1);
+
+ /**
+ * This request wrapper class extends the support class
+ * HttpServletRequestWrapper, which implements all the methods in the
+ * HttpServletRequest interface, as delegations to the wrapped request. You
+ * only need to override the methods that you need to change. You can get
+ * access to the wrapped request using the method getRequest()
+ */
+ public static class RequestWrapper extends HttpServletRequestWrapper {
+
+ private static final String URL_SESSION_IDENTIFIER = ";jsessionid=";
+
+ private ResponseWrapper response;
+
+ private boolean sessionFromCookie = false;
+
+ private boolean sessionFromURL = false;
+
+ private String requestedSessionId = null;
+
+ private GemfireHttpSession session = null;
+
+ private SessionManager manager;
+
+ private HttpServletRequest outerRequest = null;
+
+ /**
+ * Need to save this in case we need the original {@code RequestDispatcher}
+ */
+ private HttpServletRequest originalRequest;
+
+ public RequestWrapper(SessionManager manager,
+ HttpServletRequest request,
+ ResponseWrapper response) {
+
+ super(request);
+ this.response = response;
+ this.manager = manager;
+ this.originalRequest = request;
+
+ final Cookie[] cookies = request.getCookies();
+ if (cookies != null) {
+ for (final Cookie cookie : cookies) {
+ if (cookie.getName().equalsIgnoreCase(
+ manager.getSessionCookieName()) &&
+ cookie.getValue().endsWith("-GF")) {
+ requestedSessionId = cookie.getValue();
+ sessionFromCookie = true;
+
+ LOG.debug("Cookie contains sessionId: {}",
+ requestedSessionId);
+ }
+ }
+ }
+
+ if (requestedSessionId == null) {
+ requestedSessionId = extractSessionId();
+ LOG.debug("Extracted sessionId from URL {}", requestedSessionId);
+ if (requestedSessionId != null) {
+ sessionFromURL = true;
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public HttpSession getSession() {
+ return getSession(true);
+ }
+
+ /**
+ * Create our own sessions. TODO: Handle invalidated sessions
+ *
+ * @return a HttpSession
+ */
+ @Override
+ public HttpSession getSession(boolean create) {
+ if (session != null && session.isValid()) {
+ session.setIsNew(false);
+ session.updateAccessTime();
+ /*
+ * This is a massively gross hack. Currently, there is no way
+ * to actually update the last accessed time for a session, so
+ * what we do here is once we're into X% of the session's TTL
+ * we grab a new session from the container.
+ *
+ * (inactive * 1000) * (pct / 100) ==> (inactive * 10 * pct)
+ */
+ if (session.getLastAccessedTime() - session.getCreationTime() >
+ (session.getMaxInactiveInterval() * 10 * percentInactiveTimeTriggerRebuild)) {
+ HttpSession nativeSession = super.getSession();
+ session.failoverSession(nativeSession);
+ }
+ return session;
+ }
+
+ if (requestedSessionId != null) {
+ session = (GemfireHttpSession) manager.getSession(
+ requestedSessionId);
+ if (session != null) {
+ session.setIsNew(false);
+ // This means we've failed over to another node
+ if (session.getNativeSession() == null) {
+ try {
+ ThreadLocalSession.set(session);
+ HttpSession nativeSession = super.getSession();
+ session.failoverSession(nativeSession);
+ session.putInRegion();
+ } finally {
+ ThreadLocalSession.remove();
+ }
+ }
+ }
+ }
+
+ if (session == null || !session.isValid()) {
+ if (create) {
+ try {
+ session = (GemfireHttpSession) manager.wrapSession(null);
+ ThreadLocalSession.set(session);
+ HttpSession nativeSession = super.getSession();
+ if (session.getNativeSession() == null) {
+ session.setNativeSession(nativeSession);
+ } else {
+ assert (session.getNativeSession() == nativeSession);
+ }
+ session.setIsNew(true);
+ manager.putSession(session);
+ } finally {
+ ThreadLocalSession.remove();
+ }
+ } else {
+ // create is false, and session is either null or not valid.
+ // The spec says return a null:
+ return null;
+ }
+ }
+
+ if (session != null) {
+ addSessionCookie(response);
+ session.updateAccessTime();
+ }
+
+ return session;
+ }
+
+ private void addSessionCookie(HttpServletResponse response) {
+ // Don't bother if the response is already committed
+ if (response.isCommitted()) {
+ return;
+ }
+
+ // Get the existing cookies
+ Cookie[] cookies = getCookies();
+
+ Cookie cookie = new Cookie(manager.getSessionCookieName(),
+ session.getId());
+ cookie.setPath("".equals(getContextPath()) ? "/" : getContextPath());
+ // Clear out all old cookies and just set ours
+ response.addCookie(cookie);
+
+ // Replace all other cookies which aren't JSESSIONIDs
+ if (cookies != null) {
+ for (Cookie c : cookies) {
+ if (manager.getSessionCookieName().equals(c.getName())) {
+ continue;
+ }
+ response.addCookie(c);
+ }
+ }
+
+ }
+
+ private String getCookieString(Cookie c) {
+ StringBuilder cookie = new StringBuilder();
+ cookie.append(c.getName()).append("=").append(c.getValue());
+
+ if (c.getPath() != null) {
+ cookie.append("; ").append("Path=").append(c.getPath());
+ }
+ if (c.getDomain() != null) {
+ cookie.append("; ").append("Domain=").append(c.getDomain());
+ }
+ if (c.getSecure()) {
+ cookie.append("; ").append("Secure");
+ }
+
+ cookie.append("; HttpOnly");
+
+ return cookie.toString();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean isRequestedSessionIdFromCookie() {
+ return sessionFromCookie;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean isRequestedSessionIdFromURL() {
+ return sessionFromURL;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getRequestedSessionId() {
+ if (requestedSessionId != null) {
+ return requestedSessionId;
+ } else {
+ return super.getRequestedSessionId();
+ }
+ }
+
+ /*
+ * Hmmm... not sure if this is right or even good to do. So, in some
+ * cases - for ex. using a Spring security filter, we have 3 possible
+ * wrappers to deal with - the original, this one and one created by
+ * Spring. When a servlet or JSP is forwarded to the original request
+ * is passed in, but then this (the wrapped) request is used by the JSP.
+ * In some cases, the outer wrapper also contains information relevant
+ * to the request - in this case security info. So here we allow access
+ * to that. There's probably a better way....
+ */
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Principal getUserPrincipal() {
+ if (outerRequest != null) {
+ return outerRequest.getUserPrincipal();
+ } else {
+ return super.getUserPrincipal();
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getRemoteUser() {
+ if (outerRequest != null) {
+ return outerRequest.getRemoteUser();
+ } else {
+ return super.getRemoteUser();
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean isUserInRole(String role) {
+ if (outerRequest != null) {
+ return outerRequest.isUserInRole(role);
+ } else {
+ return super.isUserInRole(role);
+ }
+ }
+
+ //////////////////////////////////////////////////////////////
+ // Non-API methods
+
+ void setOuterWrapper(HttpServletRequest outer) {
+ this.outerRequest = outer;
+ }
+
+ //////////////////////////////////////////////////////////////
+ // Private methods
+ private String extractSessionId() {
+ final int prefix = getRequestURL().indexOf(URL_SESSION_IDENTIFIER);
+ if (prefix != -1) {
+ final int start = prefix + URL_SESSION_IDENTIFIER.length();
+ int suffix = getRequestURL().indexOf("?", start);
+ if (suffix < 0) {
+ suffix = getRequestURL().indexOf("#", start);
+ }
+ if (suffix <= prefix) {
+ return getRequestURL().substring(start);
+ }
+ return getRequestURL().substring(start, suffix);
+ }
+ return null;
+ }
+ }
+
+ /**
+ * This response wrapper class extends the support class
+ * HttpServletResponseWrapper, which implements all the methods in the
+ * HttpServletResponse interface, as delegations to the wrapped response. You
+ * only need to override the methods that you need to change. You can get
+ * access to the wrapped response using the method getResponse()
+ */
+ class ResponseWrapper extends HttpServletResponseWrapper {
+
+ HttpServletResponse originalResponse;
+
+ public ResponseWrapper(HttpServletResponse response) throws IOException {
+ super(response);
+ originalResponse = response;
+ }
+
+ public HttpServletResponse getOriginalResponse() {
+ return originalResponse;
+ }
+
+ @Override
+ public void setHeader(String name, String value) {
+ super.setHeader(name, value);
+ }
+
+ @Override
+ public void setIntHeader(String name, int value) {
+ super.setIntHeader(name, value);
+ }
+ }
+
+
+ public SessionCachingFilter() {
+ }
+
+ /**
+ * @param request The servlet request we are processing
+ * @param response The servlet response we are creating
+ * @param chain The filter chain we are processing
+ * @throws IOException if an input/output error occurs
+ * @throws ServletException if a servlet error occurs
+ */
+ @Override
+ public void doFilter(ServletRequest request, ServletResponse response,
+ FilterChain chain)
+ throws IOException, ServletException {
+
+ HttpServletRequest httpReq = (HttpServletRequest) request;
+ HttpServletResponse httpResp = (HttpServletResponse) response;
+
+ /**
+ * Early out if this isn't the right kind of request. We might see a
+ * RequestWrapper instance during a forward or include request.
+ */
+ if (request instanceof RequestWrapper ||
+ !(request instanceof HttpServletRequest)) {
+ LOG.debug("Handling already-wrapped request");
+ chain.doFilter(request, response);
+ return;
+ }
+
+ // Create wrappers for the request and response objects.
+ // Using these, you can extend the capabilities of the
+ // request and response, for example, allow setting parameters
+ // on the request before sending the request to the rest of the filter chain,
+ // or keep track of the cookies that are set on the response.
+ //
+ // Caveat: some servers do not handle wrappers very well for forward or
+ // include requests.
+
+ ResponseWrapper wrappedResponse = new ResponseWrapper(httpResp);
+ final RequestWrapper wrappedRequest =
+ new RequestWrapper(manager, httpReq, wrappedResponse);
+
+ Throwable problem = null;
+
+ try {
+ chain.doFilter(wrappedRequest, wrappedResponse);
+ } catch (Throwable t) {
+ // If an exception is thrown somewhere down the filter chain,
+ // we still want to execute our after processing, and then
+ // rethrow the problem after that.
+ problem = t;
+ LOG.error("Exception processing filter chain", t);
+ }
+
+ GemfireHttpSession session =
+ (GemfireHttpSession) wrappedRequest.getSession(false);
+
+ // If there was a problem, we want to rethrow it if it is
+ // a known type, otherwise log it.
+ if (problem != null) {
+ if (problem instanceof ServletException) {
+ throw (ServletException) problem;
+ }
+ if (problem instanceof IOException) {
+ throw (IOException) problem;
+ }
+ sendProcessingError(problem, response);
+ }
+
+ /**
+ * Commit any updates. What actually happens at that point is
+ * dependent on the type of attributes defined for use by the sessions.
+ */
+ if (session != null) {
+ session.commit();
+ }
+ }
+
+ /**
+ * Return the filter configuration object for this filter.
+ */
+ public FilterConfig getFilterConfig() {
+ return (this.filterConfig);
+ }
+
+ /**
+ * Set the filter configuration object for this filter.
+ *
+ * @param filterConfig The filter configuration object
+ */
+ public void setFilterConfig(FilterConfig filterConfig) {
+ this.filterConfig = filterConfig;
+ }
+
+ /**
+ * Destroy method for this filter
+ */
+ @Override
+ public void destroy() {
+ if (manager != null) {
+ manager.stop();
+ }
+ }
+
+ /**
+ * This is where all the initialization happens.
+ *
+ * @param config
+ * @throws ServletException
+ */
+ @Override
+ public void init(final FilterConfig config) {
+ LOG.info("Starting Session Filter initialization");
+ this.filterConfig = config;
+
+ if (started.getAndDecrement() > 0) {
+ /**
+ * Allow override for testing purposes
+ */
+ String managerClassStr =
+ config.getInitParameter("session-manager-class");
+
+ // Otherwise default
+ if (managerClassStr == null) {
+ managerClassStr = GemfireSessionManager.class.getName();
+ }
+
+ try {
+ manager = (SessionManager) Class.forName(
+ managerClassStr).newInstance();
+ manager.start(config, this.getClass().getClassLoader());
+ } catch (Exception ex) {
+ LOG.error("Exception creating Session Manager", ex);
+ }
+
+ startingLatch.countDown();
+ } else {
+ try {
+ startingLatch.await();
+ } catch (InterruptedException iex) {
+ }
+
+ LOG.debug("SessionManager and listener initialization skipped - "
+ + "already done.");
+ }
+
+ LOG.info("Session Filter initialization complete");
+ LOG.debug("Filter class loader {}", this.getClass().getClassLoader());
+ }
+
+ /**
+ * Return a String representation of this object.
+ */
+ @Override
+ public String toString() {
+ if (filterConfig == null) {
+ return ("SessionCachingFilter()");
+ }
+ StringBuilder sb = new StringBuilder("SessionCachingFilter(");
+ sb.append(filterConfig);
+ sb.append(")");
+ return (sb.toString());
+
+ }
+
+
+ private void sendProcessingError(Throwable t, ServletResponse response) {
+ String stackTrace = getStackTrace(t);
+
+ if (stackTrace != null && !stackTrace.equals("")) {
+ try {
+ response.setContentType("text/html");
+ PrintStream ps = new PrintStream(response.getOutputStream());
+ PrintWriter pw = new PrintWriter(ps);
+ pw.print(
+ "<html>\n<head>\n<title>Error</title>\n</head>\n<body>\n"); //NOI18N
+
+ // PENDING! Localize this for next official release
+ pw.print("<h1>The resource did not process correctly</h1>\n<pre>\n");
+ pw.print(stackTrace);
+ pw.print("</pre></body>\n</html>"); //NOI18N
+ pw.close();
+ ps.close();
+ response.getOutputStream().close();
+ } catch (Exception ex) {
+ }
+ } else {
+ try {
+ PrintStream ps = new PrintStream(response.getOutputStream());
+ t.printStackTrace(ps);
+ ps.close();
+ response.getOutputStream().close();
+ } catch (Exception ex) {
+ }
+ }
+ }
+
+ public static String getStackTrace(Throwable t) {
+ String stackTrace = null;
+ try {
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ t.printStackTrace(pw);
+ pw.close();
+ sw.close();
+ stackTrace = sw.getBuffer().toString();
+ } catch (Exception ex) {
+ }
+ return stackTrace;
+ }
+
+ /**
+ * Retrieve the SessionManager. This is only here so that tests can get access
+ * to the cache.
+ */
+ static SessionManager getSessionManager() {
+ return manager;
+ }
+
+ /**
+ * Return the GemFire session which wraps a native session
+ *
+ * @param nativeSession the native session for which the corresponding GemFire
+ * session should be returned.
+ * @return the GemFire session or null if no session maps to the native
+ * session
+ */
+ public static HttpSession getWrappingSession(HttpSession nativeSession) {
+ /*
+ * This is a special case where the GemFire session has been set as a
+ * ThreadLocal during session creation.
+ */
+ GemfireHttpSession gemfireSession = (GemfireHttpSession) ThreadLocalSession.get();
+ if (gemfireSession != null) {
+ gemfireSession.setNativeSession(nativeSession);
+ return gemfireSession;
+ }
+ return getSessionManager().getWrappingSession(nativeSession.getId());
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/92ee6a79/modules/gemfire-modules-session-external/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/SessionListener.java
----------------------------------------------------------------------
diff --git a/modules/gemfire-modules-session-external/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/SessionListener.java b/modules/gemfire-modules-session-external/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/SessionListener.java
new file mode 100644
index 0000000..254fafe
--- /dev/null
+++ b/modules/gemfire-modules-session-external/src/main/java/com/gemstone/gemfire/modules/session/internal/filter/SessionListener.java
@@ -0,0 +1,41 @@
+/*=========================================================================
+ * Copyright (c) 2010-2014 Pivotal Software, Inc. All Rights Reserved.
+ * This product is protected by U.S. and international copyright
+ * and intellectual property laws. Pivotal products are covered by
+ * one or more patents listed at http://www.pivotal.io/patents.
+ *=========================================================================
+ */
+package com.gemstone.gemfire.modules.session.internal.filter;
+
+import com.gemstone.gemfire.distributed.DistributedSystemDisconnectedException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.servlet.http.HttpSessionEvent;
+import javax.servlet.http.HttpSessionListener;
+
+public class SessionListener implements HttpSessionListener {
+
+ private static final Logger LOG =
+ LoggerFactory.getLogger(SessionListener.class.getName());
+
+ public void sessionCreated(HttpSessionEvent httpSessionEvent) {
+ }
+
+ /**
+ * This will receive events from the container using the native sessions.
+ */
+ public void sessionDestroyed(HttpSessionEvent event) {
+ String nativeId = event.getSession().getId();
+ try {
+ String sessionId = SessionCachingFilter.getSessionManager().destroyNativeSession(
+ nativeId);
+ LOG.debug(
+ "Received sessionDestroyed event for native session {} (wrapped by {})",
+ nativeId, sessionId);
+ } catch (DistributedSystemDisconnectedException dex) {
+ LOG.debug("Cache disconnected - unable to destroy native session {0}",
+ nativeId);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/92ee6a79/modules/gemfire-modules-session-external/src/test/java/com/gemstone/gemfire/modules/session/filter/AbstractListener.java
----------------------------------------------------------------------
diff --git a/modules/gemfire-modules-session-external/src/test/java/com/gemstone/gemfire/modules/session/filter/AbstractListener.java b/modules/gemfire-modules-session-external/src/test/java/com/gemstone/gemfire/modules/session/filter/AbstractListener.java
deleted file mode 100644
index 75e5c8b..0000000
--- a/modules/gemfire-modules-session-external/src/test/java/com/gemstone/gemfire/modules/session/filter/AbstractListener.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*=========================================================================
- * Copyright (c) 2010-2014 Pivotal Software, Inc. All Rights Reserved.
- * This product is protected by U.S. and international copyright
- * and intellectual property laws. Pivotal products are covered by
- * one or more patents listed at http://www.pivotal.io/patents.
- *=========================================================================
- */
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-
-package com.gemstone.gemfire.modules.session.filter;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-/**
- * @author jdeppe
- */
-public abstract class AbstractListener {
-
- protected final List<ListenerEventType> events =
- new ArrayList<ListenerEventType>();
-
- protected CountDownLatch latch;
-
- public AbstractListener() {
- this(1);
- }
-
- public AbstractListener(int numCalls) {
- latch = new CountDownLatch(numCalls);
- RendezvousManager.registerListener(this);
- }
-
- public synchronized void setLatch(int numCalls) {
- latch = new CountDownLatch(numCalls);
- events.clear();
- }
-
- public boolean await(long timeout,
- TimeUnit unit) throws InterruptedException {
- return latch.await(timeout, unit);
- }
-
- public List<ListenerEventType> getEvents() {
- return events;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/92ee6a79/modules/gemfire-modules-session-external/src/test/java/com/gemstone/gemfire/modules/session/filter/Callback.java
----------------------------------------------------------------------
diff --git a/modules/gemfire-modules-session-external/src/test/java/com/gemstone/gemfire/modules/session/filter/Callback.java b/modules/gemfire-modules-session-external/src/test/java/com/gemstone/gemfire/modules/session/filter/Callback.java
deleted file mode 100644
index ccca6c4..0000000
--- a/modules/gemfire-modules-session-external/src/test/java/com/gemstone/gemfire/modules/session/filter/Callback.java
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-
-package com.gemstone.gemfire.modules.session.filter;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-/**
- * @author jdeppe
- */
-public interface Callback {
- public void call(HttpServletRequest request,
- HttpServletResponse response);
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/92ee6a79/modules/gemfire-modules-session-external/src/test/java/com/gemstone/gemfire/modules/session/filter/CallbackServlet.java
----------------------------------------------------------------------
diff --git a/modules/gemfire-modules-session-external/src/test/java/com/gemstone/gemfire/modules/session/filter/CallbackServlet.java b/modules/gemfire-modules-session-external/src/test/java/com/gemstone/gemfire/modules/session/filter/CallbackServlet.java
deleted file mode 100644
index 69c2e09..0000000
--- a/modules/gemfire-modules-session-external/src/test/java/com/gemstone/gemfire/modules/session/filter/CallbackServlet.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*=========================================================================
- * Copyright (c) 2010-2014 Pivotal Software, Inc. All Rights Reserved.
- * This product is protected by U.S. and international copyright
- * and intellectual property laws. Pivotal products are covered by
- * one or more patents listed at http://www.pivotal.io/patents.
- *=========================================================================
- */
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-package com.gemstone.gemfire.modules.session.filter;
-
-import java.io.IOException;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-/**
- * @author jdeppe
- */
-public class CallbackServlet extends HttpServlet {
-
- private Callback callback;
-
- /**
- * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
- * methods.
- *
- * @param request servlet request
- * @param response servlet response
- * @throws ServletException if a servlet-specific error occurs
- * @throws IOException if an I/O error occurs
- */
- protected void processRequest(HttpServletRequest request,
- HttpServletResponse response)
- throws ServletException, IOException {
-
- if (callback != null) {
- callback.call(request, response);
- }
- }
-
- public void setCallback(Callback callback) {
- this.callback = callback;
- }
-
- /**
- * Handles the HTTP <code>GET</code> method.
- *
- * @param request servlet request
- * @param response servlet response
- * @throws ServletException if a servlet-specific error occurs
- * @throws IOException if an I/O error occurs
- */
- @Override
- protected void doGet(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
- processRequest(request, response);
- }
-
- /**
- * Handles the HTTP <code>POST</code> method.
- *
- * @param request servlet request
- * @param response servlet response
- * @throws ServletException if a servlet-specific error occurs
- * @throws IOException if an I/O error occurs
- */
- @Override
- protected void doPost(HttpServletRequest request,
- HttpServletResponse response)
- throws ServletException, IOException {
- processRequest(request, response);
- }
-
- /**
- * Returns a short description of the servlet.
- *
- * @return a String containing servlet description
- */
- @Override
- public String getServletInfo() {
- return "Short description";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/92ee6a79/modules/gemfire-modules-session-external/src/test/java/com/gemstone/gemfire/modules/session/filter/CommonTests.java
----------------------------------------------------------------------
diff --git a/modules/gemfire-modules-session-external/src/test/java/com/gemstone/gemfire/modules/session/filter/CommonTests.java b/modules/gemfire-modules-session-external/src/test/java/com/gemstone/gemfire/modules/session/filter/CommonTests.java
deleted file mode 100644
index 8a8a829..0000000
--- a/modules/gemfire-modules-session-external/src/test/java/com/gemstone/gemfire/modules/session/filter/CommonTests.java
+++ /dev/null
@@ -1,583 +0,0 @@
-/*=========================================================================
- * Copyright (c) 2010-2014 Pivotal Software, Inc. All Rights Reserved.
- * This product is protected by U.S. and international copyright
- * and intellectual property laws. Pivotal products are covered by
- * one or more patents listed at http://www.pivotal.io/patents.
- *=========================================================================
- */
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-package com.gemstone.gemfire.modules.session.filter;
-
-import com.mockrunner.mock.web.MockFilterConfig;
-import com.mockrunner.mock.web.MockHttpServletRequest;
-import com.mockrunner.mock.web.MockHttpServletResponse;
-import com.mockrunner.mock.web.MockHttpSession;
-import com.mockrunner.servlet.BasicServletTestCaseAdapter;
-import org.junit.After;
-import org.junit.Ignore;
-import org.junit.Test;
-
-import java.util.concurrent.TimeUnit;
-import javax.servlet.http.Cookie;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpSession;
-import javax.servlet.http.HttpSessionAttributeListener;
-
-import static junit.framework.Assert.assertEquals;
-import static org.junit.Assert.*;
-
-/**
- * This servlet tests the effects of the downstream SessionCachingFilter filter.
- * When these tests are performed, the filter would already have taken effect.
- */
-public abstract class CommonTests extends BasicServletTestCaseAdapter {
-
- protected static final String CONTEXT_PATH = "/test";
-
- @After
- public void tearDown() throws Exception {
- super.tearDown();
- }
-
- @Test
- public void testGetSession1() throws Exception {
- doFilter();
- HttpSession session1 =
- ((HttpServletRequest) getFilteredRequest()).getSession();
- HttpSession session2 =
- ((HttpServletRequest) getFilteredRequest()).getSession();
-
- assertSame("Session should be the same", session1, session2);
- }
-
- @Test
- public void testGetSession2() throws Exception {
- doFilter();
-
- HttpSession session1 = ((HttpServletRequest) getFilteredRequest()).getSession();
-
- MockHttpServletResponse response = getWebMockObjectFactory().getMockResponse();
- Cookie cookie = (Cookie) response.getCookies().get(0);
- getWebMockObjectFactory().getMockRequest().addCookie(cookie);
-
- doFilter();
-
- HttpSession session2 = ((HttpServletRequest) getFilteredRequest()).getSession();
-
- assertEquals("Session objects across requests should be the same", session1, session2);
- }
-
- @Test
- public void testGetAttributeRequest1() throws Exception {
- doFilter();
-
- getFilteredRequest().setAttribute("foo", "bar");
-
- assertEquals("bar", getFilteredRequest().getAttribute("foo"));
- assertNull("Unknown attribute should be null",
- getFilteredRequest().getAttribute("baz"));
- }
-
- @Test
- public void testGetAttributeRequest2() throws Exception {
- // Setup
- CallbackServlet s = (CallbackServlet) getServlet();
- s.setCallback(new Callback() {
- @Override
- public void call(HttpServletRequest request, HttpServletResponse response) {
- request.setAttribute("foo", "bar");
- }
- });
- doFilter();
-
- assertEquals("bar", getFilteredRequest().getAttribute("foo"));
- assertNull("Unknown attribute should be null",
- getFilteredRequest().getAttribute("baz"));
- }
-
- @Test
- public void testGetAttributeSession1() throws Exception {
- doFilter();
-
- ((HttpServletRequest) getFilteredRequest()).getSession().setAttribute("foo", "bar");
-
- HttpServletRequest request = (HttpServletRequest) getFilteredRequest();
- assertEquals("bar", request.getSession().getAttribute("foo"));
- }
-
- /**
- * Are attributes preserved across client requests?
- */
- @Test
- public void testGetAttributeSession2() throws Exception {
- doFilter();
-
- ((HttpServletRequest) getFilteredRequest()).getSession().setAttribute("foo", "bar");
-
- MockHttpServletResponse response = getWebMockObjectFactory().getMockResponse();
- Cookie cookie = (Cookie) response.getCookies().get(0);
- getWebMockObjectFactory().getMockRequest().addCookie(cookie);
-
- doFilter();
- HttpServletRequest request = (HttpServletRequest) getFilteredRequest();
-
- assertEquals("bar", request.getSession().getAttribute("foo"));
- }
-
- /**
- * Setting a session attribute to null should remove it
- */
- @Test
- public void testSetAttributeNullSession1() throws Exception {
- // Setup
- CallbackServlet s = (CallbackServlet) getServlet();
- s.setCallback(new Callback() {
- private boolean called = false;
-
- @Override
- public void call(HttpServletRequest request, HttpServletResponse response) {
- if (called) {
- request.getSession().setAttribute("foo", null);
- } else {
- request.getSession().setAttribute("foo", "bar");
- called = true;
- }
- }
- });
-
- doFilter();
- doFilter();
-
- HttpSession session = ((HttpServletRequest) getFilteredRequest()).getSession();
-
- String attr = (String) session.getAttribute("foo");
- assertNull("Attribute should be null but is " + attr, attr);
- }
-
-
- /**
- * Test that various methods throw the appropriate exception when the session is
- * invalid.
- */
- @Test
- public void testInvalidate1() throws Exception {
- doFilter();
-
- HttpSession session = ((HttpServletRequest) getFilteredRequest()).getSession();
- session.invalidate();
-
- try {
- session.getAttribute("foo");
- fail("Session should be invalid and an exception should be thrown");
- } catch (IllegalStateException iex) {
- // Pass
- }
- }
-
- @Test
- public void testInvalidate2() throws Exception {
- doFilter();
-
- HttpSession session = ((HttpServletRequest) getFilteredRequest()).getSession();
- session.invalidate();
-
- try {
- session.getAttributeNames();
- fail("Session should be invalid and an exception should be thrown");
- } catch (IllegalStateException iex) {
- // Pass
- }
- }
-
- @Ignore(value = "until mockrunner 1.0.9 - see pull request #23")
- public void testInvalidate3() throws Exception {
- doFilter();
-
- HttpSession session = ((HttpServletRequest) getFilteredRequest()).getSession();
- session.invalidate();
-
- try {
- session.getCreationTime();
- fail("Session should be invalid and an exception should be thrown");
- } catch (IllegalStateException iex) {
- // Pass
- }
- }
-
- @Test
- public void testInvalidate4() throws Exception {
- doFilter();
-
- HttpSession session = ((HttpServletRequest) getFilteredRequest()).getSession();
- session.invalidate();
-
- try {
- session.getId();
- } catch (Exception iex) {
- fail("Exception should not be thrown");
- }
- }
-
- @Test
- public void testInvalidate5() throws Exception {
- doFilter();
-
- HttpSession session = ((HttpServletRequest) getFilteredRequest()).getSession();
- session.invalidate();
-
- try {
- session.getLastAccessedTime();
- fail("Session should be invalid and an exception should be thrown");
- } catch (IllegalStateException iex) {
- // Pass
- }
- }
-
- @Test
- public void testInvalidate6() throws Exception {
- doFilter();
-
- HttpSession session = ((HttpServletRequest) getFilteredRequest()).getSession();
- session.invalidate();
-
- try {
- session.getMaxInactiveInterval();
- } catch (Exception ex) {
- fail("Exception should not be thrown");
- }
- }
-
- @Test
- public void testInvalidate7() throws Exception {
- doFilter();
-
- HttpSession session = ((HttpServletRequest) getFilteredRequest()).getSession();
- session.invalidate();
-
- try {
- session.getServletContext();
- } catch (Exception ex) {
- fail("Exception should not be thrown");
- }
- }
-
- @Test
- public void testInvalidate8() throws Exception {
- doFilter();
-
- HttpSession session = ((HttpServletRequest) getFilteredRequest()).getSession();
- session.invalidate();
-
- try {
- session.isNew();
- fail("Session should be invalid and an exception should be thrown");
- } catch (IllegalStateException iex) {
- // Pass
- }
- }
-
- @Test
- public void testInvalidate9() throws Exception {
- doFilter();
-
- HttpSession session = ((HttpServletRequest) getFilteredRequest()).getSession();
- session.invalidate();
-
- try {
- session.removeAttribute("foo");
- fail("Session should be invalid and an exception should be thrown");
- } catch (IllegalStateException iex) {
- // Pass
- }
- }
-
- @Test
- public void testInvalidate10() throws Exception {
- doFilter();
-
- HttpSession session = ((HttpServletRequest) getFilteredRequest()).getSession();
- session.invalidate();
-
- try {
- session.setAttribute("foo", "bar");
- fail("Session should be invalid and an exception should be thrown");
- } catch (IllegalStateException iex) {
- // Pass
- }
- }
-
- @Test
- public void testInvalidate11() throws Exception {
- doFilter();
-
- HttpSession session = ((HttpServletRequest) getFilteredRequest()).getSession();
- session.invalidate();
-
- try {
- session.setMaxInactiveInterval(1);
- } catch (Exception ex) {
- fail("Exception should not be thrown");
- }
- }
-
- /**
- * Test that Session Attribute events get triggered
- */
- @Test
- public void testSessionAttributeListener1() throws Exception {
- AbstractListener listener = new HttpSessionAttributeListenerImpl();
- RendezvousManager.registerListener(listener);
- listener.setLatch(3);
-
- doFilter();
-
- // Ugh
- MockHttpSession session = (MockHttpSession) ((GemfireHttpSession) ((HttpServletRequest) getFilteredRequest()).getSession()).getNativeSession();
- session.addAttributeListener((HttpSessionAttributeListener) listener);
- session.setAttribute("foo", "bar");
- session.setAttribute("foo", "baz");
- session.setAttribute("foo", null);
-
- assertTrue("Event timeout", listener.await(1, TimeUnit.SECONDS));
- assertEquals(ListenerEventType.SESSION_ATTRIBUTE_ADDED, listener.getEvents().get(0));
- assertEquals(ListenerEventType.SESSION_ATTRIBUTE_REPLACED,
- listener.getEvents().get(1));
- assertEquals(ListenerEventType.SESSION_ATTRIBUTE_REMOVED,
- listener.getEvents().get(2));
- }
-
- /**
- * Test that both replace and remove events get triggered
- */
- @Test
- public void testHttpSessionBindingListener1() throws Exception {
- doFilter();
-
- HttpSession session =
- ((HttpServletRequest) getFilteredRequest()).getSession();
-
- HttpSessionBindingListenerImpl listener1 =
- new HttpSessionBindingListenerImpl(2);
- HttpSessionBindingListenerImpl listener2 =
- new HttpSessionBindingListenerImpl(2);
-
- session.setAttribute("foo", listener1);
- session.setAttribute("foo", listener2);
- session.setAttribute("foo", null);
-
- assertTrue("Event timeout", listener1.await(1, TimeUnit.SECONDS));
- assertTrue("Event timeout", listener2.await(1, TimeUnit.SECONDS));
-
- assertEquals("Event list size incorrect", 2, listener1.getEvents().size());
- assertEquals("Event list size incorrect", 2, listener2.getEvents().size());
- assertEquals(ListenerEventType.SESSION_VALUE_BOUND, listener1.getEvents().get(0));
- assertEquals(ListenerEventType.SESSION_VALUE_UNBOUND,
- listener1.getEvents().get(1));
- assertEquals(ListenerEventType.SESSION_VALUE_BOUND, listener2.getEvents().get(0));
- assertEquals(ListenerEventType.SESSION_VALUE_UNBOUND,
- listener2.getEvents().get(1));
- }
-
- @Test
- public void testGetId1() throws Exception {
- doFilter();
-
- assertNotNull("Session Id should not be null",
- ((HttpServletRequest) getFilteredRequest()).getSession().getId());
- }
-
- /**
- * Test that multiple calls from the same client return the same session id
- */
- @Test
- public void testGetId2() throws Exception {
- doFilter();
-
- String sessionId = ((HttpServletRequest) getFilteredRequest()).getSession().getId();
-
- MockHttpServletResponse response = getWebMockObjectFactory().getMockResponse();
- Cookie cookie = (Cookie) response.getCookies().get(0);
- getWebMockObjectFactory().getMockRequest().addCookie(cookie);
-
- doFilter();
-
- assertEquals("Session Ids should be the same", sessionId,
- ((HttpServletRequest) getFilteredRequest()).getSession().getId());
- }
-
- @Test
- public void testGetCreationTime1() throws Exception {
- doFilter();
-
- HttpServletRequest request = (HttpServletRequest) getFilteredRequest();
- assertTrue("Session should have a non-zero creation time",
- request.getSession().getCreationTime() > 0);
- }
-
-
- /**
- * Test that multiple calls from the same client don't change the creation time.
- */
- @Test
- public void testGetCreationTime2() throws Exception {
- doFilter();
-
- long creationTime = ((HttpServletRequest) getFilteredRequest()).getSession().getCreationTime();
-
- MockHttpServletResponse response = getWebMockObjectFactory().getMockResponse();
- Cookie cookie = (Cookie) response.getCookies().get(0);
- getWebMockObjectFactory().getMockRequest().addCookie(cookie);
-
- doFilter();
-
- assertEquals("Session creation time should be the same", creationTime,
- ((HttpServletRequest) getFilteredRequest()).getSession().getCreationTime());
- }
-
- @Test
- public void testResponseContainsRequestedSessionId1() throws Exception {
- Cookie cookie = new Cookie("JSESSIONID", "999-GF");
- getWebMockObjectFactory().getMockRequest().addCookie(cookie);
-
- doFilter();
-
- HttpServletRequest request = (HttpServletRequest) getFilteredRequest();
-
- assertEquals("Request does not contain requested session ID", "999-GF",
- request.getRequestedSessionId());
- }
-
- @Test
- public void testGetLastAccessedTime1() throws Exception {
- doFilter();
-
- HttpServletRequest request = (HttpServletRequest) getFilteredRequest();
- assertTrue("Session should have a non-zero last access time",
- request.getSession().getLastAccessedTime() > 0);
- }
-
-
- /**
- * Test that repeated accesses update the last accessed time
- */
- @Test
- public void testGetLastAccessedTime2() throws Exception {
- // Setup
- CallbackServlet s = (CallbackServlet) getServlet();
- s.setCallback(new Callback() {
-
- @Override
- public void call(HttpServletRequest request, HttpServletResponse response) {
- request.getSession();
- }
- });
-
- doFilter();
-
- HttpServletRequest request = (HttpServletRequest) getFilteredRequest();
- long lastAccess = request.getSession().getLastAccessedTime();
- assertTrue("Session should have a non-zero last access time", lastAccess > 0);
-
- MockHttpServletResponse response = getWebMockObjectFactory().getMockResponse();
- Cookie cookie = (Cookie) response.getCookies().get(0);
-
- MockHttpServletRequest mRequest = getWebMockObjectFactory().createMockRequest();
- mRequest.setRequestURL("/test/foo/bar");
- mRequest.setContextPath(CONTEXT_PATH);
- mRequest.addCookie(cookie);
- getWebMockObjectFactory().addRequestWrapper(mRequest);
-
- Thread.sleep(50);
- doFilter();
-
- assertTrue("Last access time should be changing",
- request.getSession().getLastAccessedTime() > lastAccess);
- }
-
- @Test
- public void testGetSetMaxInactiveInterval() throws Exception {
- doFilter();
-
- HttpServletRequest request = (HttpServletRequest) getFilteredRequest();
- request.getSession().setMaxInactiveInterval(50);
-
- assertEquals(50, request.getSession().getMaxInactiveInterval());
- }
-
- @Test
- public void testIsNew1() throws Exception {
- doFilter();
-
- HttpServletRequest request = (HttpServletRequest) getFilteredRequest();
- assertTrue("Session should be new", request.getSession().isNew());
- }
-
- /**
- * Subsequent calls should not return true
- */
- @Test
- public void testIsNew2() throws Exception {
- // Setup
- CallbackServlet s = (CallbackServlet) getServlet();
- s.setCallback(new Callback() {
-
- @Override
- public void call(HttpServletRequest request, HttpServletResponse response) {
- request.getSession();
- }
- });
-
- doFilter();
-
- HttpServletRequest request = (HttpServletRequest) getFilteredRequest();
- request.getSession();
-
- MockHttpServletResponse response = getWebMockObjectFactory().getMockResponse();
- Cookie cookie = (Cookie) response.getCookies().get(0);
-
- MockHttpServletRequest mRequest = getWebMockObjectFactory().createMockRequest();
- mRequest.setRequestURL("/test/foo/bar");
- mRequest.setContextPath(CONTEXT_PATH);
- mRequest.addCookie(cookie);
- getWebMockObjectFactory().addRequestWrapper(mRequest);
-
- doFilter();
-
- request = (HttpServletRequest) getFilteredRequest();
- HttpSession s1 = request.getSession();
-
- assertFalse("Subsequent isNew() calls should be false", request.getSession().isNew());
- }
-
- @Test
- public void testIsRequestedSessionIdFromCookie() {
- MockHttpServletRequest mRequest = getWebMockObjectFactory().getMockRequest();
- Cookie c = new Cookie("JSESSIONID", "1-GF");
- mRequest.addCookie(c);
-
- doFilter();
- HttpServletRequest request = (HttpServletRequest) getFilteredRequest();
- request.getSession();
-
- assertTrue(request.isRequestedSessionIdFromCookie());
- }
-
- @Test
- public void testIsRequestedSessionIdFromURL() {
- MockHttpServletRequest mRequest = getWebMockObjectFactory().getMockRequest();
- mRequest.setRequestURL("/foo/bar;jsessionid=1");
-
- doFilter();
- HttpServletRequest request = (HttpServletRequest) getFilteredRequest();
- request.getSession();
-
- assertFalse("Session ID should not be from cookie",
- request.isRequestedSessionIdFromCookie());
- assertTrue("Session ID should be from URL", request.isRequestedSessionIdFromURL());
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/92ee6a79/modules/gemfire-modules-session-external/src/test/java/com/gemstone/gemfire/modules/session/filter/GemfireCacheTest.java
----------------------------------------------------------------------
diff --git a/modules/gemfire-modules-session-external/src/test/java/com/gemstone/gemfire/modules/session/filter/GemfireCacheTest.java b/modules/gemfire-modules-session-external/src/test/java/com/gemstone/gemfire/modules/session/filter/GemfireCacheTest.java
deleted file mode 100644
index 01ce9fb..0000000
--- a/modules/gemfire-modules-session-external/src/test/java/com/gemstone/gemfire/modules/session/filter/GemfireCacheTest.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*=========================================================================
- * Copyright (c) 2010-2014 Pivotal Software, Inc. All Rights Reserved.
- * This product is protected by U.S. and international copyright
- * and intellectual property laws. Pivotal products are covered by
- * one or more patents listed at http://www.pivotal.io/patents.
- *=========================================================================
- */
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-package com.gemstone.gemfire.modules.session.filter;
-
-import com.mockrunner.mock.web.MockFilterConfig;
-import com.mockrunner.mock.web.MockServletConfig;
-import org.junit.Before;
-
-/**
- * This servlet tests the effects of the downstream SessionCachingFilter filter.
- * When these tests are performed, the filter would already have taken effect.
- */
-public class GemfireCacheTest extends CommonTests {
-
- @Before
- public void setUp() throws Exception {
- super.setUp();
- getWebMockObjectFactory().getMockRequest().setRequestURL("/test/foo/bar");
- getWebMockObjectFactory().getMockRequest().setContextPath(CONTEXT_PATH);
- MockFilterConfig config = getWebMockObjectFactory().getMockFilterConfig();
-
- config.setInitParameter("gemfire.property.mcast-port", "19991");
- config.setInitParameter("cache-type", "peer-to-peer");
- System.setProperty("gemfire.logdir", "/tmp");
-
- getWebMockObjectFactory().getMockServletContext().setContextPath(
- CONTEXT_PATH);
-
- setDoChain(true);
-
- createFilter(SessionCachingFilter.class);
- createServlet(CallbackServlet.class);
-
- MockServletConfig servletConfig = getWebMockObjectFactory().getMockServletConfig();
- ContextManager.getInstance().putContext(servletConfig.getServletContext());
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/92ee6a79/modules/gemfire-modules-session-external/src/test/java/com/gemstone/gemfire/modules/session/filter/GemfireLocalCacheTest.java
----------------------------------------------------------------------
diff --git a/modules/gemfire-modules-session-external/src/test/java/com/gemstone/gemfire/modules/session/filter/GemfireLocalCacheTest.java b/modules/gemfire-modules-session-external/src/test/java/com/gemstone/gemfire/modules/session/filter/GemfireLocalCacheTest.java
deleted file mode 100644
index df01899..0000000
--- a/modules/gemfire-modules-session-external/src/test/java/com/gemstone/gemfire/modules/session/filter/GemfireLocalCacheTest.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*=========================================================================
- * Copyright (c) 2010-2014 Pivotal Software, Inc. All Rights Reserved.
- * This product is protected by U.S. and international copyright
- * and intellectual property laws. Pivotal products are covered by
- * one or more patents listed at http://www.pivotal.io/patents.
- *=========================================================================
- */
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-package com.gemstone.gemfire.modules.session.filter;
-
-import com.mockrunner.mock.web.MockFilterConfig;
-import com.mockrunner.mock.web.MockHttpServletRequest;
-import com.mockrunner.mock.web.MockHttpServletResponse;
-import com.mockrunner.mock.web.MockServletConfig;
-import com.mockrunner.servlet.BasicServletTestCaseAdapter;
-import org.junit.After;
-import org.junit.Before;
-
-import javax.servlet.Filter;
-import javax.servlet.http.Cookie;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-
-/**
- * This servlet tests the effects of the downstream SessionCachingFilter filter.
- * When these tests are performed, the filter would already have taken effect.
- */
-public class GemfireLocalCacheTest extends BasicServletTestCaseAdapter {
-
- Filter filter;
-
- protected static final String CONTEXT_PATH = "/test";
-
- @Before
- public void setUp() throws Exception {
- super.setUp();
- getWebMockObjectFactory().getMockRequest().setRequestURL("/test/foo/bar");
- getWebMockObjectFactory().getMockRequest().setContextPath(CONTEXT_PATH);
- MockFilterConfig config = getWebMockObjectFactory().getMockFilterConfig();
-
- config.setInitParameter("gemfire.property.mcast-port", "19991");
- config.setInitParameter("cache-type", "peer-to-peer");
- config.setInitParameter("gemfire.cache.enable_local_cache", "true");
- System.setProperty("gemfire.logdir", "/tmp");
-
- getWebMockObjectFactory().getMockServletContext().setContextPath(
- CONTEXT_PATH);
-
- setDoChain(true);
-
- filter = createFilter(SessionCachingFilter.class);
- createServlet(CallbackServlet.class);
-
- MockServletConfig servletConfig = getWebMockObjectFactory().getMockServletConfig();
- ContextManager.getInstance().putContext(servletConfig.getServletContext());
- }
-
- @After
- public void tearDown() throws Exception {
- super.tearDown();
- filter.destroy();
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/92ee6a79/modules/gemfire-modules-session-external/src/test/java/com/gemstone/gemfire/modules/session/filter/HttpSessionAttributeListenerImpl.java
----------------------------------------------------------------------
diff --git a/modules/gemfire-modules-session-external/src/test/java/com/gemstone/gemfire/modules/session/filter/HttpSessionAttributeListenerImpl.java b/modules/gemfire-modules-session-external/src/test/java/com/gemstone/gemfire/modules/session/filter/HttpSessionAttributeListenerImpl.java
deleted file mode 100644
index 484d8f7..0000000
--- a/modules/gemfire-modules-session-external/src/test/java/com/gemstone/gemfire/modules/session/filter/HttpSessionAttributeListenerImpl.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*=========================================================================
- * Copyright (c) 2010-2014 Pivotal Software, Inc. All Rights Reserved.
- * This product is protected by U.S. and international copyright
- * and intellectual property laws. Pivotal products are covered by
- * one or more patents listed at http://www.pivotal.io/patents.
- *=========================================================================
- */
-
-package com.gemstone.gemfire.modules.session.filter;
-
-import javax.servlet.http.HttpSessionAttributeListener;
-import javax.servlet.http.HttpSessionBindingEvent;
-
-/**
- *
- */
-public class HttpSessionAttributeListenerImpl extends AbstractListener
- implements HttpSessionAttributeListener {
-
- @Override
- public synchronized void attributeAdded(HttpSessionBindingEvent se) {
- events.add(ListenerEventType.SESSION_ATTRIBUTE_ADDED);
- latch.countDown();
- }
-
- @Override
- public synchronized void attributeRemoved(HttpSessionBindingEvent se) {
- events.add(ListenerEventType.SESSION_ATTRIBUTE_REMOVED);
- latch.countDown();
- }
-
- @Override
- public synchronized void attributeReplaced(HttpSessionBindingEvent se) {
- events.add(ListenerEventType.SESSION_ATTRIBUTE_REPLACED);
- latch.countDown();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/92ee6a79/modules/gemfire-modules-session-external/src/test/java/com/gemstone/gemfire/modules/session/filter/HttpSessionBindingListenerImpl.java
----------------------------------------------------------------------
diff --git a/modules/gemfire-modules-session-external/src/test/java/com/gemstone/gemfire/modules/session/filter/HttpSessionBindingListenerImpl.java b/modules/gemfire-modules-session-external/src/test/java/com/gemstone/gemfire/modules/session/filter/HttpSessionBindingListenerImpl.java
deleted file mode 100644
index 2aa7b4b..0000000
--- a/modules/gemfire-modules-session-external/src/test/java/com/gemstone/gemfire/modules/session/filter/HttpSessionBindingListenerImpl.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*=========================================================================
- * Copyright (c) 2010-2014 Pivotal Software, Inc. All Rights Reserved.
- * This product is protected by U.S. and international copyright
- * and intellectual property laws. Pivotal products are covered by
- * one or more patents listed at http://www.pivotal.io/patents.
- *=========================================================================
- */
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-
-package com.gemstone.gemfire.modules.session.filter;
-
-import java.io.Serializable;
-import javax.servlet.http.HttpSessionBindingEvent;
-import javax.servlet.http.HttpSessionBindingListener;
-
-/**
- * @author jdeppe
- */
-public class HttpSessionBindingListenerImpl extends AbstractListener implements
- HttpSessionBindingListener, Serializable {
-
- public HttpSessionBindingListenerImpl(int i) {
- super(i);
- }
-
- @Override
- public synchronized void valueBound(HttpSessionBindingEvent event) {
- events.add(ListenerEventType.SESSION_VALUE_BOUND);
- latch.countDown();
- }
-
- @Override
- public synchronized void valueUnbound(HttpSessionBindingEvent event) {
- events.add(ListenerEventType.SESSION_VALUE_UNBOUND);
- latch.countDown();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/92ee6a79/modules/gemfire-modules-session-external/src/test/java/com/gemstone/gemfire/modules/session/filter/HttpSessionListenerImpl.java
----------------------------------------------------------------------
diff --git a/modules/gemfire-modules-session-external/src/test/java/com/gemstone/gemfire/modules/session/filter/HttpSessionListenerImpl.java b/modules/gemfire-modules-session-external/src/test/java/com/gemstone/gemfire/modules/session/filter/HttpSessionListenerImpl.java
deleted file mode 100644
index 818ca6d..0000000
--- a/modules/gemfire-modules-session-external/src/test/java/com/gemstone/gemfire/modules/session/filter/HttpSessionListenerImpl.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*=========================================================================
- * Copyright (c) 2010-2014 Pivotal Software, Inc. All Rights Reserved.
- * This product is protected by U.S. and international copyright
- * and intellectual property laws. Pivotal products are covered by
- * one or more patents listed at http://www.pivotal.io/patents.
- *=========================================================================
- */
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-
-package com.gemstone.gemfire.modules.session.filter;
-
-import com.gemstone.gemfire.modules.session.filter.ListenerEventType;
-
-import javax.servlet.http.HttpSessionEvent;
-import javax.servlet.http.HttpSessionListener;
-
-/**
- * @author jdeppe
- */
-public class HttpSessionListenerImpl extends AbstractListener
- implements HttpSessionListener {
-
- public synchronized void sessionCreated(HttpSessionEvent se) {
- events.add(ListenerEventType.SESSION_CREATED);
- latch.countDown();
- }
-
- public synchronized void sessionDestroyed(HttpSessionEvent se) {
- events.add(ListenerEventType.SESSION_DESTROYED);
- latch.countDown();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/92ee6a79/modules/gemfire-modules-session-external/src/test/java/com/gemstone/gemfire/modules/session/filter/RendezvousManager.java
----------------------------------------------------------------------
diff --git a/modules/gemfire-modules-session-external/src/test/java/com/gemstone/gemfire/modules/session/filter/RendezvousManager.java b/modules/gemfire-modules-session-external/src/test/java/com/gemstone/gemfire/modules/session/filter/RendezvousManager.java
deleted file mode 100644
index 1abf1ee..0000000
--- a/modules/gemfire-modules-session-external/src/test/java/com/gemstone/gemfire/modules/session/filter/RendezvousManager.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*=========================================================================
- * Copyright (c) 2010-2014 Pivotal Software, Inc. All Rights Reserved.
- * This product is protected by U.S. and international copyright
- * and intellectual property laws. Pivotal products are covered by
- * one or more patents listed at http://www.pivotal.io/patents.
- *=========================================================================
- */
-
-package com.gemstone.gemfire.modules.session.filter;
-
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-/**
- *
- */
-public class RendezvousManager {
-
- private static AbstractListener listener = null;
-
- private static CountDownLatch latch = new CountDownLatch(1);
-
- public static void registerListener(AbstractListener listener) {
- RendezvousManager.listener = listener;
- latch.countDown();
- }
-
- public static AbstractListener getListener() {
- try {
- latch.await(2, TimeUnit.SECONDS);
- } catch (InterruptedException ex) {
- }
-
- return listener;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/92ee6a79/modules/gemfire-modules-session-external/src/test/java/com/gemstone/gemfire/modules/session/filter/ServletRequestAttributeListenerImpl.java
----------------------------------------------------------------------
diff --git a/modules/gemfire-modules-session-external/src/test/java/com/gemstone/gemfire/modules/session/filter/ServletRequestAttributeListenerImpl.java b/modules/gemfire-modules-session-external/src/test/java/com/gemstone/gemfire/modules/session/filter/ServletRequestAttributeListenerImpl.java
deleted file mode 100644
index e5d7e7b..0000000
--- a/modules/gemfire-modules-session-external/src/test/java/com/gemstone/gemfire/modules/session/filter/ServletRequestAttributeListenerImpl.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*=========================================================================
- * Copyright (c) 2010-2014 Pivotal Software, Inc. All Rights Reserved.
- * This product is protected by U.S. and international copyright
- * and intellectual property laws. Pivotal products are covered by
- * one or more patents listed at http://www.pivotal.io/patents.
- *=========================================================================
- */
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-
-package com.gemstone.gemfire.modules.session.filter;
-
-import com.gemstone.gemfire.modules.session.filter.ListenerEventType;
-
-import javax.servlet.ServletRequestAttributeEvent;
-import javax.servlet.ServletRequestAttributeListener;
-
-/**
- * @author jdeppe
- */
-public class ServletRequestAttributeListenerImpl extends AbstractListener
- implements ServletRequestAttributeListener {
-
- public synchronized void attributeAdded(ServletRequestAttributeEvent srae) {
- events.add(ListenerEventType.SERVLET_REQUEST_ATTRIBUTE_ADDED);
- latch.countDown();
- }
-
- public synchronized void attributeRemoved(ServletRequestAttributeEvent srae) {
- events.add(ListenerEventType.SERVLET_REQUEST_ATTRIBUTE_REMOVED);
- latch.countDown();
- }
-
- public synchronized void attributeReplaced(
- ServletRequestAttributeEvent srae) {
- events.add(ListenerEventType.SERVLET_REQUEST_ATTRIBUTE_REPLACED);
- latch.countDown();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/92ee6a79/modules/gemfire-modules-session-external/src/test/java/com/gemstone/gemfire/modules/session/filter/ServletRequestListenerImpl.java
----------------------------------------------------------------------
diff --git a/modules/gemfire-modules-session-external/src/test/java/com/gemstone/gemfire/modules/session/filter/ServletRequestListenerImpl.java b/modules/gemfire-modules-session-external/src/test/java/com/gemstone/gemfire/modules/session/filter/ServletRequestListenerImpl.java
deleted file mode 100644
index 0574ebc..0000000
--- a/modules/gemfire-modules-session-external/src/test/java/com/gemstone/gemfire/modules/session/filter/ServletRequestListenerImpl.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*=========================================================================
- * Copyright (c) 2010-2014 Pivotal Software, Inc. All Rights Reserved.
- * This product is protected by U.S. and international copyright
- * and intellectual property laws. Pivotal products are covered by
- * one or more patents listed at http://www.pivotal.io/patents.
- *=========================================================================
- */
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-
-package com.gemstone.gemfire.modules.session.filter;
-
-import com.gemstone.gemfire.modules.session.filter.ListenerEventType;
-
-import javax.servlet.ServletRequestEvent;
-import javax.servlet.ServletRequestListener;
-
-/**
- * @author jdeppe
- */
-public class ServletRequestListenerImpl extends AbstractListener
- implements ServletRequestListener {
-
- public synchronized void requestDestroyed(ServletRequestEvent sre) {
- events.add(ListenerEventType.SERVLET_REQUEST_DESTROYED);
- latch.countDown();
- }
-
- public synchronized void requestInitialized(ServletRequestEvent sre) {
- events.add(ListenerEventType.SERVLET_REQUEST_INITIALIZED);
- latch.countDown();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/92ee6a79/modules/gemfire-modules-session-external/src/test/java/com/gemstone/gemfire/modules/session/filter/SessionTestSuite1.java
----------------------------------------------------------------------
diff --git a/modules/gemfire-modules-session-external/src/test/java/com/gemstone/gemfire/modules/session/filter/SessionTestSuite1.java b/modules/gemfire-modules-session-external/src/test/java/com/gemstone/gemfire/modules/session/filter/SessionTestSuite1.java
deleted file mode 100644
index efe95c1..0000000
--- a/modules/gemfire-modules-session-external/src/test/java/com/gemstone/gemfire/modules/session/filter/SessionTestSuite1.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*=========================================================================
- * Copyright (c) 2010-2014 Pivotal Software, Inc. All Rights Reserved.
- * This product is protected by U.S. and international copyright
- * and intellectual property laws. Pivotal products are covered by
- * one or more patents listed at http://www.pivotal.io/patents.
- *=========================================================================
- */
-package com.gemstone.gemfire.modules.session.filter;
-
-import com.gemstone.gemfire.modules.session.junit.SeparateClassloaderTestRunner;
-import com.mockrunner.mock.web.MockFilterConfig;
-import com.mockrunner.mock.web.WebMockObjectFactory;
-import com.mockrunner.servlet.ServletTestModule;
-
-import java.io.File;
-import javax.servlet.Filter;
-
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.runner.RunWith;
-
-/**
- *
- */
-@RunWith(SeparateClassloaderTestRunner.class)
-public class SessionTestSuite1 extends GemfireCacheTest {
-
- private static Filter filter;
-
- 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"),
- "gemfire_modules-" + System.getProperty("user.name"));
- tmpdir.mkdirs();
- tmpdir.deleteOnExit();
-
- gemfire_log = tmpdir.getPath() +
- System.getProperty("file.separator") + "gemfire_modules.log";
- }
-
-
- @BeforeClass
- public static void setupClass() throws Exception {
- System.out.println("Executing " + SessionTestSuite1.class.getName());
- WebMockObjectFactory factory = new WebMockObjectFactory();
- MockFilterConfig config = factory.getMockFilterConfig();
-
- config.setInitParameter("gemfire.property.mcast-port", "19991");
- config.setInitParameter("gemfire.property.log-file", gemfire_log);
- config.setInitParameter("gemfire.property.writable-working-dir",
- tmpdir.getPath());
- config.setInitParameter("cache-type", "peer-to-peer");
- config.setInitParameter("close-cache-on-stop", "true");
-
- factory.getMockServletContext().setContextPath("");
-
- ServletTestModule module = new ServletTestModule(factory);
- filter = module.createFilter(SessionCachingFilter.class);
- }
-
- @AfterClass
- public static void teardownClass() throws Exception {
- filter.destroy();
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/92ee6a79/modules/gemfire-modules-session-external/src/test/java/com/gemstone/gemfire/modules/session/filter/SessionTestSuite2.java
----------------------------------------------------------------------
diff --git a/modules/gemfire-modules-session-external/src/test/java/com/gemstone/gemfire/modules/session/filter/SessionTestSuite2.java b/modules/gemfire-modules-session-external/src/test/java/com/gemstone/gemfire/modules/session/filter/SessionTestSuite2.java
deleted file mode 100644
index 1efeb6d..0000000
--- a/modules/gemfire-modules-session-external/src/test/java/com/gemstone/gemfire/modules/session/filter/SessionTestSuite2.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*=========================================================================
- * Copyright (c) 2010-2014 Pivotal Software, Inc. All Rights Reserved.
- * This product is protected by U.S. and international copyright
- * and intellectual property laws. Pivotal products are covered by
- * one or more patents listed at http://www.pivotal.io/patents.
- *=========================================================================
- */
-package com.gemstone.gemfire.modules.session.filter;
-
-import com.gemstone.gemfire.modules.session.junit.SeparateClassloaderTestRunner;
-import com.mockrunner.mock.web.MockFilterConfig;
-import com.mockrunner.mock.web.WebMockObjectFactory;
-import com.mockrunner.servlet.ServletTestModule;
-
-import java.io.File;
-import javax.servlet.Filter;
-
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.runner.RunWith;
-
-/**
- *
- */
-@RunWith(SeparateClassloaderTestRunner.class)
-public class SessionTestSuite2 extends GemfireCacheTest {
-
- private static Filter filter;
-
- 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"),
- "gemfire_modules-" + System.getProperty("user.name"));
- tmpdir.mkdirs();
- tmpdir.deleteOnExit();
-
- gemfire_log = tmpdir.getPath() +
- System.getProperty("file.separator") + "gemfire_modules.log";
- }
-
- @BeforeClass
- public static void setupClass() throws Exception {
- System.out.println("Executing " + SessionTestSuite2.class.getName());
- WebMockObjectFactory factory = new WebMockObjectFactory();
- MockFilterConfig config = factory.getMockFilterConfig();
-
- config.setInitParameter("mcast-port", "19991");
- config.setInitParameter("gemfire.property.log-file", gemfire_log);
- config.setInitParameter("gemfire.property.writable-working-dir",
- tmpdir.getPath());
- config.setInitParameter("cache-type", "peer-to-peer");
- config.setInitParameter("gemfire.cache.enable_local_cache", "true");
-
- factory.getMockServletContext().setContextPath("");
-
- ServletTestModule module = new ServletTestModule(factory);
- filter = module.createFilter(SessionCachingFilter.class);
- }
-
- @AfterClass
- public static void teardownClass() throws Exception {
- filter.destroy();
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/92ee6a79/modules/gemfire-modules-session-external/src/test/java/com/gemstone/gemfire/modules/session/filter/SessionUberSuite.java
----------------------------------------------------------------------
diff --git a/modules/gemfire-modules-session-external/src/test/java/com/gemstone/gemfire/modules/session/filter/SessionUberSuite.java b/modules/gemfire-modules-session-external/src/test/java/com/gemstone/gemfire/modules/session/filter/SessionUberSuite.java
deleted file mode 100644
index fa6a562..0000000
--- a/modules/gemfire-modules-session-external/src/test/java/com/gemstone/gemfire/modules/session/filter/SessionUberSuite.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*=========================================================================
- * Copyright (c) 2010-2014 Pivotal Software, Inc. All Rights Reserved.
- * This product is protected by U.S. and international copyright
- * and intellectual property laws. Pivotal products are covered by
- * one or more patents listed at http://www.pivotal.io/patents.
- *=========================================================================
- */
-package com.gemstone.gemfire.modules.session.filter;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.ArrayList;
-import java.util.List;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-/**
- * The goal of having a suite of suites is for each suite to be able to start up
- * and shut down a unique cache with a different config. Currently a restart
- * doesn't work... This is dependent on gemfire 6.5.1.4 which provides a unified
- * classloading framework. Once that can be introduced here we can simply switch
- * the URLClassLoader for a ChildFirstClassLoader and have the ability to run
- * multiple caches in a single JVM. This should also allow us the ability to
- * cleanly shut down a cache at the end of a test.
- * <p/>
- * To be continued...
- */
-@RunWith(Suite.class)
-@Suite.SuiteClasses({
- SessionTestSuite1.class,
- SessionTestSuite2.class
-})
-public class SessionUberSuite {
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/92ee6a79/modules/gemfire-modules-session-external/src/test/java/com/gemstone/gemfire/modules/session/internal/filter/AbstractListener.java
----------------------------------------------------------------------
diff --git a/modules/gemfire-modules-session-external/src/test/java/com/gemstone/gemfire/modules/session/internal/filter/AbstractListener.java b/modules/gemfire-modules-session-external/src/test/java/com/gemstone/gemfire/modules/session/internal/filter/AbstractListener.java
new file mode 100644
index 0000000..94dc07f
--- /dev/null
+++ b/modules/gemfire-modules-session-external/src/test/java/com/gemstone/gemfire/modules/session/internal/filter/AbstractListener.java
@@ -0,0 +1,52 @@
+/*=========================================================================
+ * Copyright (c) 2010-2014 Pivotal Software, Inc. All Rights Reserved.
+ * This product is protected by U.S. and international copyright
+ * and intellectual property laws. Pivotal products are covered by
+ * one or more patents listed at http://www.pivotal.io/patents.
+ *=========================================================================
+ */
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package com.gemstone.gemfire.modules.session.internal.filter;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * @author jdeppe
+ */
+public abstract class AbstractListener {
+
+ protected final List<ListenerEventType> events =
+ new ArrayList<ListenerEventType>();
+
+ protected CountDownLatch latch;
+
+ public AbstractListener() {
+ this(1);
+ }
+
+ public AbstractListener(int numCalls) {
+ latch = new CountDownLatch(numCalls);
+ RendezvousManager.registerListener(this);
+ }
+
+ public synchronized void setLatch(int numCalls) {
+ latch = new CountDownLatch(numCalls);
+ events.clear();
+ }
+
+ public boolean await(long timeout,
+ TimeUnit unit) throws InterruptedException {
+ return latch.await(timeout, unit);
+ }
+
+ public List<ListenerEventType> getEvents() {
+ return events;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/92ee6a79/modules/gemfire-modules-session-external/src/test/java/com/gemstone/gemfire/modules/session/internal/filter/Callback.java
----------------------------------------------------------------------
diff --git a/modules/gemfire-modules-session-external/src/test/java/com/gemstone/gemfire/modules/session/internal/filter/Callback.java b/modules/gemfire-modules-session-external/src/test/java/com/gemstone/gemfire/modules/session/internal/filter/Callback.java
new file mode 100644
index 0000000..ab74084
--- /dev/null
+++ b/modules/gemfire-modules-session-external/src/test/java/com/gemstone/gemfire/modules/session/internal/filter/Callback.java
@@ -0,0 +1,17 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package com.gemstone.gemfire.modules.session.internal.filter;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * @author jdeppe
+ */
+public interface Callback {
+ public void call(HttpServletRequest request,
+ HttpServletResponse response);
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/92ee6a79/modules/gemfire-modules-session-external/src/test/java/com/gemstone/gemfire/modules/session/internal/filter/CallbackServlet.java
----------------------------------------------------------------------
diff --git a/modules/gemfire-modules-session-external/src/test/java/com/gemstone/gemfire/modules/session/internal/filter/CallbackServlet.java b/modules/gemfire-modules-session-external/src/test/java/com/gemstone/gemfire/modules/session/internal/filter/CallbackServlet.java
new file mode 100644
index 0000000..f9d2971
--- /dev/null
+++ b/modules/gemfire-modules-session-external/src/test/java/com/gemstone/gemfire/modules/session/internal/filter/CallbackServlet.java
@@ -0,0 +1,88 @@
+/*=========================================================================
+ * Copyright (c) 2010-2014 Pivotal Software, Inc. All Rights Reserved.
+ * This product is protected by U.S. and international copyright
+ * and intellectual property laws. Pivotal products are covered by
+ * one or more patents listed at http://www.pivotal.io/patents.
+ *=========================================================================
+ */
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package com.gemstone.gemfire.modules.session.internal.filter;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * @author jdeppe
+ */
+public class CallbackServlet extends HttpServlet {
+
+ private Callback callback;
+
+ /**
+ * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
+ * methods.
+ *
+ * @param request servlet request
+ * @param response servlet response
+ * @throws ServletException if a servlet-specific error occurs
+ * @throws IOException if an I/O error occurs
+ */
+ protected void processRequest(HttpServletRequest request,
+ HttpServletResponse response)
+ throws ServletException, IOException {
+
+ if (callback != null) {
+ callback.call(request, response);
+ }
+ }
+
+ public void setCallback(Callback callback) {
+ this.callback = callback;
+ }
+
+ /**
+ * Handles the HTTP <code>GET</code> method.
+ *
+ * @param request servlet request
+ * @param response servlet response
+ * @throws ServletException if a servlet-specific error occurs
+ * @throws IOException if an I/O error occurs
+ */
+ @Override
+ protected void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ processRequest(request, response);
+ }
+
+ /**
+ * Handles the HTTP <code>POST</code> method.
+ *
+ * @param request servlet request
+ * @param response servlet response
+ * @throws ServletException if a servlet-specific error occurs
+ * @throws IOException if an I/O error occurs
+ */
+ @Override
+ protected void doPost(HttpServletRequest request,
+ HttpServletResponse response)
+ throws ServletException, IOException {
+ processRequest(request, response);
+ }
+
+ /**
+ * Returns a short description of the servlet.
+ *
+ * @return a String containing servlet description
+ */
+ @Override
+ public String getServletInfo() {
+ return "Short description";
+ }
+
+}