@ -924,26 +924,28 @@ class UriComponentsBuilderTests {
@@ -924,26 +924,28 @@ class UriComponentsBuilderTests {
assertThat ( components . toString ( ) ) . isEqualTo ( "" ) ;
}
@Test
@Test // gh-25243
void testCloneAndMerge ( ) {
UriComponentsBuilder builder1 = UriComponentsBuilder . newInstance ( ) ;
builder1 . scheme ( "http" ) . host ( "e1.com" ) . path ( "/p1" ) . pathSegment ( "ps1" ) . queryParam ( "q1" ) . fragment ( "f1" ) . encode ( ) ;
builder1 . scheme ( "http" ) . host ( "e1.com" ) . path ( "/p1" ) . pathSegment ( "ps1" ) . queryParam ( "q1" , "x" ) . fragment ( "f1" ) . encode ( ) ;
UriComponentsBuilder builder2 = ( UriComponentsBuilder ) builder1 . clone ( ) ;
UriComponentsBuilder builder2 = builder1 . cloneBuilder ( ) ;
builder2 . scheme ( "https" ) . host ( "e2.com" ) . path ( "p2" ) . pathSegment ( "{ps2}" ) . queryParam ( "q2" ) . fragment ( "f2" ) ;
builder1 . queryParam ( "q1" , "y" ) ; // one more entry for an existing parameter
UriComponents result1 = builder1 . build ( ) ;
assertThat ( result1 . getScheme ( ) ) . isEqualTo ( "http" ) ;
assertThat ( result1 . getHost ( ) ) . isEqualTo ( "e1.com" ) ;
assertThat ( result1 . getPath ( ) ) . isEqualTo ( "/p1/ps1" ) ;
assertThat ( result1 . getQuery ( ) ) . isEqualTo ( "q1" ) ;
assertThat ( result1 . getQuery ( ) ) . isEqualTo ( "q1=x&q1=y " ) ;
assertThat ( result1 . getFragment ( ) ) . isEqualTo ( "f1" ) ;
UriComponents result2 = builder2 . buildAndExpand ( "ps2;a" ) ;
assertThat ( result2 . getScheme ( ) ) . isEqualTo ( "https" ) ;
assertThat ( result2 . getHost ( ) ) . isEqualTo ( "e2.com" ) ;
assertThat ( result2 . getPath ( ) ) . isEqualTo ( "/p1/ps1/p2/ps2%3Ba" ) ;
assertThat ( result2 . getQuery ( ) ) . isEqualTo ( "q1&q2" ) ;
assertThat ( result2 . getQuery ( ) ) . isEqualTo ( "q1=x &q2" ) ;
assertThat ( result2 . getFragment ( ) ) . isEqualTo ( "f2" ) ;
}
@ -957,7 +959,7 @@ class UriComponentsBuilderTests {
@@ -957,7 +959,7 @@ class UriComponentsBuilderTests {
builder1 . scheme ( "http" ) . host ( "e1.com" ) . userInfo ( "user:pwd" ) . path ( "/p1" ) . pathSegment ( "{ps1}" )
. pathSegment ( "{ps2}" ) . queryParam ( "q1" ) . fragment ( "f1" ) . uriVariables ( vars ) . encode ( ) ;
UriComponentsBuilder builder2 = ( UriComponentsBuilder ) builder1 . clone ( ) ;
UriComponentsBuilder builder2 = builder1 . cloneBuilder ( ) ;
UriComponents result1 = builder1 . build ( ) ;
assertThat ( result1 . getScheme ( ) ) . isEqualTo ( "http" ) ;