Skip to content

Commit efa3ecd

Browse files
committed
URL Cleanup - Fix broken tests
See gh-22679
1 parent 13dc00a commit efa3ecd

File tree

18 files changed

+76
-72
lines changed

18 files changed

+76
-72
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.
@@ -74,7 +74,7 @@ public void marshalDOMResult() throws Exception {
7474
marshaller.marshal(flights, domResult);
7575
Document expected = builder.newDocument();
7676
Element flightsElement = expected.createElementNS("http://samples.springframework.org/flight", "tns:flights");
77-
Attr namespace = expected.createAttributeNS("https://www.w3.org/2000/xmlns/", "xmlns:tns");
77+
Attr namespace = expected.createAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:tns");
7878
namespace.setNodeValue("http://samples.springframework.org/flight");
7979
flightsElement.setAttributeNode(namespace);
8080
expected.appendChild(flightsElement);
@@ -98,7 +98,7 @@ public void marshalEmptyDOMResult() throws Exception {
9898
Document result = (Document) domResult.getNode();
9999
Document expected = builder.newDocument();
100100
Element flightsElement = expected.createElementNS("http://samples.springframework.org/flight", "tns:flights");
101-
Attr namespace = expected.createAttributeNS("https://www.w3.org/2000/xmlns/", "xmlns:tns");
101+
Attr namespace = expected.createAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:tns");
102102
namespace.setNodeValue("http://samples.springframework.org/flight");
103103
flightsElement.setAttributeNode(namespace);
104104
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
@@ -618,7 +618,7 @@ public void buildRequestRemotePort8080() throws Exception {
618618

619619
@Test
620620
public void buildRequestRemotePort80WithDefault() throws Exception {
621-
webRequest.setUrl(new URL("https://example.com/"));
621+
webRequest.setUrl(new URL("http://example.com/"));
622622

623623
MockHttpServletRequest actualRequest = requestBuilder.buildRequest(servletContext);
624624

@@ -650,7 +650,7 @@ public void buildRequestUri() {
650650
@Test
651651
public void buildRequestUrl() {
652652
String uri = requestBuilder.buildRequest(servletContext).getRequestURL().toString();
653-
assertThat(uri, equalTo("https://example.com/test/this/here"));
653+
assertThat(uri, equalTo("http://example.com/test/this/here"));
654654
}
655655

656656
@Test

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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/http/server/reactive/ServerHttpRequestTests.java

Lines changed: 6 additions & 6 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.
@@ -96,16 +96,16 @@ public void mutateRequest() throws Exception {
9696
request = createHttpRequest("/").mutate().method(HttpMethod.DELETE).build();
9797
assertEquals(HttpMethod.DELETE, request.getMethod());
9898

99-
String baseUri = "https://www.aaa.org/articles/";
99+
String baseUri = "http://www.aaa.org/articles/";
100100

101-
request = createHttpRequest(baseUri).mutate().uri(URI.create("https://bbb.org:9090/b")).build();
102-
assertEquals("https://bbb.org:9090/b", request.getURI().toString());
101+
request = createHttpRequest(baseUri).mutate().uri(URI.create("http://bbb.org:9090/b")).build();
102+
assertEquals("http://bbb.org:9090/b", request.getURI().toString());
103103

104104
request = createHttpRequest(baseUri).mutate().path("/b/c/d").build();
105-
assertEquals("https://www.aaa.org/b/c/d", request.getURI().toString());
105+
assertEquals("http://www.aaa.org/b/c/d", request.getURI().toString());
106106

107107
request = createHttpRequest(baseUri).mutate().path("/app/b/c/d").contextPath("/app").build();
108-
assertEquals("https://www.aaa.org/app/b/c/d", request.getURI().toString());
108+
assertEquals("http://www.aaa.org/app/b/c/d", request.getURI().toString());
109109
assertEquals("/app", request.getPath().contextPath().value());
110110
}
111111

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
@@ -562,7 +562,7 @@ public void ioException() throws Exception {
562562
public void ioExceptionWithEmptyQueryString() throws Exception {
563563

564564
// https://example.com/resource?
565-
URI uri = new URI("http", "example.com", "/resource", "", null);
565+
URI uri = new URI("https", "example.com", "/resource", "", null);
566566

567567
given(converter.canRead(String.class, null)).willReturn(true);
568568
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());

0 commit comments

Comments
 (0)