Browse Source

Add Jackson 2 smoke tests

See gh-47688

Co-authored-by: Andy Wilkinson <andy.wilkinson@broadcom.com>
pull/47694/head
Phillip Webb 2 months ago
parent
commit
e7f3ae19f8
  1. 2
      settings.gradle
  2. 30
      smoke-test/spring-boot-smoke-test-jackson2-mixed/build.gradle
  3. 21
      smoke-test/spring-boot-smoke-test-jackson2-mixed/src/main/java/smoketest/jackson2/mixed/Name.java
  4. 39
      smoke-test/spring-boot-smoke-test-jackson2-mixed/src/main/java/smoketest/jackson2/mixed/NamesEndpoint.java
  5. 32
      smoke-test/spring-boot-smoke-test-jackson2-mixed/src/main/java/smoketest/jackson2/mixed/SampleController.java
  6. 29
      smoke-test/spring-boot-smoke-test-jackson2-mixed/src/main/java/smoketest/jackson2/mixed/SampleJackson2MixedApplication.java
  7. 38
      smoke-test/spring-boot-smoke-test-jackson2-mixed/src/main/java/smoketest/jackson2/mixed/SampleJacksonComponent.java
  8. 40
      smoke-test/spring-boot-smoke-test-jackson2-mixed/src/main/java/smoketest/jackson2/mixed/SampleJsonComponent.java
  9. 20
      smoke-test/spring-boot-smoke-test-jackson2-mixed/src/main/java/smoketest/jackson2/mixed/package-info.java
  10. 2
      smoke-test/spring-boot-smoke-test-jackson2-mixed/src/main/resources/application.properties
  11. 42
      smoke-test/spring-boot-smoke-test-jackson2-mixed/src/test/java/smoketest/jackson2/mixed/MixedJacksonPresenceTests.java
  12. 77
      smoke-test/spring-boot-smoke-test-jackson2-mixed/src/test/java/smoketest/jackson2/mixed/SampleJackson2MixedApplicationTests.java
  13. 78
      smoke-test/spring-boot-smoke-test-jackson2-mixed/src/test/java/smoketest/jackson2/mixed/SampleJackson2MixedApplicationWithJackson3PreferredTests.java
  14. 34
      smoke-test/spring-boot-smoke-test-jackson2-only/build.gradle
  15. 29
      smoke-test/spring-boot-smoke-test-jackson2-only/src/main/java/smoketest/jackson2/only/SampleJackson2OnlyApplication.java
  16. 20
      smoke-test/spring-boot-smoke-test-jackson2-only/src/main/java/smoketest/jackson2/only/package-info.java
  17. 1
      smoke-test/spring-boot-smoke-test-jackson2-only/src/main/resources/application.properties
  18. 42
      smoke-test/spring-boot-smoke-test-jackson2-only/src/test/java/smoketest/jackson2/only/OnlyJackson2PresenceTests.java
  19. 67
      smoke-test/spring-boot-smoke-test-jackson2-only/src/test/java/smoketest/jackson2/only/SampleJackson2OnlyApplicationTests.java

2
settings.gradle

@ -414,6 +414,8 @@ include ":smoke-test:spring-boot-smoke-test-graphql" @@ -414,6 +414,8 @@ include ":smoke-test:spring-boot-smoke-test-graphql"
include ":smoke-test:spring-boot-smoke-test-hateoas"
include ":smoke-test:spring-boot-smoke-test-hibernate"
include ":smoke-test:spring-boot-smoke-test-integration"
include ":smoke-test:spring-boot-smoke-test-jackson2-mixed"
include ":smoke-test:spring-boot-smoke-test-jackson2-only"
include ":smoke-test:spring-boot-smoke-test-jetty"
include ":smoke-test:spring-boot-smoke-test-jetty-jsp"
include ":smoke-test:spring-boot-smoke-test-jetty-ssl"

30
smoke-test/spring-boot-smoke-test-jackson2-mixed/build.gradle

