-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Fix #440: EE10 Jakarta ejb-jar.xml * Update src/test/java/org/openrewrite/java/migrate/jakarta/JavaxEjbJarXmlToJakartaEjbJarXmlTest.java Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update src/test/java/org/openrewrite/java/migrate/jakarta/JavaxEjbJarXmlToJakartaEjbJarXmlTest.java Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Apply suggestions from code review * Add trailing newline * Minor polish --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Tim te Beek <[email protected]> Co-authored-by: Tim te Beek <[email protected]>
- Loading branch information
1 parent
3f65b43
commit be68bb5
Showing
2 changed files
with
182 additions
and
0 deletions.
There are no files selected for viewing
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
153 changes: 153 additions & 0 deletions
153
src/test/java/org/openrewrite/java/migrate/jakarta/JavaxEjbJarXmlToJakartaEjbJarXmlTest.java
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,153 @@ | ||
/* | ||
* Copyright 2024 the original author or authors. | ||
* <p> | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* <p> | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* <p> | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.openrewrite.java.migrate.jakarta; | ||
|
||
import org.junit.jupiter.api.Nested; | ||
import org.junit.jupiter.api.Test; | ||
import org.openrewrite.DocumentExample; | ||
import org.openrewrite.config.Environment; | ||
import org.openrewrite.test.RecipeSpec; | ||
import org.openrewrite.test.RewriteTest; | ||
|
||
import static org.openrewrite.xml.Assertions.xml; | ||
|
||
class JavaxEjbJarXmlToJakartaEjbJarXmlTest implements RewriteTest { | ||
@Override | ||
public void defaults(RecipeSpec spec) { | ||
spec.recipe(Environment.builder().scanRuntimeClasspath("org.openrewrite.java.migrate.jakarta").build() | ||
.activateRecipes("org.openrewrite.java.migrate.jakarta.JavaxEjbJarXmlToJakartaEjbJarXml")); | ||
} | ||
|
||
@Test | ||
@DocumentExample | ||
void migrateJCP() { | ||
rewriteRun( | ||
//language=xml | ||
xml( | ||
""" | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ejb-jar xmlns="http://java.sun.com/xml/ns/javaee" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd" | ||
version="3.0"> | ||
<enterprise-beans> | ||
<session> | ||
<ejb-name>HelloSessionBean</ejb-name> | ||
<mapped-name>ejb/HelloSessionBean</mapped-name> | ||
<business-local>com.mydomain.HelloSessionBeanLocal</business-local> | ||
<business-remote>com.mydomain.HelloSessionBeanRemote</business-remote> | ||
<ejb-class>com.mydomain.HelloSessionBean</ejb-class> | ||
<session-type>Stateless</session-type> | ||
<transaction-type>Container</transaction-type> | ||
</session> | ||
<message-driven> | ||
<ejb-name>MessageBean</ejb-name> | ||
<ejb-class>samples.mdb.ejb.MessageBean</ejb-class> | ||
<transaction-type>Container</transaction-type> | ||
<message-driven-destination> | ||
<destination-type>javax.jms.Queue</destination-type> | ||
</message-driven-destination> | ||
<resource-ref> | ||
<res-ref-name>jms/QueueConnectionFactory</res-ref-name> | ||
<res-type>javax.jms.QueueConnectionFactory</res-type> | ||
<res-auth>Container</res-auth> | ||
</resource-ref> | ||
</message-driven> | ||
<assembly-descriptor> | ||
<container-transaction> | ||
<method> | ||
<ejb-name>MessageBean</ejb-name> | ||
<method-intf>Bean</method-intf> | ||
<method-name>onMessage</method-name> | ||
<method-params> | ||
<method-param>javax.jms.Message</method-param> | ||
</method-params> | ||
</method> | ||
<trans-attribute>NotSupported</trans-attribute> | ||
</container-transaction> | ||
</assembly-descriptor> | ||
</enterprise-beans> | ||
</ejb-jar> | ||
""", | ||
""" | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ejb-jar xmlns="https://jakarta.ee/xml/ns/jakartaee" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/ejb-jar_4_0.xsd" | ||
version="4.0"> | ||
<enterprise-beans> | ||
<session> | ||
<ejb-name>HelloSessionBean</ejb-name> | ||
<mapped-name>ejb/HelloSessionBean</mapped-name> | ||
<business-local>com.mydomain.HelloSessionBeanLocal</business-local> | ||
<business-remote>com.mydomain.HelloSessionBeanRemote</business-remote> | ||
<ejb-class>com.mydomain.HelloSessionBean</ejb-class> | ||
<session-type>Stateless</session-type> | ||
<transaction-type>Container</transaction-type> | ||
</session> | ||
<message-driven> | ||
<ejb-name>MessageBean</ejb-name> | ||
<ejb-class>samples.mdb.ejb.MessageBean</ejb-class> | ||
<transaction-type>Container</transaction-type> | ||
<message-driven-destination> | ||
<destination-type>jakarta.jms.Queue</destination-type> | ||
</message-driven-destination> | ||
<resource-ref> | ||
<res-ref-name>jms/QueueConnectionFactory</res-ref-name> | ||
<res-type>jakarta.jms.QueueConnectionFactory</res-type> | ||
<res-auth>Container</res-auth> | ||
</resource-ref> | ||
</message-driven> | ||
<assembly-descriptor> | ||
<container-transaction> | ||
<method> | ||
<ejb-name>MessageBean</ejb-name> | ||
<method-intf>Bean</method-intf> | ||
<method-name>onMessage</method-name> | ||
<method-params> | ||
<method-param>jakarta.jms.Message</method-param> | ||
</method-params> | ||
</method> | ||
<trans-attribute>NotSupported</trans-attribute> | ||
</container-transaction> | ||
</assembly-descriptor> | ||
</enterprise-beans> | ||
</ejb-jar> | ||
""", | ||
sourceSpecs -> sourceSpecs.path("ejb-jar.xml") | ||
) | ||
); | ||
} | ||
|
||
@Nested | ||
class NoChanges { | ||
@Test | ||
void fileNotWebXml() { | ||
rewriteRun( | ||
//language=xml | ||
xml( | ||
""" | ||
<beans xmlns="http://java.sun.com/xml/ns/javaee" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd"> | ||
</beans> | ||
""", | ||
sourceSpecs -> sourceSpecs.path("not-ejb-jar.xml") | ||
) | ||
); | ||
} | ||
} | ||
} |