Package org.apache.wicket.request

Examples of org.apache.wicket.request.IRequestMapper


    // so the system mapper can interpret it
    String urlWoJSessionId = Strings.stripJSessionId(url);
    Url resolved = new Url(getRequest().getUrl());
    resolved.resolveRelative(Url.parse(urlWoJSessionId));

    IRequestMapper mapper = getApplication().getRootRequestMapper();
    Request request = getRequest().cloneWithUrl(resolved);
    IRequestHandler handler = mapper.mapRequest(request);

    if (handler != null)
    {
      getRequestCycle().scheduleRequestHandlerAfterCurrent(handler);
    }
View Full Code Here


      public String encodeURL(CharSequence url)
      {
        return url + JSESSIONID;
      }
    };
    IRequestMapper mapper = mock(IRequestMapper.class);

    Url bookmarkablePageUrl = Url.parse(BOOKMARKABLE_PAGE_URL);
    when(mapper.mapHandler(argThat(new ExactClassMatcher<BookmarkablePageRequestHandler>(BookmarkablePageRequestHandler.class)))).thenReturn(bookmarkablePageUrl);

    Url resourceUrl = Url.parse(RESOURCE_URL);
    when(mapper.mapHandler(argThat(new ExactClassMatcher<ResourceRequestHandler>(ResourceRequestHandler.class)))).thenReturn(resourceUrl);

    Url resourceReferenceUrl = Url.parse(RES_REF_URL);
    when(mapper.mapHandler(argThat(new ExactClassMatcher<ResourceReferenceRequestHandler>(ResourceReferenceRequestHandler.class)))).thenReturn(resourceReferenceUrl);

    IExceptionMapper exceptionMapper = mock(IExceptionMapper.class);
    RequestCycleContext context = new RequestCycleContext(request, response, mapper, exceptionMapper);

    requestCycle = new RequestCycle(context);
