diff --git a/pom.xml b/pom.xml
index b94498f126..dd0b8ad47a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -108,6 +108,18 @@
+
+
+
+ tools.jackson.core
+ jackson-core
+ ${jackson.version.core}
+ tests
+ test-jar
+ test
+ org.junit.jupiterjunit-jupiter
diff --git a/src/test/java/module-info.java b/src/test/java/module-info.java
index fed0e4db08..3a095aacb8 100644
--- a/src/test/java/module-info.java
+++ b/src/test/java/module-info.java
@@ -1,4 +1,4 @@
-// Jackson 3.x module-info for Tests
+// Jackson 3.x module-info for jackson-databind Tests
module tools.jackson.databind
{
requires java.desktop;
@@ -14,6 +14,15 @@
// // Actual Test dependencies
+ // Shared Jackson test functionality
+
+ // 15-Jan-2025, tatu: missing module-info for `tools.jackson.core` can't yet add
+ // (but will be included in Class path just not Module path)
+ //
+ //requires tools.jackson.core.testutil;
+
+ // Test frameworks, libraries:
+
// Guava testlib needed by CLMH tests, alas; brings in junit4
requires guava.testlib;
// JUnit4 should NOT be needed but is transitively required
@@ -86,7 +95,6 @@
opens tools.jackson.databind.ser.filter;
opens tools.jackson.databind.seq;
opens tools.jackson.databind.struct;
- opens tools.jackson.databind.testutil.failure;
opens tools.jackson.databind.tofix;
opens tools.jackson.databind.util.internal;
opens tools.jackson.databind.views;
diff --git a/src/test/java/tools/jackson/databind/introspect/JacksonAnnotationIntrospectorTest.java b/src/test/java/tools/jackson/databind/introspect/JacksonAnnotationIntrospectorTest.java
index d81695e9bb..b727733bd8 100644
--- a/src/test/java/tools/jackson/databind/introspect/JacksonAnnotationIntrospectorTest.java
+++ b/src/test/java/tools/jackson/databind/introspect/JacksonAnnotationIntrospectorTest.java
@@ -109,7 +109,7 @@ public QName deserialize(JsonParser p, DeserializationContext ctxt)
if (!p.hasToken(JsonToken.VALUE_STRING)) {
throw new IllegalArgumentException("Unexpected token "+p.currentToken());
}
- return QName.valueOf(p.getText());
+ return QName.valueOf(p.getString());
}
}
diff --git a/src/test/java/tools/jackson/databind/records/tofix/DuplicatePropertyDeserializationRecord4690Test.java b/src/test/java/tools/jackson/databind/records/tofix/DuplicatePropertyDeserializationRecord4690Test.java
index 2c87257069..468a2c424e 100644
--- a/src/test/java/tools/jackson/databind/records/tofix/DuplicatePropertyDeserializationRecord4690Test.java
+++ b/src/test/java/tools/jackson/databind/records/tofix/DuplicatePropertyDeserializationRecord4690Test.java
@@ -2,9 +2,10 @@
import org.junit.jupiter.api.Test;
+import tools.jackson.core.testutil.failure.JacksonTestFailureExpected;
+
import tools.jackson.databind.ObjectMapper;
import tools.jackson.databind.testutil.DatabindTestUtil;
-import tools.jackson.databind.testutil.failure.JacksonTestFailureExpected;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
@@ -14,7 +15,6 @@
public class DuplicatePropertyDeserializationRecord4690Test
extends DatabindTestUtil
{
-
record MyRecord(String first) { }
private final ObjectMapper mapper = newJsonMapper();
diff --git a/src/test/java/tools/jackson/databind/records/tofix/RecordUpdate3079FailingTest.java b/src/test/java/tools/jackson/databind/records/tofix/RecordUpdate3079FailingTest.java
index 876b426b91..18dee35e7c 100644
--- a/src/test/java/tools/jackson/databind/records/tofix/RecordUpdate3079FailingTest.java
+++ b/src/test/java/tools/jackson/databind/records/tofix/RecordUpdate3079FailingTest.java
@@ -3,10 +3,10 @@
import java.util.Collections;
import org.junit.jupiter.api.Test;
+import tools.jackson.core.testutil.failure.JacksonTestFailureExpected;
import tools.jackson.databind.*;
import tools.jackson.databind.testutil.DatabindTestUtil;
-import tools.jackson.databind.testutil.failure.JacksonTestFailureExpected;
import static org.junit.jupiter.api.Assertions.*;
diff --git a/src/test/java/tools/jackson/databind/records/tofix/RecordsWithJsonIncludeAndIgnorals4629Test.java b/src/test/java/tools/jackson/databind/records/tofix/RecordsWithJsonIncludeAndIgnorals4629Test.java
index af698b5ab0..4f45ca5f63 100644
--- a/src/test/java/tools/jackson/databind/records/tofix/RecordsWithJsonIncludeAndIgnorals4629Test.java
+++ b/src/test/java/tools/jackson/databind/records/tofix/RecordsWithJsonIncludeAndIgnorals4629Test.java
@@ -2,12 +2,13 @@
import org.junit.jupiter.api.Test;
+import tools.jackson.core.testutil.failure.JacksonTestFailureExpected;
+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonIncludeProperties;
import tools.jackson.databind.ObjectMapper;
import tools.jackson.databind.testutil.DatabindTestUtil;
-import tools.jackson.databind.testutil.failure.JacksonTestFailureExpected;
import static org.junit.jupiter.api.Assertions.assertEquals;
diff --git a/src/test/java/tools/jackson/databind/testutil/DatabindTestUtil.java b/src/test/java/tools/jackson/databind/testutil/DatabindTestUtil.java
index 2d235a8c87..604d627485 100644
--- a/src/test/java/tools/jackson/databind/testutil/DatabindTestUtil.java
+++ b/src/test/java/tools/jackson/databind/testutil/DatabindTestUtil.java
@@ -2,11 +2,11 @@
import java.io.*;
import java.lang.annotation.*;
-import java.nio.charset.StandardCharsets;
import java.util.*;
import tools.jackson.core.*;
import tools.jackson.core.json.JsonFactory;
+import tools.jackson.core.testutil.JacksonTestUtilBase;
import tools.jackson.databind.*;
import tools.jackson.databind.cfg.MapperConfig;
import tools.jackson.databind.introspect.AnnotatedMember;
@@ -22,6 +22,7 @@
* as part of JUnit 5 migration.
*/
public class DatabindTestUtil
+ extends JacksonTestUtilBase
{
// @since 2.18
// Helper annotation to work around lack of implicit name access with Jackson 2.x
@@ -407,37 +408,12 @@ protected String serializeAsString(Object value)
return serializeAsString(sharedMapper(), value);
}
- /*
- /**********************************************************************
- /* Encoding or String representations
- /**********************************************************************
- */
-
- public static String a2q(String json) {
- return json.replace("'", "\"");
- }
-
- public static String q(String str) {
- return '"'+str+'"';
- }
-
- public static byte[] utf8Bytes(String str) {
- return str.getBytes(StandardCharsets.UTF_8);
- }
-
/*
/**********************************************************************
/* Additional assertion methods
/**********************************************************************
*/
- public static void assertToken(JsonToken expToken, JsonToken actToken)
- {
- if (actToken != expToken) {
- fail("Expected token "+expToken+", current token "+actToken);
- }
- }
-
public static void assertValidLocation(TokenStreamLocation location) {
assertNotNull(location, "Should have non-null location");
assertTrue(location.getLineNr() > 0, "Should have positive line number");
@@ -478,78 +454,6 @@ protected void assertStandardEquals(Object o)
o.hashCode();
}
- /**
- * @param e Exception to check
- * @param anyMatches Array of Strings of which AT LEAST ONE ("any") has to be included
- * in {@code e.getMessage()} -- using case-INSENSITIVE comparison
- */
- public static void verifyException(Throwable e, String... anyMatches)
- {
- String msg = e.getMessage();
- String lmsg = (msg == null) ? "" : msg.toLowerCase();
- for (String match : anyMatches) {
- String lmatch = match.toLowerCase();
- if (lmsg.contains(lmatch)) {
- return;
- }
- }
- fail("Expected an exception with one of substrings ("
- + Arrays.asList(anyMatches)+"): got one (of type "+e.getClass().getName()
- +") with message \""+msg+"\"");
- }
-
- /**
- * Method that gets textual contents of the current token using
- * available methods, and ensures results are consistent, before
- * returning them
- */
- protected static String getAndVerifyText(JsonParser jp)
- {
- // Ok, let's verify other accessors
- int actLen = jp.getStringLength();
- char[] ch = jp.getStringCharacters();
- String str2 = new String(ch, jp.getStringOffset(), actLen);
- String str = jp.getString();
-
- if (str.length() != actLen) {
- fail("Internal problem (jp.token == "+jp.currentToken()+"): jp.getText().length() ['"+str+"'] == "+str.length()+"; jp.getTextLength() == "+actLen);
- }
- assertEquals(str, str2, "String access via getText(), getTextXxx() must be the same");
-
- return str;
- }
-
- /*
- /**********************************************************
- /* JDK ser/deser
- /**********************************************************
- */
-
- public static byte[] jdkSerialize(Object o)
- {
- ByteArrayOutputStream bytes = new ByteArrayOutputStream(2000);
- try (ObjectOutputStream obOut = new ObjectOutputStream(bytes)) {
- obOut.writeObject(o);
- obOut.close();
- return bytes.toByteArray();
- } catch (IOException e) {
- throw new UncheckedIOException(e);
- }
- }
-
- @SuppressWarnings("unchecked")
- public static T jdkDeserialize(byte[] raw)
- {
- try (ObjectInputStream objIn = new ObjectInputStream(new ByteArrayInputStream(raw))) {
- return (T) objIn.readObject();
- } catch (ClassNotFoundException e) {
- fail("Missing class: "+e.getMessage());
- return null;
- } catch (IOException e) {
- throw new UncheckedIOException(e);
- }
- }
-
/*
/**********************************************************************
/* Helper methods, other
diff --git a/src/test/java/tools/jackson/databind/testutil/UnlimitedLookupCache.java b/src/test/java/tools/jackson/databind/testutil/UnlimitedLookupCache.java
deleted file mode 100644
index c117a7f29c..0000000000
--- a/src/test/java/tools/jackson/databind/testutil/UnlimitedLookupCache.java
+++ /dev/null
@@ -1,66 +0,0 @@
-package tools.jackson.databind.testutil;
-
-import java.util.concurrent.ConcurrentHashMap;
-
-import tools.jackson.databind.util.LookupCache;
-
-/**
- * A LookupCache implementation that has no synchronization (like SimpleLookupCache does)
- * but that has the downside of not limiting the size of the cache.
- */
-public class UnlimitedLookupCache implements LookupCache {
-
- private final int _initialEntries;
- private final transient ConcurrentHashMap _map;
-
- public UnlimitedLookupCache(int initialEntries)
- {
- _initialEntries = initialEntries;
- // We'll use concurrency level of 4, seems reasonable
- _map = new ConcurrentHashMap(initialEntries, 0.8f, 4);
- }
-
- @Override
- public LookupCache snapshot() {
- return new UnlimitedLookupCache(_initialEntries);
- }
-
- @Override
- public LookupCache emptyCopy() {
- return snapshot();
- }
-
- /*
- @Override
- public void contents(BiConsumer consumer) {
- for (Map.Entry entry : _map.entrySet()) {
- consumer.accept(entry.getKey(), entry.getValue());
- }
- }
- */
-
- @Override
- public int size() {
- return _map.size();
- }
-
- @Override
- public V get(Object key) {
- return _map.get(key);
- }
-
- @Override
- public V put(K key, V value) {
- return _map.put(key, value);
- }
-
- @Override
- public V putIfAbsent(K key, V value) {
- return _map.putIfAbsent(key, value);
- }
-
- @Override
- public void clear() {
- _map.clear();
- }
-}
diff --git a/src/test/java/tools/jackson/databind/testutil/failure/JacksonTestFailureExpected.java b/src/test/java/tools/jackson/databind/testutil/failure/JacksonTestFailureExpected.java
deleted file mode 100644
index c52539d76b..0000000000
--- a/src/test/java/tools/jackson/databind/testutil/failure/JacksonTestFailureExpected.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package tools.jackson.databind.testutil.failure;
-
-import java.lang.annotation.*;
-
-import org.junit.jupiter.api.extension.ExtendWith;
-
-/**
- *
- * Annotation used to indicate that a JUnit-5 based tests method is expected to fail.
- *
- *
- * When a test method is annotated with {@code @JacksonTestFailureExpected}, the
- * {@link JacksonTestFailureExpectedInterceptor} will intercept the test execution.
- * If the test passes, which is an unexpected behavior, the interceptor will throw an exception to fail the test,
- * indicating that the test was expected to fail but didn't.
- *
- *
- *
Usage Example:
- *
- *
- *
- * @Test
- * @JacksonTestFailureExpected
- * public void testFeatureNotYetImplemented() {
- * // Test code that is expected to fail
- * }
- * }
- *
- *
- *
- *
- * @since 2.19
- */
-@Target({ElementType.METHOD})
-@Retention(RetentionPolicy.RUNTIME)
-@ExtendWith(JacksonTestFailureExpectedInterceptor.class)
-public @interface JacksonTestFailureExpected { }
diff --git a/src/test/java/tools/jackson/databind/testutil/failure/JacksonTestFailureExpectedInterceptor.java b/src/test/java/tools/jackson/databind/testutil/failure/JacksonTestFailureExpectedInterceptor.java
deleted file mode 100644
index 67dc6876a3..0000000000
--- a/src/test/java/tools/jackson/databind/testutil/failure/JacksonTestFailureExpectedInterceptor.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package tools.jackson.databind.testutil.failure;
-
-import java.lang.reflect.Method;
-
-import org.junit.jupiter.api.extension.ExtensionContext;
-import org.junit.jupiter.api.extension.InvocationInterceptor;
-import org.junit.jupiter.api.extension.ReflectiveInvocationContext;
-
-/**
- * Custom {@link InvocationInterceptor} that intercepts test method invocation.
- * To pass the test ***only if*** test fails with an exception, and fail the test otherwise.
- *
- * @since 2.19
- */
-public class JacksonTestFailureExpectedInterceptor
- implements InvocationInterceptor
-{
- @Override
- public void interceptTestMethod(Invocation invocation,
- ReflectiveInvocationContext invocationContext, ExtensionContext extensionContext)
- throws Throwable
- {
- try {
- invocation.proceed();
- } catch (Throwable t) {
- // do-nothing, we do expect an exception
- return;
- }
- handleUnexpectePassingTest(invocationContext);
- }
-
- private void handleUnexpectePassingTest(ReflectiveInvocationContext invocationContext) {
- // Collect information we need
- Object targetClass = invocationContext.getTargetClass();
- Object testMethod = invocationContext.getExecutable().getName();
- //List