Commit 1222a73d authored by Andy Wilkinson's avatar Andy Wilkinson

Polish

parent 557d1876
...@@ -14,14 +14,13 @@ ...@@ -14,14 +14,13 @@
* limitations under the License. * limitations under the License.
*/ */
package sample.jersey; package smoketest.jersey;
import javax.ws.rs.GET; import javax.ws.rs.GET;
import javax.ws.rs.Path; import javax.ws.rs.Path;
import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.server.ResourceConfig;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.actuate.autoconfigure.web.server.LocalManagementPort; import org.springframework.boot.actuate.autoconfigure.web.server.LocalManagementPort;
...@@ -33,7 +32,6 @@ import org.springframework.boot.web.server.LocalServerPort; ...@@ -33,7 +32,6 @@ import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.test.context.junit4.SpringRunner;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
...@@ -42,9 +40,8 @@ import static org.assertj.core.api.Assertions.assertThat; ...@@ -42,9 +40,8 @@ import static org.assertj.core.api.Assertions.assertThat;
* *
* @author Madhura Bhave * @author Madhura Bhave
*/ */
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, properties = "management.server.port=0") @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, properties = "management.server.port=0")
public class JerseyManagementPortTests { class JerseyManagementPortTests {
@LocalServerPort @LocalServerPort
private int port; private int port;
...@@ -56,7 +53,7 @@ public class JerseyManagementPortTests { ...@@ -56,7 +53,7 @@ public class JerseyManagementPortTests {
private TestRestTemplate testRestTemplate; private TestRestTemplate testRestTemplate;
@Test @Test
public void resourceShouldBeAvailableOnMainPort() { void resourceShouldBeAvailableOnMainPort() {
ResponseEntity<String> entity = this.testRestTemplate.getForEntity("http://localhost:" + this.port + "/test", ResponseEntity<String> entity = this.testRestTemplate.getForEntity("http://localhost:" + this.port + "/test",
String.class); String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
...@@ -64,7 +61,7 @@ public class JerseyManagementPortTests { ...@@ -64,7 +61,7 @@ public class JerseyManagementPortTests {
} }
@Test @Test
public void resourceShouldNotBeAvailableOnManagementPort() { void resourceShouldNotBeAvailableOnManagementPort() {
ResponseEntity<String> entity = this.testRestTemplate ResponseEntity<String> entity = this.testRestTemplate
.getForEntity("http://localhost:" + this.managementPort + "/test", String.class); .getForEntity("http://localhost:" + this.managementPort + "/test", String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND);
...@@ -74,7 +71,7 @@ public class JerseyManagementPortTests { ...@@ -74,7 +71,7 @@ public class JerseyManagementPortTests {
static class ResourceConfigConfiguration { static class ResourceConfigConfiguration {
@Bean @Bean
public ResourceConfigCustomizer customizer() { ResourceConfigCustomizer customizer() {
return new ResourceConfigCustomizer() { return new ResourceConfigCustomizer() {
@Override @Override
public void customize(ResourceConfig config) { public void customize(ResourceConfig config) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment