Search in sources :

Example 16 with InMemorySessionManager

use of io.undertow.server.session.InMemorySessionManager in project undertow by undertow-io.

the class CrossContextServletSharedSessionTestCase method setup.

@BeforeClass
public static void setup() throws ServletException {
    final ServletContainer container = ServletContainer.Factory.newInstance();
    final PathHandler path = new PathHandler();
    DefaultServer.setRootHandler(path);
    InMemorySessionManager manager = new InMemorySessionManager("test");
    createDeployment("1", container, path, manager);
    createDeployment("2", container, path, manager);
}
Also used : ServletContainer(io.undertow.servlet.api.ServletContainer) PathHandler(io.undertow.server.handlers.PathHandler) InMemorySessionManager(io.undertow.server.session.InMemorySessionManager) BeforeClass(org.junit.BeforeClass)

Example 17 with InMemorySessionManager

use of io.undertow.server.session.InMemorySessionManager in project undertow by undertow-io.

the class CrossContextServletSharedSessionTestCase method createDeployment.

private static void createDeployment(final String name, final ServletContainer container, final PathHandler path, InMemorySessionManager sessionManager) throws ServletException {
    ServletInfo s = new ServletInfo("servlet", SessionServlet.class).addMapping("/servlet");
    ServletInfo forward = new ServletInfo("forward", ForwardServlet.class).addMapping("/forward");
    ServletInfo include = new ServletInfo("include", IncludeServlet.class).addMapping("/include");
    ServletInfo includeAdd = new ServletInfo("includeadd", IncludeAddServlet.class).addMapping("/includeadd");
    ServletInfo forwardAdd = new ServletInfo("forwardadd", ForwardAddServlet.class).addMapping("/forwardadd");
    ServletInfo accessTimeServlet = new ServletInfo("accesstimeservlet", LastAccessTimeSessionServlet.class).addMapping("/accesstimeservlet");
    DeploymentInfo builder = new DeploymentInfo().setClassLoader(SimpleServletTestCase.class.getClassLoader()).setContextPath("/" + name).setClassIntrospecter(TestClassIntrospector.INSTANCE).setDeploymentName(name + ".war").setSessionManagerFactory(new SessionManagerFactory() {

        @Override
        public SessionManager createSessionManager(Deployment deployment) {
            return sessionManager;
        }
    }).setServletSessionConfig(new ServletSessionConfig().setPath("/")).addServlets(s, forward, include, forwardAdd, includeAdd, accessTimeServlet);
    DeploymentManager manager = container.addDeployment(builder);
    manager.deploy();
    path.addPrefixPath(builder.getContextPath(), manager.start());
}
Also used : DeploymentManager(io.undertow.servlet.api.DeploymentManager) InMemorySessionManager(io.undertow.server.session.InMemorySessionManager) SessionManager(io.undertow.server.session.SessionManager) Deployment(io.undertow.servlet.api.Deployment) ServletSessionConfig(io.undertow.servlet.api.ServletSessionConfig) SimpleServletTestCase(io.undertow.servlet.test.SimpleServletTestCase) ServletInfo(io.undertow.servlet.api.ServletInfo) SessionManagerFactory(io.undertow.servlet.api.SessionManagerFactory) DeploymentInfo(io.undertow.servlet.api.DeploymentInfo)

Aggregations

InMemorySessionManager (io.undertow.server.session.InMemorySessionManager)17 SessionAttachmentHandler (io.undertow.server.session.SessionAttachmentHandler)14 SessionCookieConfig (io.undertow.server.session.SessionCookieConfig)12 HttpHandler (io.undertow.server.HttpHandler)11 HttpServerExchange (io.undertow.server.HttpServerExchange)10 IOException (java.io.IOException)8 SessionManager (io.undertow.server.session.SessionManager)7 Session (io.undertow.server.session.Session)6 Undertow (io.undertow.Undertow)5 PathHandler (io.undertow.server.handlers.PathHandler)5 HttpString (io.undertow.util.HttpString)5 TestHttpClient (io.undertow.testutils.TestHttpClient)4 Header (org.apache.http.Header)4 HttpResponse (org.apache.http.HttpResponse)4 HttpGet (org.apache.http.client.methods.HttpGet)4 BeforeClass (org.junit.BeforeClass)4 Test (org.junit.Test)4 LearningPushHandler (io.undertow.server.handlers.LearningPushHandler)3 URI (java.net.URI)3 BasicCookieStore (org.apache.http.impl.client.BasicCookieStore)3