Esempio n. 1
0
 @Test
 public void renderFullUrlWithRelativeArgument() {
   Url baseUrl = Url.parse("one/two/three");
   baseUrl.setProtocol("http");
   baseUrl.setHost("www.example.com");
   baseUrl.setPort(8888);
   UrlRenderer renderer = new UrlRenderer(new MockWebRequest(baseUrl));
   renderer.setBaseUrl(baseUrl); // this is needed because MockWebRequest cuts data
   String fullUrl = renderer.renderFullUrl(Url.parse("../four"));
   assertEquals("http://www.example.com:8888/one/four", fullUrl);
 }
Esempio n. 2
0
 /** https://issues.apache.org/jira/browse/WICKET-4514 */
 @Test
 public void renderFullUrlWithAbsoluteArgument() {
   Url baseUrl = Url.parse("one/two/three");
   baseUrl.setProtocol("http");
   baseUrl.setHost("www.example.com");
   baseUrl.setPort(8888);
   UrlRenderer renderer = new UrlRenderer(new MockWebRequest(baseUrl));
   renderer.setBaseUrl(baseUrl); // this is needed because MockWebRequest cuts data
   String fullUrl = renderer.renderFullUrl(Url.parse("/four")); // url starting with slash is
   // considered absolute
   assertEquals("http://www.example.com:8888/four", fullUrl);
 }
Esempio n. 3
0
  /**
   * https://issues.apache.org/jira/browse/WICKET-4561
   * https://issues.apache.org/jira/browse/WICKET-4562
   */
  @Test
  public void renderUrlWithRelativeArgument() {
    Url baseUrl = Url.parse("one/two/three");
    UrlRenderer renderer = new UrlRenderer(new MockWebRequest(baseUrl));
    baseUrl.setProtocol("http");
    baseUrl.setHost("www.example.com");
    baseUrl.setPort(8888);
    renderer.setBaseUrl(baseUrl);

    Url newUrl = Url.parse("four");
    newUrl.setProtocol("https");
    String fullUrl = renderer.renderUrl(newUrl);
    assertEquals("https://www.example.com:8888/four", fullUrl);

    newUrl = Url.parse("./four");
    newUrl.setProtocol("https");
    fullUrl = renderer.renderUrl(newUrl);
    assertEquals("https://www.example.com:8888/four", fullUrl);

    newUrl = Url.parse("./././four");
    newUrl.setProtocol("https");
    fullUrl = renderer.renderUrl(newUrl);
    assertEquals("https://www.example.com:8888/four", fullUrl);

    newUrl = Url.parse("../four");
    newUrl.setProtocol("https");
    fullUrl = renderer.renderUrl(newUrl);
    assertEquals("https://www.example.com:8888/four", fullUrl);

    newUrl = Url.parse(".././four");
    newUrl.setProtocol("https");
    fullUrl = renderer.renderUrl(newUrl);
    assertEquals("https://www.example.com:8888/four", fullUrl);

    newUrl = Url.parse("../../../../four");
    newUrl.setProtocol("https");
    fullUrl = renderer.renderUrl(newUrl);
    assertEquals("https://www.example.com:8888/four", fullUrl);
  }