|
|
|
@ -1,5 +1,5 @@ |
|
|
|
|
/* |
|
|
|
|
* Copyright 2002-2013 the original author or authors. |
|
|
|
|
* Copyright 2002-2014 the original author or authors. |
|
|
|
|
* |
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
@ -23,6 +23,7 @@ import java.util.HashMap; |
|
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
|
import org.junit.Test; |
|
|
|
|
|
|
|
|
|
import org.springframework.util.LinkedMultiValueMap; |
|
|
|
|
import org.springframework.util.MultiValueMap; |
|
|
|
|
|
|
|
|
@ -50,6 +51,28 @@ public class UriComponentsBuilderTests { |
|
|
|
|
assertEquals("Invalid result URI", expected, result.toUri()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void multipleFromSameBuilder() throws URISyntaxException { |
|
|
|
|
UriComponentsBuilder builder = UriComponentsBuilder.newInstance().scheme("http").host("example.com").pathSegment("foo"); |
|
|
|
|
UriComponents result1 = builder.build(); |
|
|
|
|
builder = builder.pathSegment("foo2").queryParam("bar").fragment("baz"); |
|
|
|
|
UriComponents result2 = builder.build(); |
|
|
|
|
|
|
|
|
|
assertEquals("http", result1.getScheme()); |
|
|
|
|
assertEquals("example.com", result1.getHost()); |
|
|
|
|
assertEquals("/foo", result1.getPath()); |
|
|
|
|
URI expected = new URI("http://example.com/foo"); |
|
|
|
|
assertEquals("Invalid result URI", expected, result1.toUri()); |
|
|
|
|
|
|
|
|
|
assertEquals("http", result2.getScheme()); |
|
|
|
|
assertEquals("example.com", result2.getHost()); |
|
|
|
|
assertEquals("/foo/foo2", result2.getPath()); |
|
|
|
|
assertEquals("bar", result2.getQuery()); |
|
|
|
|
assertEquals("baz", result2.getFragment()); |
|
|
|
|
expected = new URI("http://example.com/foo/foo2?bar#baz"); |
|
|
|
|
assertEquals("Invalid result URI", expected, result2.toUri()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void fromPath() throws URISyntaxException { |
|
|
|
|
UriComponents result = UriComponentsBuilder.fromPath("foo").queryParam("bar").fragment("baz").build(); |
|
|
|
|