From 280c2a94d49f952b0f200760b8df3228dd889d61 Mon Sep 17 00:00:00 2001 From: Udi Kalifon Date: Fri, 15 Aug 2025 19:30:40 +0200 Subject: [PATCH 1/2] Java 17 - Updating the Java version to 17. - Replacing JAXB with Jackson which is more up to date. - Removeed import sun.awt.AppContext which is not allowed any more due to Java module restrictions, and is not needed any more in newer Swing version. - Removeed com.sun.security.sasl.Provider which is not needed any more since Java 9. - Removed sun.misc.BASE64Encoder and using the SDK's Base64 support. - Many small fixes due to the Java differences. --- .../resources/archetype-resources/pom.xml | 4 +- .../resources/archetype-resources/pom.xml | 4 +- jsystem-assembly/jsystem-runner/pom.xml | 34 ++++++++--- .../src/main/assembly/runner.xml | 4 +- .../main/java/jsystem/treeui/WaitDialog.java | 5 -- .../jsystem/treeui/agents/AgentsDialog.java | 4 +- .../treeui/params/AgentsSelectionDialog.java | 4 +- .../treeui/teststable/ScenarioTreeNode.java | 2 +- .../java/jsystem/treeui/tree/AssetNode.java | 4 +- .../jsystem/treeui/tree/TestCaseNode.java | 2 +- jsystem-core-projects/jsystemCore/pom.xml | 18 +++++- .../report/junit/JUnitReporter.java | 59 +++++++++---------- .../main/java/jsystem/utils/Encryptor.java | 5 +- .../src/main/java/jsystem/utils/MailUtil.java | 4 +- jsystem-core-projects/pom.xml | 23 +++++++- .../jsystem-maven-plugin/pom.xml | 16 +++++ .../jsystemtest/plugin/SurefireReporter.java | 59 +++++++++---------- jsystem-parent/pom.xml | 25 +++++++- 18 files changed, 180 insertions(+), 96 deletions(-) diff --git a/jsystem-archetypes/jsystem-so-archetype/src/main/resources/archetype-resources/pom.xml b/jsystem-archetypes/jsystem-so-archetype/src/main/resources/archetype-resources/pom.xml index 9ae6163c..6fe85ca3 100644 --- a/jsystem-archetypes/jsystem-so-archetype/src/main/resources/archetype-resources/pom.xml +++ b/jsystem-archetypes/jsystem-so-archetype/src/main/resources/archetype-resources/pom.xml @@ -7,8 +7,8 @@ ${jsystem.dependency.version} UTF-8 - 1.8 - 1.8 + 17 + 17 diff --git a/jsystem-archetypes/jsystem-tests-archetype/src/main/resources/archetype-resources/pom.xml b/jsystem-archetypes/jsystem-tests-archetype/src/main/resources/archetype-resources/pom.xml index 4ae9fd87..80223096 100644 --- a/jsystem-archetypes/jsystem-tests-archetype/src/main/resources/archetype-resources/pom.xml +++ b/jsystem-archetypes/jsystem-tests-archetype/src/main/resources/archetype-resources/pom.xml @@ -7,8 +7,8 @@ ${jsystem.dependency.version} UTF-8 - 1.8 - 1.8 + 17 + 17 diff --git a/jsystem-assembly/jsystem-runner/pom.xml b/jsystem-assembly/jsystem-runner/pom.xml index 0c7eb3b1..d84418db 100644 --- a/jsystem-assembly/jsystem-runner/pom.xml +++ b/jsystem-assembly/jsystem-runner/pom.xml @@ -77,11 +77,6 @@ comm - org.apache.ftpserver ftpserver-core @@ -174,8 +169,31 @@ ${project.version} sources - - + + com.fasterxml.jackson.core + jackson-core + 2.15.2 + + + com.fasterxml.jackson.core + jackson-databind + 2.15.2 + + + com.fasterxml.jackson.core + jackson-annotations + 2.15.2 + + + com.fasterxml.jackson.dataformat + jackson-dataformat-xml + 2.15.2 + + + org.codehaus.woodstox + stax2-api + 4.2.2 + jar @@ -203,4 +221,4 @@ - \ No newline at end of file + diff --git a/jsystem-assembly/jsystem-runner/src/main/assembly/runner.xml b/jsystem-assembly/jsystem-runner/src/main/assembly/runner.xml index 1577c537..7b717e57 100644 --- a/jsystem-assembly/jsystem-runner/src/main/assembly/runner.xml +++ b/jsystem-assembly/jsystem-runner/src/main/assembly/runner.xml @@ -126,6 +126,8 @@ *:jackson-databind:* *:jackson-annotations:* *:jackson-core:* + *:jackson-dataformat-xml:* + *:stax2-api:* *:difido-reports-common:* @@ -170,4 +172,4 @@ - \ No newline at end of file + diff --git a/jsystem-core-projects/jsystemApp/src/main/java/jsystem/treeui/WaitDialog.java b/jsystem-core-projects/jsystemApp/src/main/java/jsystem/treeui/WaitDialog.java index 2189dbfb..ec6d51d6 100644 --- a/jsystem-core-projects/jsystemApp/src/main/java/jsystem/treeui/WaitDialog.java +++ b/jsystem-core-projects/jsystemApp/src/main/java/jsystem/treeui/WaitDialog.java @@ -23,8 +23,6 @@ import javax.swing.JProgressBar; import javax.swing.SwingWorker; -import sun.awt.AppContext; - import jsystem.framework.TestRunnerFrame; /** @@ -177,9 +175,6 @@ public synchronized static void launchWaitDialog(final String title, final WaitD /* * Execute the open of the dialog in a thread as the dialog is modal */ - // This line suppose to fix bug in the SwingWorker that causes deadlocks - // in some of the Java versions. Please see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6880336 - AppContext.getAppContext().put(SwingWorker.class, Executors.newCachedThreadPool()); dialog = new WaitDialog(TestRunnerFrame.guiMainFrame, listener, title); class RunWaitDiaolg extends SwingWorker { public String doInBackground() { diff --git a/jsystem-core-projects/jsystemApp/src/main/java/jsystem/treeui/agents/AgentsDialog.java b/jsystem-core-projects/jsystemApp/src/main/java/jsystem/treeui/agents/AgentsDialog.java index d7a38fb5..91958a9a 100644 --- a/jsystem-core-projects/jsystemApp/src/main/java/jsystem/treeui/agents/AgentsDialog.java +++ b/jsystem-core-projects/jsystemApp/src/main/java/jsystem/treeui/agents/AgentsDialog.java @@ -145,7 +145,7 @@ public void initDialog() throws Exception { } private void buildAgentsListTableModel() throws Exception { - Vector model = new Vector(); + Vector> model = new Vector>(); RunnerEngine[] clients = JSystemAgentClientsPool.getClients(null); for (RunnerEngine client : clients) { Vector clientRow = getJSystemAgentDataVector(client, false); @@ -231,7 +231,7 @@ private void refreshUrl(String url, ProgressNotifier notifier, int progress) { } class AgentListTableModel extends DefaultTableModel { - AgentListTableModel(Vector model, Vector columns) { + AgentListTableModel(Vector> model, Vector columns) { super(model, columns); } diff --git a/jsystem-core-projects/jsystemApp/src/main/java/jsystem/treeui/params/AgentsSelectionDialog.java b/jsystem-core-projects/jsystemApp/src/main/java/jsystem/treeui/params/AgentsSelectionDialog.java index 301803b3..6d7de82b 100644 --- a/jsystem-core-projects/jsystemApp/src/main/java/jsystem/treeui/params/AgentsSelectionDialog.java +++ b/jsystem-core-projects/jsystemApp/src/main/java/jsystem/treeui/params/AgentsSelectionDialog.java @@ -85,7 +85,7 @@ public void initDialog(String[] selectedUrls) throws Exception { } private void buildAgentsListTableModel() throws Exception { - Vector model = new Vector(); + Vector> model = new Vector>(); JSystemAgentClient[] clients = (JSystemAgentClient[]) JSystemAgentClientsPool.getClients(null); for (JSystemAgentClient client : clients) { Vector clientRow = getJSystemAgentDataVector(client); @@ -132,7 +132,7 @@ public String[] getSelectedUrls() { class AgentSelectTableModel extends DefaultTableModel { private static final long serialVersionUID = 1L; - AgentSelectTableModel(Vector model, Vector columns) { + AgentSelectTableModel(Vector> model, Vector columns) { super(model, columns); } diff --git a/jsystem-core-projects/jsystemApp/src/main/java/jsystem/treeui/teststable/ScenarioTreeNode.java b/jsystem-core-projects/jsystemApp/src/main/java/jsystem/treeui/teststable/ScenarioTreeNode.java index ef6b6867..f86c1a98 100644 --- a/jsystem-core-projects/jsystemApp/src/main/java/jsystem/treeui/teststable/ScenarioTreeNode.java +++ b/jsystem-core-projects/jsystemApp/src/main/java/jsystem/treeui/teststable/ScenarioTreeNode.java @@ -88,7 +88,7 @@ public boolean isLeaf() { return (!isJTestContainer() || ScenarioHelpers.isScenarioAsTestAndNotRoot(getTest())); } - public Enumeration children() { + public Enumeration children() { Vector elements = new Vector(); Vector tests = null; if (isJTestContainer()) { diff --git a/jsystem-core-projects/jsystemApp/src/main/java/jsystem/treeui/tree/AssetNode.java b/jsystem-core-projects/jsystemApp/src/main/java/jsystem/treeui/tree/AssetNode.java index ec8b88e8..401f54f8 100644 --- a/jsystem-core-projects/jsystemApp/src/main/java/jsystem/treeui/tree/AssetNode.java +++ b/jsystem-core-projects/jsystemApp/src/main/java/jsystem/treeui/tree/AssetNode.java @@ -88,7 +88,7 @@ public AssetNode(AssetNode parent, Object userObject) { public AssetNode(){ isSelected = false; if (children == null) { - children = new Vector(); + children = new Vector(); } } @@ -246,7 +246,7 @@ protected void initChildren(Object[] child) throws Exception { } } if("true".equals(JSystemProperties.getInstance().getPreferenceOrDefault(FrameworkOptions.SORT_ASSETS_TREE))){ - Collections.sort(children); + Collections.sort(children, null); } } diff --git a/jsystem-core-projects/jsystemApp/src/main/java/jsystem/treeui/tree/TestCaseNode.java b/jsystem-core-projects/jsystemApp/src/main/java/jsystem/treeui/tree/TestCaseNode.java index 60b22736..74ffff8f 100644 --- a/jsystem-core-projects/jsystemApp/src/main/java/jsystem/treeui/tree/TestCaseNode.java +++ b/jsystem-core-projects/jsystemApp/src/main/java/jsystem/treeui/tree/TestCaseNode.java @@ -36,7 +36,7 @@ public TestCaseNode(AssetNode parent, Class userObject) throws Exception { createJUnit4TestNodes(userObject); } if("true".equals(JSystemProperties.getInstance().getPreferenceOrDefault(FrameworkOptions.SORT_ASSETS_TREE))){ - Collections.sort(children); + Collections.sort(children, null); } } diff --git a/jsystem-core-projects/jsystemCore/pom.xml b/jsystem-core-projects/jsystemCore/pom.xml index b2050501..477c065f 100644 --- a/jsystem-core-projects/jsystemCore/pom.xml +++ b/jsystem-core-projects/jsystemCore/pom.xml @@ -74,6 +74,22 @@ xml-apis xml-apis + + com.fasterxml.jackson.core + jackson-core + + + com.fasterxml.jackson.core + jackson-databind + + + com.fasterxml.jackson.core + jackson-annotations + + + com.fasterxml.jackson.dataformat + jackson-dataformat-xml + @@ -84,4 +100,4 @@ run - \ No newline at end of file + diff --git a/jsystem-core-projects/jsystemCore/src/main/java/jsystem/extensions/report/junit/JUnitReporter.java b/jsystem-core-projects/jsystemCore/src/main/java/jsystem/extensions/report/junit/JUnitReporter.java index 5311e896..7765b1f6 100644 --- a/jsystem-core-projects/jsystemCore/src/main/java/jsystem/extensions/report/junit/JUnitReporter.java +++ b/jsystem-core-projects/jsystemCore/src/main/java/jsystem/extensions/report/junit/JUnitReporter.java @@ -2,7 +2,7 @@ import java.io.File; import java.io.IOException; -import java.io.StringWriter; + import java.net.InetAddress; import java.net.UnknownHostException; import java.util.ArrayList; @@ -11,12 +11,12 @@ import java.util.logging.Level; import java.util.logging.Logger; -import javax.xml.bind.JAXBContext; -import javax.xml.bind.Marshaller; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlValue; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.XmlMapper; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlText; import jsystem.extensions.report.xml.XmlReporter; import jsystem.framework.FrameworkOptions; @@ -134,19 +134,17 @@ private static FailureOrError buildFailureOrError(Throwable throwable) { } /** - * Exports the model to XML. The file will be copies to the JSystem root + * Exports the model to XML. The file will be copied to the JSystem root * directory. */ public void toXml() { testSuite.setTime(getTimeDeltaInSec(testSuiteStart)); try { - JAXBContext context = JAXBContext.newInstance(testSuite.getClass()); - Marshaller marshaller = context.createMarshaller(); - StringWriter sw = new StringWriter(); - marshaller.marshal(testSuite, sw); + XmlMapper xmlMapper = new XmlMapper(); + String xmlString = xmlMapper.writeValueAsString(testSuite); final String currentLogFolder = JSystemProperties.getInstance().getPreference(FrameworkOptions.LOG_FOLDER) + File.separator + "current"; - FileUtils.write(currentLogFolder + File.separator + logFileName, sw.toString()); + FileUtils.write(currentLogFolder + File.separator + logFileName, xmlString); } catch (Exception e) { log.log(Level.SEVERE, "Failed to export report to XML", e); } @@ -177,7 +175,7 @@ static class TestCase { private FailureOrError error; - @XmlAttribute + @JacksonXmlProperty(isAttribute = true) public String getName() { return name; } @@ -186,7 +184,7 @@ public void setName(String name) { this.name = name; } - @XmlAttribute(name = "classname") + @JacksonXmlProperty(isAttribute = true, localName = "classname") public String getClassName() { return className; } @@ -195,7 +193,7 @@ public void setClassName(String className) { this.className = className; } - @XmlAttribute + @JacksonXmlProperty(isAttribute = true) public float getTime() { return time; } @@ -204,7 +202,7 @@ public void setTime(float time) { this.time = time; } - @XmlElement + @JsonProperty public FailureOrError getFailure() { return failure; } @@ -213,7 +211,7 @@ public void setFailure(FailureOrError failure) { this.failure = failure; } - @XmlElement + @JsonProperty public FailureOrError getError() { return error; } @@ -224,7 +222,7 @@ public void setError(FailureOrError error) { } - @XmlRootElement(name = "testsuite") + @JacksonXmlRootElement(localName = "testsuite") static class TestSuite { private int errors; @@ -239,7 +237,8 @@ static class TestSuite { private String timeStamp; - @XmlElement(name = "testcase") + @JacksonXmlElementWrapper(useWrapping = false) + @JsonProperty("testcase") protected List testCaseList = new ArrayList(); public TestCase getLastTestCase() { @@ -259,7 +258,7 @@ public void addTestCase(TestCase testCase) { testCaseList.add(testCase); } - @XmlAttribute + @JacksonXmlProperty(isAttribute = true) public int getErrors() { return errors; } @@ -268,7 +267,7 @@ public void addError() { errors++; } - @XmlAttribute + @JacksonXmlProperty(isAttribute = true) public int getFailures() { return failures; } @@ -277,7 +276,7 @@ public void setFailures(int failures) { this.failures = failures; } - @XmlAttribute + @JacksonXmlProperty(isAttribute = true) public String getHostName() { return hostName; } @@ -286,7 +285,7 @@ public void setHostName(String hostName) { this.hostName = hostName; } - @XmlAttribute + @JacksonXmlProperty(isAttribute = true) public String getName() { return name; } @@ -295,12 +294,12 @@ public void setName(String name) { this.name = name; } - @XmlAttribute + @JacksonXmlProperty(isAttribute = true) public String getTimeStamp() { return timeStamp; } - @XmlAttribute + @JacksonXmlProperty(isAttribute = true) public float getTime() { return time; } @@ -313,7 +312,7 @@ public void setTimeStamp(String timeStamp) { this.timeStamp = timeStamp; } - @XmlAttribute + @JacksonXmlProperty(isAttribute = true) public int getTests() { return testCaseList.size(); } @@ -325,7 +324,7 @@ static class FailureOrError { private String message; private String type; - @XmlAttribute + @JacksonXmlProperty(isAttribute = true) public String getMessage() { return message; } @@ -334,7 +333,7 @@ public void setMessage(String message) { this.message = message; } - @XmlAttribute + @JacksonXmlProperty(isAttribute = true) public String getType() { return type; } @@ -343,7 +342,7 @@ public void setType(String type) { this.type = type; } - @XmlValue + @JacksonXmlText public String getValue() { return value; } diff --git a/jsystem-core-projects/jsystemCore/src/main/java/jsystem/utils/Encryptor.java b/jsystem-core-projects/jsystemCore/src/main/java/jsystem/utils/Encryptor.java index ae79afb8..bc0b11a0 100644 --- a/jsystem-core-projects/jsystemCore/src/main/java/jsystem/utils/Encryptor.java +++ b/jsystem-core-projects/jsystemCore/src/main/java/jsystem/utils/Encryptor.java @@ -3,6 +3,7 @@ */ package jsystem.utils; +import java.util.Base64; import javax.crypto.Cipher; import javax.crypto.spec.SecretKeySpec; @@ -48,7 +49,7 @@ public static String encrypt(String str) throws Exception { byte[] enc = ecipher.doFinal(utf8); // Encode bytes to base64 to get a string - return (new sun.misc.BASE64Encoder().encode(enc))+ENCRYPTION_TERMINATING_STRING; + return Base64.getEncoder().encode(enc)+ENCRYPTION_TERMINATING_STRING; } /** @@ -70,7 +71,7 @@ public static String decrypt(String str) throws Exception { ecipher.init(Cipher.ENCRYPT_MODE, key); dcipher.init(Cipher.DECRYPT_MODE, key); // Decode base64 to get bytes - byte[] dec = new sun.misc.BASE64Decoder().decodeBuffer(str); + byte[] dec = Base64.getDecoder().decode(str); // Decrypt byte[] utf8 = dcipher.doFinal(dec); diff --git a/jsystem-core-projects/jsystemCore/src/main/java/jsystem/utils/MailUtil.java b/jsystem-core-projects/jsystemCore/src/main/java/jsystem/utils/MailUtil.java index 760be81e..a4345c14 100644 --- a/jsystem-core-projects/jsystemCore/src/main/java/jsystem/utils/MailUtil.java +++ b/jsystem-core-projects/jsystemCore/src/main/java/jsystem/utils/MailUtil.java @@ -4,7 +4,7 @@ package jsystem.utils; import java.io.File; -import java.security.Security; + import java.util.ArrayList; import java.util.Properties; @@ -169,8 +169,6 @@ public void sendMail(String title,String msgContent) throws Exception { props.put("mail.smtp.socketFactory.fallback", "false"); } - Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider()); - props.put("mail.smtp.host", smtpHostName); props.put("mail.debug", isDebug + ""); diff --git a/jsystem-core-projects/pom.xml b/jsystem-core-projects/pom.xml index 4a9c317e..1b822dec 100644 --- a/jsystem-core-projects/pom.xml +++ b/jsystem-core-projects/pom.xml @@ -20,5 +20,26 @@ jsystemAgent jsystemApp - + + + com.fasterxml.jackson.core + jackson-core + 2.15.2 + + + com.fasterxml.jackson.core + jackson-databind + 2.15.2 + + + com.fasterxml.jackson.core + jackson-annotations + 2.15.2 + + + com.fasterxml.jackson.dataformat + jackson-dataformat-xml + 2.15.2 + + \ No newline at end of file diff --git a/jsystem-miscellaneous/jsystem-maven-plugin/pom.xml b/jsystem-miscellaneous/jsystem-maven-plugin/pom.xml index fd4cb8fd..1dcc3258 100644 --- a/jsystem-miscellaneous/jsystem-maven-plugin/pom.xml +++ b/jsystem-miscellaneous/jsystem-maven-plugin/pom.xml @@ -60,6 +60,22 @@ 2.0.2 provided + + com.fasterxml.jackson.core + jackson-core + + + com.fasterxml.jackson.core + jackson-databind + + + com.fasterxml.jackson.core + jackson-annotations + + + com.fasterxml.jackson.dataformat + jackson-dataformat-xml + diff --git a/jsystem-miscellaneous/jsystem-maven-plugin/src/main/java/org/jsystemtest/plugin/SurefireReporter.java b/jsystem-miscellaneous/jsystem-maven-plugin/src/main/java/org/jsystemtest/plugin/SurefireReporter.java index 63c7840d..31c67d3a 100644 --- a/jsystem-miscellaneous/jsystem-maven-plugin/src/main/java/org/jsystemtest/plugin/SurefireReporter.java +++ b/jsystem-miscellaneous/jsystem-maven-plugin/src/main/java/org/jsystemtest/plugin/SurefireReporter.java @@ -2,7 +2,7 @@ import java.io.File; import java.io.IOException; -import java.io.StringWriter; + import java.net.InetAddress; import java.net.UnknownHostException; import java.util.ArrayList; @@ -11,12 +11,12 @@ import java.util.logging.Level; import java.util.logging.Logger; -import javax.xml.bind.JAXBContext; -import javax.xml.bind.Marshaller; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlValue; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.XmlMapper; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlText; import jsystem.extensions.report.xml.XmlReporter; import jsystem.framework.report.ExtendTestListener; @@ -146,12 +146,10 @@ private static FailureOrError buildFailureOrError(Throwable throwable) { public void toXml() { testSuite.setTime(getTimeDeltaInSec(testSuiteStart)); try { - JAXBContext context = JAXBContext.newInstance(testSuite.getClass()); - Marshaller marshaller = context.createMarshaller(); - StringWriter sw = new StringWriter(); - marshaller.marshal(testSuite, sw); - FileUtils.write(logFolderName + File.separator + logFileName, sw.toString()); - FileUtils.write(logFileName, sw.toString()); + XmlMapper xmlMapper = new XmlMapper(); + String xmlString = xmlMapper.writeValueAsString(testSuite); + FileUtils.write(logFolderName + File.separator + logFileName, xmlString); + FileUtils.write(logFileName, xmlString); } catch (Exception e) { log.log(Level.SEVERE, "Failed to export report to XML", e); } @@ -182,7 +180,7 @@ static class TestCase { private FailureOrError error; - @XmlAttribute + @JacksonXmlProperty(isAttribute = true) public String getName() { return name; } @@ -191,7 +189,7 @@ public void setName(String name) { this.name = name; } - @XmlAttribute(name = "classname") + @JacksonXmlProperty(isAttribute = true, localName = "classname") public String getClassName() { return className; } @@ -200,7 +198,7 @@ public void setClassName(String className) { this.className = className; } - @XmlAttribute + @JacksonXmlProperty(isAttribute = true) public float getTime() { return time; } @@ -209,7 +207,7 @@ public void setTime(float time) { this.time = time; } - @XmlElement + @JsonProperty public FailureOrError getFailure() { return failure; } @@ -218,7 +216,7 @@ public void setFailure(FailureOrError failure) { this.failure = failure; } - @XmlElement + @JsonProperty public FailureOrError getError() { return error; } @@ -229,7 +227,7 @@ public void setError(FailureOrError error) { } - @XmlRootElement(name = "testsuite") + @JacksonXmlRootElement(localName = "testsuite") static class TestSuite { private int errors; @@ -244,7 +242,8 @@ static class TestSuite { private String timeStamp; - @XmlElement(name = "testcase") + @JacksonXmlElementWrapper(useWrapping = false) + @JsonProperty("testcase") protected List testCaseList = new ArrayList(); public TestCase getLastTestCase() { @@ -264,7 +263,7 @@ public void addTestCase(TestCase testCase) { testCaseList.add(testCase); } - @XmlAttribute + @JacksonXmlProperty(isAttribute = true) public int getErrors() { return errors; } @@ -273,7 +272,7 @@ public void addError() { errors++; } - @XmlAttribute + @JacksonXmlProperty(isAttribute = true) public int getFailures() { return failures; } @@ -282,7 +281,7 @@ public void setFailures(int failures) { this.failures = failures; } - @XmlAttribute + @JacksonXmlProperty(isAttribute = true) public String getHostName() { return hostName; } @@ -291,7 +290,7 @@ public void setHostName(String hostName) { this.hostName = hostName; } - @XmlAttribute + @JacksonXmlProperty(isAttribute = true) public String getName() { return name; } @@ -300,12 +299,12 @@ public void setName(String name) { this.name = name; } - @XmlAttribute + @JacksonXmlProperty(isAttribute = true) public String getTimeStamp() { return timeStamp; } - @XmlAttribute + @JacksonXmlProperty(isAttribute = true) public float getTime() { return time; } @@ -318,7 +317,7 @@ public void setTimeStamp(String timeStamp) { this.timeStamp = timeStamp; } - @XmlAttribute + @JacksonXmlProperty(isAttribute = true) public int getTests() { return testCaseList.size(); } @@ -330,7 +329,7 @@ static class FailureOrError { private String message; private String type; - @XmlAttribute + @JacksonXmlProperty(isAttribute = true) public String getMessage() { return message; } @@ -339,7 +338,7 @@ public void setMessage(String message) { this.message = message; } - @XmlAttribute + @JacksonXmlProperty(isAttribute = true) public String getType() { return type; } @@ -348,7 +347,7 @@ public void setType(String type) { this.type = type; } - @XmlValue + @JacksonXmlText public String getValue() { return value; } diff --git a/jsystem-parent/pom.xml b/jsystem-parent/pom.xml index 9b4e5b80..02e63bcb 100644 --- a/jsystem-parent/pom.xml +++ b/jsystem-parent/pom.xml @@ -29,8 +29,8 @@ UTF-8 dir https://maven.top-q.co.il - 1.8 - 1.8 + 17 + 17 @@ -46,7 +46,6 @@ junit 4.13.1 - javax.mail mail @@ -209,6 +208,26 @@ xml-apis 1.4.01 + + com.fasterxml.jackson.core + jackson-core + 2.15.2 + + + com.fasterxml.jackson.core + jackson-databind + 2.15.2 + + + com.fasterxml.jackson.core + jackson-annotations + 2.15.2 + + + com.fasterxml.jackson.dataformat + jackson-dataformat-xml + 2.15.2 + From fec3f7b4eb0b76677efff1293a7f7e6abda47702 Mon Sep 17 00:00:00 2001 From: Udi Kalifon Date: Sat, 23 Aug 2025 16:16:56 +0200 Subject: [PATCH 2/2] Revert changes to JUnitReporter 1) Jackson introduced a regression in JUnitReporter, and for some strange reason the "classname" attribute was serialized out with garbage characters in it. Going back to the old version based on JAXB. Jackson is still used everywhere else. 2) Adding JAXB dependencies to the assembly to avoid the runtime error: SEVERE: Fail to endRun java.lang.NoClassDefFoundError: javax/xml/bind/JAXBContext at jsystem.extensions.report.junit.JUnitReporter.toXml(JUnitReporter.java:143) at jsystem.extensions.report.junit.JUnitReporter.endRun(JUnitReporter.java:369) --- jsystem-assembly/jsystem-runner/pom.xml | 19 +++++++ .../src/main/assembly/runner.xml | 4 ++ jsystem-core-projects/jsystemCore/pom.xml | 10 ++++ .../report/junit/JUnitReporter.java | 57 ++++++++++--------- jsystem-core-projects/pom.xml | 7 ++- jsystem-parent/pom.xml | 5 ++ 6 files changed, 73 insertions(+), 29 deletions(-) diff --git a/jsystem-assembly/jsystem-runner/pom.xml b/jsystem-assembly/jsystem-runner/pom.xml index d84418db..e22ac780 100644 --- a/jsystem-assembly/jsystem-runner/pom.xml +++ b/jsystem-assembly/jsystem-runner/pom.xml @@ -13,6 +13,25 @@ junit junit + + javax.xml.bind + jaxb-api + + + com.sun.xml.bind + jaxb-core + 2.3.0.1 + + + com.sun.xml.bind + jaxb-impl + 2.3.1 + + + org.javassist + javassist + 3.25.0-GA + ant ant-full diff --git a/jsystem-assembly/jsystem-runner/src/main/assembly/runner.xml b/jsystem-assembly/jsystem-runner/src/main/assembly/runner.xml index 7b717e57..c5a19a05 100644 --- a/jsystem-assembly/jsystem-runner/src/main/assembly/runner.xml +++ b/jsystem-assembly/jsystem-runner/src/main/assembly/runner.xml @@ -128,6 +128,10 @@ *:jackson-core:* *:jackson-dataformat-xml:* *:stax2-api:* + *:jaxb-api:* + *:jaxb-core:* + *:jaxb-impl:* + *:javassist:* *:difido-reports-common:* diff --git a/jsystem-core-projects/jsystemCore/pom.xml b/jsystem-core-projects/jsystemCore/pom.xml index 477c065f..e66636ec 100644 --- a/jsystem-core-projects/jsystemCore/pom.xml +++ b/jsystem-core-projects/jsystemCore/pom.xml @@ -90,6 +90,16 @@ com.fasterxml.jackson.dataformat jackson-dataformat-xml + + javax.xml.bind + jaxb-api + 2.3.1 + + + org.glassfish.jaxb + jaxb-runtime + 2.3.1 + diff --git a/jsystem-core-projects/jsystemCore/src/main/java/jsystem/extensions/report/junit/JUnitReporter.java b/jsystem-core-projects/jsystemCore/src/main/java/jsystem/extensions/report/junit/JUnitReporter.java index 7765b1f6..1384e8de 100644 --- a/jsystem-core-projects/jsystemCore/src/main/java/jsystem/extensions/report/junit/JUnitReporter.java +++ b/jsystem-core-projects/jsystemCore/src/main/java/jsystem/extensions/report/junit/JUnitReporter.java @@ -2,7 +2,7 @@ import java.io.File; import java.io.IOException; - +import java.io.StringWriter; import java.net.InetAddress; import java.net.UnknownHostException; import java.util.ArrayList; @@ -11,12 +11,12 @@ import java.util.logging.Level; import java.util.logging.Logger; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.dataformat.xml.XmlMapper; -import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper; -import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; -import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; -import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlText; +import javax.xml.bind.JAXBContext; +import javax.xml.bind.Marshaller; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlValue; import jsystem.extensions.report.xml.XmlReporter; import jsystem.framework.FrameworkOptions; @@ -140,11 +140,13 @@ private static FailureOrError buildFailureOrError(Throwable throwable) { public void toXml() { testSuite.setTime(getTimeDeltaInSec(testSuiteStart)); try { - XmlMapper xmlMapper = new XmlMapper(); - String xmlString = xmlMapper.writeValueAsString(testSuite); + JAXBContext context = JAXBContext.newInstance(testSuite.getClass()); + Marshaller marshaller = context.createMarshaller(); + StringWriter sw = new StringWriter(); + marshaller.marshal(testSuite, sw); final String currentLogFolder = JSystemProperties.getInstance().getPreference(FrameworkOptions.LOG_FOLDER) + File.separator + "current"; - FileUtils.write(currentLogFolder + File.separator + logFileName, xmlString); + FileUtils.write(currentLogFolder + File.separator + logFileName, sw.toString()); } catch (Exception e) { log.log(Level.SEVERE, "Failed to export report to XML", e); } @@ -175,7 +177,7 @@ static class TestCase { private FailureOrError error; - @JacksonXmlProperty(isAttribute = true) + @XmlAttribute public String getName() { return name; } @@ -184,7 +186,7 @@ public void setName(String name) { this.name = name; } - @JacksonXmlProperty(isAttribute = true, localName = "classname") + @XmlAttribute(name = "classname") public String getClassName() { return className; } @@ -193,7 +195,7 @@ public void setClassName(String className) { this.className = className; } - @JacksonXmlProperty(isAttribute = true) + @XmlAttribute public float getTime() { return time; } @@ -202,7 +204,7 @@ public void setTime(float time) { this.time = time; } - @JsonProperty + @XmlElement public FailureOrError getFailure() { return failure; } @@ -211,7 +213,7 @@ public void setFailure(FailureOrError failure) { this.failure = failure; } - @JsonProperty + @XmlElement public FailureOrError getError() { return error; } @@ -222,7 +224,7 @@ public void setError(FailureOrError error) { } - @JacksonXmlRootElement(localName = "testsuite") + @XmlRootElement(name = "testsuite") static class TestSuite { private int errors; @@ -237,8 +239,7 @@ static class TestSuite { private String timeStamp; - @JacksonXmlElementWrapper(useWrapping = false) - @JsonProperty("testcase") + @XmlElement(name = "testcase") protected List testCaseList = new ArrayList(); public TestCase getLastTestCase() { @@ -258,7 +259,7 @@ public void addTestCase(TestCase testCase) { testCaseList.add(testCase); } - @JacksonXmlProperty(isAttribute = true) + @XmlAttribute public int getErrors() { return errors; } @@ -267,7 +268,7 @@ public void addError() { errors++; } - @JacksonXmlProperty(isAttribute = true) + @XmlAttribute public int getFailures() { return failures; } @@ -276,7 +277,7 @@ public void setFailures(int failures) { this.failures = failures; } - @JacksonXmlProperty(isAttribute = true) + @XmlAttribute public String getHostName() { return hostName; } @@ -285,7 +286,7 @@ public void setHostName(String hostName) { this.hostName = hostName; } - @JacksonXmlProperty(isAttribute = true) + @XmlAttribute public String getName() { return name; } @@ -294,12 +295,12 @@ public void setName(String name) { this.name = name; } - @JacksonXmlProperty(isAttribute = true) + @XmlAttribute public String getTimeStamp() { return timeStamp; } - @JacksonXmlProperty(isAttribute = true) + @XmlAttribute public float getTime() { return time; } @@ -312,7 +313,7 @@ public void setTimeStamp(String timeStamp) { this.timeStamp = timeStamp; } - @JacksonXmlProperty(isAttribute = true) + @XmlAttribute public int getTests() { return testCaseList.size(); } @@ -324,7 +325,7 @@ static class FailureOrError { private String message; private String type; - @JacksonXmlProperty(isAttribute = true) + @XmlAttribute public String getMessage() { return message; } @@ -333,7 +334,7 @@ public void setMessage(String message) { this.message = message; } - @JacksonXmlProperty(isAttribute = true) + @XmlAttribute public String getType() { return type; } @@ -342,7 +343,7 @@ public void setType(String type) { this.type = type; } - @JacksonXmlText + @XmlValue public String getValue() { return value; } diff --git a/jsystem-core-projects/pom.xml b/jsystem-core-projects/pom.xml index 1b822dec..e1249592 100644 --- a/jsystem-core-projects/pom.xml +++ b/jsystem-core-projects/pom.xml @@ -41,5 +41,10 @@ jackson-dataformat-xml 2.15.2 + + javax.xml.bind + jaxb-api + 2.3.1 + - \ No newline at end of file + diff --git a/jsystem-parent/pom.xml b/jsystem-parent/pom.xml index 02e63bcb..af6573e0 100644 --- a/jsystem-parent/pom.xml +++ b/jsystem-parent/pom.xml @@ -228,6 +228,11 @@ jackson-dataformat-xml 2.15.2 + + javax.xml.bind + jaxb-api + 2.3.1 +