Example usage for org.apache.wicket.protocol.http.mock MockServletContext addServlet

List of usage examples for org.apache.wicket.protocol.http.mock MockServletContext addServlet

Introduction

In this page you can find the example usage for org.apache.wicket.protocol.http.mock MockServletContext addServlet.

Prototype

@Override
    public ServletRegistration.Dynamic addServlet(String servletName, Class<? extends Servlet> servletClass) 

Source Link

Usage

From source file:org.wicketstuff.jeeweb.JEEWebResolverTest.java

License:Apache License

@Test
public void testServletsAndJSPsAreResolvedRight() throws Exception {
    TestApplication testApplication = new TestApplication();
    MockServletContext mockServletContext = new MockServletContext(testApplication,
            new File("src/test/webapp").getCanonicalPath());

    mockServletContext.addServlet("/TestServlet", new HttpServlet() {
    });// w  w w.  j a v  a 2 s .  c o m

    WicketTester wicketTester = new WicketTester(testApplication, mockServletContext);
    wicketTester.startPage(TestServletAndJSPPage.class);
    String lastResponse = wicketTester.getLastResponseAsString();
    Assert.assertTrue(lastResponse.contains("INCLUDE OF RESOURCE: /TestServlet"));
    Assert.assertTrue(lastResponse.contains("INCLUDE OF RESOURCE: /TestJSP.jsp"));
}