@ -0,0 +1,30 @@ @@ -0,0 +1,30 @@
/*
* Copyright 2012-present 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.
*/
plugins {
id "java"
}
description = "Spring Boot Jackson 2 mixed with Jackson 3 smoke test"
dependencies {
implementation(project(":module:spring-boot-jackson2"))
implementation(project(":starter:spring-boot-starter-actuator"))
implementation(project(":starter:spring-boot-starter-webmvc"))
testImplementation(project(":starter:spring-boot-starter-test"))
testImplementation(project(":starter:spring-boot-starter-webmvc-test"))
}

21
smoke-test/spring-boot-smoke-test-jackson2-mixed/src/main/java/smoketest/jackson2/mixed/Name.java

@ -0,0 +1,21 @@ @@ -0,0 +1,21 @@
/*
* Copyright 2012-present 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.jackson2.mixed;
public record Name(String first, String last) {
}

39
smoke-test/spring-boot-smoke-test-jackson2-mixed/src/main/java/smoketest/jackson2/mixed/NamesEndpoint.java

@ -0,0 +1,39 @@ @@ -0,0 +1,39 @@
/*
* Copyright 2012-present 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.jackson2.mixed;
import java.util.List;
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
import org.springframework.stereotype.Component;
/**
* Names endpoint.
*
* @author Andy Wilkinson
*/
@Component
@Endpoint(id = "names")
public class NamesEndpoint {
@ReadOperation
List<Name> names() {
return List.of(new Name("Spring", "Boot"));
}
}

32
smoke-test/spring-boot-smoke-test-jackson2-mixed/src/main/java/smoketest/jackson2/mixed/SampleController.java

@ -0,0 +1,32 @@ @@ -0,0 +1,32 @@
/*
* Copyright 2012-present 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.jackson2.mixed;
import java.util.List;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class SampleController {
@GetMapping("/names")
List<Name> names() {
return List.of(new Name("Spring", "Boot"));
}
}

29
smoke-test/spring-boot-smoke-test-jackson2-mixed/src/main/java/smoketest/jackson2/mixed/SampleJackson2MixedApplication.java

@ -0,0 +1,29 @@ @@ -0,0 +1,29 @@
/*
* Copyright 2012-present 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.jackson2.mixed;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class SampleJackson2MixedApplication {
public static void main(String[] args) {
SpringApplication.run(SampleJackson2MixedApplication.class, args);
}
}

38
smoke-test/spring-boot-smoke-test-jackson2-mixed/src/main/java/smoketest/jackson2/mixed/SampleJacksonComponent.java

@ -0,0 +1,38 @@ @@ -0,0 +1,38 @@
/*
* Copyright 2012-present 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.jackson2.mixed;
import tools.jackson.core.JacksonException;
import tools.jackson.core.JsonGenerator;
import tools.jackson.databind.SerializationContext;
import tools.jackson.databind.ValueSerializer;
import org.springframework.boot.jackson.JacksonComponent;
@JacksonComponent
public class SampleJacksonComponent {
public static class Serializer extends ValueSerializer<Name> {
@Override
public void serialize(Name value, JsonGenerator gen, SerializationContext ctxt) throws JacksonException {
gen.writeString("JACKSON:%s:%s".formatted(value.first(), value.last()));
}
}
}

40
smoke-test/spring-boot-smoke-test-jackson2-mixed/src/main/java/smoketest/jackson2/mixed/SampleJsonComponent.java

@ -0,0 +1,40 @@ @@ -0,0 +1,40 @@
/*
* Copyright 2012-present 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.jackson2.mixed;
import java.io.IOException;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import org.springframework.boot.jackson2.JsonComponent;
@JsonComponent
@SuppressWarnings("removal")
public class SampleJsonComponent {
public static class Serializer extends JsonSerializer<Name> {
@Override
public void serialize(Name value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
gen.writeString("JACKSON2:%s:%s".formatted(value.first(), value.last()));
}
}
}

20
smoke-test/spring-boot-smoke-test-jackson2-mixed/src/main/java/smoketest/jackson2/mixed/package-info.java

@ -0,0 +1,20 @@ @@ -0,0 +1,20 @@
/*
* Copyright 2012-present 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.
*/
@NullMarked
package smoketest.jackson2.mixed;
import org.jspecify.annotations.NullMarked;

2
smoke-test/spring-boot-smoke-test-jackson2-mixed/src/main/resources/application.properties

@ -0,0 +1,2 @@ @@ -0,0 +1,2 @@
management.endpoints.web.exposure.include=*
spring.http.converters.preferred-json-mapper=jackson2

