-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25610 from gsmet/2.9.1-backports-3
2.9.1 backports 3
- Loading branch information
Showing
19 changed files
with
335 additions
and
75 deletions.
There are no files selected for viewing
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
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
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
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
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
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
58 changes: 58 additions & 0 deletions
58
...way/deployment/src/test/java/io/quarkus/flyway/test/FlywayDevModeModifyMigrationTest.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,58 @@ | ||
package io.quarkus.flyway.test; | ||
|
||
import static org.hamcrest.Matchers.is; | ||
|
||
import java.sql.Connection; | ||
import java.sql.ResultSet; | ||
import java.sql.SQLException; | ||
import java.sql.Statement; | ||
import java.util.function.Function; | ||
|
||
import javax.inject.Inject; | ||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.agroal.api.AgroalDataSource; | ||
import io.quarkus.test.QuarkusDevModeTest; | ||
import io.restassured.RestAssured; | ||
|
||
public class FlywayDevModeModifyMigrationTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusDevModeTest config = new QuarkusDevModeTest() | ||
.withApplicationRoot((jar) -> jar | ||
.addClasses(RowCountEndpoint.class) | ||
.addAsResource("db/migration/V1.0.0__Quarkus.sql") | ||
.addAsResource("clean-and-migrate-at-start-config.properties", "application.properties")); | ||
|
||
@Test | ||
public void testModifyingExistingMigrationScriptCausesRestart() { | ||
RestAssured.get("/row-count").then().statusCode(200).body(is("0")); | ||
config.modifyResourceFile("db/migration/V1.0.0__Quarkus.sql", new Function<String, String>() { | ||
@Override | ||
public String apply(String s) { | ||
return s + '\n' + "INSERT INTO quarked_flyway VALUES (1001, 'test')"; | ||
} | ||
}); | ||
RestAssured.get("/row-count").then().statusCode(200).body(is("1")); | ||
} | ||
|
||
@Path("/row-count") | ||
public static class RowCountEndpoint { | ||
|
||
@Inject | ||
AgroalDataSource dataSource; | ||
|
||
@GET | ||
public int rowCount() throws SQLException { | ||
try (Connection connection = dataSource.getConnection(); Statement stat = connection.createStatement()) { | ||
try (ResultSet countQuery = stat.executeQuery("select count(1) from quarked_flyway")) { | ||
return countQuery.first() ? countQuery.getInt(1) : 0; | ||
} | ||
} | ||
} | ||
} | ||
} |
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
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
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
Oops, something went wrong.