View Full Code Here

      public void detach(IRequestCycle requestCycle)
      {
        detaches++;
      }
    };
    IRequestMapper requestMapper = new IRequestMapper()
    {
      @Override
      public IRequestHandler mapRequest(Request request)
      {
        return handler;
View Full Code Here

public class HttpsMapperTest
{
  @Test
  public void getDesiredSchemeOfPageClass()
  {
    IRequestMapper delegate = mock(IRequestMapper.class);
    HttpsMapper mapper = new HttpsMapper(delegate, new HttpsConfig());

    assertThat(mapper.getDesiredSchemeFor(SecurePage.class), is(Scheme.HTTPS));
    assertThat(mapper.getDesiredSchemeFor(SecureDecendantPage.class), is(Scheme.HTTPS));
    assertThat(mapper.getDesiredSchemeFor(SecureMixinPage.class), is(Scheme.HTTPS));
View Full Code Here

  }

  @Test
  public void getDesiredSchemeOfHandler()
  {
    IRequestMapper delegate = mock(IRequestMapper.class);
    HttpsMapper mapper = new HttpsMapper(delegate, new HttpsConfig());

    IRequestHandler handler = new RenderPageRequestHandler(new PageProvider(SecurePage.class));
    assertThat(mapper.getDesiredSchemeFor(handler), is(Scheme.HTTPS));
View Full Code Here

  }

  @Test
  public void getSchemeOfRequest()
  {
    IRequestMapper delegate = mock(IRequestMapper.class);
    HttpsMapper mapper = new HttpsMapper(delegate, new HttpsConfig());

    ServletWebRequest request = mock(ServletWebRequest.class);
    HttpServletRequest req = mock(HttpServletRequest.class);
    when(request.getContainerRequest()).thenReturn(req);
View Full Code Here

  }

  @Test
  public void mapHandler()
  {
    IRequestMapper delegate = mock(IRequestMapper.class);
    HttpsMapper mapper = new HttpsMapper(delegate, new HttpsConfig());

    ServletWebRequest request = mock(ServletWebRequest.class);
    HttpServletRequest req = mock(HttpServletRequest.class);
    when(request.getContainerRequest()).thenReturn(req);

    // rendering url to https page on http, set protocol
    IRequestHandler handler = new RenderPageRequestHandler(new PageProvider(SecurePage.class));
    Url url = new Url();
    when(delegate.mapHandler(handler)).thenReturn(url);
    when(req.getScheme()).thenReturn("http");
    mapper.mapHandler(handler, request);
    assertThat(url.getProtocol(), is("https"));

    // render url to http page on http, ignore protocol
    handler = new RenderPageRequestHandler(new PageProvider(InsecurePage.class));
    url = new Url();
    reset(delegate);
    when(delegate.mapHandler(handler)).thenReturn(url);
    when(req.getScheme()).thenReturn("http");
    mapper.mapHandler(handler, request);
    assertThat(url.getProtocol(), is(nullValue()));

    // render url to http page on https, set protocol
    handler = new RenderPageRequestHandler(new PageProvider(InsecurePage.class));
    url = new Url();
    reset(delegate);
    when(delegate.mapHandler(handler)).thenReturn(url);
    when(req.getScheme()).thenReturn("https");
    mapper.mapHandler(handler, request);
    assertThat(url.getProtocol(), is("http"));
  }
View Full Code Here


  @Test
  public void mapRequest()
  {
    IRequestMapper delegate = mock(IRequestMapper.class);
    HttpsMapper mapper = new HttpsMapper(delegate, new HttpsConfig());

    ServletWebRequest request = mock(ServletWebRequest.class);
    HttpServletRequest req = mock(HttpServletRequest.class);
    when(request.getContainerRequest()).thenReturn(req);

    // https handler on http request, redirect to https
    setupRequest(req, "http", "localhost", 80, "/ctx", "foo=bar");
    IRequestHandler handler = new RenderPageRequestHandler(new PageProvider(SecurePage.class));
    when(delegate.mapRequest(request)).thenReturn(handler);
    IRequestHandler resolved = mapper.mapRequest(request);
    assertThat(resolved, is(instanceOf(RedirectHandler.class)));
    assertThat(((RedirectHandler)resolved).getUrl(), is("https://localhost/ctx?foo=bar"));

    // http handler on http request, return the original handler
    handler = new RenderPageRequestHandler(new PageProvider(InsecurePage.class));
    reset(delegate);
    when(delegate.mapRequest(request)).thenReturn(handler);
    setupRequest(req, "http", "localhost", 80, "/ctx", "foo=bar");
    resolved = mapper.mapRequest(request);
    assertThat(resolved, is(sameInstance(handler)));
  }
View Full Code Here

  }

  @Test
  public void mapRequestWithCustomPorts()
  {
    IRequestMapper delegate = mock(IRequestMapper.class);
    HttpsMapper mapper = new HttpsMapper(delegate, new HttpsConfig(10, 20));

    ServletWebRequest request = mock(ServletWebRequest.class);
    HttpServletRequest req = mock(HttpServletRequest.class);
    when(request.getContainerRequest()).thenReturn(req);

    // https handler on http request, redirect to https
    setupRequest(req, "http", "localhost", 10, "/ctx", "foo=bar");
    IRequestHandler handler = new RenderPageRequestHandler(new PageProvider(SecurePage.class));
    when(delegate.mapRequest(request)).thenReturn(handler);
    IRequestHandler resolved = mapper.mapRequest(request);
    assertThat(resolved, is(instanceOf(RedirectHandler.class)));
    assertThat(((RedirectHandler)resolved).getUrl(), is("https://localhost:20/ctx?foo=bar"));

    // http handler on http request, return the original handler
    handler = new RenderPageRequestHandler(new PageProvider(InsecurePage.class));
    reset(delegate);
    when(delegate.mapRequest(request)).thenReturn(handler);
    setupRequest(req, "https", "localhost", 20, "/ctx", "foo=bar");
    resolved = mapper.mapRequest(request);
    assertThat(resolved, is(instanceOf(RedirectHandler.class)));
    assertThat(((RedirectHandler)resolved).getUrl(), is("http://localhost:10/ctx?foo=bar"));
  }
View Full Code Here

    // so the system mapper can interpret it
    String urlWoJSessionId = Strings.stripJSessionId(url);
    Url resolved = new Url(getRequest().getUrl());
    resolved.resolveRelative(Url.parse(urlWoJSessionId));

    IRequestMapper mapper = getApplication().getRootRequestMapper();
    Request request = getRequest().cloneWithUrl(resolved);
    IRequestHandler handler = mapper.mapRequest(request);

    if (handler != null)
    {
      getRequestCycle().scheduleRequestHandlerAfterCurrent(handler);
    }
View Full Code Here

TOP

Related Classes of org.apache.wicket.request.IRequestMapper

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.