org.mongodb
mongodb-driver-async
diff --git a/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/json/AutoConfigureJsonTesters.java b/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/json/AutoConfigureJsonTesters.java
index ea48f3c07be..e68477b34d3 100644
--- a/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/json/AutoConfigureJsonTesters.java
+++ b/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/json/AutoConfigureJsonTesters.java
@@ -28,6 +28,7 @@ import org.springframework.boot.test.autoconfigure.properties.PropertyMapping;
import org.springframework.boot.test.json.BasicJsonTester;
import org.springframework.boot.test.json.GsonTester;
import org.springframework.boot.test.json.JacksonTester;
+import org.springframework.boot.test.json.JsonbTester;
/**
* Annotation that can be applied to a test class to enable and configure
@@ -45,8 +46,8 @@ import org.springframework.boot.test.json.JacksonTester;
public @interface AutoConfigureJsonTesters {
/**
- * If {@link BasicJsonTester}, {@link JacksonTester} and {@link GsonTester} beans
- * should be registered. Defaults to {@code true}
+ * If {@link BasicJsonTester}, {@link JacksonTester}, {@link JsonbTester} and
+ * {@link GsonTester} beans should be registered. Defaults to {@code true}
* @return if tester support is enabled
*/
boolean enabled() default true;
diff --git a/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/json/JsonTest.java b/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/json/JsonTest.java
index 676459c5858..84aa698d6bb 100644
--- a/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/json/JsonTest.java
+++ b/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/json/JsonTest.java
@@ -31,6 +31,7 @@ import org.springframework.boot.test.autoconfigure.filter.TypeExcludeFilters;
import org.springframework.boot.test.context.SpringBootTestContextBootstrapper;
import org.springframework.boot.test.json.GsonTester;
import org.springframework.boot.test.json.JacksonTester;
+import org.springframework.boot.test.json.JsonbTester;
import org.springframework.context.annotation.ComponentScan.Filter;
import org.springframework.core.annotation.AliasFor;
import org.springframework.test.context.BootstrapWith;
@@ -45,8 +46,9 @@ import org.springframework.test.context.BootstrapWith;
* {@code Module})
*
* By default, tests annotated with {@code JsonTest} will also initialize
- * {@link JacksonTester} and {@link GsonTester} fields. More fine-grained control can be
- * provided via the {@link AutoConfigureJsonTesters @AutoConfigureJsonTesters} annotation.
+ * {@link JacksonTester}, {@link JsonbTester} and {@link GsonTester} fields. More
+ * fine-grained control can be provided via the {@link AutoConfigureJsonTesters @AutoConfigureJsonTesters}
+ * annotation.
*
* @author Phillip Webb
* @see AutoConfigureJson
diff --git a/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/json/JsonTestersAutoConfiguration.java b/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/json/JsonTestersAutoConfiguration.java
index 4110e311670..ffb7b10c318 100644
--- a/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/json/JsonTestersAutoConfiguration.java
+++ b/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/json/JsonTestersAutoConfiguration.java
@@ -19,6 +19,8 @@ package org.springframework.boot.test.autoconfigure.json;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
+import javax.json.bind.Jsonb;
+
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.Gson;
@@ -33,10 +35,12 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.gson.GsonAutoConfiguration;
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
+import org.springframework.boot.autoconfigure.jsonb.JsonbAutoConfiguration;
import org.springframework.boot.test.json.AbstractJsonMarshalTester;
import org.springframework.boot.test.json.BasicJsonTester;
import org.springframework.boot.test.json.GsonTester;
import org.springframework.boot.test.json.JacksonTester;
+import org.springframework.boot.test.json.JsonbTester;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;
@@ -48,13 +52,15 @@ import org.springframework.util.ReflectionUtils;
* Auto-configuration for Json testers.
*
* @author Phillip Webb
+ * @author Eddú Meléndez
* @see AutoConfigureJsonTesters
* @since 1.4.0
*/
@Configuration
@ConditionalOnClass(name = "org.assertj.core.api.Assert")
@ConditionalOnProperty("spring.test.jsontesters.enabled")
-@AutoConfigureAfter({ JacksonAutoConfiguration.class, GsonAutoConfiguration.class })
+@AutoConfigureAfter({ JacksonAutoConfiguration.class, GsonAutoConfiguration.class,
+ JsonbAutoConfiguration.class })
public class JsonTestersAutoConfiguration {
@Bean
@@ -94,6 +100,18 @@ public class JsonTestersAutoConfiguration {
}
+ @ConditionalOnClass(Jsonb.class)
+ private static class JsonbJsonTesterConfiguration {
+
+ @Bean
+ @Scope("prototype")
+ @ConditionalOnBean(Jsonb.class)
+ public FactoryBean> jsonbTesterFactoryBean(Jsonb jsonb) {
+ return new JsonTesterFactoryBean<>(JsonbTester.class, jsonb);
+ }
+
+ }
+
/**
* {@link FactoryBean} used to create JSON Tester instances.
*/
diff --git a/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring.factories b/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring.factories
index 0d335481a55..783c0b60397 100644
--- a/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring.factories
+++ b/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring.factories
@@ -67,13 +67,15 @@ org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration
# AutoConfigureJson auto-configuration imports
org.springframework.boot.test.autoconfigure.json.AutoConfigureJson=\
org.springframework.boot.autoconfigure.gson.GsonAutoConfiguration,\
-org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration
+org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration,\
+org.springframework.boot.autoconfigure.jsonb.JsonbAutoConfiguration
# AutoConfigureJsonTesters auto-configuration imports
org.springframework.boot.test.autoconfigure.json.AutoConfigureJsonTesters=\
org.springframework.boot.test.autoconfigure.json.JsonTestersAutoConfiguration,\
org.springframework.boot.autoconfigure.gson.GsonAutoConfiguration,\
-org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration
+org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration,\
+org.springframework.boot.autoconfigure.jsonb.JsonbAutoConfiguration
# AutoConfigureWebClient auto-configuration imports
org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebTestClient=\
@@ -111,6 +113,7 @@ org.springframework.boot.autoconfigure.gson.GsonAutoConfiguration,\
org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration,\
org.springframework.boot.autoconfigure.http.codec.CodecsAutoConfiguration,\
org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration,\
+org.springframework.boot.autoconfigure.jsonb.JsonbAutoConfiguration,\
org.springframework.boot.autoconfigure.web.client.RestTemplateAutoConfiguration,\
org.springframework.boot.autoconfigure.web.reactive.function.client.WebClientAutoConfiguration
@@ -123,6 +126,7 @@ org.springframework.boot.autoconfigure.gson.GsonAutoConfiguration,\
org.springframework.boot.autoconfigure.hateoas.HypermediaAutoConfiguration,\
org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration,\
org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration,\
+org.springframework.boot.autoconfigure.jsonb.JsonbAutoConfiguration,\
org.springframework.boot.autoconfigure.mustache.MustacheAutoConfiguration,\
org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration,\
org.springframework.boot.autoconfigure.validation.ValidationAutoConfiguration,\
@@ -145,4 +149,4 @@ org.springframework.test.context.TestExecutionListener=\
org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener,\
org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener,\
org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener,\
-org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener
\ No newline at end of file
+org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener
diff --git a/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/JsonTestIntegrationTests.java b/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/JsonTestIntegrationTests.java
index 64dbb108ba8..f4ce184ae78 100644
--- a/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/JsonTestIntegrationTests.java
+++ b/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/JsonTestIntegrationTests.java
@@ -28,6 +28,7 @@ import org.springframework.boot.test.json.BasicJsonTester;
import org.springframework.boot.test.json.GsonTester;
import org.springframework.boot.test.json.JacksonTester;
import org.springframework.boot.test.json.JsonContent;
+import org.springframework.boot.test.json.JsonbTester;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
@@ -38,6 +39,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Phillip Webb
* @author Madhura Bhave
+ * @author Eddú Meléndez
*/
@RunWith(SpringRunner.class)
@JsonTest
@@ -59,6 +61,9 @@ public class JsonTestIntegrationTests {
@Autowired
private GsonTester gsonJson;
+ @Autowired
+ private JsonbTester jsonbJson;
+
@Test
public void basicJson() throws Exception {
assertThat(this.basicJson.from("{\"a\":\"b\"}")).hasJsonPathStringValue("@.a");
@@ -84,6 +89,13 @@ public class JsonTestIntegrationTests {
assertThat(this.gsonJson.write(object)).isEqualToJson("example.json");
}
+ @Test
+ public void jsonb() throws Exception {
+ ExampleBasicObject object = new ExampleBasicObject();
+ object.setValue("spring");
+ assertThat(this.jsonbJson.write(object)).isEqualToJson("example.json");
+ }
+
@Test
public void customView() throws Exception {
ExampleJsonObjectWithView object = new ExampleJsonObjectWithView();
diff --git a/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/JsonTestWithAutoConfigureJsonTestersTests.java b/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/JsonTestWithAutoConfigureJsonTestersTests.java
index 1c34491b132..62b44ac09f8 100644
--- a/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/JsonTestWithAutoConfigureJsonTestersTests.java
+++ b/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/JsonTestWithAutoConfigureJsonTestersTests.java
@@ -25,6 +25,7 @@ import org.springframework.boot.test.autoconfigure.json.app.ExampleJsonApplicati
import org.springframework.boot.test.json.BasicJsonTester;
import org.springframework.boot.test.json.GsonTester;
import org.springframework.boot.test.json.JacksonTester;
+import org.springframework.boot.test.json.JsonbTester;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
@@ -50,6 +51,9 @@ public class JsonTestWithAutoConfigureJsonTestersTests {
@Autowired(required = false)
private GsonTester gsonTester;
+ @Autowired(required = false)
+ private JsonbTester jsonbTester;
+
@Test
public void basicJson() throws Exception {
assertThat(this.basicJson).isNull();
@@ -65,4 +69,9 @@ public class JsonTestWithAutoConfigureJsonTestersTests {
assertThat(this.gsonTester).isNull();
}
+ @Test
+ public void jsonb() throws Exception {
+ assertThat(this.jsonbTester).isNull();
+ }
+
}
diff --git a/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/SpringBootTestWithAutoConfigureJsonTestersTests.java b/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/SpringBootTestWithAutoConfigureJsonTestersTests.java
index 8c997427bae..330dc41881e 100644
--- a/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/SpringBootTestWithAutoConfigureJsonTestersTests.java
+++ b/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/SpringBootTestWithAutoConfigureJsonTestersTests.java
@@ -26,6 +26,7 @@ import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.json.BasicJsonTester;
import org.springframework.boot.test.json.GsonTester;
import org.springframework.boot.test.json.JacksonTester;
+import org.springframework.boot.test.json.JsonbTester;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
@@ -51,10 +52,14 @@ public class SpringBootTestWithAutoConfigureJsonTestersTests {
@Autowired
private GsonTester gsonTester;
+ @Autowired
+ private JsonbTester jsonbTester;
+
@Test
public void contextLoads() {
assertThat(this.basicJson).isNotNull();
assertThat(this.jacksonTester).isNotNull();
+ assertThat(this.jsonbTester).isNotNull();
assertThat(this.gsonTester).isNotNull();
}
diff --git a/spring-boot-test/pom.xml b/spring-boot-test/pom.xml
index 77934e5e235..30b1c504dcb 100644
--- a/spring-boot-test/pom.xml
+++ b/spring-boot-test/pom.xml
@@ -45,6 +45,11 @@
reactor-netty
true
+