42
smoke-test/spring-boot-smoke-test-jackson2-mixed/src/test/java/smoketest/jackson2/mixed/MixedJacksonPresenceTests.java

@ -0,0 +1,42 @@ @@ -0,0 +1,42 @@
/*
* Copyright 2012-present 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.jackson2.mixed;
import org.junit.jupiter.api.Test;
import org.springframework.util.ClassUtils;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Tests for the presence of mixed versions of Jackson.
*
* @author Andy Wilkinson
*/
class MixedJacksonPresenceTests {
@Test
void jackson2IsPresent() {
assertThat(ClassUtils.isPresent("com.fasterxml.jackson.databind.ObjectMapper", null)).isTrue();
}
@Test
void jackson3IsPresent() {
assertThat(ClassUtils.isPresent("tools.jackson.databind.ObjectMapper", null)).isTrue();
}
}

77
smoke-test/spring-boot-smoke-test-jackson2-mixed/src/test/java/smoketest/jackson2/mixed/SampleJackson2MixedApplicationTests.java

@ -0,0 +1,77 @@ @@ -0,0 +1,77 @@
/*
* Copyright 2012-present 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.jackson2.mixed;
import java.util.Map;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.resttestclient.autoconfigure.AutoConfigureRestTestClient;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.test.web.servlet.client.RestTestClient;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Tests for {@link SampleJackson2MixedApplication}.
*
* @author Andy Wilkinson
*/
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
@AutoConfigureRestTestClient
class SampleJackson2MixedApplicationTests {
@Autowired
RestTestClient rest;
@Test
void jackson2IsUsedForHttpMessageConversion() {
this.rest.get().uri("/names").exchange().expectBody().json("[\"JACKSON2:Spring:Boot\"]");
}
@Test
void jackson2IsUsedForActuatorEndpoints() {
this.rest.get().uri("/actuator/names").exchange().expectBody().json("[\"JACKSON2:Spring:Boot\"]");
}
@Test
@SuppressWarnings("unchecked")
void configPropsShouldReturnOk() {
this.rest.get()
.uri("/actuator/configprops")
.exchange()
.expectStatus()
.isOk()
.expectBody(Map.class)
.value((body) -> assertThat(body).containsOnlyKeys("contexts"));
}
@Test
@SuppressWarnings("unchecked")
void actuatorLinksShouldReturnOk() {
this.rest.get()
.uri("/actuator")
.exchange()
.expectStatus()
.isOk()
.expectBody(Map.class)
.value((body) -> assertThat(body).containsOnlyKeys("_links"));
}
}

78
smoke-test/spring-boot-smoke-test-jackson2-mixed/src/test/java/smoketest/jackson2/mixed/SampleJackson2MixedApplicationWithJackson3PreferredTests.java

@ -0,0 +1,78 @@ @@ -0,0 +1,78 @@
/*
* Copyright 2012-present 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.jackson2.mixed;
import java.util.Map;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.resttestclient.autoconfigure.AutoConfigureRestTestClient;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.test.web.servlet.client.RestTestClient;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Tests for {@link SampleJackson2MixedApplication} when Jackson 3 is preferred.
*
* @author Andy Wilkinson
*/
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT,
properties = "spring.http.converters.preferred-json-mapper=jackson")
@AutoConfigureRestTestClient
class SampleJackson2MixedApplicationWithJackson3PreferredTests {
@Autowired
RestTestClient rest;
@Test
void jacksonIsUsedForHttpMessageConversion() {
this.rest.get().uri("/names").exchange().expectBody().json("[\"JACKSON:Spring:Boot\"]");
}
@Test
void jacksonIsUsedForActuatorEndpoints() {
this.rest.get().uri("/actuator/names").exchange().expectBody().json("[\"JACKSON:Spring:Boot\"]");
}
@Test
@SuppressWarnings("unchecked")
void configPropsShouldReturnOk() {
this.rest.get()
.uri("/actuator/configprops")
.exchange()
.expectStatus()
.isOk()
.expectBody(Map.class)
.value((body) -> assertThat(body).containsOnlyKeys("contexts"));
}
@Test
@SuppressWarnings("unchecked")
void actuatorLinksShouldReturnOk() {
this.rest.get()
.uri("/actuator")
.exchange()
.expectStatus()
.isOk()
.expectBody(Map.class)
.value((body) -> assertThat(body).containsOnlyKeys("_links"));
}
}

