-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rule that checks Tomcat external resources for Azure migration (#932)
* Lombok <1.18.22 is not compatible with JDK 17 * Rule that checks Tomcat external resources for Azure migration * Update rules/rules-reviewed/azure/tomcat/tests/tomcat-to-azure-external-resources.windup.test.xml Co-authored-by: Marco Rizzi <mrizzi@users.noreply.github.com> --------- Co-authored-by: Marco Rizzi <mrizzi@users.noreply.github.com> Co-authored-by: PhilipCattanach <31246010+PhilipCattanach@users.noreply.github.com>
- Loading branch information
1 parent
a163d71
commit 0a238ac
Showing
4 changed files
with
95 additions
and
0 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
rules/rules-reviewed/azure/tomcat/tests/data/tomcat-to-azure-external-resources/context.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<Context> | ||
|
||
<WatchedResource>WEB-INF/web.xml</WatchedResource> | ||
<WatchedResource>WEB-INF/tomcat-web.xml</WatchedResource> | ||
<WatchedResource>${catalina.base}/conf/web.xml</WatchedResource> | ||
|
||
<Resource name="jdbc/postgres1" auth="Container" type="javax.sql.DataSource" | ||
driverClassName="org.postgresql.Driver" url="jdbc:postgresql://127.0.0.1:5432" | ||
username="postgres" password="yes" maxActive="20" maxIdle="10" | ||
maxWait="-1" /> | ||
|
||
<Resource name="jdbc/postgres2" auth="Container" type="javax.sql.DataSource" | ||
driverClassName="org.postgresql.Driver" url="jdbc:postgresql://127.0.0.1:5432" | ||
username="postgres" password="yes" maxActive="20" maxIdle="10" | ||
maxWait="-1" /> | ||
|
||
<NoResource name="jdbc/postgres" auth="Container" type="javax.sql.DataSource" | ||
driverClassName="org.postgresql.Driver" url="jdbc:postgresql://127.0.0.1:5432" | ||
username="postgres" password="yes" maxActive="20" maxIdle="10" | ||
maxWait="-1" /> | ||
</Context> |
12 changes: 12 additions & 0 deletions
12
.../rules-reviewed/azure/tomcat/tests/data/tomcat-to-azure-external-resources/no-context.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<Context> | ||
|
||
<WatchedResource>WEB-INF/web.xml</WatchedResource> | ||
<WatchedResource>WEB-INF/tomcat-web.xml</WatchedResource> | ||
<WatchedResource>${catalina.base}/conf/web.xml</WatchedResource> | ||
|
||
<Resource name="jdbc/postgres" auth="Container" type="javax.sql.DataSource" | ||
driverClassName="org.postgresql.Driver" url="jdbc:postgresql://127.0.0.1:5432" | ||
username="postgres" password="yes" maxActive="20" maxIdle="10" | ||
maxWait="-1" /> | ||
</Context> |
22 changes: 22 additions & 0 deletions
22
rules/rules-reviewed/azure/tomcat/tests/tomcat-to-azure-external-resources.windup.test.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0"?> | ||
<ruletest id="tomcat-to-azure-external-resources-test" 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/tomcat-to-azure-external-resources</testDataPath> | ||
<rulePath>../tomcat-to-azure-external-resources.windup.xml</rulePath> | ||
<ruleset> | ||
<rules> | ||
<rule id="tomcat-to-azure-external-resources-test-01000"> | ||
<when> | ||
<not> | ||
<iterable-filter size="2"> | ||
<hint-exists message="External resources, such as data sources, JMS message brokers, and others are injected via Java Naming and Directory Interface \(JNDI\)"/> | ||
</iterable-filter> | ||
</not> | ||
</when> | ||
<perform> | ||
<fail message="External resources found in configuration file hint was not found!"/> | ||
</perform> | ||
</rule> | ||
</rules> | ||
</ruleset> | ||
</ruletest> |
39 changes: 39 additions & 0 deletions
39
rules/rules-reviewed/azure/tomcat/tomcat-to-azure-external-resources.windup.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?xml version="1.0"?> | ||
<ruleset id="tomcat-to-azure-external-resources" | ||
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"> | ||
<metadata> | ||
<description> | ||
Identify external resources in a Tomcat configuration file. | ||
</description> | ||
<dependencies> | ||
<addon id="org.jboss.windup.rules,windup-rules-xml,3.0.0.Final" /> | ||
</dependencies> | ||
<targetTechnology id="azure-spring-apps"/> | ||
<targetTechnology id="azure-appservice"/> | ||
<targetTechnology id="azure-aks"/> | ||
<targetTechnology id="azure-container-apps"/> | ||
<tag>tomcat</tag> | ||
</metadata> | ||
<rules> | ||
<rule id="tomcat-to-azure-external-resources-01000"> | ||
<when> | ||
<xmlfile matches="/Context/Resource" in="context.xml"/> | ||
</when> | ||
<perform> | ||
<hint title="External resources found in configuration file" category-id="cloud-mandatory" effort="5"> | ||
<message> | ||
<![CDATA[ | ||
External resources, such as data sources, JMS message brokers, and others are injected via Java Naming and Directory Interface (JNDI). | ||
Some such resources may require migration or reconfiguration. | ||
]]> | ||
</message> | ||
<link title="Inventory external resources" href="https://learn.microsoft.com/azure/developer/java/migration/migrate-tomcat-to-azure-spring-apps"/> | ||
<tag>tomcat</tag> | ||
</hint> | ||
</perform> | ||
</rule> | ||
</rules> | ||
</ruleset> |