Browse Source

Stop Jetty in Jetty8JettyEmbeddedServletContainerFactoryTests

Closes gh-12734
pull/12859/head
Andy Wilkinson 8 years ago
parent
commit
dee8750aff
  1. 41
      spring-boot/src/test/java/org/springframework/boot/context/embedded/jetty/Jetty8JettyEmbeddedServletContainerFactoryTests.java

41
spring-boot/src/test/java/org/springframework/boot/context/embedded/jetty/Jetty8JettyEmbeddedServletContainerFactoryTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2012-2017 the original author or authors.
* Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -70,23 +70,28 @@ public class Jetty8JettyEmbeddedServletContainerFactoryTests { @@ -70,23 +70,28 @@ public class Jetty8JettyEmbeddedServletContainerFactoryTests {
});
jetty.start();
int port = jetty.getPort();
RestTemplate restTemplate = new RestTemplate();
restTemplate.setErrorHandler(new ResponseErrorHandler() {
@Override
public boolean hasError(ClientHttpResponse response) throws IOException {
return false;
}
@Override
public void handleError(ClientHttpResponse response) throws IOException {
}
});
ResponseEntity<String> response = restTemplate
.getForEntity("http://localhost:" + port, String.class);
assertThat(response.getBody()).isEqualTo("An error occurred");
try {
int port = jetty.getPort();
RestTemplate restTemplate = new RestTemplate();
restTemplate.setErrorHandler(new ResponseErrorHandler() {
@Override
public boolean hasError(ClientHttpResponse response) throws IOException {
return false;
}
@Override
public void handleError(ClientHttpResponse response) throws IOException {
}
});
ResponseEntity<String> response = restTemplate
.getForEntity("http://localhost:" + port, String.class);
assertThat(response.getBody()).isEqualTo("An error occurred");
}
finally {
jetty.stop();
}
}
private static final class TestServlet extends HttpServlet {

Loading…
Cancel
Save