34
smoke-test/spring-boot-smoke-test-jackson2-only/build.gradle

@ -0,0 +1,34 @@ @@ -0,0 +1,34 @@
/*
* Copyright 2012-present 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.
*/
plugins {
id "java"
}
description = "Spring Boot Jackson 2 without Jackson 3 smoke test"
dependencies {
implementation(project(":module:spring-boot-jackson2"))
implementation(project(":starter:spring-boot-starter-actuator"))
implementation(project(":starter:spring-boot-starter-webmvc")) {
exclude module: 'spring-boot-starter-jackson'
}
testImplementation(project(":starter:spring-boot-starter-test"))
testImplementation(project(":starter:spring-boot-starter-webmvc-test")) {
exclude module: 'spring-boot-starter-jackson'
}
}

29
smoke-test/spring-boot-smoke-test-jackson2-only/src/main/java/smoketest/jackson2/only/SampleJackson2OnlyApplication.java

@ -0,0 +1,29 @@ @@ -0,0 +1,29 @@
/*
* Copyright 2012-present 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.jackson2.only;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class SampleJackson2OnlyApplication {
public static void main(String[] args) {
SpringApplication.run(SampleJackson2OnlyApplication.class, args);
}
}

20
smoke-test/spring-boot-smoke-test-jackson2-only/src/main/java/smoketest/jackson2/only/package-info.java

@ -0,0 +1,20 @@ @@ -0,0 +1,20 @@
/*
* Copyright 2012-present 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.
*/
@NullMarked
package smoketest.jackson2.only;
import org.jspecify.annotations.NullMarked;

1
smoke-test/spring-boot-smoke-test-jackson2-only/src/main/resources/application.properties

@ -0,0 +1 @@ @@ -0,0 +1 @@
management.endpoints.web.exposure.include=*

42
smoke-test/spring-boot-smoke-test-jackson2-only/src/test/java/smoketest/jackson2/only/OnlyJackson2PresenceTests.java

@ -0,0 +1,42 @@ @@ -0,0 +1,42 @@
/*
* Copyright 2012-present 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.jackson2.only;
import org.junit.jupiter.api.Test;
import org.springframework.util.ClassUtils;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Tests for the presence of mixed versions of Jackson.
*
* @author Andy Wilkinson
*/
class OnlyJackson2PresenceTests {
@Test
void jackson2IsPresent() {
assertThat(ClassUtils.isPresent("com.fasterxml.jackson.databind.ObjectMapper", null)).isTrue();
}
@Test
void jackson3IsNotPresent() {
assertThat(ClassUtils.isPresent("tools.jackson.databind.ObjectMapper", null)).isFalse();
}
}

67
smoke-test/spring-boot-smoke-test-jackson2-only/src/test/java/smoketest/jackson2/only/SampleJackson2OnlyApplicationTests.java

@ -0,0 +1,67 @@ @@ -0,0 +1,67 @@
/*
* Copyright 2012-present 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.jackson2.only;
import java.util.Map;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.resttestclient.autoconfigure.AutoConfigureRestTestClient;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.test.web.servlet.client.RestTestClient;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Tests for Actuator running in {@link SampleJackson2OnlyApplication}.
*
* @author Andy Wilkinson
*/
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
@AutoConfigureRestTestClient
class SampleJackson2OnlyApplicationTests {
@Autowired
RestTestClient rest;
@Test
@SuppressWarnings("unchecked")
void configPropsShouldReturnOk() {
this.rest.get()
.uri("/actuator/configprops")
.exchange()
.expectStatus()
.isOk()
.expectBody(Map.class)
.value((body) -> assertThat(body).containsOnlyKeys("contexts"));
}
@Test
@SuppressWarnings("unchecked")
void actuatorLinksShouldReturnOk() {
this.rest.get()
.uri("/actuator")
.exchange()
.expectStatus()
.isOk()
.expectBody(Map.class)
.value((body) -> assertThat(body).containsOnlyKeys("_links"));
}
}
Loading…
Cancel
Save