diff --git a/pom.xml b/pom.xml
index c4036e06..692a917a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -86,13 +86,8 @@ alternative support for serializing POJOs as XML and deserializing XML as pojos.
-
-
- junit
- junit
- test
-
-
+
+
org.junit.jupiter
diff --git a/src/test/java/module-info.java b/src/test/java/module-info.java
index e52fe393..9c4e3d35 100644
--- a/src/test/java/module-info.java
+++ b/src/test/java/module-info.java
@@ -10,11 +10,22 @@
requires tools.jackson.core;
requires tools.jackson.databind;
- // Then test dependencies
- requires junit;
+ /// // 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
+
requires org.junit.jupiter.api;
requires org.junit.jupiter.params;
+ // Other Test dependencies
+
requires com.ctc.wstx; // woodstox
requires jakarta.xml.bind; // Jakarta-binding
requires tools.jackson.module.jakarta.xmlbind;
diff --git a/src/test/java/tools/jackson/dataformat/xml/XmlTestBase.java b/src/test/java/tools/jackson/dataformat/xml/XmlTestBase.java
deleted file mode 100644
index b5c9975d..00000000
--- a/src/test/java/tools/jackson/dataformat/xml/XmlTestBase.java
+++ /dev/null
@@ -1,384 +0,0 @@
-package tools.jackson.dataformat.xml;
-
-import java.io.*;
-import java.nio.charset.StandardCharsets;
-import java.util.Arrays;
-
-import junit.framework.TestCase;
-
-import com.fasterxml.jackson.annotation.JsonPropertyOrder;
-
-import tools.jackson.core.*;
-
-import tools.jackson.databind.AnnotationIntrospector;
-import tools.jackson.dataformat.xml.annotation.JacksonXmlProperty;
-
-import tools.jackson.module.jakarta.xmlbind.JakartaXmlBindAnnotationIntrospector;
-
-public abstract class XmlTestBase
- extends TestCase
-{
- protected static final String DEFAULT_NEW_LINE;
-
- static {
- String newLine = System.getProperty("line.separator");
- DEFAULT_NEW_LINE = newLine == null ? "\n" : newLine;
- }
-
- @JsonPropertyOrder({ "first", "last", "id" })
- protected static class NameBean {
- @JacksonXmlProperty(isAttribute=true)
- public int age;
- public String last, first;
-
- public NameBean() { }
- public NameBean(int age, String f, String l) {
- this.age = age;
- first = f;
- last = l;
- }
- }
-
- /**
- * Sample class from Jackson tutorial ("JacksonInFiveMinutes")
- */
- public static class FiveMinuteUser {
- public enum Gender { MALE, FEMALE };
-
- public static class Name
- {
- private String _first, _last;
-
- public Name() { }
- public Name(String f, String l) {
- _first = f;
- _last = l;
- }
-
- public String getFirst() { return _first; }
- public String getLast() { return _last; }
-
- public void setFirst(String s) { _first = s; }
- public void setLast(String s) { _last = s; }
-
- @Override
- public boolean equals(Object o)
- {
- if (o == this) return true;
- if (o == null || o.getClass() != getClass()) return false;
- Name other = (Name) o;
- return _first.equals(other._first) && _last.equals(other._last);
- }
- }
-
- private Gender _gender;
- private Name _name;
- private boolean _isVerified;
- private byte[] _userImage;
-
- public FiveMinuteUser() { }
-
- public FiveMinuteUser(String first, String last, boolean verified, Gender g, byte[] data)
- {
- _name = new Name(first, last);
- _isVerified = verified;
- _gender = g;
- _userImage = data;
- }
-
- public Name getName() { return _name; }
- public boolean isVerified() { return _isVerified; }
- public Gender getGender() { return _gender; }
- public byte[] getUserImage() { return _userImage; }
-
- public void setName(Name n) { _name = n; }
- public void setVerified(boolean b) { _isVerified = b; }
- public void setGender(Gender g) { _gender = g; }
- public void setUserImage(byte[] b) { _userImage = b; }
-
- @Override
- public boolean equals(Object o)
- {
- if (o == this) return true;
- if (o == null || o.getClass() != getClass()) return false;
- FiveMinuteUser other = (FiveMinuteUser) o;
- if (_isVerified != other._isVerified) return false;
- if (_gender != other._gender) return false;
- if (!_name.equals(other._name)) return false;
- byte[] otherImage = other._userImage;
- if (otherImage.length != _userImage.length) return false;
- for (int i = 0, len = _userImage.length; i < len; ++i) {
- if (_userImage[i] != otherImage[i]) {
- return false;
- }
- }
- return true;
- }
- }
-
- protected static class StringBean
- {
- public String text;
-
- public StringBean() { this("foobar"); }
- public StringBean(String s) { text = s; }
-
- @Override
- public String toString() {
- if (text == null) return "NULL";
- return "\""+text+"\"";
- }
- }
-
- /**
- * Simple wrapper around String type, usually to test value
- * conversions or wrapping
- */
- protected static class StringWrapper {
- public String str;
-
- public StringWrapper() { }
- public StringWrapper(String value) {
- str = value;
- }
- }
-
- protected static class IntWrapper {
- public int i;
-
- public IntWrapper() { }
- public IntWrapper(int value) {
- i = value;
- }
- }
-
- public static class Point {
- public int x, y;
-
- protected Point() { } // for deser
- public Point(int x0, int y0) {
- x = x0;
- y = y0;
- }
-
- @Override
- public boolean equals(Object o) {
- if (!(o instanceof Point)) {
- return false;
- }
- Point other = (Point) o;
- return (other.x == x) && (other.y == y);
- }
-
- @Override
- public String toString() {
- return String.format("[x=%d, y=%d]", x, y);
- }
- }
-
- /*
- /**********************************************************************
- /* Some sample documents:
- /**********************************************************************
- */
-
- protected final static int SAMPLE_SPEC_VALUE_WIDTH = 800;
- protected final static int SAMPLE_SPEC_VALUE_HEIGHT = 600;
- protected final static String SAMPLE_SPEC_VALUE_TITLE = "View from 15th Floor";
- protected final static String SAMPLE_SPEC_VALUE_TN_URL = "http://www.example.com/image/481989943";
- protected final static int SAMPLE_SPEC_VALUE_TN_HEIGHT = 125;
- protected final static String SAMPLE_SPEC_VALUE_TN_WIDTH = "100";
- protected final static int SAMPLE_SPEC_VALUE_TN_ID1 = 116;
- protected final static int SAMPLE_SPEC_VALUE_TN_ID2 = 943;
- protected final static int SAMPLE_SPEC_VALUE_TN_ID3 = 234;
- protected final static int SAMPLE_SPEC_VALUE_TN_ID4 = 38793;
-
- protected final static String SAMPLE_DOC_JSON_SPEC =
- "{\n"
- +" \"Image\" : {\n"
- +" \"Width\" : "+SAMPLE_SPEC_VALUE_WIDTH+",\n"
- +" \"Height\" : "+SAMPLE_SPEC_VALUE_HEIGHT+","
- +"\"Title\" : \""+SAMPLE_SPEC_VALUE_TITLE+"\",\n"
- +" \"Thumbnail\" : {\n"
- +" \"Url\" : \""+SAMPLE_SPEC_VALUE_TN_URL+"\",\n"
- +"\"Height\" : "+SAMPLE_SPEC_VALUE_TN_HEIGHT+",\n"
- +" \"Width\" : \""+SAMPLE_SPEC_VALUE_TN_WIDTH+"\"\n"
- +" },\n"
- +" \"IDs\" : ["+SAMPLE_SPEC_VALUE_TN_ID1+","+SAMPLE_SPEC_VALUE_TN_ID2+","+SAMPLE_SPEC_VALUE_TN_ID3+","+SAMPLE_SPEC_VALUE_TN_ID4+"]\n"
- +" }"
- +"}"
- ;
-
- /*
- /**********************************************************************
- /* Construction, factory methods
- /**********************************************************************
- */
-
- protected XmlTestBase() {
- super();
- }
-
- protected XmlFactoryBuilder streamFactoryBuilder() {
- return XmlFactory.builder();
- }
-
- protected static XmlMapper newMapper() {
- return new XmlMapper();
- }
-
- protected static XmlMapper.Builder mapperBuilder() {
- return XmlMapper.builder();
- }
-
- protected static XmlMapper.Builder mapperBuilder(XmlFactory f) {
- return XmlMapper.builder(f);
- }
-
- protected XmlMapper xmlMapper(boolean useListWrapping)
- {
- return XmlMapper.builder()
- .defaultUseWrapper(useListWrapping)
- .build();
- }
-
- protected AnnotationIntrospector jakartaXMLBindAnnotationIntrospector() {
- return new JakartaXmlBindAnnotationIntrospector();
- }
-
- /*
- /**********************************************************************
- /* Additional assertion methods
- /**********************************************************************
- */
-
- protected void assertToken(JsonToken expToken, JsonToken actToken)
- {
- if (actToken != expToken) {
- fail("Expected token "+expToken+", current token "+actToken);
- }
- }
-
- protected void assertToken(JsonToken expToken, JsonParser jp)
- {
- assertToken(expToken, jp.currentToken());
- }
-
- /**
- * Method that gets textual contents of the current token using
- * available methods, and ensures results are consistent, before
- * returning them
- */
- protected 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("String access via getText(), getTextXxx() must be the same", str, str2);
-
- return str;
- }
-
- protected void verifyFieldName(JsonParser p, String expName)
- {
- assertEquals(expName, p.getString());
- assertEquals(expName, p.currentName());
- }
-
- protected void verifyException(Throwable e, String... matches)
- {
- String msg = e.getMessage();
- String lmsg = (msg == null) ? "" : msg.toLowerCase();
- for (String match : matches) {
- String lmatch = match.toLowerCase();
- if (lmsg.indexOf(lmatch) >= 0) {
- return;
- }
- }
- fail("Expected an exception with one of substrings ("+Arrays.asList(matches)+"): got one ("+
- e.getClass().getName()+") with message \""+msg+"\"");
- }
-
- /*
- /**********************************************************************
- /* Helper methods, other
- /**********************************************************************
- */
-
- protected static String a2q(String content) {
- return content.replace("'", "\"");
- }
-
- protected byte[] utf8Bytes(String str) {
- return str.getBytes(StandardCharsets.UTF_8);
- }
-
- /**
- * Helper method that tries to remove unnecessary namespace
- * declaration that default JDK XML parser (SJSXP) sees fit
- * to add.
- */
- protected static String removeSjsxpNamespace(String xml)
- {
- final String match = " xmlns=\"\"";
- int ix = xml.indexOf(match);
- if (ix > 0) {
- xml = xml.substring(0, ix) + xml.substring(ix+match.length());
- }
- return xml;
- }
-
- protected String readAll(File f) throws IOException
- {
- StringBuilder sb = new StringBuilder();
- BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(f), "UTF-8"));
- String line;
-
- while ((line = br.readLine()) != null) {
- sb.append(line).append("\n");
- }
- br.close();
- return sb.toString();
- }
-
- protected byte[] readResource(String ref)
- {
- ByteArrayOutputStream bytes = new ByteArrayOutputStream();
- final byte[] buf = new byte[4000];
-
- InputStream in = getClass().getResourceAsStream(ref);
- if (in != null) {
- try {
- int len;
- while ((len = in.read(buf)) > 0) {
- bytes.write(buf, 0, len);
- }
- in.close();
- } catch (IOException e) {
- throw new RuntimeException("Failed to read resource '"+ref+"': "+e);
- }
- }
- if (bytes.size() == 0) {
- throw new IllegalArgumentException("Failed to read resource '"+ref+"': empty resource?");
- }
- return bytes.toByteArray();
- }
-
- public String jaxbSerialized(Object ob, Class>... classes) throws Exception
- {
- StringWriter sw = new StringWriter();
- if (classes.length == 0) {
- jakarta.xml.bind.JAXB.marshal(ob, sw);
- } else {
- jakarta.xml.bind.JAXBContext.newInstance(classes).createMarshaller().marshal(ob, sw);
- }
- sw.close();
- return sw.toString();
- }
-}
diff --git a/src/test/java/tools/jackson/dataformat/xml/lists/PolymorphicList97Test.java b/src/test/java/tools/jackson/dataformat/xml/lists/PolymorphicList97Test.java
index 19a1ed18..2ddd4919 100644
--- a/src/test/java/tools/jackson/dataformat/xml/lists/PolymorphicList97Test.java
+++ b/src/test/java/tools/jackson/dataformat/xml/lists/PolymorphicList97Test.java
@@ -11,8 +11,7 @@
import tools.jackson.dataformat.xml.*;
import tools.jackson.dataformat.xml.annotation.*;
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
/**
* @author pgelinas
@@ -43,11 +42,11 @@ public void testGood() throws Exception {
.build();
String xml = "FOOBAR";
Foo fooRead = mapper.readValue(xml, Foo.class);
- assertThat(fooRead, instanceOf(FooGood.class));
+ assertInstanceOf(FooGood.class, fooRead);
xml = "FOOBAR";
fooRead = mapper.readValue(xml, Foo.class);
- assertThat(fooRead, instanceOf(FooGood.class));
+ assertInstanceOf(FooGood.class, fooRead);
}
@Test
@@ -57,10 +56,10 @@ public void testBad() throws Exception {
.build();
String xml = "FOOBAR";
Foo fooRead = mapper.readValue(xml, Foo.class);
- assertThat(fooRead, instanceOf(FooBad.class));
+ assertInstanceOf(FooBad.class, fooRead);
xml = "FOOBAR";
fooRead = mapper.readValue(xml, Foo.class);
- assertThat(fooRead, instanceOf(FooBad.class));
+ assertInstanceOf(FooBad.class, fooRead);
}
}