Search in sources :

Example 21 with MockHttpServletResponse

use of com.github.bordertech.wcomponents.util.mock.servlet.MockHttpServletResponse in project wcomponents by BorderTech.

the class WServletPerformance_Test method testWServletAppCorrectness.

/**
 * Basic sanity-test to ensure that the WComponent app is performing all the processing that it should.
 *
 * @throws Exception an exception
 */
@Test
public void testWServletAppCorrectness() throws Exception {
    SimpleWServlet servlet = new SimpleWServlet();
    servlet.init(new MockServletConfig());
    MockHttpSession session = new MockHttpSession();
    // First request
    sendWServletRequest(servlet, session, 0, null);
    // Second request
    WServletHelper helper = new WServletHelper(servlet, new MockHttpServletRequest(session), new MockHttpServletResponse());
    UIContext uic = helper.getUIContext();
    SimpleApp app = (SimpleApp) uic.getUI();
    sendWServletRequest(servlet, session, 1, uic.getEnvironment().getSessionToken());
    setActiveContext(uic);
    Assert.assertEquals("Incorrect step", 2, uic.getEnvironment().getStep());
    Assert.assertEquals("Incorrect property1 value", "p1_1", ((SimpleFormBean) app.beanContainer.getBean()).getProperty1());
    Assert.assertEquals("Incorrect property2 value", "p2_1", ((SimpleFormBean) app.beanContainer.getBean()).getProperty2());
}
Also used : WServletHelper(com.github.bordertech.wcomponents.servlet.WServlet.WServletHelper) UIContext(com.github.bordertech.wcomponents.UIContext) MockHttpServletRequest(com.github.bordertech.wcomponents.util.mock.servlet.MockHttpServletRequest) MockServletConfig(com.github.bordertech.wcomponents.util.mock.servlet.MockServletConfig) MockHttpSession(com.github.bordertech.wcomponents.util.mock.servlet.MockHttpSession) MockHttpServletResponse(com.github.bordertech.wcomponents.util.mock.servlet.MockHttpServletResponse) Test(org.junit.Test)

Aggregations

MockHttpServletResponse (com.github.bordertech.wcomponents.util.mock.servlet.MockHttpServletResponse)21 Test (org.junit.Test)15 MockHttpServletRequest (com.github.bordertech.wcomponents.util.mock.servlet.MockHttpServletRequest)13 MockServletConfig (com.github.bordertech.wcomponents.util.mock.servlet.MockServletConfig)8 MockHttpSession (com.github.bordertech.wcomponents.util.mock.servlet.MockHttpSession)6 WText (com.github.bordertech.wcomponents.WText)5 WServletHelper (com.github.bordertech.wcomponents.servlet.WServlet.WServletHelper)2 UIContext (com.github.bordertech.wcomponents.UIContext)1 ServletException (javax.servlet.ServletException)1