Skip to content

Commit

Permalink
Merge branch '2.19'
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Jan 19, 2025
2 parents f7f4e5b + a30ebe5 commit 0fa6340
Show file tree
Hide file tree
Showing 41 changed files with 287 additions and 70 deletions.
81 changes: 43 additions & 38 deletions jaxb/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,49 +41,54 @@
<version.jaxb.impl>2.3.3</version.jaxb.impl>
-->
</properties>
<dependencies>
<!-- Extends Jackson core and mapper; minor dep on annotations too (JsonInclude) -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</dependency>
<dependency>
<groupId>tools.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
</dependency>
<dependency>
<groupId>tools.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependencies>
<!-- Extends Jackson core and mapper; minor dep on annotations too (JsonInclude) -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</dependency>
<dependency>
<groupId>tools.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
</dependency>
<dependency>
<groupId>tools.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>

<!-- 20-Apr-2024, tatu: JUnit4 no longer from jackson-base -->
<!-- Test dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>

<!-- 20-May-2024: [modules-base#233]: Tolerate [2.2,3) for javax.xml.bind Import-Package
in the generated MANIFEST.MF -->
<!-- 16-Jan-2025, tatu: Let's not bother with 2.2 any more -->
<!-- https://mvnrepository.com/artifact/javax.xml.bind/jaxb-api -->
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1</version>
</dependency>
<!-- 05-May-2019, tatu: As per #111, looks like we actually need this
flavor of activation API...
-->
<!-- 16-Jan-2025, tatu: Should not be needed; adds conflict -->
<!--
<dependency>
<groupId>jakarta.activation</groupId>
<artifactId>jakarta.activation-api</artifactId>
<version>1.2.1</version>
</dependency>
-->
</dependencies>
<!-- 20-May-2024: [modules-base#233]: Tolerate [2.2,3) for javax.xml.bind Import-Package
in the generated MANIFEST.MF -->
<!-- 16-Jan-2025, tatu: Let's not bother with 2.2 any more -->
<!-- https://mvnrepository.com/artifact/javax.xml.bind/jaxb-api -->
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1</version>
</dependency>
<!-- 05-May-2019, tatu: As per #111, looks like we actually need this
flavor of activation API...
-->
<!-- 16-Jan-2025, tatu: Should not be needed; adds conflict -->
<!--
<dependency>
<groupId>jakarta.activation</groupId>
<artifactId>jakarta.activation-api</artifactId>
<version>1.2.1</version>
</dependency>
-->
</dependencies>

<build>
<plugins>
Expand Down
3 changes: 2 additions & 1 deletion jaxb/src/test/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@

// Additional test lib/framework dependencies

requires junit; // JUnit4 To Be Removed in future
requires org.junit.jupiter.api;
requires org.junit.jupiter.params;

// Further, need to open up some packages for JUnit et al

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package tools.jackson.module.jaxb;

import java.io.IOException;
import java.util.Map;

import tools.jackson.databind.*;
Expand All @@ -10,7 +9,6 @@
import tools.jackson.databind.json.JsonMapper;

public abstract class BaseJaxbTest
extends junit.framework.TestCase
{
protected BaseJaxbTest() { }

Expand Down Expand Up @@ -68,24 +66,22 @@ protected ObjectMapper getJaxbAndJacksonMapper()

@SuppressWarnings("unchecked")
protected Map<String,Object> writeAndMap(ObjectMapper m, Object value)
throws IOException
{
String str = m.writeValueAsString(value);
return (Map<String,Object>) m.readValue(str, Map.class);
}

protected Map<String,Object> writeAndMap(Object value)
throws IOException
{
return writeAndMap(new ObjectMapper(), value);
}

protected String serializeAsString(ObjectMapper m, Object value) throws IOException
protected String serializeAsString(ObjectMapper m, Object value)
{
return m.writeValueAsString(value);
}

protected String serializeAsString(Object value) throws IOException
protected String serializeAsString(Object value)
{
return serializeAsString(new ObjectMapper(), value);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
package tools.jackson.module.jaxb;

import org.junit.jupiter.api.Test;

import tools.jackson.core.Version;
import tools.jackson.core.Versioned;

import static org.junit.jupiter.api.Assertions.*;

public class TestVersions extends BaseJaxbTest
{
@Test
public void testVersions()
{
assertVersion(new JaxbAnnotationIntrospector());
Expand All @@ -19,7 +24,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);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package tools.jackson.module.jaxb.adapters;

/**
* @author Ryan Heaton
*/
public class EntryType<K, V> {

private K key;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
package tools.jackson.module.jaxb.adapters;

import javax.xml.bind.annotation.adapters.XmlAdapter;

import java.util.*;

import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import javax.xml.bind.annotation.adapters.XmlAdapter;

public class MapAdapter<K, V> extends XmlAdapter<MapType<K, V>, Map<K, V>>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@

import java.util.List;

/**
* @author Ryan Heaton
*/
public class MapType<K,V> {

public List<EntryType<K, V>> entries;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 tools.jackson.databind.ObjectMapper;
import tools.jackson.module.jaxb.BaseJaxbTest;

import static org.junit.jupiter.api.Assertions.*;

/**
* Tests for verifying JAXB adapter handling for {@link java.util.Map}
* types.
Expand Down Expand Up @@ -63,6 +67,7 @@ public Map<String, String> unmarshal(Map<String, String> input)
/**********************************************************
*/

@Test
public void testJacksonAdaptedMapType() throws IOException
{
ObjectContainingAMap obj = new ObjectContainingAMap();
Expand All @@ -82,6 +87,7 @@ public void testJacksonAdaptedMapType() throws IOException
assertEquals("here", map.get("how"));
}

@Test
public void testStringMaps() throws IOException
{
ObjectMapper mapper = getJaxbMapper();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 tools.jackson.databind.ObjectMapper;
import tools.jackson.module.jaxb.BaseJaxbTest;

import static org.junit.jupiter.api.Assertions.*;

/**
* Unit tests for checking that JAXB type adapters work (to some
* degree, anyway).
Expand Down Expand Up @@ -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);
Expand All @@ -178,6 +184,7 @@ public void testSimpleAdapterDeserialization() throws Exception
}

// [JACKSON-288]
@Test
public void testDateAdapter() throws Exception
{
Bean288 input = new Bean288("test");
Expand All @@ -189,6 +196,7 @@ public void testDateAdapter() throws Exception

// [JACKSON-656]

@Test
public void testJackson656() throws Exception
{
Bean656 bean = new Bean656();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@
import javax.xml.bind.annotation.*;
import javax.xml.bind.annotation.adapters.*;

import org.junit.jupiter.api.Test;

import tools.jackson.databind.ObjectMapper;
import tools.jackson.module.jaxb.BaseJaxbTest;
import tools.jackson.module.jaxb.introspect.JaxbAnnotationIntrospectorTest.KeyValuePair;

import static org.junit.jupiter.api.Assertions.*;

/**
* Unit tests to check that {@link XmlAdapter}s also work with
* container types (Lists, Maps)
Expand Down Expand Up @@ -111,12 +115,14 @@ public void setValues(List<Date> 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);
Expand All @@ -126,12 +132,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\"]}",
Expand All @@ -148,6 +156,7 @@ public void testAdapterOnGetterDeserialization() throws Exception
/**********************************************************
*/

@Test
public void testAdapterForBeanWithMap() throws Exception
{
ObjectMapper mapper = getJaxbMapper();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 tools.jackson.databind.ObjectMapper;
import tools.jackson.module.jaxb.BaseJaxbTest;

import static org.junit.jupiter.api.Assertions.*;

/**
* Failing unit tests related to Adapter handling.
*/
Expand Down Expand Up @@ -60,6 +64,7 @@ public IdentityAdapterPropertyBean() { }
*/

// [Issue-10]
@Test
public void testIdentityAdapterForClass() throws Exception
{
IdentityAdapterBean input = new IdentityAdapterBean("A");
Expand All @@ -73,6 +78,7 @@ public void testIdentityAdapterForClass() throws Exception
}

// [Issue-10]
@Test
public void testIdentityAdapterForProperty() throws Exception
{
IdentityAdapterPropertyBean input = new IdentityAdapterPropertyBean("B");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@
import javax.xml.bind.annotation.*;
import javax.xml.bind.annotation.adapters.*;

import org.junit.jupiter.api.Test;

import tools.jackson.databind.ObjectMapper;
import tools.jackson.module.jaxb.BaseJaxbTest;

import static org.junit.jupiter.api.Assertions.*;

public class TestEnums256 extends BaseJaxbTest
{
// [modules-base#256]
Expand Down Expand Up @@ -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);
Expand Down
Loading

0 comments on commit 0fa6340

Please sign in to comment.