Search in sources :

Example 6 with MockWebResponse

use of org.apache.wicket.mock.MockWebResponse in project wicket by apache.

the class XmlPartialPageUpdateTest method removedComponentAreNotWritten.

/**
 * WICKET-6503 removed components are not written, but no exception raised either.
 */
@Test
public void removedComponentAreNotWritten() throws Exception {
    PageForPartialUpdate page = new PageForPartialUpdate();
    tester.startPage(page);
    XmlPartialPageUpdate update = new XmlPartialPageUpdate(page);
    update.add(new Label("notInPage"), "notInPage");
    MockWebResponse response = new MockWebResponse();
    update.writeTo(response, "UTF-8");
    assertFalse("notInPage not written", response.getTextResponse().toString().contains("notInPage"));
}
Also used : MockWebResponse(org.apache.wicket.mock.MockWebResponse) Label(org.apache.wicket.markup.html.basic.Label) Test(org.junit.Test)

Example 7 with MockWebResponse

use of org.apache.wicket.mock.MockWebResponse in project openmeetings by apache.

the class ApplicationHelper method ensureApplication.

public static IApplication ensureApplication(Long langId) {
    IApplication a = ensureApplication();
    if (ThreadContext.getRequestCycle() == null) {
        ServletWebRequest req = new ServletWebRequest(new MockHttpServletRequest((Application) a, new MockHttpSession(a.getServletContext()), a.getServletContext()), "");
        RequestCycleContext rctx = new RequestCycleContext(req, new MockWebResponse(), a.getRootRequestMapper(), a.getExceptionMapperProvider().get());
        ThreadContext.setRequestCycle(new RequestCycle(rctx));
    }
    if (ThreadContext.getSession() == null) {
        WebSession s = WebSession.get();
        if (langId > 0) {
            ((IWebSession) s).setLanguage(langId);
        }
    }
    return a;
}
Also used : MockWebResponse(org.apache.wicket.mock.MockWebResponse) IApplication(org.apache.openmeetings.IApplication) RequestCycleContext(org.apache.wicket.request.cycle.RequestCycleContext) IWebSession(org.apache.openmeetings.IWebSession) WebSession(org.apache.wicket.protocol.http.WebSession) IWebSession(org.apache.openmeetings.IWebSession) MockHttpServletRequest(org.apache.wicket.protocol.http.mock.MockHttpServletRequest) RequestCycle(org.apache.wicket.request.cycle.RequestCycle) MockHttpSession(org.apache.wicket.protocol.http.mock.MockHttpSession) ServletWebRequest(org.apache.wicket.protocol.http.servlet.ServletWebRequest) IApplication(org.apache.openmeetings.IApplication) Application(org.apache.wicket.Application) WebApplication(org.apache.wicket.protocol.http.WebApplication)

Aggregations

MockWebResponse (org.apache.wicket.mock.MockWebResponse)7 Test (org.junit.Test)6 ArrayList (java.util.ArrayList)1 IApplication (org.apache.openmeetings.IApplication)1 IWebSession (org.apache.openmeetings.IWebSession)1 Application (org.apache.wicket.Application)1 Component (org.apache.wicket.Component)1 Label (org.apache.wicket.markup.html.basic.Label)1 WebApplication (org.apache.wicket.protocol.http.WebApplication)1 WebSession (org.apache.wicket.protocol.http.WebSession)1 MockHttpServletRequest (org.apache.wicket.protocol.http.mock.MockHttpServletRequest)1 MockHttpSession (org.apache.wicket.protocol.http.mock.MockHttpSession)1 ServletWebRequest (org.apache.wicket.protocol.http.servlet.ServletWebRequest)1 RequestCycle (org.apache.wicket.request.cycle.RequestCycle)1 RequestCycleContext (org.apache.wicket.request.cycle.RequestCycleContext)1 WebResponse (org.apache.wicket.request.http.WebResponse)1