Skip to content

Commit 13d2422

Browse files
committed
Merge pull request #5 from gregturn/BS-162
# By Greg Turnquist * BS-162: Tune expected exceptions to support more platforms
2 parents 19c2a07 + 9ab2f98 commit 13d2422

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

spring-bootstrap-actuator/src/test/java/org/springframework/bootstrap/actuate/autoconfigure/EndpointWebMvcAutoConfigurationTests.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
package org.springframework.bootstrap.actuate.autoconfigure;
1717

1818
import java.io.FileNotFoundException;
19-
import java.net.ConnectException;
19+
import java.net.SocketException;
2020
import java.net.URI;
2121
import java.nio.charset.Charset;
2222

@@ -49,6 +49,7 @@
4949
* Tests for {@link EndpointWebMvcAutoConfiguration}.
5050
*
5151
* @author Phillip Webb
52+
* @author Greg Turnquist
5253
*/
5354
public class EndpointWebMvcAutoConfigurationTests {
5455

@@ -170,7 +171,7 @@ public void assertContent(String url, int port, Object expected) throws Exceptio
170171
}
171172
} catch (Exception ex) {
172173
if (expected == null) {
173-
if (ConnectException.class.isInstance(ex)
174+
if (SocketException.class.isInstance(ex)
174175
|| FileNotFoundException.class.isInstance(ex)) {
175176
return;
176177
}

spring-bootstrap/src/test/java/org/springframework/bootstrap/context/embedded/AbstractEmbeddedServletContainerFactoryTests.java

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

1919
import java.io.FileWriter;
2020
import java.io.IOException;
21-
import java.net.ConnectException;
21+
import java.net.SocketException;
2222
import java.net.URI;
2323
import java.net.URISyntaxException;
2424
import java.nio.charset.Charset;
@@ -56,6 +56,7 @@
5656
* Base for testing classes that extends {@link AbstractEmbeddedServletContainerFactory}.
5757
*
5858
* @author Phillip Webb
59+
* @author Greg Turnquist
5960
*/
6061
public abstract class AbstractEmbeddedServletContainerFactoryTests {
6162

@@ -91,8 +92,7 @@ public void emptyServer() throws Exception {
9192
factory.setPort(0);
9293
this.container = factory
9394
.getEmbeddedServletContainer(exampleServletRegistration());
94-
this.thrown.expect(ConnectException.class);
95-
this.thrown.expectMessage("Connection refused");
95+
this.thrown.expect(SocketException.class);
9696
getResponse("http://localhost:8080/hello");
9797
}
9898

@@ -102,7 +102,7 @@ public void stopServlet() throws Exception {
102102
this.container = factory
103103
.getEmbeddedServletContainer(exampleServletRegistration());
104104
this.container.stop();
105-
this.thrown.expect(ConnectException.class);
105+
this.thrown.expect(SocketException.class);
106106
getResponse("http://localhost:8080/hello");
107107
}
108108

0 commit comments

Comments
 (0)