Esempio n. 1
0
 private void mockCurrentContextHttpRequest() {
   final HttpServletRequest req = Mockito.mock(HttpServletRequest.class);
   Mockito.when(req.getScheme()).thenReturn("http");
   Mockito.when(req.getServerName()).thenReturn("localhost");
   Mockito.when(req.getLocalPort()).thenReturn(80);
   ServletRequestHolder.setRequest(req);
 }
  @Test
  public void createUrl_absolute() {
    final PageUrlParams params =
        new PageUrlParams()
            .type(UrlTypeConstants.ABSOLUTE)
            .portalRequest(this.portalRequest)
            .param("a", 3);

    MockHttpServletRequest req = new MockHttpServletRequest();
    ServletRequestHolder.setRequest(req);

    final String url = this.service.pageUrl(params);
    assertEquals("http://localhost/portal/draft/context/path?a=3", url);
  }
Esempio n. 3
0
 public WebResponse dispatch(final WebRequest webRequest, final WebResponse webResponse)
     throws Exception {
   ServletRequestHolder.setRequest(webRequest.getRawRequest());
   return new WebHandlerChainImpl(webHandlerList).handle(webRequest, webResponse);
 }