Example usage for org.apache.wicket.mock MockWebRequest MockWebRequest

List of usage examples for org.apache.wicket.mock MockWebRequest MockWebRequest

Introduction

In this page you can find the example usage for org.apache.wicket.mock MockWebRequest MockWebRequest.

Prototype

public MockWebRequest(Url url) 

Source Link

Document

Construct.

Usage

From source file:at.molindo.wicketutils.utils.WicketUtils.java

License:Apache License

public static IRequestHandler getRequestHandler(final URL url) {
    if (url != null) {
        MockWebRequest request = new MockWebRequest(Url.parse(url.toString()));

        return Application.get().getRootRequestMapper().mapRequest(request);
    } else {/*from   w  w w.j  av a 2s . c  o m*/
        return null;
    }
}

From source file:com.norconex.commons.wicket.ThreadContextMocker.java

License:Apache License

/**
 * Invoke this method in the new thread before doing something with Wicket.
 *//*from  w w  w. ja  v  a2 s .c om*/
public void mock() {
    ThreadContext.setApplication(application);
    ThreadContext.setSession(session);
    final MockServletContext context = new MockServletContext(application, SystemUtils.JAVA_IO_TMPDIR);
    ThreadContext.setRequestCycle(
            application.createRequestCycle(new MockWebRequest(Url.parse("http://localhost/mock")) {
                @Override
                public Object getContainerRequest() {
                    return new MockHttpServletRequest(application, new MockHttpSession(context), context);
                }
            }, new MockWebResponse()));
}

From source file:org.ops4j.pax.wicket.internal.PageMounterTracker.java

License:Apache License

@Override
public final void removedService(ServiceReference reference, Object mounter) {
    PageMounter pageMounter = (PageMounter) mounter;
    List<MountPointInfo> infos = pageMounter.getMountPoints();
    for (MountPointInfo info : infos) {
        LOGGER.trace("Trying to mount {} with {}", info.getPath(), info.getPage().getName());
        Application oldApp = ThreadContext.getApplication();
        ThreadContext.setApplication(application);
        if (!Session.exists()) {
            Request request = new MockWebRequest(Url.parse(info.getPath()));
            ThreadContext.setSession(new WebSession(request));
        }//from  www . ja  v  a 2 s  . co  m
        application.unmount(info.getPath());
        ThreadContext.setApplication(oldApp);
        LOGGER.info("Unmounted {} with {}", info.getPath(), info.getPage().getName());
    }

    super.removedService(reference, pageMounter);
}