From f5879649f2bcff8c86317497b228fc9f52e3aad5 Mon Sep 17 00:00:00 2001 From: "Kim, Joo Hyuk" Date: Sun, 19 Jan 2025 08:47:11 +0900 Subject: [PATCH 1/4] [JSTEP-10] Migrate `/OSGi` and `no-ctor-deser` module to `JUnit 5` (#276) --- no-ctor-deser/pom.xml | 9 ++++- .../noctordeser/BasicNoConstructorTest.java | 10 +++-- osgi/pom.xml | 10 ++++- .../module/osgi/InjectOsgiServiceTest.java | 39 +++++++------------ 4 files changed, 37 insertions(+), 31 deletions(-) diff --git a/no-ctor-deser/pom.xml b/no-ctor-deser/pom.xml index aaab5c1e7..4de5e2fd7 100644 --- a/no-ctor-deser/pom.xml +++ b/no-ctor-deser/pom.xml @@ -43,8 +43,13 @@ - junit - junit + org.junit.jupiter + junit-jupiter + test + + + org.junit.jupiter + junit-jupiter-api test diff --git a/no-ctor-deser/src/test/java/com/fasterxml/jackson/module/noctordeser/BasicNoConstructorTest.java b/no-ctor-deser/src/test/java/com/fasterxml/jackson/module/noctordeser/BasicNoConstructorTest.java index c5059866b..4e7b35a64 100644 --- a/no-ctor-deser/src/test/java/com/fasterxml/jackson/module/noctordeser/BasicNoConstructorTest.java +++ b/no-ctor-deser/src/test/java/com/fasterxml/jackson/module/noctordeser/BasicNoConstructorTest.java @@ -1,13 +1,15 @@ package com.fasterxml.jackson.module.noctordeser; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.json.JsonMapper; -import junit.framework.TestCase; - import java.util.Arrays; -public class BasicNoConstructorTest extends TestCase +import static org.junit.jupiter.api.Assertions.*; + +public class BasicNoConstructorTest { static class BeanWithoutDefaultConstructor { public String value; @@ -40,6 +42,7 @@ protected static ObjectMapper newObjectMapper() { private final ObjectMapper MAPPER = newObjectMapper(); + @Test public void testReadValueWithoutDefaultConstructor() throws Exception { String json = MAPPER.writeValueAsString(new BeanWithoutDefaultConstructor("test")); @@ -66,6 +69,7 @@ public void testReadValueWithoutDefaultConstructor() throws Exception assertEquals(7, result2.y); } + @Test public void testReadValueWithDefaultConstructor() throws Exception { BeanWithDefaultConstructor bean = new BeanWithDefaultConstructor(); bean.value = "test"; diff --git a/osgi/pom.xml b/osgi/pom.xml index 554a5cb24..9e3c91c65 100644 --- a/osgi/pom.xml +++ b/osgi/pom.xml @@ -46,9 +46,15 @@ org.osgi.core ${version.osgi.core} + - junit - junit + org.junit.jupiter + junit-jupiter + test + + + org.junit.jupiter + junit-jupiter-api test diff --git a/osgi/src/test/java/com/fasterxml/jackson/module/osgi/InjectOsgiServiceTest.java b/osgi/src/test/java/com/fasterxml/jackson/module/osgi/InjectOsgiServiceTest.java index e3cae3d91..3d8fcd956 100644 --- a/osgi/src/test/java/com/fasterxml/jackson/module/osgi/InjectOsgiServiceTest.java +++ b/osgi/src/test/java/com/fasterxml/jackson/module/osgi/InjectOsgiServiceTest.java @@ -1,9 +1,5 @@ package com.fasterxml.jackson.module.osgi; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.fail; import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyString; import static org.mockito.Matchers.eq; @@ -13,15 +9,11 @@ import static org.mockito.Mockito.times; import static org.mockito.Mockito.when; -import java.util.Arrays; -import java.util.Collection; +import java.util.stream.Stream; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameter; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.mockito.Mockito; import org.osgi.framework.BundleContext; import org.osgi.framework.Filter; @@ -32,7 +24,8 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.json.JsonMapper; -@RunWith(value = Parameterized.class) +import static org.junit.jupiter.api.Assertions.*; + public class InjectOsgiServiceTest { private static final String OSGI_FILTER = "osgi.filter"; @@ -40,13 +33,9 @@ public class InjectOsgiServiceTest private BundleContext bundleContext; private ObjectMapper mapper; - - @Parameter - public Class beanClass; - - @Parameters - public static Collection> data() { - return Arrays.asList( + + public static Stream> data() { + return Stream.of( BeanWithServiceInConstructor.class, BeanWithFilter.class, BeanWithServiceInField.class, @@ -54,7 +43,7 @@ public static Collection> data() { } @SuppressWarnings("unchecked") - @Before + @BeforeEach public void setUp() throws Exception { bundleContext = mock(BundleContext.class); @@ -69,9 +58,11 @@ public void setUp() throws Exception .addModule(new OsgiJacksonModule(bundleContext)) .build(); } - - @Test - public void testServiceIsInjected() throws Exception + + @MethodSource("data") + @ParameterizedTest + public void testServiceIsInjected(Class beanClass) + throws Exception { // ACTION VerifyableBean result = mapper.reader().forType(beanClass) From fef36bb8a02c7d773b80e25ef5d80d8911d6a323 Mon Sep 17 00:00:00 2001 From: "Kim, Joo Hyuk" Date: Sun, 19 Jan 2025 09:04:00 +0900 Subject: [PATCH 2/4] Migrate `paranamer` module to JUnit 5 (#275) --- paranamer/pom.xml | 10 ++++++++-- .../jackson/module/paranamer/ModuleTestBase.java | 3 +-- .../fasterxml/jackson/module/paranamer/SimpleTest.java | 6 ++++++ .../paranamer/TestCreatorWithNamingStrategy.java | 5 +++++ .../module/paranamer/TestJDKSerializability.java | 5 +++++ .../failing/TestCreatorWithNamingStrategy.java | 5 +++++ 6 files changed, 30 insertions(+), 4 deletions(-) diff --git a/paranamer/pom.xml b/paranamer/pom.xml index 90e58fb29..4998a1e51 100644 --- a/paranamer/pom.xml +++ b/paranamer/pom.xml @@ -52,9 +52,15 @@ to introspect names of constructor (and factory method) parameters. 2.8 + - junit - junit + org.junit.jupiter + junit-jupiter + test + + + org.junit.jupiter + junit-jupiter-api test diff --git a/paranamer/src/test/java/com/fasterxml/jackson/module/paranamer/ModuleTestBase.java b/paranamer/src/test/java/com/fasterxml/jackson/module/paranamer/ModuleTestBase.java index 51ed61ff7..a2f54bd1e 100644 --- a/paranamer/src/test/java/com/fasterxml/jackson/module/paranamer/ModuleTestBase.java +++ b/paranamer/src/test/java/com/fasterxml/jackson/module/paranamer/ModuleTestBase.java @@ -2,10 +2,9 @@ import java.util.Arrays; -import junit.framework.TestCase; +import static org.junit.jupiter.api.Assertions.*; public abstract class ModuleTestBase - extends TestCase { protected void verifyException(Throwable e, String... matches) { diff --git a/paranamer/src/test/java/com/fasterxml/jackson/module/paranamer/SimpleTest.java b/paranamer/src/test/java/com/fasterxml/jackson/module/paranamer/SimpleTest.java index 09ef08464..05696ddc3 100644 --- a/paranamer/src/test/java/com/fasterxml/jackson/module/paranamer/SimpleTest.java +++ b/paranamer/src/test/java/com/fasterxml/jackson/module/paranamer/SimpleTest.java @@ -1,11 +1,15 @@ package com.fasterxml.jackson.module.paranamer; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.exc.InvalidDefinitionException; import com.fasterxml.jackson.databind.json.JsonMapper; +import static org.junit.jupiter.api.Assertions.*; + public class SimpleTest extends ModuleTestBase { static class CreatorBean @@ -27,6 +31,7 @@ public CreatorBean(int age, String name) /********************************************************** */ + @Test public void testSimple() throws Exception { final String JSON = "{\"name\":\"Bob\", \"age\":40}"; @@ -60,6 +65,7 @@ public void testSimple() throws Exception // Let's test handling of case where parameter names are not found; for example when // trying to access things for JDK types + @Test public void testWrapper() throws Exception { ObjectMapper mapper = JsonMapper.builder() diff --git a/paranamer/src/test/java/com/fasterxml/jackson/module/paranamer/TestCreatorWithNamingStrategy.java b/paranamer/src/test/java/com/fasterxml/jackson/module/paranamer/TestCreatorWithNamingStrategy.java index 0d9d0f71d..7b041389d 100644 --- a/paranamer/src/test/java/com/fasterxml/jackson/module/paranamer/TestCreatorWithNamingStrategy.java +++ b/paranamer/src/test/java/com/fasterxml/jackson/module/paranamer/TestCreatorWithNamingStrategy.java @@ -1,9 +1,13 @@ package com.fasterxml.jackson.module.paranamer; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.PropertyNamingStrategies; +import static org.junit.jupiter.api.Assertions.*; + public class TestCreatorWithNamingStrategy extends ModuleTestBase { @@ -24,6 +28,7 @@ public CreatorBean(int myAge, String myName) .registerModule(new ParanamerModule()) .setPropertyNamingStrategy(PropertyNamingStrategies.UPPER_CAMEL_CASE); + @Test public void testSimpleConstructor() throws Exception { CreatorBean bean = MAPPER.readValue("{ \"MyAge\" : 42, \"MyName\" : \"NotMyRealName\" }", CreatorBean.class); diff --git a/paranamer/src/test/java/com/fasterxml/jackson/module/paranamer/TestJDKSerializability.java b/paranamer/src/test/java/com/fasterxml/jackson/module/paranamer/TestJDKSerializability.java index 2fdd9ea29..e5126262a 100644 --- a/paranamer/src/test/java/com/fasterxml/jackson/module/paranamer/TestJDKSerializability.java +++ b/paranamer/src/test/java/com/fasterxml/jackson/module/paranamer/TestJDKSerializability.java @@ -6,14 +6,19 @@ import java.io.ObjectInputStream; import java.io.ObjectOutputStream; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.databind.ObjectMapper; +import static org.junit.jupiter.api.Assertions.*; + public class TestJDKSerializability extends ModuleTestBase { static class Point { public int x, y; } + @Test public void testMapper() throws Exception { ObjectMapper mapper = new ObjectMapper().registerModule(new ParanamerModule()); diff --git a/paranamer/src/test/java/com/fasterxml/jackson/module/paranamer/failing/TestCreatorWithNamingStrategy.java b/paranamer/src/test/java/com/fasterxml/jackson/module/paranamer/failing/TestCreatorWithNamingStrategy.java index 97c6902a5..8584b9a8d 100644 --- a/paranamer/src/test/java/com/fasterxml/jackson/module/paranamer/failing/TestCreatorWithNamingStrategy.java +++ b/paranamer/src/test/java/com/fasterxml/jackson/module/paranamer/failing/TestCreatorWithNamingStrategy.java @@ -1,11 +1,15 @@ package com.fasterxml.jackson.module.paranamer.failing; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.PropertyNamingStrategies; import com.fasterxml.jackson.module.paranamer.ParanamerModule; import com.fasterxml.jackson.module.paranamer.ModuleTestBase; +import static org.junit.jupiter.api.Assertions.*; + public class TestCreatorWithNamingStrategy extends ModuleTestBase { @@ -36,6 +40,7 @@ public static StaticStringCreatorBean parse(String delimited) .registerModule(new ParanamerModule()) .setPropertyNamingStrategy(PropertyNamingStrategies.UPPER_CAMEL_CASE); + @Test public void testStaticStringCreator() throws Exception { StaticStringCreatorBean bean = MAPPER.readValue("\"42|NotMyRealName\"", StaticStringCreatorBean.class); From a30ebe5f1a6502e77a1f95981a8ccd2673139029 Mon Sep 17 00:00:00 2001 From: "Kim, Joo Hyuk" Date: Sun, 19 Jan 2025 09:05:53 +0900 Subject: [PATCH 3/4] Migrate tests jaxb (#278) --- jaxb/pom.xml | 9 +++++++-- .../jackson/module/jaxb/BaseJaxbTest.java | 1 - .../jackson/module/jaxb/TestVersions.java | 7 ++++++- .../jackson/module/jaxb/adapters/EntryType.java | 4 ++++ .../jackson/module/jaxb/adapters/MapAdapter.java | 4 ++++ .../jackson/module/jaxb/adapters/MapType.java | 4 ++++ .../module/jaxb/adapters/TestAdaptedMapType.java | 6 ++++++ .../jackson/module/jaxb/adapters/TestAdapters.java | 8 ++++++++ .../jaxb/adapters/TestAdaptersForContainers.java | 9 +++++++++ .../module/jaxb/adapters/TestIdentityAdapters.java | 6 ++++++ .../jackson/module/jaxb/failing/TestEnums256.java | 5 +++++ .../module/jaxb/failing/TestUnwrapping.java | 5 +++++ .../jackson/module/jaxb/failing/TestXmlID3.java | 5 +++++ .../jackson/module/jaxb/id/TestXmlID.java | 5 +++++ .../jackson/module/jaxb/id/TestXmlID2.java | 6 ++++++ .../module/jaxb/introspect/TestAccessType.java | 13 ++++++++++--- .../jaxb/introspect/TestAnnotationPriority.java | 5 +++++ .../jaxb/introspect/TestIntrospectorPair.java | 10 ++++++++++ .../introspect/TestJaxbAnnotationIntrospector.java | 9 +++++++++ .../module/jaxb/introspect/TestJaxbAutoDetect.java | 10 +++++++++- .../jaxb/introspect/TestJaxbFieldAccess.java | 6 ++++++ .../jaxb/introspect/TestPropertyOrdering.java | 7 +++++++ .../jaxb/introspect/TestPropertyVisibility.java | 7 +++++++ .../module/jaxb/introspect/TestXmlValue.java | 7 +++++++ .../module/jaxb/misc/TestDeserializerCaching.java | 5 +++++ .../jaxb/misc/TestDomElementSerialization.java | 5 +++++ .../module/jaxb/misc/TestElementWrapper.java | 7 +++++++ .../jackson/module/jaxb/misc/TestEnums.java | 5 +++++ .../module/jaxb/misc/TestJaxbNullProperties.java | 7 +++++++ .../jackson/module/jaxb/misc/TestRootName.java | 5 +++++ .../module/jaxb/misc/TestSchemaGeneration.java | 9 +++++++-- .../jaxb/misc/TestSerializationInclusion.java | 5 +++++ .../jaxb/misc/TestXmlAnyElementWithElementRef.java | 5 +++++ .../module/jaxb/ser/TestVirtualProperties.java | 7 +++++++ .../jaxb/types/OptionalTypeRefinementTest.java | 5 +++++ .../jackson/module/jaxb/types/TestCyclicTypes.java | 5 +++++ .../module/jaxb/types/TestJaxbPolymorphic.java | 14 +++++++++++--- .../jaxb/types/TestJaxbPolymorphicLists.java | 13 ++++++++++--- .../module/jaxb/types/TestJaxbPolymorphicMaps.java | 6 ++++++ .../jaxb/types/TestJaxbTypeCoercion1023.java | 5 +++++ .../jackson/module/jaxb/types/TestJaxbTypes.java | 12 ++++++++++++ .../jaxb/types/XmlSeeAlsoForSubtypes195Test.java | 5 +++++ 42 files changed, 267 insertions(+), 16 deletions(-) diff --git a/jaxb/pom.xml b/jaxb/pom.xml index a22db6c44..0b49a7604 100644 --- a/jaxb/pom.xml +++ b/jaxb/pom.xml @@ -75,8 +75,13 @@ for configuring data-binding. - junit - junit + org.junit.jupiter + junit-jupiter + test + + + org.junit.jupiter + junit-jupiter-api test diff --git a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/BaseJaxbTest.java b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/BaseJaxbTest.java index 8c016a40b..8335237b7 100644 --- a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/BaseJaxbTest.java +++ b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/BaseJaxbTest.java @@ -12,7 +12,6 @@ import com.fasterxml.jackson.databind.jsontype.PolymorphicTypeValidator; public abstract class BaseJaxbTest - extends junit.framework.TestCase { public static class NoCheckSubTypeValidator extends PolymorphicTypeValidator.Base diff --git a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/TestVersions.java b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/TestVersions.java index 4d9461f98..359e29127 100644 --- a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/TestVersions.java +++ b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/TestVersions.java @@ -1,12 +1,17 @@ package com.fasterxml.jackson.module.jaxb; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.core.Version; import com.fasterxml.jackson.core.Versioned; import com.fasterxml.jackson.databind.type.TypeFactory; +import static org.junit.jupiter.api.Assertions.*; + public class TestVersions extends BaseJaxbTest { + @Test public void testVersions() { assertVersion(new JaxbAnnotationIntrospector(TypeFactory.defaultInstance())); @@ -21,7 +26,7 @@ public void testVersions() private void assertVersion(Versioned vers) { Version v = vers.version(); - assertFalse("Should find version information (got "+v+")", v.isUnknownVersion()); + assertFalse(v.isUnknownVersion(), "Should find version information (got "+v+")"); Version exp = PackageVersion.VERSION; assertEquals(exp.toFullString(), v.toFullString()); assertEquals(exp, v); diff --git a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/adapters/EntryType.java b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/adapters/EntryType.java index d647ab412..3f8458593 100644 --- a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/adapters/EntryType.java +++ b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/adapters/EntryType.java @@ -3,6 +3,10 @@ /** * @author Ryan Heaton */ +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + public class EntryType { private K key; diff --git a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/adapters/MapAdapter.java b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/adapters/MapAdapter.java index 239e88f61..a4a326924 100644 --- a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/adapters/MapAdapter.java +++ b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/adapters/MapAdapter.java @@ -8,6 +8,10 @@ import java.util.List; import java.util.Map; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + public class MapAdapter extends XmlAdapter, Map> { @Override diff --git a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/adapters/MapType.java b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/adapters/MapType.java index 63ddf6699..73672d87e 100644 --- a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/adapters/MapType.java +++ b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/adapters/MapType.java @@ -5,6 +5,10 @@ /** * @author Ryan Heaton */ +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + public class MapType { public List> entries; diff --git a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/adapters/TestAdaptedMapType.java b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/adapters/TestAdaptedMapType.java index 72f94232e..7257a8421 100644 --- a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/adapters/TestAdaptedMapType.java +++ b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/adapters/TestAdaptedMapType.java @@ -6,10 +6,14 @@ import javax.xml.bind.annotation.adapters.XmlAdapter; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.module.jaxb.BaseJaxbTest; +import static org.junit.jupiter.api.Assertions.*; + /** * Tests for verifying JAXB adapter handling for {@link java.util.Map} * types. @@ -64,6 +68,7 @@ public Map unmarshal(Map input) /********************************************************** */ + @Test public void testJacksonAdaptedMapType() throws IOException { ObjectContainingAMap obj = new ObjectContainingAMap(); @@ -83,6 +88,7 @@ public void testJacksonAdaptedMapType() throws IOException assertEquals("here", map.get("how")); } + @Test public void testStringMaps() throws IOException { ObjectMapper mapper = getJaxbMapper(); diff --git a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/adapters/TestAdapters.java b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/adapters/TestAdapters.java index 5b91d555e..efe8ad431 100644 --- a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/adapters/TestAdapters.java +++ b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/adapters/TestAdapters.java @@ -6,9 +6,13 @@ import javax.xml.bind.annotation.adapters.XmlAdapter; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.module.jaxb.BaseJaxbTest; +import static org.junit.jupiter.api.Assertions.*; + /** * Unit tests for checking that JAXB type adapters work (to some * degree, anyway). @@ -164,12 +168,14 @@ public IdentityAdapterPropertyBean() { } /********************************************************** */ + @Test public void testSimpleAdapterSerialization() throws Exception { Bean bean = new Bean(123L); assertEquals("{\"value\":\"XXX\"}", getJaxbMapper().writeValueAsString(bean)); } + @Test public void testSimpleAdapterDeserialization() throws Exception { Bean bean = getJaxbMapper().readValue("{\"value\":\"abc\"}", Bean.class); @@ -178,6 +184,7 @@ public void testSimpleAdapterDeserialization() throws Exception } // [JACKSON-288] + @Test public void testDateAdapter() throws Exception { Bean288 input = new Bean288("test"); @@ -189,6 +196,7 @@ public void testDateAdapter() throws Exception // [JACKSON-656] + @Test public void testJackson656() throws Exception { Bean656 bean = new Bean656(); diff --git a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/adapters/TestAdaptersForContainers.java b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/adapters/TestAdaptersForContainers.java index f0b7df805..496c1c4a9 100644 --- a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/adapters/TestAdaptersForContainers.java +++ b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/adapters/TestAdaptersForContainers.java @@ -6,11 +6,15 @@ import javax.xml.bind.annotation.*; import javax.xml.bind.annotation.adapters.*; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.module.jaxb.BaseJaxbTest; import com.fasterxml.jackson.module.jaxb.introspect.TestJaxbAnnotationIntrospector.KeyValuePair; +import static org.junit.jupiter.api.Assertions.*; + /** * Unit tests to check that {@link XmlAdapter}s also work with * container types (Lists, Maps) @@ -112,12 +116,14 @@ public void setValues(List values) { /********************************************************** */ + @Test public void testAdapterForList() throws Exception { Wrapper w = new Wrapper(123L); assertEquals("{\"values\":[\"XXX\"]}", getJaxbMapper().writeValueAsString(w)); } + @Test public void testSimpleAdapterDeserialization() throws Exception { Wrapper w = getJaxbMapper().readValue("{\"values\":[\"abc\"]}", Wrapper.class); @@ -127,12 +133,14 @@ public void testSimpleAdapterDeserialization() throws Exception assertEquals(29L, w.values.get(0).getTime()); } + @Test public void testAdapterOnGetterSerialization() throws Exception { WrapperWithGetterAndSetter w = new WrapperWithGetterAndSetter(123L); assertEquals("{\"values\":[\"XXX\"]}", getJaxbMapper().writeValueAsString(w)); } + @Test public void testAdapterOnGetterDeserialization() throws Exception { WrapperWithGetterAndSetter w = getJaxbMapper().readValue("{\"values\":[\"abc\"]}", @@ -149,6 +157,7 @@ public void testAdapterOnGetterDeserialization() throws Exception /********************************************************** */ + @Test public void testAdapterForBeanWithMap() throws Exception { ObjectMapper mapper = getJaxbMapper(); diff --git a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/adapters/TestIdentityAdapters.java b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/adapters/TestIdentityAdapters.java index bd2792f45..e49153702 100644 --- a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/adapters/TestIdentityAdapters.java +++ b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/adapters/TestIdentityAdapters.java @@ -3,9 +3,13 @@ import javax.xml.bind.annotation.adapters.XmlAdapter; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.module.jaxb.BaseJaxbTest; +import static org.junit.jupiter.api.Assertions.*; + /** * Failing unit tests related to Adapter handling. */ @@ -60,6 +64,7 @@ public IdentityAdapterPropertyBean() { } */ // [Issue-10] + @Test public void testIdentityAdapterForClass() throws Exception { IdentityAdapterBean input = new IdentityAdapterBean("A"); @@ -73,6 +78,7 @@ public void testIdentityAdapterForClass() throws Exception } // [Issue-10] + @Test public void testIdentityAdapterForProperty() throws Exception { IdentityAdapterPropertyBean input = new IdentityAdapterPropertyBean("B"); diff --git a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/failing/TestEnums256.java b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/failing/TestEnums256.java index 1ffc3cb54..20e418fe6 100644 --- a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/failing/TestEnums256.java +++ b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/failing/TestEnums256.java @@ -3,9 +3,13 @@ import javax.xml.bind.annotation.*; import javax.xml.bind.annotation.adapters.*; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.module.jaxb.BaseJaxbTest; +import static org.junit.jupiter.api.Assertions.*; + public class TestEnums256 extends BaseJaxbTest { // [modules-base#256] @@ -40,6 +44,7 @@ public enum Code { private final ObjectMapper MAPPER = getJaxbMapper(); // [modules-base#256] + @Test public void testEnumSerialize256() throws Exception { final Document256 document = new Document256(Code.RED); diff --git a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/failing/TestUnwrapping.java b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/failing/TestUnwrapping.java index a428b49d4..d6f7e138c 100644 --- a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/failing/TestUnwrapping.java +++ b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/failing/TestUnwrapping.java @@ -2,6 +2,8 @@ import javax.xml.bind.annotation.*; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.annotation.JsonUnwrapped; import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.introspect.AnnotationIntrospectorPair; @@ -9,6 +11,8 @@ import com.fasterxml.jackson.module.jaxb.BaseJaxbTest; import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector; +import static org.junit.jupiter.api.Assertions.*; + public class TestUnwrapping extends BaseJaxbTest { @XmlRootElement @@ -51,6 +55,7 @@ public B(String type) { */ // not asserting anything + @Test public void testXmlElementAndXmlElementRefs() throws Exception { Bean bean = new Bean(); diff --git a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/failing/TestXmlID3.java b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/failing/TestXmlID3.java index 71d9492cd..4cb0414d8 100644 --- a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/failing/TestXmlID3.java +++ b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/failing/TestXmlID3.java @@ -6,9 +6,13 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlID; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.module.jaxb.BaseJaxbTest; +import static org.junit.jupiter.api.Assertions.*; + // for [modules-base#46]: XmlId semantics can not be supported by Jackson/JAXB-annotation-mapper public class TestXmlID3 extends BaseJaxbTest { @@ -45,6 +49,7 @@ static class HasIDList public HasID getParent() { return parent; } } + @Test public void testIssue46() throws Exception { ObjectMapper mapper = getJaxbAndJacksonMapper(); diff --git a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/id/TestXmlID.java b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/id/TestXmlID.java index af5b235fa..3434ac6c0 100644 --- a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/id/TestXmlID.java +++ b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/id/TestXmlID.java @@ -4,9 +4,13 @@ import javax.xml.bind.annotation.*; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.module.jaxb.BaseJaxbTest; +import static org.junit.jupiter.api.Assertions.*; + /** * Simple testing to verify that XmlID and XMLIDREF handling works * to degree we can make it work. @@ -55,6 +59,7 @@ public Employee() { /********************************************************** */ + @Test public void testSimpleRefs() throws Exception { final ObjectMapper mapper = getJaxbMapper(); diff --git a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/id/TestXmlID2.java b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/id/TestXmlID2.java index eabb71f4a..d850e4056 100644 --- a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/id/TestXmlID2.java +++ b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/id/TestXmlID2.java @@ -4,6 +4,8 @@ import javax.xml.bind.annotation.*; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.*; @@ -12,6 +14,8 @@ import com.fasterxml.jackson.module.jaxb.BaseJaxbTest; import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector; +import static org.junit.jupiter.api.Assertions.*; + // Reproduction of [Issue-9] public class TestXmlID2 extends BaseJaxbTest { @@ -113,6 +117,7 @@ private List getUserList() return resultList; } + @Test public void testIdWithJacksonRules() throws Exception { ObjectMapper mapper = JsonMapper.builder() @@ -144,6 +149,7 @@ public void testIdWithJacksonRules() throws Exception assertEquals(null, result.get(2).department); } + @Test public void testIdWithJaxbRules() throws Exception { // but then also variant where ID is ALWAYS used for XmlID / XmlIDREF diff --git a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/introspect/TestAccessType.java b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/introspect/TestAccessType.java index 82cc66a87..9ab4cb5d8 100644 --- a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/introspect/TestAccessType.java +++ b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/introspect/TestAccessType.java @@ -6,9 +6,13 @@ import javax.xml.bind.annotation.adapters.XmlAdapter; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.module.jaxb.BaseJaxbTest; +import static org.junit.jupiter.api.Assertions.*; + /** * Unit test(s) written for [JACKSON-303]; we should be able to detect setter * even though it is not annotated, because there is matching annotated getter. @@ -75,7 +79,8 @@ public class Bean40 /********************************************************** */ - public void testXmlElementTypeDeser() throws Exception + @Test + public void testXmlElementTypeDeser() throws Exception { ObjectMapper mapper = getJaxbMapper(); @@ -93,7 +98,8 @@ public void testXmlElementTypeDeser() throws Exception } } - public void testForJackson288() throws Exception + @Test + public void testForJackson288() throws Exception { final long TIMESTAMP = 12345678L; ObjectMapper mapper = getJaxbMapper(); @@ -104,7 +110,8 @@ public void testForJackson288() throws Exception assertEquals(TIMESTAMP, d.getTime()); } - public void testInclusionIssue40() throws Exception + @Test + public void testInclusionIssue40() throws Exception { ObjectMapper mapper = getJaxbMapperBuilder() .enable(MapperFeature.USE_WRAPPER_NAME_AS_PROPERTY_NAME) diff --git a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/introspect/TestAnnotationPriority.java b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/introspect/TestAnnotationPriority.java index 2d2b341be..3c0e294b9 100644 --- a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/introspect/TestAnnotationPriority.java +++ b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/introspect/TestAnnotationPriority.java @@ -2,9 +2,13 @@ import javax.xml.bind.annotation.XmlElement; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.module.jaxb.BaseJaxbTest; +import static org.junit.jupiter.api.Assertions.*; + /** * Unit test(s) to verify that annotations from super classes and * interfaces are properly used (for example, wrt [JACKSON-450]) @@ -48,6 +52,7 @@ static class IdBean extends IdBase implements Identifiable { /********************************************************** */ + @Test public void testInterfacesAndClasses() throws Exception { ObjectMapper mapper = getJaxbMapper(); diff --git a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/introspect/TestIntrospectorPair.java b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/introspect/TestIntrospectorPair.java index 66006a312..1c58a01be 100644 --- a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/introspect/TestIntrospectorPair.java +++ b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/introspect/TestIntrospectorPair.java @@ -4,6 +4,8 @@ import javax.xml.bind.annotation.*; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.annotation.*; import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.introspect.AnnotatedClassResolver; @@ -14,6 +16,8 @@ import com.fasterxml.jackson.module.jaxb.BaseJaxbTest; import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector; +import static org.junit.jupiter.api.Assertions.*; + /** * Simple testing that AnnotationIntrospector.Pair works as * expected, when used with Jackson and JAXB-based introspector. @@ -115,6 +119,7 @@ public CreatorBean(@JsonProperty("name") String name) { /********************************************************** */ + @Test public void testSimple() throws Exception { ObjectMapper mapper; @@ -145,6 +150,7 @@ public void testSimple() throws Exception assertEquals("3", result.get("bothJaxb")); } + @Test public void testNaming() throws Exception { ObjectMapper mapper; @@ -174,6 +180,7 @@ public void testNaming() throws Exception //assertEquals("123", result.get("jackson")); } + @Test public void testSimpleIgnore() throws Exception { // first: only Jackson introspector (default) @@ -210,6 +217,7 @@ public void testSimpleIgnore() throws Exception assertEquals(Boolean.TRUE, result.get("any")); } + @Test public void testSimpleFieldIgnore() throws Exception { ObjectMapper mapper; @@ -248,6 +256,7 @@ public void testSimpleFieldIgnore() throws Exception assertEquals(Boolean.TRUE, result.get("any")); } + @Test public void testRootName() throws Exception { // first: test with Jackson/Jaxb pair (jackson having precedence) @@ -280,6 +289,7 @@ public void testRootName() throws Exception * Test that will just use Jackson annotations, but did trigger [JACKSON-495] due to a bug * in JAXB annotation introspector. */ + @Test public void testIssue495() throws Exception { ObjectMapper mapper = new ObjectMapper(); diff --git a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/introspect/TestJaxbAnnotationIntrospector.java b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/introspect/TestJaxbAnnotationIntrospector.java index f5bfa9361..0d21554d1 100644 --- a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/introspect/TestJaxbAnnotationIntrospector.java +++ b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/introspect/TestJaxbAnnotationIntrospector.java @@ -7,6 +7,8 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import javax.xml.namespace.QName; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.introspect.AnnotatedClass; import com.fasterxml.jackson.databind.introspect.AnnotatedClassResolver; @@ -16,6 +18,8 @@ import com.fasterxml.jackson.module.jaxb.BaseJaxbTest; import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector; +import static org.junit.jupiter.api.Assertions.*; + /** * Tests for verifying that JAXB annotation based introspector * implementation works as expected @@ -213,6 +217,7 @@ public void setValue(String value) { private final ObjectMapper MAPPER = getJaxbMapper(); + @Test public void testDetection() throws Exception { Map result = writeAndMap(MAPPER, new SimpleBean()); @@ -231,6 +236,7 @@ public void testDetection() throws Exception /** * tests getting serializer/deserializer instances. */ + @Test public void testSerializeDeserializeWithJaxbAnnotations() throws Exception { ObjectMapper mapper = getJaxbMapperBuilder() @@ -278,6 +284,7 @@ public void testSerializeDeserializeWithJaxbAnnotations() throws Exception assertNull(readEx.propertyToIgnore); } + @Test public void testRootNameAccess() throws Exception { final TypeFactory tf = TypeFactory.defaultInstance(); @@ -301,6 +308,7 @@ public void testRootNameAccess() throws Exception } // JAXB can specify that properties are to be written in alphabetic order... + @Test public void testSerializationAlphaOrdering() throws Exception { assertEquals("{\"a\":1,\"b\":2,\"c\":3}", MAPPER.writeValueAsString(new AlphaBean())); @@ -312,6 +320,7 @@ public void testSerializationAlphaOrdering() throws Exception * * @since 2.1 */ + @Test public void testNamespaces() throws Exception { final TypeFactory tf = TypeFactory.defaultInstance(); diff --git a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/introspect/TestJaxbAutoDetect.java b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/introspect/TestJaxbAutoDetect.java index 5e7c79eb9..804273a38 100644 --- a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/introspect/TestJaxbAutoDetect.java +++ b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/introspect/TestJaxbAutoDetect.java @@ -6,6 +6,8 @@ import javax.xml.bind.annotation.*; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.introspect.AnnotationIntrospectorPair; import com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector; @@ -14,6 +16,8 @@ import com.fasterxml.jackson.module.jaxb.BaseJaxbTest; import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector; +import static org.junit.jupiter.api.Assertions.*; + /** * Tests for verifying auto-detection settings with JAXB annotations. * @@ -99,6 +103,7 @@ public DualAnnotationObjectMapper() { /********************************************************** */ + @Test public void testAutoDetectDisable() throws IOException { ObjectMapper mapper = getJaxbMapper(); @@ -121,6 +126,7 @@ public void testAutoDetectDisable() throws IOException assertEquals("b", result.get("b")); } + @Test public void testIssue246() throws IOException { ObjectMapper mapper = getJaxbMapper(); @@ -130,17 +136,19 @@ public void testIssue246() throws IOException } // [JACKSON-556] + @Test public void testJaxbAnnotatedObject() throws Exception { JaxbAnnotatedObject original = new JaxbAnnotatedObject("123"); ObjectMapper mapper = new DualAnnotationObjectMapper(); String json = mapper.writeValueAsString(original); - assertFalse("numberString field in JSON", json.contains("numberString")); // kinda hack-y :) + assertFalse(json.contains("numberString"), "numberString field in JSON"); // kinda hack-y :) JaxbAnnotatedObject result = mapper.readValue(json, JaxbAnnotatedObject.class); assertEquals(new BigDecimal("123"), result.number); } /* + @Test public void testJaxbAnnotatedObjectXML() throws Exception { JAXBContext ctxt = JAXBContext.newInstance(JaxbAnnotatedObject.class); diff --git a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/introspect/TestJaxbFieldAccess.java b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/introspect/TestJaxbFieldAccess.java index 5fc85b9f7..a17b4e890 100644 --- a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/introspect/TestJaxbFieldAccess.java +++ b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/introspect/TestJaxbFieldAccess.java @@ -8,6 +8,10 @@ import com.fasterxml.jackson.module.jaxb.BaseJaxbTest; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + public class TestJaxbFieldAccess extends BaseJaxbTest { /* @@ -31,6 +35,7 @@ public Fields() { } */ // Verify serialization wrt [JACKSON-202] + @Test public void testFieldSerialization() throws IOException { ObjectMapper mapper = getJaxbMapper(); @@ -38,6 +43,7 @@ public void testFieldSerialization() throws IOException } // Verify deserialization wrt [JACKSON-202] + @Test public void testFieldDeserialization() throws IOException { ObjectMapper mapper = getJaxbMapper(); diff --git a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/introspect/TestPropertyOrdering.java b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/introspect/TestPropertyOrdering.java index 17a347a9c..08db56cf1 100644 --- a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/introspect/TestPropertyOrdering.java +++ b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/introspect/TestPropertyOrdering.java @@ -5,6 +5,10 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.module.jaxb.BaseJaxbTest; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + public class TestPropertyOrdering extends BaseJaxbTest { @@ -59,6 +63,7 @@ public static class AlphaBean2 /********************************************************** */ + @Test public void testSerializationExplicitOrdering() throws Exception { ObjectMapper mapper = getJaxbMapper(); @@ -66,12 +71,14 @@ public void testSerializationExplicitOrdering() throws Exception } // Trying to reproduce [JACKSON-268] + @Test public void testOrderingWithRename() throws Exception { ObjectMapper mapper = getJaxbMapper(); assertEquals("{\"cparty\":\"dto\",\"contacts\":[1,2,3]}", mapper.writeValueAsString(new BeanFor268())); } + @Test public void testOrderingWithOriginalPropName() throws Exception { ObjectMapper mapper = getJaxbMapper(); diff --git a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/introspect/TestPropertyVisibility.java b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/introspect/TestPropertyVisibility.java index f73ff6647..6aefdcec0 100644 --- a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/introspect/TestPropertyVisibility.java +++ b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/introspect/TestPropertyVisibility.java @@ -4,11 +4,15 @@ import javax.xml.bind.annotation.*; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.module.jaxb.BaseJaxbTest; +import static org.junit.jupiter.api.Assertions.*; + public class TestPropertyVisibility extends BaseJaxbTest { @@ -84,12 +88,14 @@ public NoneAccessBean(Object o, Object b) { // Verify serialization wrt [JACKSON-354] // // NOTE: fails currently because we use Bean Introspector which only sees public methods -- need to rewrite + @Test public void testJackson354Serialization() throws IOException { assertEquals("{\"name\":\"foo\"}", MAPPER.writeValueAsString(new Bean354())); } // For [JACKSON-539] + @Test public void testJacksonSerialization() throws Exception { @@ -110,6 +116,7 @@ public void testJacksonSerialization() } // for [modules-base#44] + @Test public void testNoneAccessWithXmlElements() throws Exception { NoneAccessBean input = new NoneAccessBean(new Foo44()); diff --git a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/introspect/TestXmlValue.java b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/introspect/TestXmlValue.java index 9b440492d..385e0dc36 100644 --- a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/introspect/TestXmlValue.java +++ b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/introspect/TestXmlValue.java @@ -4,10 +4,14 @@ import javax.xml.bind.annotation.*; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.module.jaxb.BaseJaxbTest; +import static org.junit.jupiter.api.Assertions.*; + public class TestXmlValue extends BaseJaxbTest { static class WithXmlValueNoOverride @@ -48,6 +52,7 @@ public void setQuery(final String pQuery) { */ // For [jaxb-annotations#30] + @Test public void testXmlValueDefault() throws IOException { ObjectMapper mapper = getJaxbAndJacksonMapper(); @@ -56,6 +61,7 @@ public void testXmlValueDefault() throws IOException } // For [jaxb-annotations#30] + @Test public void testXmlValueOverride() throws IOException { ObjectMapper mapper = getJaxbAndJacksonMapper(); @@ -64,6 +70,7 @@ public void testXmlValueOverride() throws IOException } // For [jaxb-annotations#31] + @Test public void testXmlValueDefault2() throws IOException { ObjectMapper mapper = getJaxbAndJacksonMapper(); diff --git a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/misc/TestDeserializerCaching.java b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/misc/TestDeserializerCaching.java index 54c1fcb42..d54dc209b 100644 --- a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/misc/TestDeserializerCaching.java +++ b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/misc/TestDeserializerCaching.java @@ -1,5 +1,7 @@ package com.fasterxml.jackson.module.jaxb.misc; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.core.*; import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.deser.BeanDeserializer; @@ -7,6 +9,8 @@ import com.fasterxml.jackson.module.jaxb.BaseJaxbTest; +import static org.junit.jupiter.api.Assertions.*; + /** * Unit test(s) for [JACKSON-472] */ @@ -74,6 +78,7 @@ public JsonDeserializer modifyDeserializer(DeserializationConfig config, /********************************************************** */ + @Test public void testCaching() throws Exception { final String JSON = "{\"value1\" : {\"name\" : \"fruit\", \"value\" : \"apple\"},\n" diff --git a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/misc/TestDomElementSerialization.java b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/misc/TestDomElementSerialization.java index df32d9bb7..561e3adb5 100644 --- a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/misc/TestDomElementSerialization.java +++ b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/misc/TestDomElementSerialization.java @@ -7,6 +7,8 @@ import java.io.ByteArrayInputStream; import java.io.StringWriter; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.core.Version; import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.module.SimpleModule; @@ -14,6 +16,8 @@ import com.fasterxml.jackson.module.jaxb.BaseJaxbTest; +import static org.junit.jupiter.api.Assertions.*; + /** * @author Ryan Heaton */ @@ -66,6 +70,7 @@ public JsonSerializer findSerializer(SerializationConfig config, /********************************************************** */ + @Test public void testBasicDomElementSerializationDeserialization() throws Exception { ObjectMapper mapper = new ObjectMapper(); diff --git a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/misc/TestElementWrapper.java b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/misc/TestElementWrapper.java index fbaf7dd36..14ac28855 100644 --- a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/misc/TestElementWrapper.java +++ b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/misc/TestElementWrapper.java @@ -2,6 +2,8 @@ import java.util.*; +import org.junit.jupiter.api.Test; + import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElementWrapper; @@ -9,6 +11,8 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.module.jaxb.BaseJaxbTest; +import static org.junit.jupiter.api.Assertions.*; + /** * Unit tests to verify handling of @XmlElementWrapper annotation. */ @@ -75,6 +79,7 @@ public Bean25(int... v0) { */ // [JACKSON-436] + @Test public void testWrapperWithCollection() throws Exception { ObjectMapper mapper = getJaxbMapperBuilder() @@ -100,6 +105,7 @@ public void testWrapperWithCollection() throws Exception } // [Issue#13] + @Test public void testWrapperRenaming() throws Exception { ObjectMapper mapper = getJaxbMapper(); @@ -116,6 +122,7 @@ public void testWrapperRenaming() throws Exception } // [Issue#25] + @Test public void testWrapperDefaultName() throws Exception { ObjectMapper mapper = getJaxbMapper(); diff --git a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/misc/TestEnums.java b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/misc/TestEnums.java index e117b9bf9..dff06963c 100644 --- a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/misc/TestEnums.java +++ b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/misc/TestEnums.java @@ -2,9 +2,13 @@ import javax.xml.bind.annotation.*; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.module.jaxb.BaseJaxbTest; +import static org.junit.jupiter.api.Assertions.*; + public class TestEnums extends BaseJaxbTest { enum Plain { A, B; } @@ -21,6 +25,7 @@ enum Numeric { A, B; } private final ObjectMapper MAPPER = getJaxbMapper(); // [JACKSON-436] + @Test public void testWrapperWithCollection() throws Exception { assertEquals("\"B\"", MAPPER.writeValueAsString(Plain.B)); diff --git a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/misc/TestJaxbNullProperties.java b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/misc/TestJaxbNullProperties.java index d684df7f4..69c83a614 100644 --- a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/misc/TestJaxbNullProperties.java +++ b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/misc/TestJaxbNullProperties.java @@ -3,12 +3,16 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.module.jaxb.BaseJaxbTest; import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector; import com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule; +import static org.junit.jupiter.api.Assertions.*; + /** * Unit tests to ensure that handling of writing of null properties (or not) * works when using JAXB annotation introspector. @@ -65,6 +69,7 @@ public NonNillableZ(int i) { private final ObjectMapper MAPPER = getJaxbMapper(); + @Test public void testWriteNulls() throws Exception { BeanWithNillable bean = new BeanWithNillable(); @@ -72,6 +77,7 @@ public void testWriteNulls() throws Exception assertEquals("{\"X\":{\"Z\":null}}", MAPPER.writeValueAsString(bean)); } + @Test public void testNullProps() throws Exception { ObjectMapper mapper = getJaxbMapper(); @@ -79,6 +85,7 @@ public void testNullProps() throws Exception assertEquals("{\"x\":\"y\"}", mapper.writeValueAsString(new Bean())); } + @Test public void testNillability() throws Exception { ObjectMapper mapper = getJaxbMapper(); diff --git a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/misc/TestRootName.java b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/misc/TestRootName.java index 98fed5532..d48502af0 100644 --- a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/misc/TestRootName.java +++ b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/misc/TestRootName.java @@ -2,11 +2,15 @@ import javax.xml.bind.annotation.XmlRootElement; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.module.jaxb.BaseJaxbTest; +import static org.junit.jupiter.api.Assertions.*; + public class TestRootName extends BaseJaxbTest { /* @@ -27,6 +31,7 @@ static class MyType /********************************************************** */ + @Test public void testRootName() throws Exception { ObjectMapper mapper = getJaxbMapper(); diff --git a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/misc/TestSchemaGeneration.java b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/misc/TestSchemaGeneration.java index 513ae1997..d93dc58b3 100644 --- a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/misc/TestSchemaGeneration.java +++ b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/misc/TestSchemaGeneration.java @@ -2,12 +2,16 @@ import javax.xml.bind.annotation.*; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.jsonschema.JsonSchema; import com.fasterxml.jackson.module.jaxb.BaseJaxbTest; +import static org.junit.jupiter.api.Assertions.*; + /** * Test(s) to see that JAXB annotations-based information is properly * accessible and used by JSON Schema generation @@ -55,6 +59,7 @@ protected static class Address implements IAddress { * * @since 1.7 */ + @Test public void testWithJaxb() throws Exception { ObjectMapper mapper = getJaxbMapper(); @@ -62,8 +67,8 @@ public void testWithJaxb() throws Exception ObjectNode root = jsonSchema.getSchemaNode(); // should find two properties ("city", "state"), not just one... JsonNode itemsNode = root.findValue("properties"); - assertNotNull("Missing 'state' field", itemsNode.get("state")); - assertNotNull("Missing 'city' field", itemsNode.get("city")); + assertNotNull(itemsNode.get("state"), "Missing 'state' field"); + assertNotNull(itemsNode.get("city"), "Missing 'city' field"); assertEquals(2, itemsNode.size()); } } diff --git a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/misc/TestSerializationInclusion.java b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/misc/TestSerializationInclusion.java index 95a6592b9..f6d3b9095 100644 --- a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/misc/TestSerializationInclusion.java +++ b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/misc/TestSerializationInclusion.java @@ -4,11 +4,15 @@ import javax.xml.bind.annotation.XmlElement; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.module.jaxb.BaseJaxbTest; import com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule; +import static org.junit.jupiter.api.Assertions.*; + public class TestSerializationInclusion extends BaseJaxbTest { static class Data { @@ -20,6 +24,7 @@ public List getStuff() { } } + @Test public void testIssue39() throws Exception { // First: use plain JAXB introspector: diff --git a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/misc/TestXmlAnyElementWithElementRef.java b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/misc/TestXmlAnyElementWithElementRef.java index 55731622f..31dc328fd 100644 --- a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/misc/TestXmlAnyElementWithElementRef.java +++ b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/misc/TestXmlAnyElementWithElementRef.java @@ -4,9 +4,13 @@ import javax.xml.bind.annotation.*; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.module.jaxb.BaseJaxbTest; +import static org.junit.jupiter.api.Assertions.*; + public class TestXmlAnyElementWithElementRef extends BaseJaxbTest { @@ -40,6 +44,7 @@ static class Count { */ // [JACKSON-254]: verify that things do work + @Test public void testXmlAnyElementWithElementRef() throws Exception { ObjectMapper mapper = getJaxbMapper(); diff --git a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/ser/TestVirtualProperties.java b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/ser/TestVirtualProperties.java index 2beed4837..ebb7f1dc8 100644 --- a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/ser/TestVirtualProperties.java +++ b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/ser/TestVirtualProperties.java @@ -2,6 +2,10 @@ import java.util.*; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.*; @@ -92,6 +96,7 @@ static class CustomVBean private final ObjectWriter WRITER = newObjectMapper().writer(); + @Test public void testAttributeProperties() throws Exception { Map stuff = new LinkedHashMap(); @@ -109,6 +114,7 @@ public void testAttributeProperties() throws Exception assertEquals(a2q("{'id':'abc123','extra':{'x':3,'y':'B'},'value':13}"), json); } + @Test public void testAttributePropInclusion() throws Exception { // first, with desc @@ -126,6 +132,7 @@ public void testAttributePropInclusion() throws Exception assertEquals(a2q("{'value':28}"), json); } + @Test public void testCustomProperties() throws Exception { String json = WRITER.withAttribute("desc", "nice") diff --git a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/types/OptionalTypeRefinementTest.java b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/types/OptionalTypeRefinementTest.java index 9b313de53..3310d19ec 100644 --- a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/types/OptionalTypeRefinementTest.java +++ b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/types/OptionalTypeRefinementTest.java @@ -2,9 +2,13 @@ import java.util.concurrent.atomic.AtomicReference; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.module.jaxb.BaseJaxbTest; +import static org.junit.jupiter.api.Assertions.*; + // [jaxb-annotations#63] public class OptionalTypeRefinementTest extends BaseJaxbTest { @@ -12,6 +16,7 @@ static class Stuff63 { public AtomicReference value = new AtomicReference("abc"); } + @Test public void testWithReferenceType() throws Exception { final ObjectMapper mapper = getJaxbMapper(); diff --git a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/types/TestCyclicTypes.java b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/types/TestCyclicTypes.java index 9454eeba1..3dd50f52f 100644 --- a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/types/TestCyclicTypes.java +++ b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/types/TestCyclicTypes.java @@ -4,10 +4,14 @@ import javax.xml.bind.annotation.*; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.module.jaxb.BaseJaxbTest; +import static org.junit.jupiter.api.Assertions.*; + /** * Simple unit tests to verify that it is possible to handle * potentially cyclic structures, as long as object graph itself @@ -49,6 +53,7 @@ public Bean(Bean next, String name) { /* Added to check for [JACKSON-171], i.e. that type its being * cyclic is not a problem (instances are). */ + @Test public void testWithJAXB() throws Exception { ObjectMapper mapper = getJaxbMapper(); diff --git a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/types/TestJaxbPolymorphic.java b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/types/TestJaxbPolymorphic.java index 76bff2d0b..a11ce054f 100644 --- a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/types/TestJaxbPolymorphic.java +++ b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/types/TestJaxbPolymorphic.java @@ -12,6 +12,10 @@ * @author Tatu Saloranta * @author Ryan Heaton */ +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + public class TestJaxbPolymorphic extends PolymorpicTestBase { @@ -89,6 +93,7 @@ static class ContainerForBase //First a simple test with non-collection field @SuppressWarnings("unchecked") + @Test public void testSinglePolymorphic() throws Exception { Bean input = new Bean(new Buffalo("Billy", "brown")); @@ -113,7 +118,8 @@ public void testSinglePolymorphic() throws Exception assertEquals("brown", ((Buffalo) a).hairColor); } - public void testPolymorphicArray() throws Exception + @Test + public void testPolymorphicArray() throws Exception { Animal a1 = new Buffalo("Bill", "grey"); Animal a2 = new Whale("moe", 3000); @@ -135,7 +141,8 @@ public void testPolymorphicArray() throws Exception assertEquals(3000, ((Whale)a2).weightInTons); } - public void testPolymorphicArrayElementRef() throws Exception + @Test + public void testPolymorphicArrayElementRef() throws Exception { Animal a1 = new Emu("Bill", "grey"); Animal a2 = new Cow("moe", 3000); @@ -159,7 +166,8 @@ public void testPolymorphicArrayElementRef() throws Exception } // For [Issue#1] - public void testXmlSeeAlso() throws Exception + @Test + public void testXmlSeeAlso() throws Exception { ContainerForBase input = new ContainerForBase(); input.stuff = new Base[] { new BaseImpl("xyz") }; diff --git a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/types/TestJaxbPolymorphicLists.java b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/types/TestJaxbPolymorphicLists.java index 419092194..fe0e5c734 100644 --- a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/types/TestJaxbPolymorphicLists.java +++ b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/types/TestJaxbPolymorphicLists.java @@ -10,6 +10,10 @@ * Tests for handling of type-related JAXB annotations with collection (List) * types. */ +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + public class TestJaxbPolymorphicLists extends PolymorpicTestBase { @@ -60,7 +64,8 @@ static class ShortListHolder { /** * And then a test for collection types */ - public void testPolymorphicList() throws Exception + @Test + public void testPolymorphicList() throws Exception { ObjectMapper mapper = getJaxbMapper(); ListBean input = new ListBean(new Whale("bluey", 150), @@ -85,7 +90,8 @@ public void testPolymorphicList() throws Exception /** * And then a test for collection types using element ref(s) */ - public void testPolymorphicListElementRef() throws Exception + @Test + public void testPolymorphicListElementRef() throws Exception { ObjectMapper mapper = getJaxbMapper(); ListBean input = new ListBean(); @@ -110,7 +116,8 @@ public void testPolymorphicListElementRef() throws Exception } // [JACKSON-348] - public void testShortList() throws Exception + @Test + public void testShortList() throws Exception { ShortListHolder holder = getJaxbMapper().readValue("{\"id\":[1,2,3]}", ShortListHolder.class); diff --git a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/types/TestJaxbPolymorphicMaps.java b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/types/TestJaxbPolymorphicMaps.java index b3568f323..ea1edf0bc 100644 --- a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/types/TestJaxbPolymorphicMaps.java +++ b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/types/TestJaxbPolymorphicMaps.java @@ -9,6 +9,10 @@ /** * Tests for handling of type-related JAXB annotations */ +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + public class TestJaxbPolymorphicMaps extends PolymorpicTestBase { @@ -47,6 +51,7 @@ public MapBean() { /********************************************************** */ + @Test public void testPolymorphicMap() throws Exception { ObjectMapper mapper = getJaxbMapper(); @@ -66,6 +71,7 @@ public void testPolymorphicMap() throws Exception assertEquals("Pena", ((Whale) map.get(Integer.valueOf(3))).nickname); } + @Test public void testPolymorphicMapElementRefs() throws Exception { ObjectMapper mapper = getJaxbMapper(); diff --git a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/types/TestJaxbTypeCoercion1023.java b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/types/TestJaxbTypeCoercion1023.java index 6b49fd201..0a36243ec 100644 --- a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/types/TestJaxbTypeCoercion1023.java +++ b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/types/TestJaxbTypeCoercion1023.java @@ -6,6 +6,10 @@ import com.fasterxml.jackson.module.jaxb.BaseJaxbTest; // Failing temporarily due to [databind#1023] +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + public class TestJaxbTypeCoercion1023 extends BaseJaxbTest { /* @@ -39,6 +43,7 @@ static class Jackson416Sub extends Jackson416Base /********************************************************** */ + @Test public void testIssue416() throws Exception { ObjectMapper mapper = getJaxbAndJacksonMapper(); diff --git a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/types/TestJaxbTypes.java b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/types/TestJaxbTypes.java index 2031f014b..64c591ab5 100644 --- a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/types/TestJaxbTypes.java +++ b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/types/TestJaxbTypes.java @@ -13,6 +13,10 @@ /** * Tests for handling of type-related JAXB annotations */ +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + public class TestJaxbTypes extends BaseJaxbTest { @@ -110,6 +114,7 @@ public P2() { } /********************************************************** */ + @Test public void testXmlElementTypeDeser() throws Exception { ObjectMapper mapper = getJaxbMapper(); @@ -120,6 +125,7 @@ public void testXmlElementTypeDeser() throws Exception assertEquals("...", bean.b); } + @Test public void testXmlElementTypeSer() throws Exception { ObjectMapper mapper = getJaxbAndJacksonMapper(); @@ -128,6 +134,7 @@ public void testXmlElementTypeSer() throws Exception mapper.writeValueAsString(wrapper)); } + @Test public void testXmlElementListTypeDeser() throws Exception { ObjectMapper mapper = getJaxbMapper(); @@ -150,6 +157,7 @@ public void testXmlElementListTypeDeser() throws Exception assertEquals("b", bean.b); } + @Test public void testXmlElementListArrayDeser() throws Exception { ObjectMapper mapper = getJaxbMapper(); @@ -169,6 +177,7 @@ public void testXmlElementListArrayDeser() throws Exception assertEquals("b", bean.b); } + @Test public void testXmlElementListTypeSer() throws Exception { // important: Jackson mapper so we can force ordering @@ -183,6 +192,7 @@ public void testXmlElementListTypeSer() throws Exception mapper.writeValueAsString(bean)); } + @Test public void testRoundTrip() throws Exception { ComboBean input = new ComboBean(new BeanImpl(3, "abc"), @@ -206,6 +216,7 @@ public void testRoundTrip() throws Exception assertEquals("c", (result.beans.get(2)).b); } + @Test public void testListWithDefaultTyping() throws Exception { Object input = new ListBean(new BeanImpl(1, "a")); @@ -225,6 +236,7 @@ public void testListWithDefaultTyping() throws Exception assertEquals("a", bean.b); } + @Test public void testIssue250() throws Exception { ObjectMapper mapper = getJaxbAndJacksonMapper(); diff --git a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/types/XmlSeeAlsoForSubtypes195Test.java b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/types/XmlSeeAlsoForSubtypes195Test.java index 517fe91f3..c754441a7 100644 --- a/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/types/XmlSeeAlsoForSubtypes195Test.java +++ b/jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/types/XmlSeeAlsoForSubtypes195Test.java @@ -10,6 +10,10 @@ import com.fasterxml.jackson.module.jaxb.BaseJaxbTest; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + public class XmlSeeAlsoForSubtypes195Test extends BaseJaxbTest { @@ -38,6 +42,7 @@ static class Sub195B extends Base195 { } private final ObjectMapper MAPPER = getJaxbAndJacksonMapper(); // [modules-base#195] + @Test public void testXmlSeeAlso195() throws Exception { String json = MAPPER.writeValueAsString(new Root195(new Sub195B())); From b3275377da4cea7b767646b6bb9ec10a77344934 Mon Sep 17 00:00:00 2001 From: "Kim, Joo Hyuk" Date: Sun, 19 Jan 2025 09:25:11 +0900 Subject: [PATCH 4/4] Migrate `jakarta-xmlbind` module tests to JUnit 5 (#277) --- jakarta-xmlbind/pom.xml | 9 +++++++-- .../module/jakarta/xmlbind/ModuleTestBase.java | 1 - .../module/jakarta/xmlbind/TestVersions.java | 6 +++++- .../module/jakarta/xmlbind/adapters/EntryType.java | 3 +++ .../jakarta/xmlbind/adapters/MapAdapter.java | 3 +++ .../module/jakarta/xmlbind/adapters/MapType.java | 3 +++ .../xmlbind/adapters/TestAdaptedMapType.java | 6 ++++++ .../jakarta/xmlbind/adapters/TestAdapters.java | 8 ++++++++ .../adapters/TestAdaptersForContainers.java | 9 +++++++++ .../xmlbind/adapters/TestIdentityAdapters.java | 6 ++++++ .../jakarta/xmlbind/failing/TestUnwrapping.java | 5 +++++ .../module/jakarta/xmlbind/failing/TestXmlID3.java | 5 +++++ .../module/jakarta/xmlbind/id/TestXmlID.java | 5 +++++ .../module/jakarta/xmlbind/id/TestXmlID2.java | 6 ++++++ .../JakartaXmlBindAnnotationIntrospectorTest.java | 9 +++++++++ .../introspect/JakartaXmlBindAutoDetectTest.java | 10 +++++++++- .../introspect/JakartaXmlBindFieldAccessTest.java | 6 ++++++ .../jakarta/xmlbind/introspect/TestAccessType.java | 13 ++++++++++--- .../xmlbind/introspect/TestAnnotationPriority.java | 4 ++++ .../xmlbind/introspect/TestIntrospectorPair.java | 10 ++++++++++ .../xmlbind/introspect/TestPropertyOrdering.java | 7 +++++++ .../xmlbind/introspect/TestPropertyVisibility.java | 7 +++++++ .../jakarta/xmlbind/introspect/TestXmlValue.java | 7 +++++++ .../jakarta/xmlbind/misc/NullPropertiesTest.java | 7 +++++++ .../xmlbind/misc/TestDeserializerCaching.java | 5 +++++ .../jakarta/xmlbind/misc/TestElementWrapper.java | 7 +++++++ .../module/jakarta/xmlbind/misc/TestEnums.java | 5 +++++ .../module/jakarta/xmlbind/misc/TestRootName.java | 5 +++++ .../jakarta/xmlbind/misc/TestSchemaGeneration.java | 9 +++++++-- .../xmlbind/misc/TestSerializationInclusion.java | 5 +++++ .../misc/TestXmlAnyElementWithElementRef.java | 5 +++++ .../jakarta/xmlbind/ser/TestVirtualProperties.java | 7 +++++++ .../xmlbind/types/OptionalTypeRefinementTest.java | 5 +++++ .../jakarta/xmlbind/types/TestCyclicTypes.java | 5 +++++ .../jakarta/xmlbind/types/TestJaxbPolymorphic.java | 14 +++++++++++--- .../xmlbind/types/TestJaxbPolymorphicLists.java | 13 ++++++++++--- .../xmlbind/types/TestJaxbPolymorphicMaps.java | 6 ++++++ .../xmlbind/types/TestJaxbTypeCoercion1023.java | 5 +++++ .../jakarta/xmlbind/types/TestJaxbTypes.java | 12 ++++++++++++ .../types/XmlSeeAlsoForSubtypes195Test.java | 5 +++++ 40 files changed, 252 insertions(+), 16 deletions(-) diff --git a/jakarta-xmlbind/pom.xml b/jakarta-xmlbind/pom.xml index 71c6f4b65..7d02588c8 100644 --- a/jakarta-xmlbind/pom.xml +++ b/jakarta-xmlbind/pom.xml @@ -76,8 +76,13 @@ - junit - junit + org.junit.jupiter + junit-jupiter + test + + + org.junit.jupiter + junit-jupiter-api test diff --git a/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/ModuleTestBase.java b/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/ModuleTestBase.java index 9d595ee55..3a96ad2fa 100644 --- a/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/ModuleTestBase.java +++ b/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/ModuleTestBase.java @@ -12,7 +12,6 @@ import com.fasterxml.jackson.databind.jsontype.PolymorphicTypeValidator; public abstract class ModuleTestBase - extends junit.framework.TestCase { public static class NoCheckSubTypeValidator extends PolymorphicTypeValidator.Base diff --git a/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/TestVersions.java b/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/TestVersions.java index 66909fa04..0226ac004 100644 --- a/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/TestVersions.java +++ b/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/TestVersions.java @@ -5,8 +5,12 @@ import com.fasterxml.jackson.databind.type.TypeFactory; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; + public class TestVersions extends ModuleTestBase { + @Test public void testVersions() { assertVersion(new JakartaXmlBindAnnotationIntrospector(TypeFactory.defaultInstance())); @@ -21,7 +25,7 @@ public void testVersions() private void assertVersion(Versioned vers) { Version v = vers.version(); - assertFalse("Should find version information (got "+v+")", v.isUnknownVersion()); + assertFalse(v.isUnknownVersion(), "Should find version information (got "+v+")"); Version exp = PackageVersion.VERSION; assertEquals(exp.toFullString(), v.toFullString()); assertEquals(exp, v); diff --git a/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/adapters/EntryType.java b/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/adapters/EntryType.java index 8cd95e74e..fe672d499 100644 --- a/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/adapters/EntryType.java +++ b/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/adapters/EntryType.java @@ -1,5 +1,8 @@ package com.fasterxml.jackson.module.jakarta.xmlbind.adapters; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; + public class EntryType { private K key; diff --git a/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/adapters/MapAdapter.java b/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/adapters/MapAdapter.java index cd45569a6..f997b9a7c 100644 --- a/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/adapters/MapAdapter.java +++ b/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/adapters/MapAdapter.java @@ -7,6 +7,9 @@ import jakarta.xml.bind.annotation.adapters.XmlAdapter; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; + public class MapAdapter extends XmlAdapter, Map> { @Override diff --git a/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/adapters/MapType.java b/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/adapters/MapType.java index 485ef9020..8373c9d47 100644 --- a/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/adapters/MapType.java +++ b/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/adapters/MapType.java @@ -2,6 +2,9 @@ import java.util.List; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; + public class MapType { public List> entries; diff --git a/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/adapters/TestAdaptedMapType.java b/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/adapters/TestAdaptedMapType.java index 9a27c31ab..8b1438236 100644 --- a/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/adapters/TestAdaptedMapType.java +++ b/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/adapters/TestAdaptedMapType.java @@ -6,10 +6,14 @@ import java.io.*; import java.util.*; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.module.jakarta.xmlbind.ModuleTestBase; +import static org.junit.jupiter.api.Assertions.*; + /** * Tests for verifying JAXB adapter handling for {@link java.util.Map} * types. @@ -64,6 +68,7 @@ public Map unmarshal(Map input) /********************************************************** */ + @Test public void testJacksonAdaptedMapType() throws IOException { ObjectContainingAMap obj = new ObjectContainingAMap(); @@ -83,6 +88,7 @@ public void testJacksonAdaptedMapType() throws IOException assertEquals("here", map.get("how")); } + @Test public void testStringMaps() throws IOException { ObjectMapper mapper = getJaxbMapper(); diff --git a/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/adapters/TestAdapters.java b/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/adapters/TestAdapters.java index fa9fe7b7f..df11a1c95 100644 --- a/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/adapters/TestAdapters.java +++ b/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/adapters/TestAdapters.java @@ -7,10 +7,14 @@ import jakarta.xml.bind.annotation.adapters.XmlAdapter; import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.module.jakarta.xmlbind.ModuleTestBase; +import static org.junit.jupiter.api.Assertions.*; + /** * Unit tests for checking that JAXB type adapters work (to some * degree, anyway). @@ -163,12 +167,14 @@ public IdentityAdapterPropertyBean() { } /********************************************************** */ + @Test public void testSimpleAdapterSerialization() throws Exception { Bean bean = new Bean(123L); assertEquals("{\"value\":\"XXX\"}", getJaxbMapper().writeValueAsString(bean)); } + @Test public void testSimpleAdapterDeserialization() throws Exception { Bean bean = getJaxbMapper().readValue("{\"value\":\"abc\"}", Bean.class); @@ -177,6 +183,7 @@ public void testSimpleAdapterDeserialization() throws Exception } // [JACKSON-288] + @Test public void testDateAdapter() throws Exception { Bean288 input = new Bean288("test"); @@ -188,6 +195,7 @@ public void testDateAdapter() throws Exception // [JACKSON-656] + @Test public void testJackson656() throws Exception { Bean656 bean = new Bean656(); diff --git a/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/adapters/TestAdaptersForContainers.java b/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/adapters/TestAdaptersForContainers.java index 53c391d07..6bb4e851c 100644 --- a/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/adapters/TestAdaptersForContainers.java +++ b/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/adapters/TestAdaptersForContainers.java @@ -6,12 +6,16 @@ import jakarta.xml.bind.annotation.*; import jakarta.xml.bind.annotation.adapters.*; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.module.jakarta.xmlbind.ModuleTestBase; import com.fasterxml.jackson.module.jakarta.xmlbind.introspect.JakartaXmlBindAnnotationIntrospectorTest.KeyValuePair; +import static org.junit.jupiter.api.Assertions.*; + /** * Unit tests to check that {@link XmlAdapter}s also work with * container types (Lists, Maps) @@ -113,12 +117,14 @@ public void setValues(List values) { /********************************************************** */ + @Test public void testAdapterForList() throws Exception { Wrapper w = new Wrapper(123L); assertEquals("{\"values\":[\"XXX\"]}", getJaxbMapper().writeValueAsString(w)); } + @Test public void testSimpleAdapterDeserialization() throws Exception { Wrapper w = getJaxbMapper().readValue("{\"values\":[\"abc\"]}", Wrapper.class); @@ -128,12 +134,14 @@ public void testSimpleAdapterDeserialization() throws Exception assertEquals(29L, w.values.get(0).getTime()); } + @Test public void testAdapterOnGetterSerialization() throws Exception { WrapperWithGetterAndSetter w = new WrapperWithGetterAndSetter(123L); assertEquals("{\"values\":[\"XXX\"]}", getJaxbMapper().writeValueAsString(w)); } + @Test public void testAdapterOnGetterDeserialization() throws Exception { WrapperWithGetterAndSetter w = getJaxbMapper().readValue("{\"values\":[\"abc\"]}", @@ -150,6 +158,7 @@ public void testAdapterOnGetterDeserialization() throws Exception /********************************************************** */ + @Test public void testAdapterForBeanWithMap() throws Exception { ObjectMapper mapper = getJaxbMapper(); diff --git a/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/adapters/TestIdentityAdapters.java b/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/adapters/TestIdentityAdapters.java index 2f9005765..329160861 100644 --- a/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/adapters/TestIdentityAdapters.java +++ b/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/adapters/TestIdentityAdapters.java @@ -3,10 +3,14 @@ import jakarta.xml.bind.annotation.adapters.XmlAdapter; import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.module.jakarta.xmlbind.ModuleTestBase; +import static org.junit.jupiter.api.Assertions.*; + /** * Failing unit tests related to Adapter handling. */ @@ -61,6 +65,7 @@ public IdentityAdapterPropertyBean() { } */ // [Issue-10] + @Test public void testIdentityAdapterForClass() throws Exception { IdentityAdapterBean input = new IdentityAdapterBean("A"); @@ -74,6 +79,7 @@ public void testIdentityAdapterForClass() throws Exception } // [Issue-10] + @Test public void testIdentityAdapterForProperty() throws Exception { IdentityAdapterPropertyBean input = new IdentityAdapterPropertyBean("B"); diff --git a/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/failing/TestUnwrapping.java b/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/failing/TestUnwrapping.java index e60fb07ff..1b6e2a2f2 100644 --- a/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/failing/TestUnwrapping.java +++ b/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/failing/TestUnwrapping.java @@ -2,6 +2,8 @@ import jakarta.xml.bind.annotation.*; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.annotation.JsonUnwrapped; import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.introspect.AnnotationIntrospectorPair; @@ -11,6 +13,8 @@ import com.fasterxml.jackson.module.jakarta.xmlbind.ModuleTestBase; +import static org.junit.jupiter.api.Assertions.*; + public class TestUnwrapping extends ModuleTestBase { @XmlRootElement @@ -53,6 +57,7 @@ public B(String type) { */ // not asserting anything + @Test public void testXmlElementAndXmlElementRefs() throws Exception { Bean bean = new Bean(); diff --git a/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/failing/TestXmlID3.java b/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/failing/TestXmlID3.java index 601ff0d37..b3fa1632a 100644 --- a/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/failing/TestXmlID3.java +++ b/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/failing/TestXmlID3.java @@ -6,10 +6,14 @@ import jakarta.xml.bind.annotation.XmlElement; import jakarta.xml.bind.annotation.XmlID; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.module.jakarta.xmlbind.ModuleTestBase; +import static org.junit.jupiter.api.Assertions.*; + // for [modules-base#46]: XmlId semantics can not be supported by Jackson/JAXB-annotation-mapper public class TestXmlID3 extends ModuleTestBase { @@ -46,6 +50,7 @@ static class HasIDList public HasID getParent() { return parent; } } + @Test public void testIssue46() throws Exception { ObjectMapper mapper = getJaxbAndJacksonMapper(); diff --git a/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/id/TestXmlID.java b/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/id/TestXmlID.java index 34913d0f7..db7949df2 100644 --- a/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/id/TestXmlID.java +++ b/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/id/TestXmlID.java @@ -4,10 +4,14 @@ import jakarta.xml.bind.annotation.*; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.module.jakarta.xmlbind.ModuleTestBase; +import static org.junit.jupiter.api.Assertions.*; + /** * Simple testing to verify that XmlID and XMLIDREF handling works * to degree we can make it work. @@ -56,6 +60,7 @@ public Employee() { /********************************************************** */ + @Test public void testSimpleRefs() throws Exception { final ObjectMapper mapper = getJaxbMapper(); diff --git a/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/id/TestXmlID2.java b/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/id/TestXmlID2.java index 4436ec66d..1411c771b 100644 --- a/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/id/TestXmlID2.java +++ b/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/id/TestXmlID2.java @@ -4,6 +4,8 @@ import jakarta.xml.bind.annotation.*; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.core.type.TypeReference; @@ -14,6 +16,8 @@ import com.fasterxml.jackson.module.jakarta.xmlbind.ModuleTestBase; +import static org.junit.jupiter.api.Assertions.*; + public class TestXmlID2 extends ModuleTestBase { @XmlRootElement(name = "department") @@ -114,6 +118,7 @@ private List getUserList() return resultList; } + @Test public void testIdWithJacksonRules() throws Exception { String expected = "[{\"id\":11,\"username\":\"11\",\"email\":\"11@test.com\"," @@ -138,6 +143,7 @@ public void testIdWithJacksonRules() throws Exception assertEquals(Long.valueOf(33), result.get(2).id); } + @Test public void testIdWithJaxbRules() throws Exception { ObjectMapper mapper = JsonMapper.builder() diff --git a/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/introspect/JakartaXmlBindAnnotationIntrospectorTest.java b/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/introspect/JakartaXmlBindAnnotationIntrospectorTest.java index a5b8edd44..ce02e6d01 100644 --- a/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/introspect/JakartaXmlBindAnnotationIntrospectorTest.java +++ b/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/introspect/JakartaXmlBindAnnotationIntrospectorTest.java @@ -8,6 +8,8 @@ import javax.xml.namespace.QName; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.introspect.AnnotatedClass; import com.fasterxml.jackson.databind.introspect.AnnotatedClassResolver; @@ -18,6 +20,8 @@ import com.fasterxml.jackson.module.jakarta.xmlbind.ModuleTestBase; +import static org.junit.jupiter.api.Assertions.*; + /** * Tests for verifying that JAXB annotation based introspector * implementation works as expected @@ -212,6 +216,7 @@ public void setValue(String value) { private final ObjectMapper MAPPER = getJaxbMapper(); + @Test public void testDetection() throws Exception { Map result = writeAndMap(MAPPER, new SimpleBean()); @@ -230,6 +235,7 @@ public void testDetection() throws Exception /** * tests getting serializer/deserializer instances. */ + @Test public void testSerializeDeserializeWithJaxbAnnotations() throws Exception { ObjectMapper mapper = getJaxbMapperBuilder() @@ -277,6 +283,7 @@ public void testSerializeDeserializeWithJaxbAnnotations() throws Exception assertNull(readEx.propertyToIgnore); } + @Test public void testRootNameAccess() throws Exception { final TypeFactory tf = TypeFactory.defaultInstance(); @@ -300,6 +307,7 @@ public void testRootNameAccess() throws Exception } // JAXB can specify that properties are to be written in alphabetic order... + @Test public void testSerializationAlphaOrdering() throws Exception { assertEquals("{\"a\":1,\"b\":2,\"c\":3}", MAPPER.writeValueAsString(new AlphaBean())); @@ -311,6 +319,7 @@ public void testSerializationAlphaOrdering() throws Exception * * @since 2.1 */ + @Test public void testNamespaces() throws Exception { final TypeFactory tf = TypeFactory.defaultInstance(); diff --git a/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/introspect/JakartaXmlBindAutoDetectTest.java b/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/introspect/JakartaXmlBindAutoDetectTest.java index cad3327d6..4566b9e8d 100644 --- a/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/introspect/JakartaXmlBindAutoDetectTest.java +++ b/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/introspect/JakartaXmlBindAutoDetectTest.java @@ -6,6 +6,8 @@ import jakarta.xml.bind.annotation.*; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.introspect.AnnotationIntrospectorPair; import com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector; @@ -15,6 +17,8 @@ import com.fasterxml.jackson.module.jakarta.xmlbind.ModuleTestBase; +import static org.junit.jupiter.api.Assertions.*; + /** * Tests for verifying auto-detection settings with JAXB annotations. * @@ -100,6 +104,7 @@ public DualAnnotationObjectMapper() { /********************************************************** */ + @Test public void testAutoDetectDisable() throws IOException { ObjectMapper mapper = getJaxbMapper(); @@ -122,6 +127,7 @@ public void testAutoDetectDisable() throws IOException assertEquals("b", result.get("b")); } + @Test public void testIssue246() throws IOException { ObjectMapper mapper = getJaxbMapper(); @@ -131,17 +137,19 @@ public void testIssue246() throws IOException } // [JACKSON-556] + @Test public void testJaxbAnnotatedObject() throws Exception { JaxbAnnotatedObject original = new JaxbAnnotatedObject("123"); ObjectMapper mapper = new DualAnnotationObjectMapper(); String json = mapper.writeValueAsString(original); - assertFalse("numberString field in JSON", json.contains("numberString")); // kinda hack-y :) + assertFalse(json.contains("numberString"), "numberString field in JSON"); // kinda hack-y :) JaxbAnnotatedObject result = mapper.readValue(json, JaxbAnnotatedObject.class); assertEquals(new BigDecimal("123"), result.number); } /* + @Test public void testJaxbAnnotatedObjectXML() throws Exception { JAXBContext ctxt = JAXBContext.newInstance(JaxbAnnotatedObject.class); diff --git a/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/introspect/JakartaXmlBindFieldAccessTest.java b/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/introspect/JakartaXmlBindFieldAccessTest.java index 27fb2e843..13ec72205 100644 --- a/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/introspect/JakartaXmlBindFieldAccessTest.java +++ b/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/introspect/JakartaXmlBindFieldAccessTest.java @@ -4,10 +4,14 @@ import jakarta.xml.bind.annotation.*; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.module.jakarta.xmlbind.ModuleTestBase; +import static org.junit.jupiter.api.Assertions.*; + public class JakartaXmlBindFieldAccessTest extends ModuleTestBase { /* @@ -31,6 +35,7 @@ public Fields() { } */ // Verify serialization wrt [JACKSON-202] + @Test public void testFieldSerialization() throws IOException { ObjectMapper mapper = getJaxbMapper(); @@ -38,6 +43,7 @@ public void testFieldSerialization() throws IOException } // Verify deserialization wrt [JACKSON-202] + @Test public void testFieldDeserialization() throws IOException { ObjectMapper mapper = getJaxbMapper(); diff --git a/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/introspect/TestAccessType.java b/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/introspect/TestAccessType.java index 993417e6e..8968dfee7 100644 --- a/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/introspect/TestAccessType.java +++ b/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/introspect/TestAccessType.java @@ -6,10 +6,14 @@ import jakarta.xml.bind.annotation.adapters.XmlAdapter; import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.module.jakarta.xmlbind.ModuleTestBase; +import static org.junit.jupiter.api.Assertions.*; + /** * Unit test(s) written for [JACKSON-303]; we should be able to detect setter * even though it is not annotated, because there is matching annotated getter. @@ -75,7 +79,8 @@ public class Bean40 /********************************************************** */ - public void testXmlElementTypeDeser() throws Exception + @Test + public void testXmlElementTypeDeser() throws Exception { ObjectMapper mapper = getJaxbMapper(); @@ -93,7 +98,8 @@ public void testXmlElementTypeDeser() throws Exception } } - public void testForJackson288() throws Exception + @Test + public void testForJackson288() throws Exception { final long TIMESTAMP = 12345678L; ObjectMapper mapper = getJaxbMapper(); @@ -104,7 +110,8 @@ public void testForJackson288() throws Exception assertEquals(TIMESTAMP, d.getTime()); } - public void testInclusionIssue40() throws Exception + @Test + public void testInclusionIssue40() throws Exception { ObjectMapper mapper = getJaxbMapperBuilder() .enable(MapperFeature.USE_WRAPPER_NAME_AS_PROPERTY_NAME) diff --git a/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/introspect/TestAnnotationPriority.java b/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/introspect/TestAnnotationPriority.java index 70ef8e4f1..b353d8bd3 100644 --- a/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/introspect/TestAnnotationPriority.java +++ b/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/introspect/TestAnnotationPriority.java @@ -10,6 +10,9 @@ * Unit test(s) to verify that annotations from super classes and * interfaces are properly used (for example, wrt [JACKSON-450]) */ +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; + public class TestAnnotationPriority extends ModuleTestBase { /* @@ -49,6 +52,7 @@ static class IdBean extends IdBase implements Identifiable { /********************************************************** */ + @Test public void testInterfacesAndClasses() throws Exception { ObjectMapper mapper = getJaxbMapper(); diff --git a/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/introspect/TestIntrospectorPair.java b/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/introspect/TestIntrospectorPair.java index 4699ece9a..b06139782 100644 --- a/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/introspect/TestIntrospectorPair.java +++ b/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/introspect/TestIntrospectorPair.java @@ -8,6 +8,8 @@ import jakarta.xml.bind.annotation.XmlRootElement; import jakarta.xml.bind.annotation.XmlTransient; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.annotation.*; import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.introspect.AnnotatedClassResolver; @@ -19,6 +21,8 @@ import com.fasterxml.jackson.module.jakarta.xmlbind.ModuleTestBase; +import static org.junit.jupiter.api.Assertions.*; + /** * Simple testing that AnnotationIntrospector.Pair works as * expected, when used with Jackson and JAXB-based introspector. @@ -120,6 +124,7 @@ public CreatorBean(@JsonProperty("name") String name) { /********************************************************** */ + @Test public void testSimple() throws Exception { ObjectMapper mapper; @@ -150,6 +155,7 @@ public void testSimple() throws Exception assertEquals("3", result.get("bothJaxb")); } + @Test public void testNaming() throws Exception { ObjectMapper mapper; @@ -179,6 +185,7 @@ public void testNaming() throws Exception //assertEquals("123", result.get("jackson")); } + @Test public void testSimpleIgnore() throws Exception { // first: only Jackson introspector (default) @@ -215,6 +222,7 @@ public void testSimpleIgnore() throws Exception assertEquals(Boolean.TRUE, result.get("any")); } + @Test public void testSimpleFieldIgnore() throws Exception { ObjectMapper mapper; @@ -253,6 +261,7 @@ public void testSimpleFieldIgnore() throws Exception assertEquals(Boolean.TRUE, result.get("any")); } + @Test public void testRootName() throws Exception { // first: test with Jackson/Jaxb pair (jackson having precedence) @@ -285,6 +294,7 @@ public void testRootName() throws Exception * Test that will just use Jackson annotations, but did trigger [JACKSON-495] due to a bug * in JAXB annotation introspector. */ + @Test public void testIssue495() throws Exception { ObjectMapper mapper = new ObjectMapper(); diff --git a/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/introspect/TestPropertyOrdering.java b/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/introspect/TestPropertyOrdering.java index 7be58ec81..37f869c39 100644 --- a/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/introspect/TestPropertyOrdering.java +++ b/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/introspect/TestPropertyOrdering.java @@ -2,10 +2,14 @@ import jakarta.xml.bind.annotation.*; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.module.jakarta.xmlbind.ModuleTestBase; +import static org.junit.jupiter.api.Assertions.*; + public class TestPropertyOrdering extends ModuleTestBase { @@ -60,6 +64,7 @@ public static class AlphaBean2 /********************************************************** */ + @Test public void testSerializationExplicitOrdering() throws Exception { ObjectMapper mapper = getJaxbMapper(); @@ -67,12 +72,14 @@ public void testSerializationExplicitOrdering() throws Exception } // Trying to reproduce [JACKSON-268] + @Test public void testOrderingWithRename() throws Exception { ObjectMapper mapper = getJaxbMapper(); assertEquals("{\"cparty\":\"dto\",\"contacts\":[1,2,3]}", mapper.writeValueAsString(new BeanFor268())); } + @Test public void testOrderingWithOriginalPropName() throws Exception { ObjectMapper mapper = getJaxbMapper(); diff --git a/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/introspect/TestPropertyVisibility.java b/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/introspect/TestPropertyVisibility.java index 6dc701d92..77b0acf13 100644 --- a/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/introspect/TestPropertyVisibility.java +++ b/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/introspect/TestPropertyVisibility.java @@ -4,12 +4,16 @@ import jakarta.xml.bind.annotation.*; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.module.jakarta.xmlbind.ModuleTestBase; +import static org.junit.jupiter.api.Assertions.*; + public class TestPropertyVisibility extends ModuleTestBase { @@ -85,12 +89,14 @@ public NoneAccessBean(Object o, Object b) { // Verify serialization wrt [JACKSON-354] // // NOTE: fails currently because we use Bean Introspector which only sees public methods -- need to rewrite + @Test public void testJackson354Serialization() throws IOException { assertEquals("{\"name\":\"foo\"}", MAPPER.writeValueAsString(new Bean354())); } // For [JACKSON-539] + @Test public void testJacksonSerialization() throws Exception { @@ -111,6 +117,7 @@ public void testJacksonSerialization() } // for [modules-base#44] + @Test public void testNoneAccessWithXmlElements() throws Exception { NoneAccessBean input = new NoneAccessBean(new Foo44()); diff --git a/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/introspect/TestXmlValue.java b/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/introspect/TestXmlValue.java index 66d667de2..cfdd80b33 100644 --- a/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/introspect/TestXmlValue.java +++ b/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/introspect/TestXmlValue.java @@ -4,12 +4,16 @@ import jakarta.xml.bind.annotation.*; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.module.jakarta.xmlbind.ModuleTestBase; +import static org.junit.jupiter.api.Assertions.*; + public class TestXmlValue extends ModuleTestBase { static class WithXmlValueNoOverride @@ -50,6 +54,7 @@ public void setQuery(final String pQuery) { */ // For [jaxb-annotations#30] + @Test public void testXmlValueDefault() throws IOException { ObjectMapper mapper = getJaxbAndJacksonMapper(); @@ -58,6 +63,7 @@ public void testXmlValueDefault() throws IOException } // For [jaxb-annotations#30] + @Test public void testXmlValueOverride() throws IOException { ObjectMapper mapper = getJaxbAndJacksonMapper(); @@ -66,6 +72,7 @@ public void testXmlValueOverride() throws IOException } // For [jaxb-annotations#31] + @Test public void testXmlValueDefault2() throws IOException { ObjectMapper mapper = getJaxbAndJacksonMapper(); diff --git a/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/misc/NullPropertiesTest.java b/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/misc/NullPropertiesTest.java index 559dfc2eb..623da65d6 100644 --- a/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/misc/NullPropertiesTest.java +++ b/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/misc/NullPropertiesTest.java @@ -3,6 +3,8 @@ import jakarta.xml.bind.annotation.XmlElement; import jakarta.xml.bind.annotation.XmlRootElement; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.databind.ObjectMapper; @@ -12,6 +14,8 @@ import com.fasterxml.jackson.module.jakarta.xmlbind.ModuleTestBase; +import static org.junit.jupiter.api.Assertions.*; + /** * Unit tests to ensure that handling of writing of null properties (or not) * works when using JAXB annotation introspector. @@ -67,6 +71,7 @@ public NonNillableZ(int i) { private final ObjectMapper MAPPER = getJaxbMapper(); + @Test public void testWriteNulls() throws Exception { BeanWithNillable bean = new BeanWithNillable(); @@ -74,6 +79,7 @@ public void testWriteNulls() throws Exception assertEquals("{\"X\":{\"Z\":null}}", MAPPER.writeValueAsString(bean)); } + @Test public void testNullProps() throws Exception { ObjectMapper mapper = getJaxbMapper(); @@ -81,6 +87,7 @@ public void testNullProps() throws Exception assertEquals("{\"x\":\"y\"}", mapper.writeValueAsString(new Bean())); } + @Test public void testNillability() throws Exception { ObjectMapper mapper = getJaxbMapper(); diff --git a/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/misc/TestDeserializerCaching.java b/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/misc/TestDeserializerCaching.java index a8a93a24b..bc6a26023 100644 --- a/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/misc/TestDeserializerCaching.java +++ b/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/misc/TestDeserializerCaching.java @@ -1,5 +1,7 @@ package com.fasterxml.jackson.module.jakarta.xmlbind.misc; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.core.*; import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.deser.BeanDeserializer; @@ -7,6 +9,8 @@ import com.fasterxml.jackson.module.jakarta.xmlbind.ModuleTestBase; +import static org.junit.jupiter.api.Assertions.*; + public class TestDeserializerCaching extends ModuleTestBase { /* @@ -71,6 +75,7 @@ public JsonDeserializer modifyDeserializer(DeserializationConfig config, /********************************************************** */ + @Test public void testCaching() throws Exception { final String JSON = "{\"value1\" : {\"name\" : \"fruit\", \"value\" : \"apple\"},\n" diff --git a/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/misc/TestElementWrapper.java b/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/misc/TestElementWrapper.java index 9510089f5..bba461b27 100644 --- a/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/misc/TestElementWrapper.java +++ b/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/misc/TestElementWrapper.java @@ -2,6 +2,8 @@ import java.util.*; +import org.junit.jupiter.api.Test; + import jakarta.xml.bind.annotation.XmlElement; import jakarta.xml.bind.annotation.XmlElementWrapper; @@ -10,6 +12,8 @@ import com.fasterxml.jackson.module.jakarta.xmlbind.ModuleTestBase; +import static org.junit.jupiter.api.Assertions.*; + /** * Unit tests to verify handling of @XmlElementWrapper annotation. */ @@ -76,6 +80,7 @@ public Bean25(int... v0) { */ // [JACKSON-436] + @Test public void testWrapperWithCollection() throws Exception { ObjectMapper mapper = getJaxbMapperBuilder() @@ -101,6 +106,7 @@ public void testWrapperWithCollection() throws Exception } // [Issue#13] + @Test public void testWrapperRenaming() throws Exception { ObjectMapper mapper = getJaxbMapper(); @@ -117,6 +123,7 @@ public void testWrapperRenaming() throws Exception } // [Issue#25] + @Test public void testWrapperDefaultName() throws Exception { ObjectMapper mapper = getJaxbMapper(); diff --git a/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/misc/TestEnums.java b/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/misc/TestEnums.java index 5fa153c18..f067029e4 100644 --- a/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/misc/TestEnums.java +++ b/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/misc/TestEnums.java @@ -2,10 +2,14 @@ import jakarta.xml.bind.annotation.XmlEnum; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.module.jakarta.xmlbind.ModuleTestBase; +import static org.junit.jupiter.api.Assertions.*; + public class TestEnums extends ModuleTestBase { enum Plain { A, B; } @@ -20,6 +24,7 @@ enum Numeric { A, B; } */ // [JACKSON-436] + @Test public void testWrapperWithCollection() throws Exception { ObjectMapper mapper = getJaxbMapper(); diff --git a/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/misc/TestRootName.java b/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/misc/TestRootName.java index 5426d4fe2..eb67d72f0 100644 --- a/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/misc/TestRootName.java +++ b/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/misc/TestRootName.java @@ -2,11 +2,15 @@ import jakarta.xml.bind.annotation.XmlRootElement; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.module.jakarta.xmlbind.ModuleTestBase; +import static org.junit.jupiter.api.Assertions.*; + public class TestRootName extends ModuleTestBase { /* @@ -27,6 +31,7 @@ static class MyType /********************************************************** */ + @Test public void testRootName() throws Exception { ObjectMapper mapper = getJaxbMapper(); diff --git a/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/misc/TestSchemaGeneration.java b/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/misc/TestSchemaGeneration.java index bbb85521a..03fdaad99 100644 --- a/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/misc/TestSchemaGeneration.java +++ b/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/misc/TestSchemaGeneration.java @@ -2,6 +2,8 @@ import jakarta.xml.bind.annotation.*; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ObjectNode; @@ -9,6 +11,8 @@ import com.fasterxml.jackson.module.jakarta.xmlbind.ModuleTestBase; +import static org.junit.jupiter.api.Assertions.*; + /** * Test(s) to see that JAXB annotations-based information is properly * accessible and used by JSON Schema generation @@ -56,6 +60,7 @@ protected static class Address implements IAddress { * * @since 1.7 */ + @Test public void testWithJaxb() throws Exception { ObjectMapper mapper = getJaxbMapper(); @@ -63,8 +68,8 @@ public void testWithJaxb() throws Exception ObjectNode root = jsonSchema.getSchemaNode(); // should find two properties ("city", "state"), not just one... JsonNode itemsNode = root.findValue("properties"); - assertNotNull("Missing 'state' field", itemsNode.get("state")); - assertNotNull("Missing 'city' field", itemsNode.get("city")); + assertNotNull(itemsNode.get("state"), "Missing 'state' field"); + assertNotNull(itemsNode.get("city"), "Missing 'city' field"); assertEquals(2, itemsNode.size()); } } diff --git a/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/misc/TestSerializationInclusion.java b/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/misc/TestSerializationInclusion.java index ccf66c4c3..93f61be27 100644 --- a/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/misc/TestSerializationInclusion.java +++ b/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/misc/TestSerializationInclusion.java @@ -4,6 +4,8 @@ import jakarta.xml.bind.annotation.XmlElement; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.databind.ObjectMapper; @@ -11,6 +13,8 @@ import com.fasterxml.jackson.module.jakarta.xmlbind.ModuleTestBase; +import static org.junit.jupiter.api.Assertions.*; + public class TestSerializationInclusion extends ModuleTestBase { static class Data { @@ -22,6 +26,7 @@ public List getStuff() { } } + @Test public void testIssue39() throws Exception { // First: use plain JAXB introspector: diff --git a/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/misc/TestXmlAnyElementWithElementRef.java b/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/misc/TestXmlAnyElementWithElementRef.java index f11df7d12..cae6ab7be 100644 --- a/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/misc/TestXmlAnyElementWithElementRef.java +++ b/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/misc/TestXmlAnyElementWithElementRef.java @@ -4,10 +4,14 @@ import jakarta.xml.bind.annotation.*; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.module.jakarta.xmlbind.ModuleTestBase; +import static org.junit.jupiter.api.Assertions.*; + public class TestXmlAnyElementWithElementRef extends ModuleTestBase { @@ -41,6 +45,7 @@ static class Count { */ // [JACKSON-254]: verify that things do work + @Test public void testXmlAnyElementWithElementRef() throws Exception { ObjectMapper mapper = getJaxbMapper(); diff --git a/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/ser/TestVirtualProperties.java b/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/ser/TestVirtualProperties.java index f9e070f57..0ba064f7e 100644 --- a/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/ser/TestVirtualProperties.java +++ b/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/ser/TestVirtualProperties.java @@ -2,6 +2,8 @@ import java.util.*; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.core.JsonGenerator; @@ -16,6 +18,8 @@ import com.fasterxml.jackson.module.jakarta.xmlbind.ModuleTestBase; +import static org.junit.jupiter.api.Assertions.*; + //Copied from [com.fasterxml.jackson.databind.ser] /** * Tests for verifying that one can append virtual properties after regular ones. @@ -95,6 +99,7 @@ static class CustomVBean private final ObjectWriter WRITER = newObjectMapper().writer(); + @Test public void testAttributeProperties() throws Exception { Map stuff = new LinkedHashMap(); @@ -112,6 +117,7 @@ public void testAttributeProperties() throws Exception assertEquals(a2q("{'id':'abc123','extra':{'x':3,'y':'B'},'value':13}"), json); } + @Test public void testAttributePropInclusion() throws Exception { // first, with desc @@ -129,6 +135,7 @@ public void testAttributePropInclusion() throws Exception assertEquals(a2q("{'value':28}"), json); } + @Test public void testCustomProperties() throws Exception { String json = WRITER.withAttribute("desc", "nice") diff --git a/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/types/OptionalTypeRefinementTest.java b/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/types/OptionalTypeRefinementTest.java index 1888771c1..48f48720f 100644 --- a/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/types/OptionalTypeRefinementTest.java +++ b/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/types/OptionalTypeRefinementTest.java @@ -2,10 +2,14 @@ import java.util.concurrent.atomic.AtomicReference; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.module.jakarta.xmlbind.ModuleTestBase; +import static org.junit.jupiter.api.Assertions.*; + // [jaxb-annotations#63] public class OptionalTypeRefinementTest extends ModuleTestBase { @@ -13,6 +17,7 @@ static class Stuff63 { public AtomicReference value = new AtomicReference("abc"); } + @Test public void testWithReferenceType() throws Exception { final ObjectMapper mapper = getJaxbMapper(); diff --git a/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/types/TestCyclicTypes.java b/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/types/TestCyclicTypes.java index 1ec7c78d4..e74bbde5d 100644 --- a/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/types/TestCyclicTypes.java +++ b/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/types/TestCyclicTypes.java @@ -4,10 +4,14 @@ import jakarta.xml.bind.annotation.*; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.module.jakarta.xmlbind.ModuleTestBase; +import static org.junit.jupiter.api.Assertions.*; + /** * Simple unit tests to verify that it is possible to handle * potentially cyclic structures, as long as object graph itself @@ -49,6 +53,7 @@ public Bean(Bean next, String name) { /* Added to check for [JACKSON-171], i.e. that type its being * cyclic is not a problem (instances are). */ + @Test public void testWithJAXB() throws Exception { ObjectMapper mapper = getJaxbMapper(); diff --git a/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/types/TestJaxbPolymorphic.java b/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/types/TestJaxbPolymorphic.java index 9eb537855..697b32edf 100644 --- a/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/types/TestJaxbPolymorphic.java +++ b/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/types/TestJaxbPolymorphic.java @@ -4,8 +4,12 @@ import jakarta.xml.bind.annotation.*; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.databind.ObjectMapper; +import static org.junit.jupiter.api.Assertions.*; + /** * Tests for handling of type-related JAXB annotations */ @@ -86,6 +90,7 @@ static class ContainerForBase //First a simple test with non-collection field @SuppressWarnings("unchecked") + @Test public void testSinglePolymorphic() throws Exception { Bean input = new Bean(new Buffalo("Billy", "brown")); @@ -110,7 +115,8 @@ public void testSinglePolymorphic() throws Exception assertEquals("brown", ((Buffalo) a).hairColor); } - public void testPolymorphicArray() throws Exception + @Test + public void testPolymorphicArray() throws Exception { Animal a1 = new Buffalo("Bill", "grey"); Animal a2 = new Whale("moe", 3000); @@ -132,7 +138,8 @@ public void testPolymorphicArray() throws Exception assertEquals(3000, ((Whale)a2).weightInTons); } - public void testPolymorphicArrayElementRef() throws Exception + @Test + public void testPolymorphicArrayElementRef() throws Exception { Animal a1 = new Emu("Bill", "grey"); Animal a2 = new Cow("moe", 3000); @@ -156,7 +163,8 @@ public void testPolymorphicArrayElementRef() throws Exception } // For [Issue#1] - public void testXmlSeeAlso() throws Exception + @Test + public void testXmlSeeAlso() throws Exception { ContainerForBase input = new ContainerForBase(); input.stuff = new Base[] { new BaseImpl("xyz") }; diff --git a/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/types/TestJaxbPolymorphicLists.java b/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/types/TestJaxbPolymorphicLists.java index 9e54ac52f..2f6c8c25c 100644 --- a/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/types/TestJaxbPolymorphicLists.java +++ b/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/types/TestJaxbPolymorphicLists.java @@ -4,8 +4,12 @@ import jakarta.xml.bind.annotation.*; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.databind.ObjectMapper; +import static org.junit.jupiter.api.Assertions.*; + /** * Tests for handling of type-related JAXB annotations with collection (List) * types. @@ -60,7 +64,8 @@ static class ShortListHolder { /** * And then a test for collection types */ - public void testPolymorphicList() throws Exception + @Test + public void testPolymorphicList() throws Exception { ObjectMapper mapper = getJaxbMapper(); ListBean input = new ListBean(new Whale("bluey", 150), @@ -85,7 +90,8 @@ public void testPolymorphicList() throws Exception /** * And then a test for collection types using element ref(s) */ - public void testPolymorphicListElementRef() throws Exception + @Test + public void testPolymorphicListElementRef() throws Exception { ObjectMapper mapper = getJaxbMapper(); ListBean input = new ListBean(); @@ -110,7 +116,8 @@ public void testPolymorphicListElementRef() throws Exception } // [JACKSON-348] - public void testShortList() throws Exception + @Test + public void testShortList() throws Exception { ShortListHolder holder = getJaxbMapper().readValue("{\"id\":[1,2,3]}", ShortListHolder.class); diff --git a/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/types/TestJaxbPolymorphicMaps.java b/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/types/TestJaxbPolymorphicMaps.java index e9c318667..19ed20917 100644 --- a/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/types/TestJaxbPolymorphicMaps.java +++ b/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/types/TestJaxbPolymorphicMaps.java @@ -4,8 +4,12 @@ import jakarta.xml.bind.annotation.*; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.databind.ObjectMapper; +import static org.junit.jupiter.api.Assertions.*; + /** * Tests for handling of type-related JAXB annotations */ @@ -47,6 +51,7 @@ public MapBean() { /********************************************************** */ + @Test public void testPolymorphicMap() throws Exception { ObjectMapper mapper = getJaxbMapper(); @@ -66,6 +71,7 @@ public void testPolymorphicMap() throws Exception assertEquals("Pena", ((Whale) map.get(Integer.valueOf(3))).nickname); } + @Test public void testPolymorphicMapElementRefs() throws Exception { ObjectMapper mapper = getJaxbMapper(); diff --git a/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/types/TestJaxbTypeCoercion1023.java b/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/types/TestJaxbTypeCoercion1023.java index dc5dbf31a..7069eae6b 100644 --- a/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/types/TestJaxbTypeCoercion1023.java +++ b/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/types/TestJaxbTypeCoercion1023.java @@ -2,9 +2,13 @@ import jakarta.xml.bind.annotation.XmlElement; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.module.jakarta.xmlbind.ModuleTestBase; +import static org.junit.jupiter.api.Assertions.*; + // Failing temporarily due to [databind#1023] public class TestJaxbTypeCoercion1023 extends ModuleTestBase { @@ -39,6 +43,7 @@ static class Jackson416Sub extends Jackson416Base /********************************************************** */ + @Test public void testIssue416() throws Exception { ObjectMapper mapper = getJaxbAndJacksonMapper(); diff --git a/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/types/TestJaxbTypes.java b/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/types/TestJaxbTypes.java index 873e34ba9..c601548cb 100644 --- a/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/types/TestJaxbTypes.java +++ b/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/types/TestJaxbTypes.java @@ -4,6 +4,8 @@ import jakarta.xml.bind.annotation.*; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.annotation.JsonTypeName; @@ -12,6 +14,8 @@ import com.fasterxml.jackson.module.jakarta.xmlbind.ModuleTestBase; +import static org.junit.jupiter.api.Assertions.*; + /** * Tests for handling of type-related JAXB annotations */ @@ -112,6 +116,7 @@ public P2() { } /********************************************************** */ + @Test public void testXmlElementTypeDeser() throws Exception { ObjectMapper mapper = getJaxbMapper(); @@ -122,6 +127,7 @@ public void testXmlElementTypeDeser() throws Exception assertEquals("...", bean.b); } + @Test public void testXmlElementTypeSer() throws Exception { ObjectMapper mapper = getJaxbAndJacksonMapper(); @@ -130,6 +136,7 @@ public void testXmlElementTypeSer() throws Exception mapper.writeValueAsString(wrapper)); } + @Test public void testXmlElementListTypeDeser() throws Exception { ObjectMapper mapper = getJaxbMapper(); @@ -152,6 +159,7 @@ public void testXmlElementListTypeDeser() throws Exception assertEquals("b", bean.b); } + @Test public void testXmlElementListArrayDeser() throws Exception { ObjectMapper mapper = getJaxbMapper(); @@ -171,6 +179,7 @@ public void testXmlElementListArrayDeser() throws Exception assertEquals("b", bean.b); } + @Test public void testXmlElementListTypeSer() throws Exception { // important: Jackson mapper so we can force ordering @@ -185,6 +194,7 @@ public void testXmlElementListTypeSer() throws Exception mapper.writeValueAsString(bean)); } + @Test public void testRoundTrip() throws Exception { ComboBean input = new ComboBean(new BeanImpl(3, "abc"), @@ -208,6 +218,7 @@ public void testRoundTrip() throws Exception assertEquals("c", (result.beans.get(2)).b); } + @Test public void testListWithDefaultTyping() throws Exception { Object input = new ListBean(new BeanImpl(1, "a")); @@ -227,6 +238,7 @@ public void testListWithDefaultTyping() throws Exception assertEquals("a", bean.b); } + @Test public void testIssue250() throws Exception { ObjectMapper mapper = getJaxbAndJacksonMapper(); diff --git a/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/types/XmlSeeAlsoForSubtypes195Test.java b/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/types/XmlSeeAlsoForSubtypes195Test.java index df749455a..c9c0b67a9 100644 --- a/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/types/XmlSeeAlsoForSubtypes195Test.java +++ b/jakarta-xmlbind/src/test/java/com/fasterxml/jackson/module/jakarta/xmlbind/types/XmlSeeAlsoForSubtypes195Test.java @@ -2,12 +2,16 @@ import jakarta.xml.bind.annotation.XmlSeeAlso; +import org.junit.jupiter.api.Test; + import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.annotation.JsonTypeInfo.As; import com.fasterxml.jackson.annotation.JsonTypeInfo.Id; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.module.jakarta.xmlbind.ModuleTestBase; +import static org.junit.jupiter.api.Assertions.*; + public class XmlSeeAlsoForSubtypes195Test extends ModuleTestBase { @@ -36,6 +40,7 @@ static class Sub195B extends Base195 { } private final ObjectMapper MAPPER = getJaxbAndJacksonMapper(); // [modules-base#195] + @Test public void testXmlSeeAlso195() throws Exception { String json = MAPPER.writeValueAsString(new Root195(new Sub195B()));