From a317089d67c85d9d2ba7442e0b9d4fab7887c4af Mon Sep 17 00:00:00 2001 From: melloware Date: Sun, 30 Apr 2023 10:24:14 -0400 Subject: [PATCH] ServletContextInitializer IT test --- .../ServletContainerInitializerTestCase.java | 4 +++- .../java/io/quarkus/undertow/test/TestSCI.java | 18 +++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/extensions/undertow/deployment/src/test/java/io/quarkus/undertow/test/ServletContainerInitializerTestCase.java b/extensions/undertow/deployment/src/test/java/io/quarkus/undertow/test/ServletContainerInitializerTestCase.java index 7460719ec0ee5..2487a0a693f83 100644 --- a/extensions/undertow/deployment/src/test/java/io/quarkus/undertow/test/ServletContainerInitializerTestCase.java +++ b/extensions/undertow/deployment/src/test/java/io/quarkus/undertow/test/ServletContainerInitializerTestCase.java @@ -4,6 +4,7 @@ import jakarta.servlet.ServletContainerInitializer; +import org.jboss.shrinkwrap.api.asset.StringAsset; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; @@ -16,6 +17,7 @@ public class ServletContainerInitializerTestCase { static QuarkusUnitTest runner = new QuarkusUnitTest() .withApplicationRoot((jar) -> jar .addAsServiceProvider(ServletContainerInitializer.class, TestSCI.class) + .addAsResource(new StringAsset("index.html"), "META-INF/resources/index.html") .addClasses(SCIInterface.class, SCIImplementation.class, TestSCI.class, SCIAnnotation.class, AnnotatedSCIClass.class)); @@ -27,4 +29,4 @@ public void testSci() { containsString("io.quarkus.undertow.test.AnnotatedSCIClass")); } -} +} \ No newline at end of file diff --git a/extensions/undertow/deployment/src/test/java/io/quarkus/undertow/test/TestSCI.java b/extensions/undertow/deployment/src/test/java/io/quarkus/undertow/test/TestSCI.java index b1c44663b3b65..565fc708232c3 100644 --- a/extensions/undertow/deployment/src/test/java/io/quarkus/undertow/test/TestSCI.java +++ b/extensions/undertow/deployment/src/test/java/io/quarkus/undertow/test/TestSCI.java @@ -12,8 +12,13 @@ import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; +import org.jboss.logging.Logger; + @HandlesTypes({ SCIInterface.class, SCIAnnotation.class }) public class TestSCI implements ServletContainerInitializer { + + private static final Logger log = Logger.getLogger(TestSCI.class); + @Override public void onStartup(Set> c, ServletContext ctx) throws ServletException { ServletRegistration.Dynamic info = ctx.addServlet("test", new HttpServlet() { @@ -25,5 +30,16 @@ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws Se } }); info.addMapping("/sci"); + + log.info("Checking servlet resource paths..."); + + Set resourcePaths = ctx.getResourcePaths("/"); + for (String resourcePath : resourcePaths) { + log.info("Resource: " + resourcePath); + } + + if (resourcePaths.isEmpty()) { + throw new RuntimeException("NO servlet resource paths found!"); + } } -} +} \ No newline at end of file