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 Feb 2, 2025
2 parents 04016d1 + eec3990 commit 598f51d
Show file tree
Hide file tree
Showing 57 changed files with 315 additions and 88 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dep_build_v2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Set up JDK
uses: actions/setup-java@7a6d8a8234af8eb26422e24e3006232cccaa061b # v4.6.0
uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 # v4.7.0
with:
distribution: 'temurin'
java-version: ${{ matrix.java_version }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/dep_build_v3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
with:
ref: master
- name: Set up JDK
uses: actions/setup-java@7a6d8a8234af8eb26422e24e3006232cccaa061b # v4.6.0
uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 # v4.7.0
with:
distribution: 'temurin'
java-version: ${{ matrix.java_version }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Set up JDK
uses: actions/setup-java@7a6d8a8234af8eb26422e24e3006232cccaa061b # v4.6.0
uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 # v4.7.0
with:
distribution: 'temurin'
java-version: ${{ matrix.java_version }}
Expand Down
3 changes: 2 additions & 1 deletion base/src/test/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
requires transitive tools.jackson.databind;

// Additional test lib/framework dependencies
requires junit; // JUnit 4
requires org.junit.jupiter.api;
requires org.junit.jupiter.params;

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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package tools.jackson.jaxrs.base;

public abstract class BaseTestBase
extends junit.framework.TestCase
{
// for now just placeholder
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@
import java.util.Arrays;
import java.util.HashSet;

import org.junit.jupiter.api.Test;

import com.fasterxml.jackson.annotation.*;
import tools.jackson.databind.annotation.JsonDeserialize;
import tools.jackson.databind.annotation.JsonSerialize;
import tools.jackson.jaxrs.base.BaseTestBase;
import tools.jackson.jaxrs.cfg.AnnotationBundleKey;

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

// for [jaxrs-providers#111]
public class AnnotationBundleKeyTest
extends BaseTestBase
Expand Down Expand Up @@ -39,6 +43,7 @@ public Helper(@JsonProperty("x") int x) { }
public void setX(@JsonProperty("x") int x) { }
}

@Test
public void testWithClassAnnotations() throws Exception
{
Annotation[] annotation1 = Helper.class.getAnnotations();
Expand All @@ -48,6 +53,7 @@ public void testWithClassAnnotations() throws Exception
_checkWith(annotation1, annotation2);
}

@Test
public void testWithMethodAnnotationEquals() throws Exception
{
// First, same method parameters definitely should match
Expand All @@ -65,25 +71,29 @@ public void testWithMethodAnnotationEquals() throws Exception
_checkWith(annotation3, annotation4);
}

@Test
public void testWithMethodAnnotationDifferent() throws Exception
{
// However: not so with actually differing annotations
_checkNotEqual(Helper.class.getDeclaredMethod("getX").getAnnotations(),
Helper.class.getDeclaredMethod("notX").getAnnotations());
}

@Test
public void testWithMethodParameterAnnotation() throws Exception
{
_checkWith(Helper.class.getDeclaredMethod("setX", Integer.TYPE).getParameterAnnotations()[0],
Helper.class.getDeclaredMethod("setX", Integer.TYPE).getParameterAnnotations()[0]);
}

@Test
public void testWithConstructorAnnotation() throws Exception
{
_checkWith(Helper.class.getConstructor(Integer.TYPE).getAnnotations(),
Helper.class.getConstructor(Integer.TYPE).getAnnotations());
}


@Test
public void testWithConstructorParameterAnnotation() throws Exception
{
_checkWith(Helper.class.getConstructor(Integer.TYPE).getParameterAnnotations()[0],
Expand All @@ -97,18 +107,18 @@ protected void _checkWith(Annotation[] anns1, Annotation[] anns2) {
}
HashSet<Annotation> annsSet1 = new HashSet<Annotation>(Arrays.asList(anns1));
HashSet<Annotation> annsSet2 = new HashSet<Annotation>(Arrays.asList(anns2));
assertTrue("Internal error: should never differ", annsSet1.equals(annsSet2));
assertEquals(annsSet1, annsSet2, "Internal error: should never differ");

AnnotationBundleKey b1 = new AnnotationBundleKey(anns1, Object.class);
AnnotationBundleKey b2 = new AnnotationBundleKey(anns2, Object.class);

assertTrue(String.format("Implementations over %s backed annotations differ", anns1[0].getClass()), (b1.equals(b2) && b2.equals(b1)));
assertTrue((b1.equals(b2) && b2.equals(b1)), String.format("Implementations over %s backed annotations differ", anns1[0].getClass()));
}

protected void _checkNotEqual(Annotation[] anns1, Annotation[] anns2) {
AnnotationBundleKey b1 = new AnnotationBundleKey(anns1, Object.class);
AnnotationBundleKey b2 = new AnnotationBundleKey(anns2, Object.class);

assertFalse(String.format("Implementations over %s backed annotations SHOULD differ but won't", anns1[0].getClass()), (b1.equals(b2) || b2.equals(b1)));
assertFalse((b1.equals(b2) || b2.equals(b1)), String.format("Implementations over %s backed annotations SHOULD differ but won't", anns1[0].getClass()));
}
}
3 changes: 2 additions & 1 deletion cbor/src/test/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
requires java.ws.rs;

// Additional test lib/framework dependencies
requires junit; // JUnit 4
requires org.junit.jupiter.api;
requires org.junit.jupiter.params;

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
import java.io.InputStream;
import java.util.Arrays;

import org.junit.Assert;

import tools.jackson.core.*;

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

public abstract class JaxrsTestBase
extends junit.framework.TestCase
{
/*
/**********************************************************
Expand Down Expand Up @@ -56,7 +55,7 @@ protected void verifyException(Throwable e, String... matches)

protected void _verifyBytes(byte[] actBytes, byte... expBytes)
{
Assert.assertArrayEquals(expBytes, actBytes);
assertArrayEquals(expBytes, actBytes);
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
package tools.jackson.jaxrs.cbor;

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 TestCBORVersions extends JaxrsTestBase
{
@Test
public void testMapperVersions()
{
assertVersion(new JacksonCBORProvider());
Expand All @@ -19,7 +24,7 @@ public void testMapperVersions()
private void assertVersion(Versioned vers)
{
final 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
Expand Up @@ -3,10 +3,14 @@
import java.io.*;
import java.lang.annotation.Annotation;

import org.junit.jupiter.api.Test;

import javax.ws.rs.core.MediaType;

import tools.jackson.jaxrs.cbor.JacksonCBORProvider;

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

/**
* Unit test to check [JACKSON-540]
*/
Expand All @@ -17,6 +21,7 @@ static class Bean {
}

// [Issue#1]: exception for no content
@Test
public void testCanSerializeEmpty() throws IOException
{
JacksonCBORProvider prov = new JacksonCBORProvider();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@
import javax.ws.rs.Produces;

import org.eclipse.jetty.server.Server;
import org.junit.Assert;

import org.junit.jupiter.api.Test;

import tools.jackson.databind.ObjectMapper;
import tools.jackson.dataformat.cbor.CBORFactory;
import tools.jackson.jaxrs.cbor.CBORMediaTypes;

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

public abstract class SimpleEndpointTestBase extends ResourceTestBase
{
final static int TEST_PORT = 6011;
Expand Down Expand Up @@ -72,6 +75,7 @@ public static class SimpleRawApp extends CBORApplicationWithJackson {
/**********************************************************
*/

@Test
public void testSimpleObject() throws Exception
{
final ObjectMapper mapper = new ObjectMapper(new CBORFactory());
Expand All @@ -91,6 +95,7 @@ public void testSimpleObject() throws Exception
assertEquals(2, p.y);
}

@Test
public void testCustomMediaTypeWithCborExtension() throws Exception
{
final ObjectMapper mapper = new ObjectMapper(new CBORFactory());
Expand All @@ -115,12 +120,13 @@ public void testCustomMediaTypeWithCborExtension() throws Exception

// [Issue#34] Verify that Untouchables act the way as they should
@SuppressWarnings("resource")
@Test
public void testUntouchables() throws Exception
{
Server server = startServer(TEST_PORT, SimpleRawApp.class);
try {
InputStream in = new URL("http://localhost:"+TEST_PORT+"/raw/bytes").openStream();
Assert.assertArrayEquals(UNTOUCHABLE_RESPONSE, readAll(in));
assertArrayEquals(UNTOUCHABLE_RESPONSE, readAll(in));
} finally {
server.stop();
}
Expand Down
3 changes: 2 additions & 1 deletion datatypes/src/test/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
requires java.ws.rs;

// Additional test lib/framework dependencies
requires junit; // JUnit 4
requires org.junit.jupiter.api;
requires org.junit.jupiter.params;

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@

import javax.ws.rs.core.Link;

import org.junit.jupiter.api.Test;

import tools.jackson.databind.ObjectMapper;

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

public class LinkTest extends ModuleTestBase
{
private final ObjectMapper MAPPER = mapperWithModule();


@Test
public void testLink() throws Exception
{
Link input = Link.fromUri("http://dot.com?foo=bar")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
import tools.jackson.core.*;
import tools.jackson.databind.ObjectMapper;
import tools.jackson.databind.json.JsonMapper;
import tools.jackson.datatype.jaxrs.Jaxrs2TypesModule;

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

public abstract class ModuleTestBase
extends junit.framework.TestCase
{
protected ObjectMapper mapperWithModule() {
return JsonMapper.builder()
Expand Down
3 changes: 2 additions & 1 deletion json/src/test/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
requires java.ws.rs;

// Additional test lib/framework dependencies
requires junit; // JUnit 4
requires org.junit.jupiter.api;
requires org.junit.jupiter.params;

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

import java.util.*;

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

public abstract class JaxrsTestBase
extends junit.framework.TestCase
{
/*
/**********************************************************************
Expand Down Expand Up @@ -39,7 +38,7 @@ protected void verifyException(Throwable e, String... matches)

protected void _verifyBytes(byte[] actBytes, byte... expBytes)
{
Assert.assertArrayEquals(expBytes, actBytes);
assertArrayEquals(expBytes, actBytes);
}

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,21 @@
import java.util.LinkedHashMap;
import java.util.Map;

import org.junit.jupiter.api.Test;

import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.NoContentException;

import tools.jackson.jaxrs.cfg.JaxRSFeature;
import tools.jackson.jaxrs.json.JacksonJsonProvider;

/**
* Unit test to check [JACKSON-540]
*/
public class TestCanDeserialize extends JaxrsTestBase {
import static org.junit.jupiter.api.Assertions.*;

@SuppressWarnings({ "unchecked", "rawtypes" })
public void testCanDeserialize() throws IOException {
public class TestCanDeserialize extends JaxrsTestBase
{
@SuppressWarnings({ "unchecked", "rawtypes" })
@Test
public void testCanDeserialize() throws IOException {
Map<String, Object> object = new LinkedHashMap<String, Object>();
JacksonJsonProvider prov = new JacksonJsonProvider();

Expand All @@ -33,6 +35,7 @@ public void testCanDeserialize() throws IOException {
}

@SuppressWarnings({ "unchecked", "rawtypes" })
@Test
public void testCanDeserializeEmpty() throws IOException {
JacksonJsonProvider prov = new JacksonJsonProvider();

Expand All @@ -48,7 +51,8 @@ public void testCanDeserializeEmpty() throws IOException {
/**
* Unit test for verifying functioning of {@link JaxRSFeature#ALLOW_EMPTY_INPUT}.
*/
public void testFailingDeserializeEmpty() throws IOException {
@Test
public void testFailingDeserializeEmpty() throws IOException {
JacksonJsonProvider prov = new JacksonJsonProvider();
prov.disable(JaxRSFeature.ALLOW_EMPTY_INPUT);

Expand Down
Loading

0 comments on commit 598f51d

Please sign in to comment.