Skip to content

Commit 03d654a

Browse files
authored
Merge pull request #31922 from famod/liquibase-includeAll-prod
Add more lenient Liquibase ZipPathHandler to work around includeAll not working in prod mode
2 parents 351fcd3 + c33b9b7 commit 03d654a

File tree

5 files changed

+100
-1
lines changed

5 files changed

+100
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package io.quarkus.liquibase;
2+
3+
import java.io.FileNotFoundException;
4+
5+
import liquibase.resource.ResourceAccessor;
6+
import liquibase.resource.ZipPathHandler;
7+
8+
// https://github.com/liquibase/liquibase/issues/3524#issuecomment-1465282155
9+
public class LiquibaseLenientZipPathHandler extends ZipPathHandler {
10+
11+
@Override
12+
public int getPriority(String root) {
13+
if (root != null && root.startsWith("jar:") && root.contains("!/")) {
14+
return PRIORITY_SPECIALIZED;
15+
}
16+
return PRIORITY_NOT_APPLICABLE;
17+
}
18+
19+
@Override
20+
public ResourceAccessor getResourceAccessor(String root) throws FileNotFoundException {
21+
int idx = root.indexOf("!/");
22+
return super.getResourceAccessor(idx > 0 ? root.substring(0, idx) : root);
23+
}
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
io.quarkus.liquibase.LiquibaseLenientZipPathHandler

integration-tests/liquibase/pom.xml

+32
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@
1212
<artifactId>quarkus-integration-test-liquibase</artifactId>
1313
<name>Quarkus - Integration Tests - Liquibase</name>
1414
<description>Module that contains Liquibase related tests</description>
15+
16+
<properties>
17+
<skipTests>false</skipTests>
18+
<skipPMTests>${skipTests}</skipPMTests>
19+
</properties>
20+
1521
<dependencies>
1622
<dependency>
1723
<groupId>io.quarkus</groupId>
@@ -35,6 +41,11 @@
3541
<artifactId>quarkus-junit5</artifactId>
3642
<scope>test</scope>
3743
</dependency>
44+
<dependency>
45+
<groupId>io.quarkus</groupId>
46+
<artifactId>quarkus-junit5-internal</artifactId>
47+
<scope>test</scope>
48+
</dependency>
3849
<dependency>
3950
<groupId>io.quarkus</groupId>
4051
<artifactId>quarkus-test-h2</artifactId>
@@ -126,6 +137,27 @@
126137
</execution>
127138
</executions>
128139
</plugin>
140+
<plugin>
141+
<artifactId>maven-surefire-plugin</artifactId>
142+
<executions>
143+
<!--
144+
The prod mode tests need to be part of a different execution to ensure that they don't mess with the standard tests.
145+
By adding this configuration we ensure that the maven surefire plugin will execute twice, one for the regular **/*Test.java
146+
tests (using the 'default-test' execution), and one for the prod mode tests (this 'prod-mode' execution)
147+
-->
148+
<execution>
149+
<id>prod-mode</id>
150+
<phase>test</phase>
151+
<goals>
152+
<goal>test</goal>
153+
</goals>
154+
<configuration>
155+
<includes>**/*PMT.java</includes>
156+
<skip>${skipPMTests}</skip>
157+
</configuration>
158+
</execution>
159+
</executions>
160+
</plugin>
129161
</plugins>
130162
</build>
131163

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package io.quarkus.it.liquibase;
2+
3+
import java.io.IOException;
4+
import java.nio.file.Files;
5+
import java.nio.file.Path;
6+
7+
import org.junit.jupiter.api.AfterEach;
8+
import org.junit.jupiter.api.Test;
9+
import org.junit.jupiter.api.extension.RegisterExtension;
10+
11+
import io.quarkus.test.LogFile;
12+
import io.quarkus.test.QuarkusProdModeTest;
13+
14+
public class LiquibaseFunctionalityPMT {
15+
16+
@RegisterExtension
17+
static final QuarkusProdModeTest config = new QuarkusProdModeTest()
18+
.withApplicationRoot(jar -> jar
19+
.addClasses(LiquibaseApp.class, LiquibaseFunctionalityResource.class)
20+
.addAsResource("db")
21+
.addAsResource("application.properties"))
22+
.setApplicationName("liquibase-prodmode-test")
23+
.setLogFileName("liquibase-prodmode-test.log")
24+
.setRun(true);
25+
26+
@LogFile
27+
private Path logfile;
28+
29+
@Test
30+
public void test() {
31+
LiquibaseFunctionalityTest.doTestLiquibaseQuarkusFunctionality(true);
32+
}
33+
34+
@AfterEach
35+
void dumpLog() throws IOException {
36+
System.out.println(Files.readString(logfile));
37+
}
38+
}

integration-tests/liquibase/src/test/java/io/quarkus/it/liquibase/LiquibaseFunctionalityTest.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,16 @@ public class LiquibaseFunctionalityTest {
1515
@Test
1616
@DisplayName("Migrates a schema correctly using integrated instance")
1717
public void testLiquibaseQuarkusFunctionality() {
18+
doTestLiquibaseQuarkusFunctionality(isIncludeAllExpectedToWork());
19+
}
20+
21+
static void doTestLiquibaseQuarkusFunctionality(boolean isIncludeAllExpectedToWork) {
1822
when()
1923
.get("/liquibase/update")
2024
.then()
2125
.body(is(
2226
"create-tables-1,test-1,create-view-inline,create-view-file-abs,create-view-file-rel,"
23-
+ (isIncludeAllExpectedToWork() ? "includeAll-1,includeAll-2," : "")
27+
+ (isIncludeAllExpectedToWork ? "includeAll-1,includeAll-2," : "")
2428
+ "json-create-tables-1,json-test-1,"
2529
+ "sql-create-tables-1,sql-test-1,"
2630
+ "yaml-create-tables-1,yaml-test-1,"

0 commit comments

Comments
 (0)