Search in sources :

Example 26 with ServletConfig

use of javax.servlet.ServletConfig in project atmosphere by Atmosphere.

the class QueryStringTest method create.

@BeforeMethod
public void create() throws Throwable {
    framework = new AtmosphereFramework();
    framework.setAsyncSupport(new BlockingIOCometSupport(framework.getAtmosphereConfig()));
    framework.init(new ServletConfig() {

        @Override
        public String getServletName() {
            return "void";
        }

        @Override
        public ServletContext getServletContext() {
            return mock(ServletContext.class);
        }

        @Override
        public String getInitParameter(String name) {
            return null;
        }

        @Override
        public Enumeration<String> getInitParameterNames() {
            return null;
        }
    });
}
Also used : BlockingIOCometSupport(org.atmosphere.container.BlockingIOCometSupport) Enumeration(java.util.Enumeration) ServletConfig(javax.servlet.ServletConfig) ServletContext(javax.servlet.ServletContext) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 27 with ServletConfig

use of javax.servlet.ServletConfig in project atmosphere by Atmosphere.

the class TrackMessageSizeInterceptorTest method create.

@BeforeMethod
public void create() throws Throwable {
    framework = new AtmosphereFramework();
    framework.setAsyncSupport(new AsynchronousProcessor(framework.getAtmosphereConfig()) {

        @Override
        public Action service(AtmosphereRequest req, AtmosphereResponse res) throws IOException, ServletException {
            return action(req, res);
        }
    });
    framework.init(new ServletConfig() {

        @Override
        public String getServletName() {
            return "void";
        }

        @Override
        public ServletContext getServletContext() {
            return mock(ServletContext.class);
        }

        @Override
        public String getInitParameter(String name) {
            return null;
        }

        @Override
        public Enumeration<String> getInitParameterNames() {
            return null;
        }
    });
}
Also used : ServletException(javax.servlet.ServletException) Enumeration(java.util.Enumeration) ServletConfig(javax.servlet.ServletConfig) ServletContext(javax.servlet.ServletContext) IOException(java.io.IOException) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 28 with ServletConfig

use of javax.servlet.ServletConfig in project atmosphere by Atmosphere.

the class AtmosphereFrameworkTest method testAtmosphereServlet.

@Test
public void testAtmosphereServlet() throws ServletException {
    AtmosphereServlet s = new MyAtmosphereServlet();
    s.init(new ServletConfig() {

        @Override
        public String getServletName() {
            return "void";
        }

        @Override
        public ServletContext getServletContext() {
            return mock(ServletContext.class);
        }

        @Override
        public String getInitParameter(String name) {
            return null;
        }

        @Override
        public Enumeration<String> getInitParameterNames() {
            return null;
        }
    });
    assertNotNull(s);
}
Also used : Enumeration(java.util.Enumeration) ServletConfig(javax.servlet.ServletConfig) ServletContext(javax.servlet.ServletContext) Test(org.testng.annotations.Test)

Example 29 with ServletConfig

use of javax.servlet.ServletConfig in project atmosphere by Atmosphere.

the class AtmosphereInterceptorTest method create.

@BeforeMethod
public void create() throws Throwable {
    framework = new AtmosphereFramework();
    framework.setAsyncSupport(mock(AsyncSupport.class));
    framework.init(new ServletConfig() {

        @Override
        public String getServletName() {
            return "void";
        }

        @Override
        public ServletContext getServletContext() {
            return mock(ServletContext.class);
        }

        @Override
        public String getInitParameter(String name) {
            return null;
        }

        @Override
        public Enumeration<String> getInitParameterNames() {
            return null;
        }
    });
    config = framework.getAtmosphereConfig();
    processor = new AsynchronousProcessor(config) {

        @Override
        public Action service(AtmosphereRequest req, AtmosphereResponse res) throws IOException, ServletException {
            return action(req, res);
        }
    };
}
Also used : Enumeration(java.util.Enumeration) ServletConfig(javax.servlet.ServletConfig) IOException(java.io.IOException) ServletException(javax.servlet.ServletException) ServletContext(javax.servlet.ServletContext) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 30 with ServletConfig

use of javax.servlet.ServletConfig in project atmosphere by Atmosphere.

the class AtmosphereInterceptorTest method configureTest.

@Test
public void configureTest() throws ServletException, IOException {
    final AtomicInteger count = new AtomicInteger();
    framework = new AtmosphereFramework();
    framework.setAsyncSupport(mock(AsyncSupport.class));
    framework.interceptor(new AtmosphereInterceptor() {

        @Override
        public void configure(AtmosphereConfig config) {
            count.incrementAndGet();
        }

        @Override
        public Action inspect(AtmosphereResource r) {
            return Action.CREATED;
        }

        @Override
        public void destroy() {
        }

        @Override
        public void postInspect(AtmosphereResource r) {
        }
    });
    framework.init(new ServletConfig() {

        @Override
        public String getServletName() {
            return "void";
        }

        @Override
        public ServletContext getServletContext() {
            return mock(ServletContext.class);
        }

        @Override
        public String getInitParameter(String name) {
            return null;
        }

        @Override
        public Enumeration<String> getInitParameterNames() {
            return null;
        }
    });
    config = framework.getAtmosphereConfig();
    processor = new AsynchronousProcessor(config) {

        @Override
        public Action service(AtmosphereRequest req, AtmosphereResponse res) throws IOException, ServletException {
            return action(req, res);
        }
    };
    framework.addAtmosphereHandler("/*", handler);
    assertEquals(Action.CREATED, processor.service(mock(AtmosphereRequestImpl.class), AtmosphereResponseImpl.newInstance()));
    assertEquals(1, count.get());
}
Also used : Enumeration(java.util.Enumeration) ServletConfig(javax.servlet.ServletConfig) IOException(java.io.IOException) ServletException(javax.servlet.ServletException) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ServletContext(javax.servlet.ServletContext) Test(org.testng.annotations.Test)

Aggregations

ServletConfig (javax.servlet.ServletConfig)69 ServletContext (javax.servlet.ServletContext)52 Enumeration (java.util.Enumeration)37 BeforeMethod (org.testng.annotations.BeforeMethod)21 ServletException (javax.servlet.ServletException)20 Test (org.junit.Test)15 IOException (java.io.IOException)12 BlockingIOCometSupport (org.atmosphere.container.BlockingIOCometSupport)9 MockServletConfig (org.springframework.mock.web.test.MockServletConfig)8 HttpServletRequest (javax.servlet.http.HttpServletRequest)7 MockServletContext (org.springframework.mock.web.test.MockServletContext)7 HttpServletResponse (javax.servlet.http.HttpServletResponse)6 AtmosphereFramework (org.atmosphere.runtime.AtmosphereFramework)6 ServletContextAwareProcessor (org.springframework.web.context.support.ServletContextAwareProcessor)6 HttpServlet (javax.servlet.http.HttpServlet)5 SimpleBroadcaster (org.atmosphere.util.SimpleBroadcaster)5 UnavailableException (javax.servlet.UnavailableException)4 PrintWriter (java.io.PrintWriter)3 AsynchronousProcessor (org.atmosphere.runtime.AsynchronousProcessor)3 AtmosphereRequest (org.atmosphere.runtime.AtmosphereRequest)3