forked from quarkus-qe/quarkus-test-suite
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test coverage for the issue quarkusio/quarkus#43825
Ensure the missing servlet class in web.xml is ignored Test coverage for quarkusio/quarkus#44063 scenario
- Loading branch information
1 parent
6c55951
commit b27147e
Showing
2 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
...ervlet-undertow/src/test/java/io/quarkus/ts/http/undertow/UndertowMissServletClassIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package io.quarkus.ts.http.undertow; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; | ||
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
|
||
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.scenarios.annotations.DisabledOnQuarkusVersion; | ||
import io.quarkus.test.services.QuarkusApplication; | ||
|
||
@QuarkusScenario | ||
@DisabledOnQuarkusVersion(version = "3\\.(8|9|10|11|12|13|14)\\..*|3\\.15\\.(0|1)(\\..*)?", reason = "Disabled on Quarkus versions before 3.15.2 due to build fail because missing servlet class configuration undertow issue https://github.com/quarkusio/quarkus/issues/43825") | ||
public class UndertowMissServletClassIT { | ||
@QuarkusApplication | ||
static RestService app = new RestService() | ||
.setAutoStart(false) | ||
.onPreStart(UndertowMissServletClassIT::replaceForInvalidXML); | ||
|
||
@Tag("https://github.com/quarkusio/quarkus/issues/44063") | ||
@Test | ||
void verifyUndertowIgnoreServletClassMissing() { | ||
assertDoesNotThrow(() -> app.start(), | ||
"The app should start without any issue"); | ||
String logs = app.getLogs().toString(); | ||
assertFalse(logs.contains("Local name must not be null")); | ||
|
||
} | ||
|
||
private static void replaceForInvalidXML(Service service) { | ||
if (service instanceof RestService) { | ||
RestService restService = (RestService) service; | ||
Path invalidWebXml = Path.of("src/test/resources/invalid-web.xml"); | ||
|
||
Path targetWebXml = restService.getServiceFolder().resolve("src/main/resources/META-INF/web.xml"); | ||
try { | ||
Files.createDirectories(targetWebXml.getParent()); | ||
Files.copy(invalidWebXml, targetWebXml); | ||
} 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"); | ||
} | ||
|
||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
http/servlet-undertow/src/test/resources/META-INF/invalid-web.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<web-app> | ||
<servlet> | ||
<servlet-name>InvalidServlet</servlet-name> | ||
</servlet> | ||
<servlet-mapping> | ||
<servlet-name>InvalidServlet</servlet-name> | ||
<url-pattern>/invalid</url-pattern> | ||
</servlet-mapping> | ||
</web-app> |