|
| 1 | +/* |
| 2 | + * Copyright 2025 the original author or authors. |
| 3 | + * <p> |
| 4 | + * Licensed under the Moderne Source Available License (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * <p> |
| 8 | + * https://docs.moderne.io/licensing/moderne-source-available-license |
| 9 | + * <p> |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | +package org.openrewrite.java.migrate.jakarta; |
| 17 | + |
| 18 | +import org.junit.jupiter.api.Nested; |
| 19 | +import org.junit.jupiter.api.Test; |
| 20 | +import org.openrewrite.test.RecipeSpec; |
| 21 | +import org.openrewrite.test.RewriteTest; |
| 22 | + |
| 23 | +import static org.openrewrite.xml.Assertions.xml; |
| 24 | + |
| 25 | +public class UpdateXJCBindingsToJakartaEE implements RewriteTest { |
| 26 | + @Override |
| 27 | + public void defaults(RecipeSpec spec) { |
| 28 | + spec.recipeFromResources("org.openrewrite.java.migrate.jakarta.JavaxXmlToJakartaXmlXJCBinding"); |
| 29 | + } |
| 30 | + |
| 31 | + @Test |
| 32 | + void noMigrate() { |
| 33 | + rewriteRun( |
| 34 | + xml( |
| 35 | + //language=xml |
| 36 | + """ |
| 37 | + <?xml version="1.0" encoding="UTF-8"?> |
| 38 | + <jxb:bindings version="3.0" |
| 39 | + xmlns:jxb="https://jakarta.ee/xml/ns/jaxb" |
| 40 | + xmlns:xs="http://www.w3.org/2001/XMLSchema"> |
| 41 | + </jxb:bindings> |
| 42 | + """ |
| 43 | + ) |
| 44 | + ); |
| 45 | + } |
| 46 | + |
| 47 | + @Nested |
| 48 | + class Migrate { |
| 49 | + @Test |
| 50 | + void version() { |
| 51 | + rewriteRun( |
| 52 | + //language=xml |
| 53 | + xml( |
| 54 | + """ |
| 55 | + <?xml version="1.0" encoding="UTF-8"?> |
| 56 | + <jxb:bindings version="1.0" |
| 57 | + xmlns:jxb="https://jakarta.ee/xml/ns/jaxb" |
| 58 | + xmlns:xs="http://www.w3.org/2001/XMLSchema"> |
| 59 | + </jxb:bindings> |
| 60 | + """, |
| 61 | + """ |
| 62 | + <?xml version="1.0" encoding="UTF-8"?> |
| 63 | + <jxb:bindings version="3.0" |
| 64 | + xmlns:jxb="https://jakarta.ee/xml/ns/jaxb" |
| 65 | + xmlns:xs="http://www.w3.org/2001/XMLSchema"> |
| 66 | + </jxb:bindings> |
| 67 | + """ |
| 68 | + ) |
| 69 | + ); |
| 70 | + } |
| 71 | + |
| 72 | + @Test |
| 73 | + void namespace() { |
| 74 | + rewriteRun( |
| 75 | + //language=xml |
| 76 | + xml( |
| 77 | + """ |
| 78 | + <?xml version="1.0" encoding="UTF-8"?> |
| 79 | + <jxb:bindings version="3.0" |
| 80 | + xmlns:jxb="http://java.sun.com/xml/ns/jaxb" |
| 81 | + xmlns:xs="http://www.w3.org/2001/XMLSchema"> |
| 82 | + </jxb:bindings> |
| 83 | + """, |
| 84 | + """ |
| 85 | + <?xml version="1.0" encoding="UTF-8"?> |
| 86 | + <jxb:bindings version="3.0" |
| 87 | + xmlns:jxb="https://jakarta.ee/xml/ns/jaxb" |
| 88 | + xmlns:xs="http://www.w3.org/2001/XMLSchema"> |
| 89 | + </jxb:bindings> |
| 90 | + """ |
| 91 | + ) |
| 92 | + ); |
| 93 | + } |
| 94 | + |
| 95 | + @Test |
| 96 | + void both() { |
| 97 | + rewriteRun( |
| 98 | + //language=xml |
| 99 | + xml( |
| 100 | + """ |
| 101 | + <?xml version="1.0" encoding="UTF-8"?> |
| 102 | + <jxb:bindings version="1.0" |
| 103 | + xmlns:jxb="http://java.sun.com/xml/ns/jaxb" |
| 104 | + xmlns:xs="http://www.w3.org/2001/XMLSchema"> |
| 105 | + </jxb:bindings> |
| 106 | + """, |
| 107 | + """ |
| 108 | + <?xml version="1.0" encoding="UTF-8"?> |
| 109 | + <jxb:bindings version="3.0" |
| 110 | + xmlns:jxb="https://jakarta.ee/xml/ns/jaxb" |
| 111 | + xmlns:xs="http://www.w3.org/2001/XMLSchema"> |
| 112 | + </jxb:bindings> |
| 113 | + """ |
| 114 | + ) |
| 115 | + ); |
| 116 | + } |
| 117 | + } |
| 118 | +} |
0 commit comments