[jboss-cvs] JBossAS SVN: r72456 - in branches/JBPAPP_4_3_0_GA_JBPAPP-784: testsuite/src/main/org/jboss/test/cluster/web and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Apr 18 18:11:35 EDT 2008
Author: bstansberry at jboss.com
Date: 2008-04-18 18:11:34 -0400 (Fri, 18 Apr 2008)
New Revision: 72456
Added:
branches/JBPAPP_4_3_0_GA_JBPAPP-784/testsuite/src/main/org/jboss/test/cluster/test/JvmRouteValveUnitTestCase.java
branches/JBPAPP_4_3_0_GA_JBPAPP-784/testsuite/src/main/org/jboss/test/cluster/web/jvmroute/
branches/JBPAPP_4_3_0_GA_JBPAPP-784/testsuite/src/main/org/jboss/test/cluster/web/jvmroute/MockJBossManager.java
branches/JBPAPP_4_3_0_GA_JBPAPP-784/testsuite/src/main/org/jboss/test/cluster/web/jvmroute/MockRequest.java
branches/JBPAPP_4_3_0_GA_JBPAPP-784/testsuite/src/main/org/jboss/test/cluster/web/jvmroute/MockSession.java
branches/JBPAPP_4_3_0_GA_JBPAPP-784/testsuite/src/main/org/jboss/test/cluster/web/jvmroute/MockValve.java
Modified:
branches/JBPAPP_4_3_0_GA_JBPAPP-784/tomcat/src/main/org/jboss/web/tomcat/service/session/ClusteredSession.java
branches/JBPAPP_4_3_0_GA_JBPAPP-784/tomcat/src/main/org/jboss/web/tomcat/service/session/JvmRouteValve.java
Log:
[JBPAPP-784] Avoid NPE in JvmRouteValve.handleJvmRoute
Added: branches/JBPAPP_4_3_0_GA_JBPAPP-784/testsuite/src/main/org/jboss/test/cluster/test/JvmRouteValveUnitTestCase.java
===================================================================
--- branches/JBPAPP_4_3_0_GA_JBPAPP-784/testsuite/src/main/org/jboss/test/cluster/test/JvmRouteValveUnitTestCase.java (rev 0)
+++ branches/JBPAPP_4_3_0_GA_JBPAPP-784/testsuite/src/main/org/jboss/test/cluster/test/JvmRouteValveUnitTestCase.java 2008-04-18 22:11:34 UTC (rev 72456)
@@ -0,0 +1,474 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.test.cluster.test;
+
+import junit.framework.TestCase;
+
+import org.apache.catalina.Session;
+import org.apache.catalina.connector.Response;
+import org.jboss.logging.Logger;
+import org.jboss.test.cluster.web.jvmroute.MockJBossManager;
+import org.jboss.test.cluster.web.jvmroute.MockRequest;
+import org.jboss.test.cluster.web.jvmroute.MockValve;
+import org.jboss.web.tomcat.service.session.JvmRouteValve;
+
+/**
+ * Tests of the JvmRouteValve.
+ *
+ * @author Brian Stansberry
+ */
+public class JvmRouteValveUnitTestCase extends TestCase
+{
+ private static final Logger log = Logger.getLogger(JvmRouteValveUnitTestCase.class);
+
+ private static final String JVM_ROUTE = "node1";
+ private static final String NON_FAILOVER_ID = "123." + JVM_ROUTE;
+ private static final String FAILOVER_ID = "123.node2";
+
+ /**
+ * Create a new JvmRouteValueUnitTestCase.
+ *
+ * @param name
+ */
+ public JvmRouteValveUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testNonFailover() throws Exception
+ {
+ log.info("Enter testNonFailover");
+
+ MockJBossManager mgr = new MockJBossManager();
+ mgr.setJvmRoute(JVM_ROUTE);
+
+ JvmRouteValve jvmRouteValve = new JvmRouteValve(mgr);
+
+ MockValve mockValve = new MockValve();
+
+ jvmRouteValve.setNext(mockValve);
+
+ Session session = mgr.createSession(NON_FAILOVER_ID);
+ MockRequest req = new MockRequest();
+ req.setSession(session.getSession());
+ req.setRequestedSessionId(session.getId());
+
+ Response res = new Response();
+
+ jvmRouteValve.invoke(req, res);
+
+ assertSame(req, mockValve.getInvokedRequest());
+ assertSame(res, mockValve.getInvokedResponse());
+ assertEquals(NON_FAILOVER_ID, session.getId());
+ assertEquals(null, mgr.getNewCookieIdSession());
+ }
+
+ public void testFailover() throws Exception
+ {
+ log.info("Enter testFailover");
+
+ MockJBossManager mgr = new MockJBossManager();
+ mgr.setJvmRoute(JVM_ROUTE);
+
+ JvmRouteValve jvmRouteValve = new JvmRouteValve(mgr);
+
+ MockValve mockValve = new MockValve();
+
+ jvmRouteValve.setNext(mockValve);
+
+ Session session = mgr.createSession(FAILOVER_ID);
+ MockRequest req = new MockRequest();
+ req.setSession(session.getSession());
+ req.setRequestedSessionId(session.getId());
+
+ Response res = new Response();
+
+ jvmRouteValve.invoke(req, res);
+
+ assertSame(req, mockValve.getInvokedRequest());
+ assertSame(res, mockValve.getInvokedResponse());
+ assertEquals(NON_FAILOVER_ID, session.getId());
+ assertEquals(NON_FAILOVER_ID, mgr.getNewCookieIdSession());
+
+ }
+
+ public void testFailoverFromURL() throws Exception
+ {
+ log.info("Enter testFailoverFromURL");
+
+ MockJBossManager mgr = new MockJBossManager();
+ mgr.setJvmRoute(JVM_ROUTE);
+
+ JvmRouteValve jvmRouteValve = new JvmRouteValve(mgr);
+
+ MockValve mockValve = new MockValve();
+
+ jvmRouteValve.setNext(mockValve);
+
+ Session session = mgr.createSession(FAILOVER_ID);
+ MockRequest req = new MockRequest();
+ req.setSession(session.getSession());
+ req.setRequestedSessionId(session.getId());
+ req.setRequestedSessionIdFromURL(true);
+
+ Response res = new Response();
+
+ jvmRouteValve.invoke(req, res);
+
+ assertSame(req, mockValve.getInvokedRequest());
+ assertSame(res, mockValve.getInvokedResponse());
+ assertEquals(NON_FAILOVER_ID, session.getId());
+ assertEquals(null, mgr.getNewCookieIdSession());
+ }
+
+ public void testFailoverMismatchBadReq() throws Exception
+ {
+ log.info("Enter testFailoverMismatchBadReq");
+
+ MockJBossManager mgr = new MockJBossManager();
+ mgr.setJvmRoute(JVM_ROUTE);
+
+ JvmRouteValve jvmRouteValve = new JvmRouteValve(mgr);
+
+ MockValve mockValve = new MockValve();
+
+ jvmRouteValve.setNext(mockValve);
+
+ Session session = mgr.createSession(NON_FAILOVER_ID);
+ MockRequest req = new MockRequest();
+ req.setSession(session.getSession());
+ req.setRequestedSessionId(FAILOVER_ID);
+
+ Response res = new Response();
+
+ jvmRouteValve.invoke(req, res);
+
+ assertSame(req, mockValve.getInvokedRequest());
+ assertSame(res, mockValve.getInvokedResponse());
+ assertEquals(NON_FAILOVER_ID, session.getId());
+ assertEquals(NON_FAILOVER_ID, mgr.getNewCookieIdSession());
+ }
+
+ public void testFailoverMismatchBadReqFromURL() throws Exception
+ {
+ log.info("Enter testFailoverMismatchBadReqFromURL");
+
+ MockJBossManager mgr = new MockJBossManager();
+ mgr.setJvmRoute(JVM_ROUTE);
+
+ JvmRouteValve jvmRouteValve = new JvmRouteValve(mgr);
+
+ MockValve mockValve = new MockValve();
+
+ jvmRouteValve.setNext(mockValve);
+
+ Session session = mgr.createSession(NON_FAILOVER_ID);
+ MockRequest req = new MockRequest();
+ req.setSession(session.getSession());
+ req.setRequestedSessionId(FAILOVER_ID);
+ req.setRequestedSessionIdFromURL(true);
+
+ Response res = new Response();
+
+ jvmRouteValve.invoke(req, res);
+
+ assertSame(req, mockValve.getInvokedRequest());
+ assertSame(res, mockValve.getInvokedResponse());
+ assertEquals(NON_FAILOVER_ID, session.getId());
+ assertEquals(null, mgr.getNewCookieIdSession());
+ }
+
+ public void testFailoverMismatchBadSession() throws Exception
+ {
+ log.info("Enter testFailoverMismatchBadSession");
+
+ MockJBossManager mgr = new MockJBossManager();
+ mgr.setJvmRoute(JVM_ROUTE);
+
+ JvmRouteValve jvmRouteValve = new JvmRouteValve(mgr);
+
+ MockValve mockValve = new MockValve();
+
+ jvmRouteValve.setNext(mockValve);
+
+ Session session = mgr.createSession(FAILOVER_ID);
+ MockRequest req = new MockRequest();
+ req.setSession(session.getSession());
+ req.setRequestedSessionId(NON_FAILOVER_ID);
+
+ Response res = new Response();
+
+ jvmRouteValve.invoke(req, res);
+
+ assertSame(req, mockValve.getInvokedRequest());
+ assertSame(res, mockValve.getInvokedResponse());
+ assertEquals(NON_FAILOVER_ID, session.getId());
+ assertEquals(NON_FAILOVER_ID, mgr.getNewCookieIdSession());
+ }
+
+ public void testFailoverMismatchBadSessionFromURL() throws Exception
+ {
+ log.info("Enter testFailoverMismatchBadSessionFromURL");
+
+ MockJBossManager mgr = new MockJBossManager();
+ mgr.setJvmRoute(JVM_ROUTE);
+
+ JvmRouteValve jvmRouteValve = new JvmRouteValve(mgr);
+
+ MockValve mockValve = new MockValve();
+
+ jvmRouteValve.setNext(mockValve);
+
+ Session session = mgr.createSession(FAILOVER_ID);
+ MockRequest req = new MockRequest();
+ req.setSession(session.getSession());
+ req.setRequestedSessionId(NON_FAILOVER_ID);
+ req.setRequestedSessionIdFromURL(true);
+
+ Response res = new Response();
+
+ jvmRouteValve.invoke(req, res);
+
+ assertSame(req, mockValve.getInvokedRequest());
+ assertSame(res, mockValve.getInvokedResponse());
+ assertEquals(NON_FAILOVER_ID, session.getId());
+ assertEquals(null, mgr.getNewCookieIdSession());
+ }
+
+ public void testNoSession() throws Exception
+ {
+ log.info("Enter testNoSession");
+
+ MockJBossManager mgr = new MockJBossManager();
+ mgr.setJvmRoute(JVM_ROUTE);
+
+ JvmRouteValve jvmRouteValve = new JvmRouteValve(mgr);
+
+ MockValve mockValve = new MockValve();
+
+ jvmRouteValve.setNext(mockValve);
+
+ MockRequest req = new MockRequest();
+ req.setRequestedSessionId(NON_FAILOVER_ID);
+
+ Response res = new Response();
+
+ jvmRouteValve.invoke(req, res);
+
+ assertSame(req, mockValve.getInvokedRequest());
+ assertSame(res, mockValve.getInvokedResponse());
+ assertEquals(null, mgr.findSession("123.node1"));
+ assertEquals(null, mgr.getNewCookieIdSession());
+ }
+
+ public void testNoSessionFromURL() throws Exception
+ {
+ log.info("Enter testNoSessionFromURL");
+
+ MockJBossManager mgr = new MockJBossManager();
+ mgr.setJvmRoute(JVM_ROUTE);
+
+ JvmRouteValve jvmRouteValve = new JvmRouteValve(mgr);
+
+ MockValve mockValve = new MockValve();
+
+ jvmRouteValve.setNext(mockValve);
+
+ MockRequest req = new MockRequest();
+ req.setRequestedSessionId(NON_FAILOVER_ID);
+ req.setRequestedSessionIdFromURL(true);
+
+ Response res = new Response();
+
+ jvmRouteValve.invoke(req, res);
+
+ assertSame(req, mockValve.getInvokedRequest());
+ assertSame(res, mockValve.getInvokedResponse());
+ assertEquals(null, mgr.findSession(NON_FAILOVER_ID));
+ assertEquals(null, mgr.getNewCookieIdSession());
+ }
+
+ public void testFailoverNoSession() throws Exception
+ {
+ log.info("Enter testFailoverNoSession");
+
+ MockJBossManager mgr = new MockJBossManager();
+ mgr.setJvmRoute(JVM_ROUTE);
+
+ JvmRouteValve jvmRouteValve = new JvmRouteValve(mgr);
+
+ MockValve mockValve = new MockValve();
+
+ jvmRouteValve.setNext(mockValve);
+
+ MockRequest req = new MockRequest();
+ req.setRequestedSessionId(FAILOVER_ID);
+
+ Response res = new Response();
+
+ jvmRouteValve.invoke(req, res);
+
+ assertSame(req, mockValve.getInvokedRequest());
+ assertSame(res, mockValve.getInvokedResponse());
+ assertEquals(null, mgr.findSession(NON_FAILOVER_ID));
+ assertEquals(null, mgr.findSession("123.node2"));
+ assertEquals(null, mgr.getNewCookieIdSession());
+ }
+
+ public void testNoSessionNoRequestedSession() throws Exception
+ {
+ log.info("Enter testNoSessionNoRequestedSession");
+
+ MockJBossManager mgr = new MockJBossManager();
+ mgr.setJvmRoute(JVM_ROUTE);
+
+ JvmRouteValve jvmRouteValve = new JvmRouteValve(mgr);
+
+ MockValve mockValve = new MockValve();
+
+ jvmRouteValve.setNext(mockValve);
+
+ MockRequest req = new MockRequest();
+
+ Response res = new Response();
+
+ jvmRouteValve.invoke(req, res);
+
+ assertSame(req, mockValve.getInvokedRequest());
+ assertSame(res, mockValve.getInvokedResponse());
+ assertEquals(null, mgr.findSession(NON_FAILOVER_ID));
+ assertEquals(null, mgr.findSession(FAILOVER_ID));
+ assertEquals(null, mgr.getNewCookieIdSession());
+ }
+
+ public void testSessionNoRequestedSession() throws Exception
+ {
+ log.info("Enter testSessionNoRequestedSession");
+
+ MockJBossManager mgr = new MockJBossManager();
+ mgr.setJvmRoute(JVM_ROUTE);
+
+ JvmRouteValve jvmRouteValve = new JvmRouteValve(mgr);
+
+ MockValve mockValve = new MockValve();
+
+ jvmRouteValve.setNext(mockValve);
+
+ Session session = mgr.createSession(NON_FAILOVER_ID);
+ MockRequest req = new MockRequest();
+ req.setSession(session.getSession());
+
+ Response res = new Response();
+
+ jvmRouteValve.invoke(req, res);
+
+ assertSame(req, mockValve.getInvokedRequest());
+ assertSame(res, mockValve.getInvokedResponse());
+ assertEquals(NON_FAILOVER_ID, session.getId());
+ assertEquals(NON_FAILOVER_ID, mgr.getNewCookieIdSession());
+ }
+
+ public void testSessionNoRequestedSessionFromURL() throws Exception
+ {
+ log.info("Enter testSessionNoRequestedSessionFromURL");
+
+ MockJBossManager mgr = new MockJBossManager();
+ mgr.setJvmRoute(JVM_ROUTE);
+
+ JvmRouteValve jvmRouteValve = new JvmRouteValve(mgr);
+
+ MockValve mockValve = new MockValve();
+
+ jvmRouteValve.setNext(mockValve);
+
+ Session session = mgr.createSession(NON_FAILOVER_ID);
+ MockRequest req = new MockRequest();
+ req.setSession(session.getSession());
+ req.setRequestedSessionIdFromURL(true);
+
+ Response res = new Response();
+
+ jvmRouteValve.invoke(req, res);
+
+ assertSame(req, mockValve.getInvokedRequest());
+ assertSame(res, mockValve.getInvokedResponse());
+ assertEquals(NON_FAILOVER_ID, session.getId());
+ assertEquals(null, mgr.getNewCookieIdSession());
+ }
+
+ public void testFailoverSessionNoRequestedSession() throws Exception
+ {
+ log.info("Enter testFailoverSessionNoRequestedSession");
+
+ MockJBossManager mgr = new MockJBossManager();
+ mgr.setJvmRoute(JVM_ROUTE);
+
+ JvmRouteValve jvmRouteValve = new JvmRouteValve(mgr);
+
+ MockValve mockValve = new MockValve();
+
+ jvmRouteValve.setNext(mockValve);
+
+ Session session = mgr.createSession(FAILOVER_ID);
+ MockRequest req = new MockRequest();
+ req.setSession(session.getSession());
+
+ Response res = new Response();
+
+ jvmRouteValve.invoke(req, res);
+
+ assertSame(req, mockValve.getInvokedRequest());
+ assertSame(res, mockValve.getInvokedResponse());
+ assertEquals(NON_FAILOVER_ID, session.getId());
+ assertEquals(NON_FAILOVER_ID, mgr.getNewCookieIdSession());
+ }
+
+ public void testFailoverSessionNoRequestedSessionFromURL() throws Exception
+ {
+ log.info("Enter testFailoverSessionNoRequestedSessionFromURL");
+
+ MockJBossManager mgr = new MockJBossManager();
+ mgr.setJvmRoute(JVM_ROUTE);
+
+ JvmRouteValve jvmRouteValve = new JvmRouteValve(mgr);
+
+ MockValve mockValve = new MockValve();
+
+ jvmRouteValve.setNext(mockValve);
+
+ Session session = mgr.createSession(FAILOVER_ID);
+ MockRequest req = new MockRequest();
+ req.setSession(session.getSession());
+ req.setRequestedSessionIdFromURL(true);
+
+ Response res = new Response();
+
+ jvmRouteValve.invoke(req, res);
+
+ assertSame(req, mockValve.getInvokedRequest());
+ assertSame(res, mockValve.getInvokedResponse());
+ assertEquals(NON_FAILOVER_ID, session.getId());
+ assertEquals(null, mgr.getNewCookieIdSession());
+ }
+
+}
Added: branches/JBPAPP_4_3_0_GA_JBPAPP-784/testsuite/src/main/org/jboss/test/cluster/web/jvmroute/MockJBossManager.java
===================================================================
--- branches/JBPAPP_4_3_0_GA_JBPAPP-784/testsuite/src/main/org/jboss/test/cluster/web/jvmroute/MockJBossManager.java (rev 0)
+++ branches/JBPAPP_4_3_0_GA_JBPAPP-784/testsuite/src/main/org/jboss/test/cluster/web/jvmroute/MockJBossManager.java 2008-04-18 22:11:34 UTC (rev 72456)
@@ -0,0 +1,251 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.test.cluster.web.jvmroute;
+
+import java.beans.PropertyChangeListener;
+import java.io.IOException;
+
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.catalina.Container;
+import org.apache.catalina.Session;
+import org.jboss.metadata.WebMetaData;
+import org.jboss.web.tomcat.service.session.AbstractJBossManager;
+import org.jboss.web.tomcat.service.session.ClusteringNotSupportedException;
+
+/**
+ * @author Brian Stansberry
+ *
+ */
+public class MockJBossManager implements AbstractJBossManager
+{
+ private String jvmRoute = null;
+ private String newCookieIdSession = null;
+ private Session session = null;
+
+ /**
+ * Create a new MockJBossManager.
+ *
+ */
+ public MockJBossManager()
+ {
+ // TODO Auto-generated constructor stub
+ }
+
+ public String getJvmRoute()
+ {
+ return jvmRoute;
+ }
+
+ public void setJvmRoute(String jvmRoute)
+ {
+ this.jvmRoute = jvmRoute;
+ }
+
+ public void setNewSessionCookie(String sessionId, HttpServletResponse response)
+ {
+ newCookieIdSession = sessionId;
+ }
+
+ public String getNewCookieIdSession()
+ {
+ return newCookieIdSession;
+ }
+
+ public Session createSession(String s)
+ {
+ Session newSession = new MockSession(this);
+ newSession.setId(s);
+ return newSession;
+ }
+
+ public Session findSession(String s) throws IOException
+ {
+ return session;
+ }
+
+ public void add(Session session)
+ {
+ this.session = session;
+ }
+
+ public void removeLocal(Session session)
+ {
+ }
+
+ public boolean storeSession(Session session)
+ {
+ return false;
+ }
+
+ public void addPropertyChangeListener(PropertyChangeListener propertychangelistener)
+ {
+ }
+
+ public void backgroundProcess()
+ {
+ }
+
+ public Session createEmptySession()
+ {
+ return null;
+ }
+
+ public Session createSession()
+ {
+ return null;
+ }
+
+ public Session[] findSessions()
+ {
+ return null;
+ }
+
+ public int getActiveSessions()
+ {
+ return 0;
+ }
+
+ public Container getContainer()
+ {
+ return null;
+ }
+
+ public boolean getDistributable()
+ {
+ return false;
+ }
+
+ public int getExpiredSessions()
+ {
+ return 0;
+ }
+
+ public String getInfo()
+ {
+ return null;
+ }
+
+ public int getMaxActive()
+ {
+ return 0;
+ }
+
+ public int getMaxInactiveInterval()
+ {
+ return 0;
+ }
+
+ public int getRejectedSessions()
+ {
+ return 0;
+ }
+
+ public int getSessionAverageAliveTime()
+ {
+ return 0;
+ }
+
+ public int getSessionCounter()
+ {
+ return 0;
+ }
+
+ public int getSessionIdLength()
+ {
+ return 0;
+ }
+
+ public int getSessionMaxAliveTime()
+ {
+ return 0;
+ }
+
+ public void load() throws ClassNotFoundException, IOException
+ {
+ }
+
+ public void remove(Session session)
+ {
+ }
+
+ public void removePropertyChangeListener(PropertyChangeListener propertychangelistener)
+ {
+ }
+
+ public void setContainer(Container container)
+ {
+ }
+
+ public void setDistributable(boolean flag)
+ {
+ }
+
+ public void setExpiredSessions(int i)
+ {
+ }
+
+ public void setMaxActive(int i)
+ {
+ }
+
+ public void setMaxInactiveInterval(int i)
+ {
+ }
+
+ public void setRejectedSessions(int i)
+ {
+ }
+
+ public void setSessionAverageAliveTime(int i)
+ {
+ }
+
+ public void setSessionCounter(int i)
+ {
+ }
+
+ public void setSessionIdLength(int i)
+ {
+ }
+
+ public void setSessionMaxAliveTime(int i)
+ {
+ }
+
+ public void unload() throws IOException
+ {
+ }
+
+ public int getInvalidateSessionPolicy()
+ {
+ return 0;
+ }
+
+ public void init(String name, WebMetaData webMetaData, boolean useJK, boolean useLocalCache)
+ throws ClusteringNotSupportedException
+ {
+ }
+
+
+}
Added: branches/JBPAPP_4_3_0_GA_JBPAPP-784/testsuite/src/main/org/jboss/test/cluster/web/jvmroute/MockRequest.java
===================================================================
--- branches/JBPAPP_4_3_0_GA_JBPAPP-784/testsuite/src/main/org/jboss/test/cluster/web/jvmroute/MockRequest.java (rev 0)
+++ branches/JBPAPP_4_3_0_GA_JBPAPP-784/testsuite/src/main/org/jboss/test/cluster/web/jvmroute/MockRequest.java 2008-04-18 22:11:34 UTC (rev 72456)
@@ -0,0 +1,80 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.test.cluster.web.jvmroute;
+
+import javax.servlet.http.HttpSession;
+
+import org.apache.catalina.connector.Request;
+
+/**
+ * @author Brian Stansberry
+ *
+ */
+public class MockRequest extends Request
+{
+ private HttpSession session;
+ private String requestedSessionId;
+ private boolean requestedSessionIdFromURL;
+
+ /**
+ * Create a new MockRequest.
+ *
+ */
+ public MockRequest()
+ {
+ }
+
+ @Override
+ public String getRequestedSessionId()
+ {
+ return requestedSessionId;
+ }
+
+ public void setRequestedSessionId(String requestedSessionId)
+ {
+ this.requestedSessionId = requestedSessionId;
+ }
+
+ @Override
+ public HttpSession getSession(boolean create)
+ {
+ return session;
+ }
+
+ public void setSession(HttpSession session)
+ {
+ this.session = session;
+ }
+
+ @Override
+ public boolean isRequestedSessionIdFromURL()
+ {
+ return requestedSessionIdFromURL;
+ }
+
+ public void setRequestedSessionIdFromURL(boolean requestedSessionIdFromURL)
+ {
+ this.requestedSessionIdFromURL = requestedSessionIdFromURL;
+ }
+
+}
Added: branches/JBPAPP_4_3_0_GA_JBPAPP-784/testsuite/src/main/org/jboss/test/cluster/web/jvmroute/MockSession.java
===================================================================
--- branches/JBPAPP_4_3_0_GA_JBPAPP-784/testsuite/src/main/org/jboss/test/cluster/web/jvmroute/MockSession.java (rev 0)
+++ branches/JBPAPP_4_3_0_GA_JBPAPP-784/testsuite/src/main/org/jboss/test/cluster/web/jvmroute/MockSession.java 2008-04-18 22:11:34 UTC (rev 72456)
@@ -0,0 +1,119 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.test.cluster.web.jvmroute;
+
+import java.util.Map;
+
+import javax.servlet.http.HttpSession;
+
+import org.apache.catalina.session.StandardSessionFacade;
+import org.jboss.web.tomcat.service.session.AbstractJBossManager;
+import org.jboss.web.tomcat.service.session.ClusteredSession;
+
+/**
+ * @author Brian Stansberry
+ *
+ */
+public class MockSession extends ClusteredSession
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Create a new MockSession.
+ *
+ * @param manager
+ */
+ public MockSession(MockJBossManager manager)
+ {
+ super(manager, true);
+ }
+
+ @Override
+ public void tellNew()
+ {
+ // no-op
+ }
+
+ @Override
+ public String getId()
+ {
+ // bypass any expiration logic
+ return getIdInternal();
+ }
+
+ @Override
+ public HttpSession getSession()
+ {
+ return new StandardSessionFacade(this);
+ }
+
+ // Inherited abstract methods
+
+ @Override
+ protected Object getJBossInternalAttribute(String name)
+ {
+ return null;
+ }
+
+ @Override
+ protected Map getJBossInternalAttributes()
+ {
+ return null;
+ }
+
+ @Override
+ public void initAfterLoad(AbstractJBossManager manager)
+ {
+
+ }
+
+ @Override
+ public void processSessionRepl()
+ {
+ }
+
+ @Override
+ protected Object removeJBossInternalAttribute(String name)
+ {
+ return null;
+ }
+
+ @Override
+ public void removeMyself()
+ {
+ }
+
+ @Override
+ public void removeMyselfLocal()
+ {
+ }
+
+ @Override
+ protected Object setJBossInternalAttribute(String name, Object value)
+ {
+ return null;
+ }
+
+
+}
Added: branches/JBPAPP_4_3_0_GA_JBPAPP-784/testsuite/src/main/org/jboss/test/cluster/web/jvmroute/MockValve.java
===================================================================
--- branches/JBPAPP_4_3_0_GA_JBPAPP-784/testsuite/src/main/org/jboss/test/cluster/web/jvmroute/MockValve.java (rev 0)
+++ branches/JBPAPP_4_3_0_GA_JBPAPP-784/testsuite/src/main/org/jboss/test/cluster/web/jvmroute/MockValve.java 2008-04-18 22:11:34 UTC (rev 72456)
@@ -0,0 +1,92 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.test.cluster.web.jvmroute;
+
+import java.io.IOException;
+
+import javax.servlet.ServletException;
+
+import org.apache.catalina.CometEvent;
+import org.apache.catalina.Valve;
+import org.apache.catalina.connector.Request;
+import org.apache.catalina.connector.Response;
+
+/**
+ * @author Brian Stansberry
+ *
+ */
+public class MockValve implements Valve
+{
+ private Request invokedRequest;
+ private Response invokedResponse;
+
+ /**
+ * Create a new MockValve.
+ *
+ */
+ public MockValve()
+ {
+ }
+
+ public void backgroundProcess()
+ {
+ }
+
+ public String getInfo()
+ {
+ return "MockValve";
+ }
+
+ public Valve getNext()
+ {
+ return null;
+ }
+
+ public void invoke(Request request, Response response) throws IOException, ServletException
+ {
+ this.invokedRequest = request;
+ this.invokedResponse = response;
+ }
+
+ public void setNext(Valve valve)
+ {
+
+ }
+
+ public Request getInvokedRequest()
+ {
+ return invokedRequest;
+ }
+
+ public Response getInvokedResponse()
+ {
+ return invokedResponse;
+ }
+
+ public void event(Request request, Response response, CometEvent event) throws IOException, ServletException
+ {
+ }
+
+
+
+}
Modified: branches/JBPAPP_4_3_0_GA_JBPAPP-784/tomcat/src/main/org/jboss/web/tomcat/service/session/ClusteredSession.java
===================================================================
--- branches/JBPAPP_4_3_0_GA_JBPAPP-784/tomcat/src/main/org/jboss/web/tomcat/service/session/ClusteredSession.java 2008-04-18 21:48:52 UTC (rev 72455)
+++ branches/JBPAPP_4_3_0_GA_JBPAPP-784/tomcat/src/main/org/jboss/web/tomcat/service/session/ClusteredSession.java 2008-04-18 22:11:34 UTC (rev 72456)
@@ -60,7 +60,7 @@
*
* @version $Revision: 57206 $
*/
-abstract class ClusteredSession
+public abstract class ClusteredSession
extends StandardSession
implements Externalizable
{
Modified: branches/JBPAPP_4_3_0_GA_JBPAPP-784/tomcat/src/main/org/jboss/web/tomcat/service/session/JvmRouteValve.java
===================================================================
--- branches/JBPAPP_4_3_0_GA_JBPAPP-784/tomcat/src/main/org/jboss/web/tomcat/service/session/JvmRouteValve.java 2008-04-18 21:48:52 UTC (rev 72455)
+++ branches/JBPAPP_4_3_0_GA_JBPAPP-784/tomcat/src/main/org/jboss/web/tomcat/service/session/JvmRouteValve.java 2008-04-18 22:11:34 UTC (rev 72456)
@@ -119,13 +119,17 @@
HttpServletResponse response,
boolean setCookie)
{
+ int index;
// Get requested jvmRoute.
// TODO. The current format is assumed to be id.jvmRoute. Can be generalized later.
String receivedJvmRoute = null;
- int index = oldsessionId.lastIndexOf(".");
- if (index > 0)
+ if (oldsessionId != null)
{
- receivedJvmRoute = oldsessionId.substring(index + 1, oldsessionId.length());
+ index = oldsessionId.lastIndexOf(".");
+ if (index > 0)
+ {
+ receivedJvmRoute = oldsessionId.substring(index + 1, oldsessionId.length());
+ }
}
String requestedJvmRoute = null;
More information about the jboss-cvs-commits
mailing list