colls = db.getCollectionNames();
+
+ System.err.println("Colls="+colls);
+
+ DBCollection coll = db.getCollection("testCollection");
+
+
+ BasicDBObject key = new BasicDBObject("id","1234");
+ BasicDBObject sets = new BasicDBObject("name","value");
+ BasicDBObject upsert=new BasicDBObject("$set",sets);
+
+ WriteResult result =coll.update(key,upsert,true,false);
+
+ System.err.println(result.getLastError());
+
+
+ while (coll.count()>0)
+ {
+ DBObject docZ = coll.findOne();
+ System.err.println("removing "+ docZ);
+ if (docZ!=null)
+ coll.remove(docZ);
+ }
+
+
+ }
+}
diff --git a/jetty-nosql/src/test/java/org/eclipse/jetty/nosql/mongodb/MongoTestServer.java b/jetty-nosql/src/test/java/org/eclipse/jetty/nosql/mongodb/MongoTestServer.java
new file mode 100644
index 00000000000..5bda287bf29
--- /dev/null
+++ b/jetty-nosql/src/test/java/org/eclipse/jetty/nosql/mongodb/MongoTestServer.java
@@ -0,0 +1,137 @@
+package org.eclipse.jetty.nosql.mongodb;
+
+// ========================================================================
+// Copyright (c) 1996-2009 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v1.0
+// and Apache License v2.0 which accompanies this distribution.
+// The Eclipse Public License is available at
+// http://www.eclipse.org/legal/epl-v10.html
+// The Apache License v2.0 is available at
+// http://www.opensource.org/licenses/apache2.0.php
+// You may elect to redistribute this code under either of these licenses.
+// ========================================================================
+
+
+
+import java.util.concurrent.TimeUnit;
+
+import org.eclipse.jetty.nosql.mongodb.MongoSessionIdManager;
+import org.eclipse.jetty.nosql.mongodb.MongoSessionManager;
+import org.eclipse.jetty.server.SessionIdManager;
+import org.eclipse.jetty.server.SessionManager;
+import org.eclipse.jetty.server.session.AbstractTestServer;
+import org.eclipse.jetty.server.session.SessionHandler;
+
+
+/**
+ * @version $Revision$ $Date$
+ */
+public class MongoTestServer extends AbstractTestServer
+{
+
+ static MongoSessionIdManager _idManager;
+ private boolean _saveAllAttributes = false; // false save dirty, true save all
+
+ public MongoTestServer(int port)
+ {
+ super(port, 30, 10);
+ }
+
+ public MongoTestServer(int port, int maxInactivePeriod, int scavengePeriod)
+ {
+ super(port, maxInactivePeriod, scavengePeriod);
+ }
+
+
+ public MongoTestServer(int port, int maxInactivePeriod, int scavengePeriod, boolean saveAllAttributes)
+ {
+ super(port, maxInactivePeriod, scavengePeriod);
+
+ _saveAllAttributes = saveAllAttributes;
+ }
+
+ public SessionIdManager newSessionIdManager()
+ {
+ if ( _idManager != null )
+ {
+ try
+ {
+ _idManager.stop();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+
+ _idManager.setScavengeDelay(_scavengePeriod + 1000);
+ _idManager.setScavengePeriod(_maxInactivePeriod);
+
+ try
+ {
+ _idManager.start();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+
+ return _idManager;
+ }
+
+ try
+ {
+ System.err.println("MongoTestServer:SessionIdManager:" + _maxInactivePeriod + "/" + _scavengePeriod);
+ _idManager = new MongoSessionIdManager(_server);
+
+ _idManager.setScavengeDelay((int)TimeUnit.SECONDS.toMillis(_scavengePeriod));
+ _idManager.setScavengePeriod(_maxInactivePeriod);
+
+ return _idManager;
+ }
+ catch (Exception e)
+ {
+ throw new IllegalStateException();
+ }
+ }
+
+ public SessionManager newSessionManager()
+ {
+ MongoSessionManager manager;
+ try
+ {
+ manager = new MongoSessionManager();
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+
+ manager.setSavePeriod(1);
+ manager.setStalePeriod(0);
+ manager.setSaveAllAttributes(_saveAllAttributes);
+ //manager.setScavengePeriod((int)TimeUnit.SECONDS.toMillis(_scavengePeriod));
+ return manager;
+ }
+
+ public SessionHandler newSessionHandler(SessionManager sessionManager)
+ {
+ return new SessionHandler(sessionManager);
+ }
+
+ public static void main(String... args) throws Exception
+ {
+ MongoTestServer server8080 = new MongoTestServer(8080);
+ server8080.addContext("/").addServlet(SessionDump.class,"/");
+ server8080.start();
+
+ MongoTestServer server8081 = new MongoTestServer(8081);
+ server8081.addContext("/").addServlet(SessionDump.class,"/");
+ server8081.start();
+
+ server8080.join();
+ server8081.join();
+ }
+
+}
diff --git a/jetty-nosql/src/test/java/org/eclipse/jetty/nosql/mongodb/NewSessionTest.java b/jetty-nosql/src/test/java/org/eclipse/jetty/nosql/mongodb/NewSessionTest.java
new file mode 100644
index 00000000000..216770ca0f1
--- /dev/null
+++ b/jetty-nosql/src/test/java/org/eclipse/jetty/nosql/mongodb/NewSessionTest.java
@@ -0,0 +1,38 @@
+package org.eclipse.jetty.nosql.mongodb;
+
+// ========================================================================
+// Copyright (c) 1996-2009 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v1.0
+// and Apache License v2.0 which accompanies this distribution.
+// The Eclipse Public License is available at
+// http://www.eclipse.org/legal/epl-v10.html
+// The Apache License v2.0 is available at
+// http://www.opensource.org/licenses/apache2.0.php
+// You may elect to redistribute this code under either of these licenses.
+// ========================================================================
+
+import org.eclipse.jetty.server.session.AbstractNewSessionTest;
+import org.eclipse.jetty.server.session.AbstractTestServer;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ * NewSessionTest
+ */
+public class NewSessionTest extends AbstractNewSessionTest
+{
+
+ public AbstractTestServer createServer(int port, int max, int scavenge)
+ {
+ return new MongoTestServer(port,max,scavenge);
+ }
+
+ @Test
+ @Ignore ("requires mongodb server")
+ public void testNewSession() throws Exception
+ {
+ super.testNewSession();
+ }
+}
diff --git a/jetty-nosql/src/test/java/org/eclipse/jetty/nosql/mongodb/OrphanedSessionTest.java b/jetty-nosql/src/test/java/org/eclipse/jetty/nosql/mongodb/OrphanedSessionTest.java
new file mode 100644
index 00000000000..b38524cb229
--- /dev/null
+++ b/jetty-nosql/src/test/java/org/eclipse/jetty/nosql/mongodb/OrphanedSessionTest.java
@@ -0,0 +1,37 @@
+package org.eclipse.jetty.nosql.mongodb;
+
+// ========================================================================
+// Copyright (c) 1996-2009 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v1.0
+// and Apache License v2.0 which accompanies this distribution.
+// The Eclipse Public License is available at
+// http://www.eclipse.org/legal/epl-v10.html
+// The Apache License v2.0 is available at
+// http://www.opensource.org/licenses/apache2.0.php
+// You may elect to redistribute this code under either of these licenses.
+// ========================================================================
+
+import org.eclipse.jetty.server.session.AbstractOrphanedSessionTest;
+import org.eclipse.jetty.server.session.AbstractTestServer;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ * OrphanedSessionTest
+ */
+public class OrphanedSessionTest extends AbstractOrphanedSessionTest
+{
+ public AbstractTestServer createServer(int port, int max, int scavenge)
+ {
+ return new MongoTestServer(port,max,scavenge);
+ }
+
+ @Test
+ @Ignore ("requires mongodb server")
+ public void testOrphanedSession() throws Exception
+ {
+ super.testOrphanedSession();
+ }
+}
diff --git a/jetty-nosql/src/test/java/org/eclipse/jetty/nosql/mongodb/ReentrantRequestSessionTest.java b/jetty-nosql/src/test/java/org/eclipse/jetty/nosql/mongodb/ReentrantRequestSessionTest.java
new file mode 100644
index 00000000000..a342a734ee7
--- /dev/null
+++ b/jetty-nosql/src/test/java/org/eclipse/jetty/nosql/mongodb/ReentrantRequestSessionTest.java
@@ -0,0 +1,38 @@
+package org.eclipse.jetty.nosql.mongodb;
+
+// ========================================================================
+// Copyright (c) 1996-2009 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v1.0
+// and Apache License v2.0 which accompanies this distribution.
+// The Eclipse Public License is available at
+// http://www.eclipse.org/legal/epl-v10.html
+// The Apache License v2.0 is available at
+// http://www.opensource.org/licenses/apache2.0.php
+// You may elect to redistribute this code under either of these licenses.
+// ========================================================================
+
+import org.eclipse.jetty.server.session.AbstractReentrantRequestSessionTest;
+import org.eclipse.jetty.server.session.AbstractTestServer;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ * ReentrantRequestSessionTest
+ */
+public class ReentrantRequestSessionTest extends AbstractReentrantRequestSessionTest
+{
+ public AbstractTestServer createServer(int port)
+ {
+ return new MongoTestServer(port);
+ }
+
+ @Test
+ @Ignore ("requires mongodb server")
+ public void testReentrantRequestSession() throws Exception
+ {
+ super.testReentrantRequestSession();
+ }
+
+}
diff --git a/jetty-nosql/src/test/java/org/eclipse/jetty/nosql/mongodb/RemoveSessionTest.java b/jetty-nosql/src/test/java/org/eclipse/jetty/nosql/mongodb/RemoveSessionTest.java
new file mode 100644
index 00000000000..bbbf85628a1
--- /dev/null
+++ b/jetty-nosql/src/test/java/org/eclipse/jetty/nosql/mongodb/RemoveSessionTest.java
@@ -0,0 +1,35 @@
+package org.eclipse.jetty.nosql.mongodb;
+//========================================================================
+//Copyright (c) 2011 Intalio, Inc.
+//------------------------------------------------------------------------
+//All rights reserved. This program and the accompanying materials
+//are made available under the terms of the Eclipse Public License v1.0
+//and Apache License v2.0 which accompanies this distribution.
+//The Eclipse Public License is available at
+//http://www.eclipse.org/legal/epl-v10.html
+//The Apache License v2.0 is available at
+//http://www.opensource.org/licenses/apache2.0.php
+//You may elect to redistribute this code under either of these licenses.
+//========================================================================
+
+import org.eclipse.jetty.server.session.AbstractRemoveSessionTest;
+import org.eclipse.jetty.server.session.AbstractTestServer;
+import org.junit.Ignore;
+import org.junit.Test;
+
+public class RemoveSessionTest extends AbstractRemoveSessionTest
+{
+
+ public AbstractTestServer createServer(int port, int max, int scavenge)
+ {
+ return new MongoTestServer(port,max,scavenge);
+ }
+
+ @Test
+ @Ignore ("requires mongodb server")
+ public void testRemoveSession() throws Exception
+ {
+ super.testRemoveSession();
+ }
+
+}
diff --git a/jetty-nosql/src/test/java/org/eclipse/jetty/nosql/mongodb/ServerCrossContextSessionTest.java b/jetty-nosql/src/test/java/org/eclipse/jetty/nosql/mongodb/ServerCrossContextSessionTest.java
new file mode 100644
index 00000000000..d5c308363a9
--- /dev/null
+++ b/jetty-nosql/src/test/java/org/eclipse/jetty/nosql/mongodb/ServerCrossContextSessionTest.java
@@ -0,0 +1,34 @@
+package org.eclipse.jetty.nosql.mongodb;
+
+// ========================================================================
+// Copyright (c) 1996-2009 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v1.0
+// and Apache License v2.0 which accompanies this distribution.
+// The Eclipse Public License is available at
+// http://www.eclipse.org/legal/epl-v10.html
+// The Apache License v2.0 is available at
+// http://www.opensource.org/licenses/apache2.0.php
+// You may elect to redistribute this code under either of these licenses.
+// ========================================================================
+
+import org.eclipse.jetty.server.session.AbstractServerCrossContextSessionTest;
+import org.eclipse.jetty.server.session.AbstractTestServer;
+import org.junit.Ignore;
+import org.junit.Test;
+
+public class ServerCrossContextSessionTest extends AbstractServerCrossContextSessionTest
+{
+ public AbstractTestServer createServer(int port)
+ {
+ return new MongoTestServer(port);
+ }
+
+ @Test
+ @Ignore ("requires mongodb server")
+ public void testCrossContextDispatch() throws Exception
+ {
+ super.testCrossContextDispatch();
+ }
+}
diff --git a/jetty-nosql/src/test/java/org/eclipse/jetty/nosql/mongodb/SessionDump.java b/jetty-nosql/src/test/java/org/eclipse/jetty/nosql/mongodb/SessionDump.java
new file mode 100644
index 00000000000..481f6c13332
--- /dev/null
+++ b/jetty-nosql/src/test/java/org/eclipse/jetty/nosql/mongodb/SessionDump.java
@@ -0,0 +1,181 @@
+package org.eclipse.jetty.nosql.mongodb;
+
+// ========================================================================
+// Copyright (c) 1996-2009 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v1.0
+// and Apache License v2.0 which accompanies this distribution.
+// The Eclipse Public License is available at
+// http://www.eclipse.org/legal/epl-v10.html
+// The Apache License v2.0 is available at
+// http://www.opensource.org/licenses/apache2.0.php
+// You may elect to redistribute this code under either of these licenses.
+// ========================================================================
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Date;
+import java.util.Enumeration;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+
+/* ------------------------------------------------------------ */
+/** Test Servlet Sessions.
+ *
+ *
+ */
+public class SessionDump extends HttpServlet
+{
+
+ int redirectCount=0;
+ /* ------------------------------------------------------------ */
+ String pageType;
+
+ /* ------------------------------------------------------------ */
+ @Override
+ public void init(ServletConfig config)
+ throws ServletException
+ {
+ super.init(config);
+ }
+
+ /* ------------------------------------------------------------ */
+ protected void handleForm(HttpServletRequest request,
+ HttpServletResponse response)
+ {
+ HttpSession session = request.getSession(false);
+ String action = request.getParameter("Action");
+ String name = request.getParameter("Name");
+ String value = request.getParameter("Value");
+
+ if (action!=null)
+ {
+ if(action.equals("New Session"))
+ {
+ session = request.getSession(true);
+ session.setAttribute("test","value");
+ }
+ else if (session!=null)
+ {
+ if (action.equals("Invalidate"))
+ session.invalidate();
+ else if (action.equals("Set") && name!=null && name.length()>0)
+ session.setAttribute(name,value);
+ else if (action.equals("Remove"))
+ session.removeAttribute(name);
+ }
+ }
+ }
+
+ /* ------------------------------------------------------------ */
+ @Override
+ public void doPost(HttpServletRequest request,
+ HttpServletResponse response)
+ throws ServletException, IOException
+ {
+ handleForm(request,response);
+ String nextUrl = getURI(request)+"?R="+redirectCount++;
+ String encodedUrl=response.encodeRedirectURL(nextUrl);
+ response.sendRedirect(encodedUrl);
+ }
+
+ /* ------------------------------------------------------------ */
+ @Override
+ public void doGet(HttpServletRequest request,
+ HttpServletResponse response)
+ throws ServletException, IOException
+ {
+ handleForm(request,response);
+
+ response.setContentType("text/html");
+
+ HttpSession session = request.getSession(getURI(request).indexOf("new")>0);
+ try
+ {
+ if (session!=null)
+ session.isNew();
+ }
+ catch(IllegalStateException e)
+ {
+ session=null;
+ }
+
+ PrintWriter out = response.getWriter();
+ out.println("Session Dump Servlet:
");
+ out.println("
");
+
+ if (request.isRequestedSessionIdFromCookie())
+ out.println("Turn off cookies in your browser to try url encoding
");
+
+ if (request.isRequestedSessionIdFromURL())
+ out.println("
Turn on cookies in your browser to try cookie encoding
");
+ out.println("Encoded Link
");
+
+ }
+ catch (IllegalStateException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ }
+
+ /* ------------------------------------------------------------ */
+ @Override
+ public String getServletInfo() {
+ return "Session Dump Servlet";
+ }
+
+ /* ------------------------------------------------------------ */
+ private String getURI(HttpServletRequest request)
+ {
+ String uri=(String)request.getAttribute("javax.servlet.forward.request_uri");
+ if (uri==null)
+ uri=request.getRequestURI();
+ return uri;
+ }
+
+}
diff --git a/jetty-nosql/src/test/java/org/eclipse/jetty/nosql/mongodb/SessionSavingValueTest.java b/jetty-nosql/src/test/java/org/eclipse/jetty/nosql/mongodb/SessionSavingValueTest.java
new file mode 100644
index 00000000000..773c201146f
--- /dev/null
+++ b/jetty-nosql/src/test/java/org/eclipse/jetty/nosql/mongodb/SessionSavingValueTest.java
@@ -0,0 +1,246 @@
+package org.eclipse.jetty.nosql.mongodb;
+
+//========================================================================
+//Copyright (c) 2011 Intalio, Inc.
+//------------------------------------------------------------------------
+//All rights reserved. This program and the accompanying materials
+//are made available under the terms of the Eclipse Public License v1.0
+//and Apache License v2.0 which accompanies this distribution.
+//The Eclipse Public License is available at
+//http://www.eclipse.org/legal/epl-v10.html
+//The Apache License v2.0 is available at
+//http://www.opensource.org/licenses/apache2.0.php
+//You may elect to redistribute this code under either of these licenses.
+//========================================================================
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.Serializable;
+import java.lang.management.ManagementFactory;
+import java.net.MalformedURLException;
+
+import javax.management.remote.JMXServiceURL;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.eclipse.jetty.client.ContentExchange;
+import org.eclipse.jetty.client.HttpClient;
+import org.eclipse.jetty.http.HttpMethods;
+import org.eclipse.jetty.jmx.ConnectorServer;
+import org.eclipse.jetty.jmx.MBeanContainer;
+import org.eclipse.jetty.nosql.NoSqlSession;
+import org.eclipse.jetty.server.session.AbstractSessionValueSavingTest;
+import org.eclipse.jetty.server.session.AbstractTestServer;
+import org.junit.Ignore;
+import org.junit.Test;
+
+public class SessionSavingValueTest extends AbstractSessionValueSavingTest
+{
+
+
+
+ public AbstractTestServer createServer(int port, int max, int scavenge)
+ {
+// ConnectorServer srv = null;
+ try
+ {
+// srv = new ConnectorServer(
+// new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:0/jettytest"),
+// "org.eclipse.jetty:name=rmiconnectorserver");
+// srv.start();
+
+ MongoTestServer server = new MongoTestServer(port,max,scavenge,true);
+
+// MBeanContainer mbean = new MBeanContainer(ManagementFactory.getPlatformMBeanServer());
+//
+// server.getServer().getContainer().addEventListener(mbean);
+// server.getServer().addBean(mbean);
+//
+// mbean.start();
+
+ return server;
+
+ }
+// catch (MalformedURLException e)
+// {
+// // TODO Auto-generated catch block
+// e.printStackTrace();
+// }
+ catch (Exception e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ return null;
+ }
+
+ @Test
+ @Ignore ("requires mongodb server")
+ public void testSessionValueSaving() throws Exception
+ {
+ String contextPath = "";
+ String servletMapping = "/server";
+ int maxInactivePeriod = 10000;
+ int scavengePeriod = 20000;
+ AbstractTestServer server1 = createServer(0,maxInactivePeriod,scavengePeriod);
+ server1.addContext(contextPath).addServlet(TestServlet.class,servletMapping);
+ server1.start();
+ int port1 = server1.getPort();
+ try
+ {
+
+ HttpClient client = new HttpClient();
+ client.setConnectorType(HttpClient.CONNECTOR_SOCKET);
+ client.start();
+ try
+ {
+ String[] sessionTestValue = new String[]
+ { "0", "null" };
+
+ // Perform one request to server1 to create a session
+ ContentExchange exchange1 = new ContentExchange(true);
+ exchange1.setMethod(HttpMethods.GET);
+ exchange1.setURL("http://localhost:" + port1 + contextPath + servletMapping + "?action=init");
+ client.send(exchange1);
+ exchange1.waitForDone();
+ assertEquals(HttpServletResponse.SC_OK,exchange1.getResponseStatus());
+
+ String[] sessionTestResponse = exchange1.getResponseContent().split("/");
+ assertTrue(Long.parseLong(sessionTestValue[0]) < Long.parseLong(sessionTestResponse[0]));
+
+ sessionTestValue = sessionTestResponse;
+
+ String sessionCookie = exchange1.getResponseFields().getStringField("Set-Cookie");
+ assertTrue(sessionCookie != null);
+ // Mangle the cookie, replacing Path with $Path, etc.
+ sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=","$1\\$Path=");
+
+ // Perform some request to server2 using the session cookie from the previous request
+ // This should migrate the session from server1 to server2, and leave server1's
+ // session in a very stale state, while server2 has a very fresh session.
+ // We want to test that optimizations done to the saving of the shared lastAccessTime
+ // do not break the correct working
+ int requestInterval = 500;
+
+ for (int i = 0; i < 10; ++i)
+ {
+ ContentExchange exchange2 = new ContentExchange(true);
+ exchange2.setMethod(HttpMethods.GET);
+ exchange2.setURL("http://localhost:" + port1 + contextPath + servletMapping);
+ exchange2.getRequestFields().add("Cookie",sessionCookie);
+ client.send(exchange2);
+ exchange2.waitForDone();
+ assertEquals(HttpServletResponse.SC_OK,exchange2.getResponseStatus());
+
+ sessionTestResponse = exchange2.getResponseContent().split("/");
+
+ assertTrue(Long.parseLong(sessionTestValue[0]) < Long.parseLong(sessionTestResponse[0]));
+ assertTrue(Long.parseLong(sessionTestValue[1]) < Long.parseLong(sessionTestResponse[1]));
+
+ sessionTestValue = sessionTestResponse;
+
+ String setCookie = exchange1.getResponseFields().getStringField("Set-Cookie");
+ if (setCookie != null)
+ sessionCookie = setCookie.replaceFirst("(\\W)(P|p)ath=","$1\\$Path=");
+
+ Thread.sleep(requestInterval);
+ }
+
+ // Thread.sleep(320000);
+ }
+ finally
+ {
+ client.stop();
+ }
+ }
+ finally
+ {
+ server1.stop();
+ }
+ }
+
+ public static class TestServlet extends HttpServlet
+ {
+ @Override
+ protected void doGet(HttpServletRequest request, HttpServletResponse httpServletResponse) throws ServletException, IOException
+ {
+ String action = request.getParameter("action");
+ if ("init".equals(action))
+ {
+ NoSqlSession session = (NoSqlSession)request.getSession(true);
+ session.setAttribute("test",System.currentTimeMillis());
+ session.setAttribute("objectTest", new Pojo("foo","bar"));
+
+ sendResult(session,httpServletResponse.getWriter());
+
+ }
+ else
+ {
+ NoSqlSession session = (NoSqlSession)request.getSession(false);
+ if (session != null)
+ {
+ long value = System.currentTimeMillis();
+ session.setAttribute("test",value);
+
+ }
+
+ sendResult(session,httpServletResponse.getWriter());
+
+ Pojo p = (Pojo)session.getAttribute("objectTest");
+
+ //System.out.println(p.getName() + " / " + p.getValue() );
+ }
+
+ }
+
+ private void sendResult(NoSqlSession session, PrintWriter writer)
+ {
+ if (session != null)
+ {
+ if (session.getVersion() == null)
+ {
+ writer.print(session.getAttribute("test") + "/-1");
+ }
+ else
+ {
+ writer.print(session.getAttribute("test") + "/" + session.getVersion());
+ }
+ }
+ else
+ {
+ writer.print("0/-1");
+ }
+ }
+
+ public class Pojo implements Serializable
+ {
+ private String _name;
+ private String _value;
+
+ public Pojo( String name, String value )
+ {
+ _name = name;
+ _value = value;
+ }
+
+ public String getName()
+ {
+ return _name;
+ }
+
+ public String getValue()
+ {
+ return _value;
+ }
+ }
+
+ }
+
+
+}
diff --git a/pom.xml b/pom.xml
index 7a7224c843f..93337e04b15 100644
--- a/pom.xml
+++ b/pom.xml
@@ -319,6 +319,7 @@
jetty-start
jetty-nested
jetty-overlay-deployer
+ jetty-nosql
test-continuation
test-continuation-jetty6
test-jetty-servlet