From 490954d557cf8fcc9ef0368d93d57e9129ed21d7 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Thu, 16 Jan 2025 18:25:34 -0800 Subject: [PATCH 1/4] Try using shared test util classes --- pom.xml | 14 ++- .../jackson/dataformat/xml/XmlTestUtil.java | 89 ++----------------- 2 files changed, 20 insertions(+), 83 deletions(-) diff --git a/pom.xml b/pom.xml index 692a917a..5c94cb62 100644 --- a/pom.xml +++ b/pom.xml @@ -87,7 +87,19 @@ alternative support for serializing POJOs as XML and deserializing XML as pojos. - + + + + tools.jackson.core + jackson-core + ${jackson.version.core} + tests + test-jar + test + + org.junit.jupiter diff --git a/src/test/java/tools/jackson/dataformat/xml/XmlTestUtil.java b/src/test/java/tools/jackson/dataformat/xml/XmlTestUtil.java index 525afe02..3e6c878d 100644 --- a/src/test/java/tools/jackson/dataformat/xml/XmlTestUtil.java +++ b/src/test/java/tools/jackson/dataformat/xml/XmlTestUtil.java @@ -1,19 +1,23 @@ package tools.jackson.dataformat.xml; import java.io.*; -import java.nio.charset.StandardCharsets; -import java.util.Arrays; import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import tools.jackson.core.*; + +import tools.jackson.core.JsonParser; +import tools.jackson.core.testutil.JacksonTestUtilBase; + import tools.jackson.databind.AnnotationIntrospector; + import tools.jackson.dataformat.xml.annotation.JacksonXmlProperty; + import tools.jackson.module.jakarta.xmlbind.JakartaXmlBindAnnotationIntrospector; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.fail; public abstract class XmlTestUtil + extends JacksonTestUtilBase { protected static final String DEFAULT_NEW_LINE; @@ -249,60 +253,12 @@ protected AnnotationIntrospector jakartaXMLBindAnnotationIntrospector() { /********************************************************** */ - 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) - throws IOException - { - // 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; - } - protected void verifyFieldName(JsonParser jp, String expName) throws IOException { assertEquals(expName, jp.getString()); assertEquals(expName, jp.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+"\""); - } /* /********************************************************** @@ -310,14 +266,6 @@ protected void verifyException(Throwable e, String... matches) /********************************************************** */ - 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 @@ -346,29 +294,6 @@ protected String readAll(File f) throws IOException 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(); From 678fe6e0a738d4ba5231b3e7f7f32c97179e8720 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Thu, 16 Jan 2025 18:27:17 -0800 Subject: [PATCH 2/4] ... --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5c94cb62..e591624e 100644 --- a/pom.xml +++ b/pom.xml @@ -112,7 +112,7 @@ alternative support for serializing POJOs as XML and deserializing XML as pojos. test - From ce4c058201fb7f610b0fa23c3cf41912b27040fa Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Mon, 20 Jan 2025 11:06:50 -0800 Subject: [PATCH 3/4] Manual pom.xml merge --- pom.xml | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/pom.xml b/pom.xml index e591624e..5ef0ff6e 100644 --- a/pom.xml +++ b/pom.xml @@ -193,21 +193,6 @@ alternative support for serializing POJOs as XML and deserializing XML as pojos. com.google.code.maven-replacer-plugin replacer - - - org.apache.maven.plugins - maven-surefire-plugin - ${version.plugin.surefire} - - - **/failing/**/*.java - - - **/Test*.java - **/*Test.java - - - de.jjohannes From c03bc9023ae65555f34452212da9fde797e242dc Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Mon, 20 Jan 2025 11:09:00 -0800 Subject: [PATCH 4/4] Try forcing dep version to try to get test jar to show up... --- pom.xml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 5ef0ff6e..62274fd9 100644 --- a/pom.xml +++ b/pom.xml @@ -45,17 +45,19 @@ alternative support for serializing POJOs as XML and deserializing XML as pojos. - - tools.jackson.core - jackson-core - com.fasterxml.jackson.core jackson-annotations + + tools.jackson.core + jackson-core + ${jackson.version.core} + tools.jackson.core jackson-databind + ${jackson.version.databind}