Skip to content

Commit

Permalink
Adding UnnecessarySpringExtension to boot migration.
Browse files Browse the repository at this point in the history
  • Loading branch information
tkvangorder committed Jun 30, 2021
1 parent 67ac1cc commit 2b93850
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/main/resources/META-INF/rewrite/spring-boot2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ recipeList:
# There is a third variant of this class in spring-cloud-commons and there is not yet a suitable migration
# path. Once one exists, this can likely be added for removal as well.
#- org.springframework.cloud.test.ModifiedClassPathRunner
- org.openrewrite.java.spring.boot2.UnnecessarySpringExtension
- org.openrewrite.maven.AddDependency:
groupId: org.springframework.boot
artifactId: spring-boot-tools
Expand All @@ -56,6 +57,7 @@ tags:
recipeList:
- org.openrewrite.java.spring.NoRequestMappingAnnotation
- org.openrewrite.java.spring.ImplicitWebAnnotationNames
- org.openrewrite.java.spring.boot2.UnnecessarySpringExtension
---
type: specs.openrewrite.org/v1beta/recipe
name: org.openrewrite.java.spring.boot2.SpringBoot1To2Migration
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
* Copyright 2020 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.spring.org.openrewrite.java.spring.boot2

import org.junit.jupiter.api.Test
import org.junit.jupiter.params.ParameterizedTest
import org.junit.jupiter.params.provider.ValueSource
import org.openrewrite.Issue
import org.openrewrite.Parser
import org.openrewrite.Recipe
import org.openrewrite.config.Environment
import org.openrewrite.java.JavaParser
import org.openrewrite.java.JavaRecipeTest
import org.openrewrite.java.spring.boot2.UnnecessarySpringExtension

class SpringBootMigrationTest : JavaRecipeTest {

override val recipe: Recipe
get() = Environment.builder()
.scanRuntimeClasspath("org.openrewrite.java.spring")
.build()
.activateRecipes("org.openrewrite.java.spring.boot2.SpringBoot1To2Migration")

@Issue("https://github.com/openrewrite/rewrite-spring/issues/43")
@Test
fun springBootRunWithRemovedNoExtension() = assertChanged(
parser = JavaParser.fromJavaVersion()
.classpath("spring-boot-test", "junit-jupiter-api", "junit", "spring-test")
.logCompilationWarningsAndErrors(true)

.build(),
recipe = Environment.builder()
.scanRuntimeClasspath("org.openrewrite.java.spring")
.build()
.activateRecipes("org.openrewrite.java.spring.boot2.SpringBoot1To2Migration"),
before = """
package org.springframework.samples.petclinic.system;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@SpringBootTest
@RunWith(SpringRunner.class)
public class ProductionConfigurationTests {
@Test
public void testFindAll() {
}
}
""",
after = """
package org.springframework.samples.petclinic.system;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
public class ProductionConfigurationTests {
@Test
public void testFindAll() {
}
}
"""
)
}

0 comments on commit 2b93850

Please sign in to comment.