Package org.springframework.web.util

Examples of org.springframework.web.util.UriComponents$UriTemplateVariables


    assertThat(queryParams.get("offset"), contains("10"));
  }

  @Test
  public void testFromMethodCallWithPathVarAndMultiValueRequestParams() {
    UriComponents uriComponents = fromMethodCall(on(
        ControllerWithMethods.class).methodWithMultiValueRequestParams("1", Arrays.asList(3, 7), 5)).build();

    assertThat(uriComponents.getPath(), is("/something/1/foo"));

    MultiValueMap<String, String> queryParams = uriComponents.getQueryParams();
    assertThat(queryParams.get("limit"), contains("5"));
    assertThat(queryParams.get("items"), containsInAnyOrder("3", "7"));
  }
View Full Code Here


  }

  @Test
  public void usesForwardedHostAsHostIfHeaderIsSet() {
    this.request.addHeader("X-Forwarded-Host", "somethingDifferent");
    UriComponents uriComponents = fromController(PersonControllerImpl.class).build();

    assertThat(uriComponents.toUriString(), startsWith("http://somethingDifferent"));
  }
View Full Code Here

  }

  @Test
  public void usesForwardedHostAndPortFromHeader() {
    request.addHeader("X-Forwarded-Host", "foobar:8088");
    UriComponents uriComponents = fromController(PersonControllerImpl.class).build();

    assertThat(uriComponents.toUriString(), startsWith("http://foobar:8088"));
  }
View Full Code Here

  }

  @Test
  public void usesFirstHostOfXForwardedHost() {
    request.addHeader("X-Forwarded-Host", "barfoo:8888, localhost:8088");
    UriComponents uriComponents = fromController(PersonControllerImpl.class).build();

    assertThat(uriComponents.toUriString(), startsWith("http://barfoo:8888"));
  }
View Full Code Here

  @Test
  public void fromRequestWithForwardedHostIncludingPort() {
    request.addHeader("X-Forwarded-Host", "webtest.foo.bar.com:443");
    request.setRequestURI("/mvc-showcase/data/param");
    request.setQueryString("foo=123");
    UriComponents result = ServletUriComponentsBuilder.fromRequest(request).build();

    assertEquals("webtest.foo.bar.com", result.getHost());
    assertEquals(443, result.getPort());
  }
View Full Code Here

  @Test
  public void fromRequestWithForwardedHostAndPort() {
    this.request.addHeader("X-Forwarded-Host", "foobarhost");
    this.request.addHeader("X-Forwarded-Port", "9090");
    this.request.setServerPort(8080);
    UriComponents uriComponents = ServletUriComponentsBuilder.fromRequest(this.request).build();

    assertEquals("foobarhost", uriComponents.getHost());
    assertEquals(9090, uriComponents.getPort());
  }
View Full Code Here

  @Test
  public void fromRequestWithForwardedHostWithDefaultPort() {
    this.request.setServerPort(10080);
    this.request.addHeader("X-Forwarded-Host", "example.org");
    UriComponents result = ServletUriComponentsBuilder.fromRequest(request).build();

    assertEquals("example.org", result.getHost());
    assertEquals("should have used the default port of the forwarded request", -1, result.getPort());
  }
View Full Code Here

  @Test
  public void fromRequestWithForwardedHostWithForwardedScheme() {
    this.request.setServerPort(10080);
    this.request.addHeader("X-Forwarded-Proto", "https");
    this.request.addHeader("X-Forwarded-Host", "example.org");
    UriComponents result = ServletUriComponentsBuilder.fromRequest(request).build();

    assertEquals("example.org", result.getHost());
    assertEquals("should have derived scheme from header", "https", result.getScheme());
    assertEquals("should have used the default port of the forwarded request", -1, result.getPort());
  }
View Full Code Here

    @Test
    public final void whenURIIsParsed_thenResultIsCorrect() {
        final String uri = "http://localhost:8080/rest-sec/api/privilege?q=name%3DjDiedXRD";

        // When
        final UriComponents uriComponents = UriComponentsBuilder.fromUriString(uri).build();

        // Then
        assertTrue(uriComponents.getQueryParams().size() == 1);
    }
View Full Code Here

  }

  @RequestMapping(value="/uriComponentsBuilder", method=RequestMethod.GET)
  public String uriComponentsBuilder() {
    String date = this.conversionService.convert(new LocalDate(2011, 12, 31), String.class);
    UriComponents redirectUri = UriComponentsBuilder.fromPath("/redirect/{account}").queryParam("date", date)
        .build().expand("a123").encode();
    return "redirect:" + redirectUri.toUriString();
  }
View Full Code Here

TOP

Related Classes of org.springframework.web.util.UriComponents$UriTemplateVariables

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.