-
Notifications
You must be signed in to change notification settings - Fork 40.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update smoketests to test isolated actuator object mapper use
- Loading branch information
Showing
16 changed files
with
453 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
...-actuator/src/test/java/smoketest/actuator/ApplicationStartupSpringBootContextLoader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright 2012-2022 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. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package smoketest.actuator; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.context.metrics.buffering.BufferingApplicationStartup; | ||
import org.springframework.boot.test.context.SpringBootContextLoader; | ||
|
||
class ApplicationStartupSpringBootContextLoader extends SpringBootContextLoader { | ||
|
||
@Override | ||
protected SpringApplication getSpringApplication() { | ||
SpringApplication application = new SpringApplication(); | ||
application.setApplicationStartup(new BufferingApplicationStartup(1024)); | ||
return application; | ||
} | ||
|
||
} |
52 changes: 52 additions & 0 deletions
52
...test/java/smoketest/actuator/SampleActuatorApplicationIsolatedObjectMapperFalseTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Copyright 2012-2022 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. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package smoketest.actuator; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; | ||
import org.springframework.boot.test.web.client.TestRestTemplate; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.test.context.ContextConfiguration; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
/** | ||
* Integration test for WebMVC actuator when using an isolated {@link ObjectMapper}. | ||
* | ||
* @author Phillip Webb | ||
*/ | ||
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, | ||
properties = "management.endpoints.jackson.isolated-object-mapper=false") | ||
@ContextConfiguration(loader = ApplicationStartupSpringBootContextLoader.class) | ||
class SampleActuatorApplicationIsolatedObjectMapperFalseTests { | ||
|
||
@Autowired | ||
private TestRestTemplate testRestTemplate; | ||
|
||
@Test | ||
void resourceShouldBeAvailableOnMainPort() { | ||
ResponseEntity<String> entity = this.testRestTemplate.withBasicAuth("user", "password") | ||
.getForEntity("/actuator/startup", String.class); | ||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR); | ||
} | ||
|
||
} |
53 changes: 53 additions & 0 deletions
53
.../test/java/smoketest/actuator/SampleActuatorApplicationIsolatedObjectMapperTrueTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Copyright 2012-2022 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. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package smoketest.actuator; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; | ||
import org.springframework.boot.test.web.client.TestRestTemplate; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.test.context.ContextConfiguration; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
/** | ||
* Integration test for WebMVC actuator when using an isolated {@link ObjectMapper}. | ||
* | ||
* @author Phillip Webb | ||
*/ | ||
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, | ||
properties = "management.endpoints.jackson.isolated-object-mapper=true") | ||
@ContextConfiguration(loader = ApplicationStartupSpringBootContextLoader.class) | ||
class SampleActuatorApplicationIsolatedObjectMapperTrueTests { | ||
|
||
@Autowired | ||
private TestRestTemplate testRestTemplate; | ||
|
||
@Test | ||
void resourceShouldBeAvailableOnMainPort() { | ||
ResponseEntity<String> entity = this.testRestTemplate.withBasicAuth("user", "password") | ||
.getForEntity("/actuator/startup", String.class); | ||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); | ||
assertThat(entity.getBody()).contains("\"timeline\":"); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
...-boot-smoke-tests/spring-boot-smoke-test-jersey/src/main/resources/application.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
management.endpoints.web.exposure.include=* | ||
management.endpoints.jackson.isolated-object-mapper=true | ||
spring.jackson.visibility.field=any |
32 changes: 32 additions & 0 deletions
32
...test-jersey/src/test/java/smoketest/jersey/ApplicationStartupSpringBootContextLoader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright 2012-2022 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. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package smoketest.jersey; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.context.metrics.buffering.BufferingApplicationStartup; | ||
import org.springframework.boot.test.context.SpringBootContextLoader; | ||
|
||
class ApplicationStartupSpringBootContextLoader extends SpringBootContextLoader { | ||
|
||
@Override | ||
protected SpringApplication getSpringApplication() { | ||
SpringApplication application = new SpringApplication(); | ||
application.setApplicationStartup(new BufferingApplicationStartup(1024)); | ||
return application; | ||
} | ||
|
||
} |
62 changes: 62 additions & 0 deletions
62
...t-jersey/src/test/java/smoketest/jersey/JerseyActuatorIsolatedObjectMapperFalseTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Copyright 2012-2022 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. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package smoketest.jersey; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; | ||
import org.springframework.boot.test.web.client.TestRestTemplate; | ||
import org.springframework.boot.test.web.server.LocalManagementPort; | ||
import org.springframework.boot.test.web.server.LocalServerPort; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.test.context.ContextConfiguration; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
/** | ||
* Integration test for Jersey actuator when not using an isolated {@link ObjectMapper}. | ||
* | ||
* @author Phillip Webb | ||
*/ | ||
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, | ||
properties = "management.endpoints.jackson.isolated-object-mapper=false") | ||
@ContextConfiguration(loader = ApplicationStartupSpringBootContextLoader.class) | ||
public class JerseyActuatorIsolatedObjectMapperFalseTests { | ||
|
||
@LocalServerPort | ||
private int port; | ||
|
||
@LocalManagementPort | ||
private int managementPort; | ||
|
||
@Autowired | ||
private TestRestTemplate testRestTemplate; | ||
|
||
@Test | ||
void resourceShouldBeAvailableOnMainPort() { | ||
ResponseEntity<String> entity = this.testRestTemplate | ||
.getForEntity("http://localhost:" + this.port + "/actuator/startup", String.class); | ||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.BAD_REQUEST); | ||
assertThat(entity.getBody()) | ||
.contains("Java 8 date/time type `java.time.Clock$SystemClock` not supported by default"); | ||
} | ||
|
||
} |
61 changes: 61 additions & 0 deletions
61
...st-jersey/src/test/java/smoketest/jersey/JerseyActuatorIsolatedObjectMapperTrueTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* Copyright 2012-2022 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. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package smoketest.jersey; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; | ||
import org.springframework.boot.test.web.client.TestRestTemplate; | ||
import org.springframework.boot.test.web.server.LocalManagementPort; | ||
import org.springframework.boot.test.web.server.LocalServerPort; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.test.context.ContextConfiguration; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
/** | ||
* Integration test for Jersey actuator when using an isolated {@link ObjectMapper}. | ||
* | ||
* @author Phillip Webb | ||
*/ | ||
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, | ||
properties = "management.endpoints.jackson.isolated-object-mapper=true") | ||
@ContextConfiguration(loader = ApplicationStartupSpringBootContextLoader.class) | ||
public class JerseyActuatorIsolatedObjectMapperTrueTests { | ||
|
||
@LocalServerPort | ||
private int port; | ||
|
||
@LocalManagementPort | ||
private int managementPort; | ||
|
||
@Autowired | ||
private TestRestTemplate testRestTemplate; | ||
|
||
@Test | ||
void resourceShouldBeAvailableOnMainPort() { | ||
ResponseEntity<String> entity = this.testRestTemplate | ||
.getForEntity("http://localhost:" + this.port + "/actuator/startup", String.class); | ||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); | ||
assertThat(entity.getBody()).contains("\"timeline\":"); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
...boot-smoke-tests/spring-boot-smoke-test-webflux/src/main/resources/application.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
management.endpoints.web.exposure.include=* | ||
management.endpoints.jackson.isolated-object-mapper=true | ||
spring.jackson.visibility.field=any |
Oops, something went wrong.