Skip to content

Commit

Permalink
[WINDUPRULE-1019] adds eap 8 ruleset deprecated-initialcontextfactory…
Browse files Browse the repository at this point in the history
…-is-removed (#1044)
  • Loading branch information
emmartins committed Dec 11, 2023
1 parent fc3be5a commit 3898ec3
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0"?>
<ruleset xmlns="http://windup.jboss.org/schema/jboss-ruleset" id="deprecated-initialcontextfactory-is-removed"
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 change their sources due to the removal of deprecated InitialContextFactory class.
</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" />
<addon id="org.jboss.windup.rules,windup-rules-xml,3.0.0.Final" />
</dependencies>
<sourceTechnology id="eap" versionRange="[6,8)" />
<targetTechnology id="eap" versionRange="[8,)" />
</metadata>
<rules>
<rule id="deprecated-initialcontextfactory-is-removed-00001">
<when>
<or>
<javaclass references="org.jboss.naming.remote.client.InitialContextFactory" />
<filecontent pattern='"org.jboss.naming.remote.client.InitialContextFactory"' filename="{*}.java"/>
<filecontent pattern="org.jboss.naming.remote.client.InitialContextFactory" filename="{*}.wsdl"/>
</or>
</when>
<perform>
<hint title="Class org.jboss.naming.remote.client.InitialContextFactory has been removed" effort="1" category-id="mandatory">
<message>Replace this class with `org.wildfly.naming.client.WildFlyInitialContextFactory`.</message>
<tag>JakartaEE</tag>
</hint>
</perform>
</rule>
</rules>
</ruleset>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import org.jboss.naming.remote.client.InitialContextFactory;

public class DeprecatedInitialcontextfactoryIsRemoved {

String propertyValue = "org.jboss.naming.remote.client.InitialContextFactory";

public String getDeprecatedClassName() {
return InitialContextFactory.class.getName();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<definitions name = "HelloService"
targetNamespace = "http://www.examples.com/wsdl/HelloService.wsdl"
xmlns = "http://schemas.xmlsoap.org/wsdl/"
xmlns:soapjms = "http://schemas.xmlsoap.org/wsdl/soap/">
<service name="exampleService">
<soapjms:jndiInitialContextFactory>org.jboss.naming.remote.client.InitialContextFactory</soapjms:jndiInitialContextFactory>
</service>
</definitions>
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0"?>
<ruletest id="deprecated-initialcontextfactory-is-removed-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/deprecated-initialcontextfactory-is-removed</testDataPath>
<rulePath>../deprecated-initialcontextfactory-is-removed.windup.xml</rulePath>
<ruleset>
<rules>
<rule id="deprecated-initialcontextfactory-is-removed-00001-test">
<when>
<not>
<iterable-filter size="3">
<hint-exists message="Replace this class with `org.wildfly.naming.client.WildFlyInitialContextFactory`."/>
</iterable-filter>
</not>
</when>
<perform>
<fail message="[deprecated-initialcontextfactory-is-removed-00001] The hint was not found!" />
</perform>
</rule>
</rules>
</ruleset>
</ruletest>

0 comments on commit 3898ec3

Please sign in to comment.