- * 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 - *
- * https://www.apache.org/licenses/LICENSE-2.0 - *
- * 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.javax
-
-import org.junit.jupiter.api.Test
-import org.openrewrite.Recipe
-import org.openrewrite.config.Environment
-import org.openrewrite.maven.MavenRecipeTest
-
-class AddJaxbDependenciesTest : MavenRecipeTest {
- override val recipe: Recipe = Environment.builder()
- .scanRuntimeClasspath("org.openrewrite.java.migrate")
- .build()
- .activateRecipes("org.openrewrite.java.migrate.javax.AddJaxbDependencies")
-
- companion object {
- private val jaxbContextStub : String = """
- package javax.xml.bind;
- public class JAXBContext {
- public static JAXBContext newInstance(String packages) {
- return null;
- }
- public static JAXBContext newInstance(java.lang.Class> packages) {
- return null;
- }
- }
- """.trimIndent()
-
- private val javaSourceWithJaxb : String = """
- package org.old.code;
- import javax.xml.bind.JAXBContext;
-
- public class Yep {
- private static final JAXBContext context = JAXBContext.newInstance("org.old.code");
- }
- """.trimIndent()
- private val javaSourceWithoutJaxb : String = """
- package org.old.code;
- public class Nope {
- }
- """.trimIndent()
- }
-
- @Test
- fun onlyIfUsingJaxb() = assertChanged(
- before = """
-
- * 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 - *
- * https://www.apache.org/licenses/LICENSE-2.0 - *
- * 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.javax
-
-import org.junit.jupiter.api.Test
-import org.openrewrite.Recipe
-import org.openrewrite.config.Environment
-import org.openrewrite.maven.MavenRecipeTest
-
-class AddJaxwsDependenciesTest : MavenRecipeTest {
- override val recipe: Recipe = Environment.builder()
- .scanRuntimeClasspath("org.openrewrite.java.migrate")
- .build()
- .activateRecipes("org.openrewrite.java.migrate.javax.AddJaxwsDependencies")
-
- companion object {
- private val jaxbContextStub : String = """
- package javax.jws;
-
- import java.lang.annotation.Target;
- import java.lang.annotation.Retention;
- import java.lang.annotation.RetentionPolicy;
- import java.lang.annotation.ElementType;
-
- @Retention(value = RetentionPolicy.RUNTIME)
- @Target(value = {ElementType.TYPE})
- public @interface WebService {
- }
- """.trimIndent()
-
- private val javaSourceWithJaxws : String = """
- package org.old.code;
- import javax.jws.WebService;
-
- @WebService
- public class Yep {
- }
- """.trimIndent()
- private val javaSourceWithoutJaxws : String = """
- package org.old.code;
- public class Nope {
- }
- """.trimIndent()
- }
-
- @Test
- fun onlyIfUsingJaxws() = assertChanged(
- before = """
-