Search in sources :

Example 1 with MockContainer

use of com.github.bordertech.wcomponents.MockContainer in project wcomponents by BorderTech.

the class WServlet_Test method testServiceNormalRequest.

@Test
public void testServiceNormalRequest() throws ServletException, IOException {
    MockServletConfig config = new MockServletConfig();
    config.setInitParameter(WServlet.WServletHelper.ONGOING_URL_SUFFIX, "foo");
    MockContainer content = new MockContainer();
    content.add(new WText(LABEL_TEXT));
    content.setLocked(true);
    MyWServlet servlet = new MyWServlet(content);
    servlet.init(config);
    MockHttpSession session1 = new MockHttpSession();
    MockHttpSession session2 = new MockHttpSession();
    sendRequest(session1, servlet);
    sendRequest(session2, servlet);
    sendRequest(session1, servlet);
    // check handle request / paint counts for each session
    UIContext uic = getContextForSession(servlet, session1);
    setActiveContext(uic);
    Assert.assertEquals("Incorrect handle request count for session1", 2, content.getHandleRequestCount());
    Assert.assertEquals("Incorrect paint count for session1", 2, content.getPaintCount());
    uic = getContextForSession(servlet, session2);
    setActiveContext(uic);
    Assert.assertEquals("Incorrect handle request count for session2", 1, content.getHandleRequestCount());
    Assert.assertEquals("Incorrect paint count for session2", 1, content.getPaintCount());
}
Also used : MockContainer(com.github.bordertech.wcomponents.MockContainer) WText(com.github.bordertech.wcomponents.WText) UIContext(com.github.bordertech.wcomponents.UIContext) MockServletConfig(com.github.bordertech.wcomponents.util.mock.servlet.MockServletConfig) MockHttpSession(com.github.bordertech.wcomponents.util.mock.servlet.MockHttpSession) Test(org.junit.Test)

Aggregations

MockContainer (com.github.bordertech.wcomponents.MockContainer)1 UIContext (com.github.bordertech.wcomponents.UIContext)1 WText (com.github.bordertech.wcomponents.WText)1 MockHttpSession (com.github.bordertech.wcomponents.util.mock.servlet.MockHttpSession)1 MockServletConfig (com.github.bordertech.wcomponents.util.mock.servlet.MockServletConfig)1 Test (org.junit.Test)1