diff --git a/http/servlet-undertow/src/test/java/io/quarkus/ts/http/undertow/UndertowMissingServletClassIT.java b/http/servlet-undertow/src/test/java/io/quarkus/ts/http/undertow/UndertowMissingServletClassIT.java new file mode 100644 index 000000000..2a16b8996 --- /dev/null +++ b/http/servlet-undertow/src/test/java/io/quarkus/ts/http/undertow/UndertowMissingServletClassIT.java @@ -0,0 +1,50 @@ +package io.quarkus.ts.http.undertow; + +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.StandardCopyOption; + +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +import io.quarkus.test.bootstrap.RestService; +import io.quarkus.test.bootstrap.Service; +import io.quarkus.test.scenarios.QuarkusScenario; +import io.quarkus.test.services.QuarkusApplication; + +@QuarkusScenario +public class UndertowMissingServletClassIT { + @QuarkusApplication(builder = WithMissingServlet.class) + static RestService app = new RestService() + .setAutoStart(false); + + @Tag("https://github.com/quarkusio/quarkus/issues/44063") + @Test + void verifyUndertowIgnoreServletClassMissing() { + assertDoesNotThrow(() -> app.start(), + "The app should start without any issue"); + app.logs().assertDoesNotContain("Local name must not be null"); + } + + public static void replaceForInvalidXML(Service service) { + if (service instanceof RestService) { + RestService restService = (RestService) service; + Path invalidWebXml = Path.of("src/test/resources/META-INF/invalid-web.xml"); + + Path targetWebXml = restService.getServiceFolder().resolve("META-INF/web.xml"); + try { + Files.createDirectories(targetWebXml.getParent()); + Files.copy(invalidWebXml, targetWebXml, StandardCopyOption.REPLACE_EXISTING); + } catch (IOException e) { + throw new RuntimeException("Failed to replace web.xml with invalid version", e); + } + } else { + throw new IllegalArgumentException("Service is not an instance of RestService"); + } + + } + +} diff --git a/http/servlet-undertow/src/test/java/io/quarkus/ts/http/undertow/WithMissingServlet.java b/http/servlet-undertow/src/test/java/io/quarkus/ts/http/undertow/WithMissingServlet.java new file mode 100644 index 000000000..168480b2c --- /dev/null +++ b/http/servlet-undertow/src/test/java/io/quarkus/ts/http/undertow/WithMissingServlet.java @@ -0,0 +1,14 @@ +package io.quarkus.ts.http.undertow; + +import static io.quarkus.ts.http.undertow.UndertowMissingServletClassIT.replaceForInvalidXML; + +import io.quarkus.test.services.quarkus.ProdQuarkusApplicationManagedResourceBuilder; + +public class WithMissingServlet extends ProdQuarkusApplicationManagedResourceBuilder { + + @Override + protected void copyResourcesToAppFolder() { + super.copyResourcesToAppFolder(); + replaceForInvalidXML(getContext().getOwner()); + } +} diff --git a/http/servlet-undertow/src/test/resources/META-INF/invalid-web.xml b/http/servlet-undertow/src/test/resources/META-INF/invalid-web.xml new file mode 100644 index 000000000..098b807c8 --- /dev/null +++ b/http/servlet-undertow/src/test/resources/META-INF/invalid-web.xml @@ -0,0 +1,10 @@ + + + + InvalidServlet + + + InvalidServlet + /invalid + +