Skip to content

Commit

Permalink
Stop Jetty in Jetty8JettyEmbeddedServletContainerFactoryTests
Browse files Browse the repository at this point in the history
  • Loading branch information
wilkinsona committed Apr 3, 2018
1 parent edc00ee commit dee8750
Showing 1 changed file with 23 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -70,23 +70,28 @@ public void onStartup(ServletContext servletContext)

});
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 {
Expand Down

0 comments on commit dee8750

Please sign in to comment.