Skip to content

Commit 1c4b17e

Browse files
wilkinsonagregturn
authored andcommitted
SWS-923 Update tests to be compatible with latest version of Http Components
More recent versions of HTTP components normalise an HTTPHost when it’s used to create an HTTPRoute. As part of this normalization the host’s port is set to the default port for the host’s scheme, e.g. an https scheme will result in a port of 443 and an http scheme will result in a port of 80 This commit updates the tests so that they will accept the behaviour of HTTP Components 4.3.x (the port is -1) and HTTP Components 4.5.x (the port is 80 for http and 443 for https). Compatibility with HTTP Components 4.5.x allows Spring Web Services’ tests to pass when they’re run as part of the Spring IO Platform 2.0 release process which uses a more recent version of HTTP components than the default Spring Web Services build.
1 parent 3c7a6b9 commit 1c4b17e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

spring-ws-core/src/test/java/org/springframework/ws/transport/http/HttpComponentsMessageSenderIntegrationTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import static org.hamcrest.core.IsEqual.*;
2020
import static org.springframework.test.util.MatcherAssertionErrors.*;
21+
import static org.junit.Assert.assertTrue;
2122

2223
import java.io.IOException;
2324
import java.net.URI;
@@ -61,7 +62,7 @@ public void testMaxConnections() throws URISyntaxException, URIException {
6162
HttpRoute route1 = new HttpRoute(host1, null, true);
6263
assertThat(route1.isSecure(), equalTo(true));
6364
assertThat(route1.getTargetHost().getHostName(), equalTo("www.example.com"));
64-
assertThat(route1.getTargetHost().getPort(), equalTo(-1));
65+
assertTrue((route1.getTargetHost().getPort() == -1) || (route1.getTargetHost().getPort() == 443));
6566

6667
final String url2 = "http://www.example.com:8080";
6768
URI uri2 = new URI(url2);
@@ -77,7 +78,7 @@ public void testMaxConnections() throws URISyntaxException, URIException {
7778
HttpRoute route3 = new HttpRoute(host3);
7879
assertThat(route3.isSecure(), equalTo(false));
7980
assertThat(route3.getTargetHost().getHostName(), equalTo("www.springframework.org"));
80-
assertThat(route3.getTargetHost().getPort(), equalTo(-1));
81+
assertTrue((route3.getTargetHost().getPort() == -1) || (route3.getTargetHost().getPort() == 80));
8182

8283
HttpComponentsMessageSender messageSender = new HttpComponentsMessageSender();
8384
messageSender.setMaxTotalConnections(2);

0 commit comments

Comments
 (0)