Skip to content

Commit

Permalink
[WINDUPRULE-911] Rules for Jakarta SOAP 3.0 (#863)
Browse files Browse the repository at this point in the history
* [WINDUPRULE-911] Rules for Jakarta SOAP 3.0

* [WINDUPRULE-911] Fix test

* Fix javax-to-jakarta-package.windup.test.xml hints

---------

Co-authored-by: carlosthe19916 <2582866+carlosthe19916@users.noreply.github.com>
  • Loading branch information
jmle and carlosthe19916 committed Feb 22, 2023
1 parent 2d706b6 commit 3bbf0be
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 1 deletion.
39 changes: 39 additions & 0 deletions rules/rules-reviewed/eap8/eap7/jakarta-soap.windup.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0"?>
<ruleset xmlns="http://windup.jboss.org/schema/jboss-ruleset" id="jakarta-soap"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://windup.jboss.org/schema/jboss-ruleset http://windup.jboss.org/schema/jboss-ruleset/windup-jboss-ruleset.xsd">
<metadata>
<description>
This ruleset provides analysis of Java EE applications that need to migrate to Jakarta SOAP with Attachments 3.0.
</description>
<dependencies>
<addon id="org.jboss.windup.rules,windup-rules-javaee,3.0.0.Final" />
<addon id="org.jboss.windup.rules,windup-rules-java,3.0.0.Final" />
</dependencies>
<targetTechnology id="eap" versionRange="[8,9)" />
</metadata>
<rules>
<rule id="jakarta-soap-00010">
<when>
<javaclass references="javax.xml.soap.SOAPElementFactory.newInstance({*})"/>
</when>
<perform>
<hint title="javax.xml.soap.SOAPElementFactory.newInstance() must be replaced" effort="1" category-id="mandatory">
<message>`javax.xml.soap.SOAPElementFactory.newInstance()` must be replaced with `jakarta.xml.soap.SOAPFactory.newInstance()`.</message>
</hint>
</perform>
</rule>
<rule id="jakarta-soap-00020">
<when>
<javaclass references="javax.xml.soap.SOAPElementFactory.create({*})">
<location>METHOD_CALL</location>
</javaclass>
</when>
<perform>
<hint title="javax.xml.soap.SOAPElementFactory.create() must be replaced" effort="1" category-id="mandatory">
<message>`javax.xml.soap.SOAPElementFactory.create()` must be replaced with `jakarta.xml.soap.SOAPFactory.createElement()`. If `javax.xml.soap.Name` is passed as a parameter, it must be replaced with `jakarta.xml.soap.Name`.</message>
</hint>
</perform>
</rule>
</rules>
</ruleset>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import javax.xml.soap.SOAPElementFactory;
import javax.xml.soap.Name;

public class JakartaSOAP {

public static void main(String[] args) {
SOAPElementFactory factory = SOAPElementFactory.newInstance();

Name name = null;
factory.create(name);
factory.create("name");
factory.create("name", "name", "name");
}
}
34 changes: 34 additions & 0 deletions rules/rules-reviewed/eap8/eap7/tests/jakarta-soap.windup.test.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0"?>
<ruletest id="jakarta-soap-tests"
xmlns="http://windup.jboss.org/schema/jboss-ruleset"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://windup.jboss.org/schema/jboss-ruleset http://windup.jboss.org/schema/jboss-ruleset/windup-jboss-ruleset.xsd">
<testDataPath>data/jakarta-soap</testDataPath>
<rulePath>../jakarta-soap.windup.xml</rulePath>
<ruleset>
<rules>
<rule id="jakarta-soap-00010-test">
<when>
<not>
<hint-exists message="`javax.xml.soap.SOAPElementFactory.newInstance\(\)` must be replaced with `jakarta.xml.soap.SOAPFactory.newInstance\(\)`."/>
</not>
</when>
<perform>
<fail message="[jakarta-soap-00010] The hint was not found!" />
</perform>
</rule>
<rule id="jakarta-soap-00020-test">
<when>
<not>
<iterable-filter size="3">
<hint-exists message="`javax.xml.soap.SOAPElementFactory.create\(\)` must be replaced with `jakarta.xml.soap.SOAPFactory.createElement\(\)`. If `javax.xml.soap.Name` is passed as a parameter, it must be replaced with `jakarta.xml.soap.Name`."/>
</iterable-filter>
</not>
</when>
<perform>
<fail message="[jakarta-soap-00020] The hint was not found!" />
</perform>
</rule>
</rules>
</ruleset>
</ruletest>
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<rule id="javax-to-jakarta-import-00001-test">
<when>
<not>
<iterable-filter size="39">
<iterable-filter size="41">
<hint-exists message="Replace the `javax."/>
</iterable-filter>
</not>
Expand Down

0 comments on commit 3bbf0be

Please sign in to comment.