diff --git a/applications/spring-shell/src/test/java/org/springframework/sbm/MigrateAnnotatedServletsIntegrationTest.java b/applications/spring-shell/src/test/java/org/springframework/sbm/MigrateAnnotatedServletsIntegrationTest.java index ac340517e..edb729c11 100644 --- a/applications/spring-shell/src/test/java/org/springframework/sbm/MigrateAnnotatedServletsIntegrationTest.java +++ b/applications/spring-shell/src/test/java/org/springframework/sbm/MigrateAnnotatedServletsIntegrationTest.java @@ -22,7 +22,6 @@ import static org.assertj.core.api.AssertionsForClassTypes.assertThat; -@Disabled("Temporary disabled before CI will be fixed with docker in docker issue: #351") public class MigrateAnnotatedServletsIntegrationTest extends IntegrationTestBaseClass { @@ -31,6 +30,7 @@ protected String getTestSubDir() { return "bootify-servlets"; } + @Disabled("Temporary disabled before CI will be fixed with docker in docker issue: #351") @Tag("integration") @Test void happyPath() { @@ -125,7 +125,7 @@ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws Se } @Test - void recipeNBotApplicableWhenOnlyFilterExists() { + void shouldMigrateWebFilter() { String pom = """ "@SpringBootApplication annotation not found"); + assertThat(content).contains("@ServletComponentScan").withFailMessage(() -> "@ServletComponentScan annotation not found"); } } diff --git a/components/sbm-recipes-jee-to-boot/src/main/resources/recipes/migrate-annotated-servlets.yaml b/components/sbm-recipes-jee-to-boot/src/main/resources/recipes/migrate-annotated-servlets.yaml index 28f126d34..632ace2eb 100644 --- a/components/sbm-recipes-jee-to-boot/src/main/resources/recipes/migrate-annotated-servlets.yaml +++ b/components/sbm-recipes-jee-to-boot/src/main/resources/recipes/migrate-annotated-servlets.yaml @@ -1,10 +1,10 @@ - name: migrate-annotated-servlets - description: Allow Spring Boot to deploy servlets annotated with @WebServlet + description: Allow Spring Boot to deploy servlets and filters annotated with @WebServlet or @WebFilter order: 70 condition: - description: Any class has import starting with javax.servlet - type: org.springframework.sbm.java.migration.conditions.HasTypeAnnotation - annotation: javax.servlet.annotation.WebServlet + description: Any class has import starting with javax.servlet.annotation + type: org.springframework.sbm.java.migration.conditions.HasImportStartingWith + value: javax.servlet.annotation actions: - type: org.springframework.sbm.build.migration.actions.AddDependencies condition: diff --git a/components/sbm-recipes-jee-to-boot/testcode/jee/web/given/src/main/java/com/examples/jee/web/TheFilter.java b/components/sbm-recipes-jee-to-boot/testcode/jee/web/given/src/main/java/com/examples/jee/web/TheFilter.java new file mode 100644 index 000000000..7462613e4 --- /dev/null +++ b/components/sbm-recipes-jee-to-boot/testcode/jee/web/given/src/main/java/com/examples/jee/web/TheFilter.java @@ -0,0 +1,26 @@ +package com.examples.jee.web; + +import javax.servlet.Filter; +import javax.servlet.FilterChain; +import javax.servlet.FilterConfig; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.annotation.WebFilter; +import java.io.IOException; + +@WebFilter(filterName = "The Filter", urlPatterns = {"/*"}) +public class TheFilter implements Filter { + @Override + public void init(FilterConfig filterConfig) throws ServletException { + } + + @Override + public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { + chain.doFilter(request, response); + } + + @Override + public void destroy() { + } +}