|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2013 the original author or authors. |
| 2 | + * Copyright 2002-2014 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
23 | 23 | import java.util.Map;
|
24 | 24 |
|
25 | 25 | import org.junit.Test;
|
| 26 | + |
26 | 27 | import org.springframework.util.LinkedMultiValueMap;
|
27 | 28 | import org.springframework.util.MultiValueMap;
|
28 | 29 |
|
@@ -50,6 +51,28 @@ public void plain() throws URISyntaxException {
|
50 | 51 | assertEquals("Invalid result URI", expected, result.toUri());
|
51 | 52 | }
|
52 | 53 |
|
| 54 | + @Test |
| 55 | + public void multipleFromSameBuilder() throws URISyntaxException { |
| 56 | + UriComponentsBuilder builder = UriComponentsBuilder.newInstance().scheme("http").host("example.com").pathSegment("foo"); |
| 57 | + UriComponents result1 = builder.build(); |
| 58 | + builder = builder.pathSegment("foo2").queryParam("bar").fragment("baz"); |
| 59 | + UriComponents result2 = builder.build(); |
| 60 | + |
| 61 | + assertEquals("http", result1.getScheme()); |
| 62 | + assertEquals("example.com", result1.getHost()); |
| 63 | + assertEquals("/foo", result1.getPath()); |
| 64 | + URI expected = new URI("http://example.com/foo"); |
| 65 | + assertEquals("Invalid result URI", expected, result1.toUri()); |
| 66 | + |
| 67 | + assertEquals("http", result2.getScheme()); |
| 68 | + assertEquals("example.com", result2.getHost()); |
| 69 | + assertEquals("/foo/foo2", result2.getPath()); |
| 70 | + assertEquals("bar", result2.getQuery()); |
| 71 | + assertEquals("baz", result2.getFragment()); |
| 72 | + expected = new URI("http://example.com/foo/foo2?bar#baz"); |
| 73 | + assertEquals("Invalid result URI", expected, result2.toUri()); |
| 74 | + } |
| 75 | + |
53 | 76 | @Test
|
54 | 77 | public void fromPath() throws URISyntaxException {
|
55 | 78 | UriComponents result = UriComponentsBuilder.fromPath("foo").queryParam("bar").fragment("baz").build();
|
|
0 commit comments