Skip to content

Commit e435ea7

Browse files
committed
URL Cleanup - Fix broken tests
See gh-22678
1 parent 0e93443 commit e435ea7

File tree

14 files changed

+54
-51
lines changed

14 files changed

+54
-51
lines changed

spring-messaging/src/test/java/org/springframework/messaging/simp/SimpMessagingTemplateTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -83,7 +83,7 @@ public void convertAndSendToUserWithEncoding() {
8383
MessageHeaderAccessor.getAccessor(messages.get(0), SimpMessageHeaderAccessor.class);
8484

8585
assertNotNull(headerAccessor);
86-
assertEquals("/user/http:%2F%2Fjoe.openid.example.org%2F/queue/foo", headerAccessor.getDestination());
86+
assertEquals("/user/https:%2F%2Fjoe.openid.example.org%2F/queue/foo", headerAccessor.getDestination());
8787
}
8888

8989
@Test

spring-oxm/src/test/java/org/springframework/oxm/AbstractMarshallerTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2015 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -79,7 +79,7 @@ public void marshalDOMResult() throws Exception {
7979
marshaller.marshal(flights, domResult);
8080
Document expected = builder.newDocument();
8181
Element flightsElement = expected.createElementNS("http://samples.springframework.org/flight", "tns:flights");
82-
Attr namespace = expected.createAttributeNS("https://www.w3.org/2000/xmlns/", "xmlns:tns");
82+
Attr namespace = expected.createAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:tns");
8383
namespace.setNodeValue("http://samples.springframework.org/flight");
8484
flightsElement.setAttributeNode(namespace);
8585
expected.appendChild(flightsElement);
@@ -103,7 +103,7 @@ public void marshalEmptyDOMResult() throws Exception {
103103
Document result = (Document) domResult.getNode();
104104
Document expected = builder.newDocument();
105105
Element flightsElement = expected.createElementNS("http://samples.springframework.org/flight", "tns:flights");
106-
Attr namespace = expected.createAttributeNS("https://www.w3.org/2000/xmlns/", "xmlns:tns");
106+
Attr namespace = expected.createAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:tns");
107107
namespace.setNodeValue("http://samples.springframework.org/flight");
108108
flightsElement.setAttributeNode(namespace);
109109
expected.appendChild(flightsElement);

spring-oxm/src/test/java/org/springframework/oxm/castor/CastorMarshallerTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -76,7 +76,7 @@ public class CastorMarshallerTests extends AbstractMarshallerTests<CastorMarshal
7676
*/
7777
private static final String XSI_EXPECTED_STRING = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
7878
"<objects><castor-object xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" +
79-
" xmlns:java=\"https://java.sun.com\"" +
79+
" xmlns:java=\"http://java.sun.com\"" +
8080
" xsi:type=\"java:org.springframework.oxm.castor.CastorObject\">" +
8181
"<name>test</name><value>8</value></castor-object></objects>";
8282

@@ -91,7 +91,7 @@ public class CastorMarshallerTests extends AbstractMarshallerTests<CastorMarshal
9191
*/
9292
private static final String ROOT_WITH_XSI_EXPECTED_STRING = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
9393
"<objects xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" +
94-
" xmlns:java=\"https://java.sun.com\"" +
94+
" xmlns:java=\"http://java.sun.com\"" +
9595
" xsi:type=\"java:java.util.Arrays$ArrayList\">" +
9696
"<castor-object xsi:type=\"java:org.springframework.oxm.castor.CastorObject\">" +
9797
"<name>test</name><value>8</value></castor-object></objects>";
@@ -101,7 +101,7 @@ public class CastorMarshallerTests extends AbstractMarshallerTests<CastorMarshal
101101
*/
102102
private static final String ROOT_WITHOUT_XSI_EXPECTED_STRING = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
103103
"<objects><castor-object xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" +
104-
" xmlns:java=\"https://java.sun.com\"" +
104+
" xmlns:java=\"http://java.sun.com\"" +
105105
" xsi:type=\"java:org.springframework.oxm.castor.CastorObject\">" +
106106
"<name>test</name><value>8</value></castor-object></objects>";
107107

spring-oxm/src/test/java/org/springframework/oxm/jaxb/Jaxb2UnmarshallerTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2015 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -91,9 +91,9 @@ public void marshalAttachments() throws Exception {
9191
given(mimeContainer.getAttachment("<99bd1592-0521-41a2-9688-a8bfb40192fb@http://springframework.org/spring-ws>")).willReturn(dataHandler);
9292
given(mimeContainer.getAttachment("[email protected]")).willReturn(dataHandler);
9393
String content = "<binaryObject xmlns='http://springframework.org/spring-ws'>" + "<bytes>" +
94-
"<xop:Include href='cid:6b76528d-7a9c-4def-8e13-095ab89e9bb7@http://springframework.org/spring-ws' xmlns:xop='https://www.w3.org/2004/08/xop/include'/>" +
94+
"<xop:Include href='cid:6b76528d-7a9c-4def-8e13-095ab89e9bb7@http://springframework.org/spring-ws' xmlns:xop='http://www.w3.org/2004/08/xop/include'/>" +
9595
"</bytes>" + "<dataHandler>" +
96-
"<xop:Include href='cid:99bd1592-0521-41a2-9688-a8bfb40192fb@http://springframework.org/spring-ws' xmlns:xop='https://www.w3.org/2004/08/xop/include'/>" +
96+
"<xop:Include href='cid:99bd1592-0521-41a2-9688-a8bfb40192fb@http://springframework.org/spring-ws' xmlns:xop='http://www.w3.org/2004/08/xop/include'/>" +
9797
"</dataHandler>" +
9898
"<swaDataHandler>[email protected]</swaDataHandler>" +
9999
"</binaryObject>";

spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/HtmlUnitRequestBuilderTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ public void buildRequestRemotePort8080() throws Exception {
614614

615615
@Test
616616
public void buildRequestRemotePort80WithDefault() throws Exception {
617-
webRequest.setUrl(new URL("https://example.com/"));
617+
webRequest.setUrl(new URL("http://example.com/"));
618618

619619
MockHttpServletRequest actualRequest = requestBuilder.buildRequest(servletContext);
620620

@@ -646,7 +646,7 @@ public void buildRequestUri() {
646646
@Test
647647
public void buildRequestUrl() {
648648
String uri = requestBuilder.buildRequest(servletContext).getRequestURL().toString();
649-
assertThat(uri, equalTo("https://example.com/test/this/here"));
649+
assertThat(uri, equalTo("http://example.com/test/this/here"));
650650
}
651651

652652
@Test

spring-web/src/test/java/org/springframework/http/RequestEntityTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -61,7 +61,7 @@ public void uriVariablesExpansion() throws URISyntaxException {
6161
URI uri = new UriTemplate("https://example.com/{foo}").expand("bar");
6262
RequestEntity.get(uri).accept(MediaType.TEXT_PLAIN).build();
6363

64-
String url = "http://www.{host}.com/{path}";
64+
String url = "https://www.{host}.com/{path}";
6565
String host = "example";
6666
String path = "foo/bar";
6767
URI expected = new URI("https://www.example.com/foo/bar");

spring-web/src/test/java/org/springframework/http/server/ServletServerHttpRequestTests.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -60,6 +60,7 @@ public void getMethod() {
6060
@Test
6161
public void getUriForSimplePath() throws URISyntaxException {
6262
URI uri = new URI("https://example.com/path");
63+
mockRequest.setScheme(uri.getScheme());
6364
mockRequest.setServerName(uri.getHost());
6465
mockRequest.setServerPort(uri.getPort());
6566
mockRequest.setRequestURI(uri.getPath());
@@ -70,6 +71,7 @@ public void getUriForSimplePath() throws URISyntaxException {
7071
@Test
7172
public void getUriWithQueryString() throws URISyntaxException {
7273
URI uri = new URI("https://example.com/path?query");
74+
mockRequest.setScheme(uri.getScheme());
7375
mockRequest.setServerName(uri.getHost());
7476
mockRequest.setServerPort(uri.getPort());
7577
mockRequest.setRequestURI(uri.getPath());
@@ -82,15 +84,15 @@ public void getUriWithQueryParam() throws URISyntaxException {
8284
mockRequest.setServerName("example.com");
8385
mockRequest.setRequestURI("/path");
8486
mockRequest.setQueryString("query=foo");
85-
assertEquals(new URI("https://example.com/path?query=foo"), request.getURI());
87+
assertEquals(new URI("http://example.com/path?query=foo"), request.getURI());
8688
}
8789

8890
@Test // SPR-16414
8991
public void getUriWithMalformedQueryParam() throws URISyntaxException {
9092
mockRequest.setServerName("example.com");
9193
mockRequest.setRequestURI("/path");
9294
mockRequest.setQueryString("query=foo%%x");
93-
assertEquals(new URI("https://example.com/path"), request.getURI());
95+
assertEquals(new URI("http://example.com/path"), request.getURI());
9496
}
9597

9698
@Test // SPR-13876

spring-web/src/test/java/org/springframework/web/client/RestTemplateTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,7 @@ public void ioException() throws Exception {
728728
public void ioExceptionWithEmptyQueryString() throws Exception {
729729

730730
// https://example.com/resource?
731-
URI uri = new URI("http", "example.com", "/resource", "", null);
731+
URI uri = new URI("https", "example.com", "/resource", "", null);
732732

733733
given(converter.canRead(String.class, null)).willReturn(true);
734734
given(converter.getSupportedMediaTypes()).willReturn(Collections.singletonList(parseMediaType("foo/bar")));

spring-web/src/test/java/org/springframework/web/multipart/support/RequestPartServletServerHttpRequestTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -57,6 +57,7 @@ public void getURI() throws Exception {
5757
ServerHttpRequest request = new RequestPartServletServerHttpRequest(this.mockRequest, "part");
5858

5959
URI uri = new URI("https://example.com/path?query");
60+
this.mockRequest.setScheme("https");
6061
this.mockRequest.setServerName(uri.getHost());
6162
this.mockRequest.setServerPort(uri.getPort());
6263
this.mockRequest.setRequestURI(uri.getPath());

spring-web/src/test/java/org/springframework/web/util/DefaultUriTemplateHandlerTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -142,7 +142,7 @@ public void strictEncodingAndDefaultUriVariables() throws Exception {
142142
Map<String, Object> vars = new HashMap<>(1);
143143
vars.put("userId", "john;doe");
144144

145-
String template = "http://{host}/user/{userId}/dashboard";
145+
String template = "https://{host}/user/{userId}/dashboard";
146146
URI actual = this.handler.expand(template, vars);
147147

148148
assertEquals("https://www.example.com/user/john%3Bdoe/dashboard", actual.toString());

0 commit comments

Comments
 (0)