Commit 612a929c authored by Andy Wilkinson's avatar Andy Wilkinson

Merge branch '2.0.x' into 2.1.x

parents 24925c3d 5c21c681
/* /*
* Copyright 2012-2018 the original author or authors. * Copyright 2012-2019 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -35,8 +35,7 @@ public class SampleGlassfishDeployApplicationIT { ...@@ -35,8 +35,7 @@ public class SampleGlassfishDeployApplicationIT {
public void testHome() throws Exception { public void testHome() throws Exception {
String url = "http://localhost:" + this.port + "/bootapp/"; String url = "http://localhost:" + this.port + "/bootapp/";
System.out.println(url); System.out.println(url);
ResponseEntity<String> entity = new TestRestTemplate().getForEntity(url, ResponseEntity<String> entity = new TestRestTemplate().getForEntity(url, String.class);
String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(entity.getBody()).isEqualTo("Hello World"); assertThat(entity.getBody()).isEqualTo("Hello World");
} }
...@@ -45,8 +44,7 @@ public class SampleGlassfishDeployApplicationIT { ...@@ -45,8 +44,7 @@ public class SampleGlassfishDeployApplicationIT {
public void testHealth() throws Exception { public void testHealth() throws Exception {
String url = "http://localhost:" + this.port + "/bootapp/actuator/health"; String url = "http://localhost:" + this.port + "/bootapp/actuator/health";
System.out.println(url); System.out.println(url);
ResponseEntity<String> entity = new TestRestTemplate().getForEntity(url, ResponseEntity<String> entity = new TestRestTemplate().getForEntity(url, String.class);
String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(entity.getBody()).isEqualTo("{\"status\":\"UP\"}"); assertThat(entity.getBody()).isEqualTo("{\"status\":\"UP\"}");
} }
......
/* /*
* Copyright 2012-2018 the original author or authors. * Copyright 2012-2019 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -49,64 +49,50 @@ public class SampleTomcatDeployApplicationIT { ...@@ -49,64 +49,50 @@ public class SampleTomcatDeployApplicationIT {
public void testHealth() throws Exception { public void testHealth() throws Exception {
String url = "http://localhost:" + this.port + "/bootapp/actuator/health"; String url = "http://localhost:" + this.port + "/bootapp/actuator/health";
System.out.println(url); System.out.println(url);
ResponseEntity<String> entity = new TestRestTemplate().getForEntity(url, ResponseEntity<String> entity = new TestRestTemplate().getForEntity(url, String.class);
String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(entity.getBody()).isEqualTo("{\"status\":\"UP\"}"); assertThat(entity.getBody()).isEqualTo("{\"status\":\"UP\"}");
} }
@Test @Test
public void errorFromExceptionForRequestAcceptingAnythingProducesAJsonResponse() public void errorFromExceptionForRequestAcceptingAnythingProducesAJsonResponse() throws Exception {
throws Exception { assertThatPathProducesExpectedResponse("/bootapp/exception", MediaType.ALL, MediaType.APPLICATION_JSON);
assertThatPathProducesExpectedResponse("/bootapp/exception", MediaType.ALL,
MediaType.APPLICATION_JSON);
} }
@Test @Test
public void errorFromExceptionForRequestAcceptingJsonProducesAJsonResponse() public void errorFromExceptionForRequestAcceptingJsonProducesAJsonResponse() throws Exception {
throws Exception { assertThatPathProducesExpectedResponse("/bootapp/exception", MediaType.APPLICATION_JSON,
assertThatPathProducesExpectedResponse("/bootapp/exception", MediaType.APPLICATION_JSON);
MediaType.APPLICATION_JSON, MediaType.APPLICATION_JSON);
} }
@Test @Test
public void errorFromExceptionForRequestAcceptingHtmlProducesAnHtmlResponse() public void errorFromExceptionForRequestAcceptingHtmlProducesAnHtmlResponse() throws Exception {
throws Exception { assertThatPathProducesExpectedResponse("/bootapp/exception", MediaType.TEXT_HTML, MediaType.TEXT_HTML);
assertThatPathProducesExpectedResponse("/bootapp/exception", MediaType.TEXT_HTML,
MediaType.TEXT_HTML);
} }
@Test @Test
public void sendErrorForRequestAcceptingAnythingProducesAJsonResponse() public void sendErrorForRequestAcceptingAnythingProducesAJsonResponse() throws Exception {
throws Exception { assertThatPathProducesExpectedResponse("/bootapp/send-error", MediaType.ALL, MediaType.APPLICATION_JSON);
assertThatPathProducesExpectedResponse("/bootapp/send-error", MediaType.ALL,
MediaType.APPLICATION_JSON);
} }
@Test @Test
public void sendErrorForRequestAcceptingJsonProducesAJsonResponse() throws Exception { public void sendErrorForRequestAcceptingJsonProducesAJsonResponse() throws Exception {
assertThatPathProducesExpectedResponse("/bootapp/send-error", assertThatPathProducesExpectedResponse("/bootapp/send-error", MediaType.APPLICATION_JSON,
MediaType.APPLICATION_JSON, MediaType.APPLICATION_JSON); MediaType.APPLICATION_JSON);
} }
@Test @Test
public void sendErrorForRequestAcceptingHtmlProducesAnHtmlResponse() public void sendErrorForRequestAcceptingHtmlProducesAnHtmlResponse() throws Exception {
throws Exception { assertThatPathProducesExpectedResponse("/bootapp/send-error", MediaType.TEXT_HTML, MediaType.TEXT_HTML);
assertThatPathProducesExpectedResponse("/bootapp/send-error", MediaType.TEXT_HTML,
MediaType.TEXT_HTML);
} }
private void assertThatPathProducesExpectedResponse(String path, MediaType accept, private void assertThatPathProducesExpectedResponse(String path, MediaType accept, MediaType contentType) {
MediaType contentType) { RequestEntity<Void> request = RequestEntity.get(URI.create("http://localhost:" + this.port + path))
RequestEntity<Void> request = RequestEntity .accept(accept).build();
.get(URI.create("http://localhost:" + this.port + path)).accept(accept)
.build();
ResponseEntity<String> response = this.rest.exchange(request, String.class); ResponseEntity<String> response = this.rest.exchange(request, String.class);
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR); assertThat(response.getStatusCode()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR);
assertThat(contentType.isCompatibleWith(response.getHeaders().getContentType())) assertThat(contentType.isCompatibleWith(response.getHeaders().getContentType()))
.as("%s is compatible with %s", contentType, .as("%s is compatible with %s", contentType, response.getHeaders().getContentType()).isTrue();
response.getHeaders().getContentType())
.isTrue();
} }
} }
/* /*
* Copyright 2012-2018 the original author or authors. * Copyright 2012-2019 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -34,8 +34,7 @@ public class SampleTomEEDeployApplicationIT { ...@@ -34,8 +34,7 @@ public class SampleTomEEDeployApplicationIT {
@Test @Test
public void testHome() throws Exception { public void testHome() throws Exception {
String url = "http://localhost:" + this.port + "/bootapp/"; String url = "http://localhost:" + this.port + "/bootapp/";
ResponseEntity<String> entity = new TestRestTemplate().getForEntity(url, ResponseEntity<String> entity = new TestRestTemplate().getForEntity(url, String.class);
String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(entity.getBody()).isEqualTo("Hello World"); assertThat(entity.getBody()).isEqualTo("Hello World");
} }
...@@ -44,8 +43,7 @@ public class SampleTomEEDeployApplicationIT { ...@@ -44,8 +43,7 @@ public class SampleTomEEDeployApplicationIT {
public void testHealth() throws Exception { public void testHealth() throws Exception {
String url = "http://localhost:" + this.port + "/bootapp/actuator/health"; String url = "http://localhost:" + this.port + "/bootapp/actuator/health";
System.out.println(url); System.out.println(url);
ResponseEntity<String> entity = new TestRestTemplate().getForEntity(url, ResponseEntity<String> entity = new TestRestTemplate().getForEntity(url, String.class);
String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(entity.getBody()).isEqualTo("{\"status\":\"UP\"}"); assertThat(entity.getBody()).isEqualTo("{\"status\":\"UP\"}");
} }
......
/* /*
* Copyright 2012-2018 the original author or authors. * Copyright 2012-2019 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -34,8 +34,7 @@ public class SampleWildFlyDeployApplicationIT { ...@@ -34,8 +34,7 @@ public class SampleWildFlyDeployApplicationIT {
@Test @Test
public void testHome() throws Exception { public void testHome() throws Exception {
String url = "http://localhost:" + this.port + "/bootapp/"; String url = "http://localhost:" + this.port + "/bootapp/";
ResponseEntity<String> entity = new TestRestTemplate().getForEntity(url, ResponseEntity<String> entity = new TestRestTemplate().getForEntity(url, String.class);
String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(entity.getBody()).isEqualTo("Hello World"); assertThat(entity.getBody()).isEqualTo("Hello World");
} }
...@@ -44,8 +43,7 @@ public class SampleWildFlyDeployApplicationIT { ...@@ -44,8 +43,7 @@ public class SampleWildFlyDeployApplicationIT {
public void testHealth() throws Exception { public void testHealth() throws Exception {
String url = "http://localhost:" + this.port + "/bootapp/actuator/health"; String url = "http://localhost:" + this.port + "/bootapp/actuator/health";
System.out.println(url); System.out.println(url);
ResponseEntity<String> entity = new TestRestTemplate().getForEntity(url, ResponseEntity<String> entity = new TestRestTemplate().getForEntity(url, String.class);
String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(entity.getBody()).isEqualTo("{\"status\":\"UP\"}"); assertThat(entity.getBody()).isEqualTo("{\"status\":\"UP\"}");
} }
......
/* /*
* Copyright 2012-2018 the original author or authors. * Copyright 2012-2019 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -34,8 +34,7 @@ public class SampleWlpDeployApplicationIT { ...@@ -34,8 +34,7 @@ public class SampleWlpDeployApplicationIT {
@Test @Test
public void testHome() throws Exception { public void testHome() throws Exception {
String url = "http://localhost:" + this.port + "/bootapp/"; String url = "http://localhost:" + this.port + "/bootapp/";
ResponseEntity<String> entity = new TestRestTemplate().getForEntity(url, ResponseEntity<String> entity = new TestRestTemplate().getForEntity(url, String.class);
String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(entity.getBody()).isEqualTo("Hello World"); assertThat(entity.getBody()).isEqualTo("Hello World");
} }
...@@ -44,8 +43,7 @@ public class SampleWlpDeployApplicationIT { ...@@ -44,8 +43,7 @@ public class SampleWlpDeployApplicationIT {
public void testHealth() throws Exception { public void testHealth() throws Exception {
String url = "http://localhost:" + this.port + "/bootapp/actuator/health"; String url = "http://localhost:" + this.port + "/bootapp/actuator/health";
System.out.println(url); System.out.println(url);
ResponseEntity<String> entity = new TestRestTemplate().getForEntity(url, ResponseEntity<String> entity = new TestRestTemplate().getForEntity(url, String.class);
String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(entity.getBody()).isEqualTo("{\"status\":\"UP\"}"); assertThat(entity.getBody()).isEqualTo("{\"status\":\"UP\"}");
} }
......
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