Package org.springframework.web.util

Examples of org.springframework.web.util.UriComponents.toUriString()


    UriComponents baseUri = UriComponentsBuilder.fromUriString("http://foo:9090").build();

    PagedResourcesAssembler<Person> assembler = new PagedResourcesAssembler<Person>(resolver, baseUri);
    PagedResources<Resource<Person>> resources = assembler.toResource(createPage(1));

    assertThat(resources.getLink(Link.REL_PREVIOUS).getHref(), startsWith(baseUri.toUriString()));
    assertThat(resources.getLink(Link.REL_SELF), is(notNullValue()));
    assertThat(resources.getLink(Link.REL_NEXT).getHref(), startsWith(baseUri.toUriString()));
  }

  @Test
View Full Code Here


    PagedResourcesAssembler<Person> assembler = new PagedResourcesAssembler<Person>(resolver, baseUri);
    PagedResources<Resource<Person>> resources = assembler.toResource(createPage(1));

    assertThat(resources.getLink(Link.REL_PREVIOUS).getHref(), startsWith(baseUri.toUriString()));
    assertThat(resources.getLink(Link.REL_SELF), is(notNullValue()));
    assertThat(resources.getLink(Link.REL_NEXT).getHref(), startsWith(baseUri.toUriString()));
  }

  @Test
  public void usesCustomLinkProvided() {
View Full Code Here

            builder = builder.queryParam(TAGGED_PARAM, tagsString);
        }

        UriComponents uriComponents = builder.build();

        Questions result = restClient.get(restOperations, uriComponents.toUriString(), Questions.class);

        return result.items;
    }

    private UriComponentsBuilder getBuilderFor(String uri) {
View Full Code Here

        builder.queryParam(key, parameter.asString());
      }
    }

    UriComponents components = applyUriComponentsContributer(builder, invocation).buildAndExpand(values);
    return new ControllerLinkBuilder(UriComponentsBuilder.fromUriString(components.toUriString()));
  }

  /*
   * (non-Javadoc)
   * @see org.springframework.hateoas.MethodLinkBuilderFactory#linkTo(java.lang.reflect.Method, java.lang.Object[])
View Full Code Here


  @Test
  public void testFromController() {
    UriComponents uriComponents = fromController(PersonControllerImpl.class).build();
    assertThat(uriComponents.toUriString(), Matchers.endsWith("/people"));
  }

  @Test
  public void testFromControllerUriTemplate() {
    UriComponents uriComponents = fromController(PersonsAddressesController.class).buildAndExpand(15);
View Full Code Here

  }

  @Test
  public void testFromControllerUriTemplate() {
    UriComponents uriComponents = fromController(PersonsAddressesController.class).buildAndExpand(15);
    assertThat(uriComponents.toUriString(), endsWith("/people/15/addresses"));
  }

  @Test
  public void testFromControllerSubResource() {
    UriComponents uriComponents = fromController(PersonControllerImpl.class).pathSegment("something").build();
View Full Code Here

  @Test
  public void testFromControllerSubResource() {
    UriComponents uriComponents = fromController(PersonControllerImpl.class).pathSegment("something").build();

    assertThat(uriComponents.toUriString(), endsWith("/people/something"));
  }

  @Test
  public void testFromControllerTwoTypeLevelMappings() {
    UriComponents uriComponents = fromController(InvalidController.class).build();
View Full Code Here

  }

  @Test
  public void testFromControllerTwoTypeLevelMappings() {
    UriComponents uriComponents = fromController(InvalidController.class).build();
    assertThat(uriComponents.toUriString(), is("http://localhost/persons"));
  }

  @Test
  public void testFromControllerNotMapped() {
    UriComponents uriComponents = fromController(UnmappedController.class).build();
View Full Code Here

  }

  @Test
  public void testFromControllerNotMapped() {
    UriComponents uriComponents = fromController(UnmappedController.class).build();
    assertThat(uriComponents.toUriString(), is("http://localhost/"));
  }

  @Test
  public void testFromMethodNamePathVariable() throws Exception {
    UriComponents uriComponents = fromMethodName(
View Full Code Here

  @Test
  public void testFromMethodNamePathVariable() throws Exception {
    UriComponents uriComponents = fromMethodName(
        ControllerWithMethods.class, "methodWithPathVariable", new Object[]{"1"}).build();

    assertThat(uriComponents.toUriString(), is("http://localhost/something/1/foo"));
  }

  @Test
  public void testFromMethodNameTypeLevelPathVariable() throws Exception {
    this.request.setContextPath("/myapp");
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.