forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix issue in Java migration in dev-mode
Fixes: quarkusio#36299 (cherry picked from commit 7e23cf5)
- Loading branch information
1 parent
c2b33a4
commit 839e10f
Showing
3 changed files
with
80 additions
and
1 deletion.
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
40 changes: 40 additions & 0 deletions
40
...ent/src/test/java/io/quarkus/flyway/test/FlywayExtensionWithJavaMigrationDevModeTest.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,40 @@ | ||
package io.quarkus.flyway.test; | ||
|
||
import static io.restassured.RestAssured.get; | ||
import static org.hamcrest.Matchers.is; | ||
|
||
import java.sql.SQLException; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import db.migration.V1_0_1__Update; | ||
import db.migration.V1_0_2__Update; | ||
import io.quarkus.test.QuarkusDevModeTest; | ||
|
||
public class FlywayExtensionWithJavaMigrationDevModeTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusDevModeTest config = new QuarkusDevModeTest() | ||
.withApplicationRoot((jar) -> jar | ||
.addClasses(V1_0_1__Update.class, V1_0_2__Update.class, | ||
FlywayExtensionWithJavaMigrationDevModeTestEndpoint.class) | ||
.addAsResource("db/migration/V1.0.0__Quarkus.sql") | ||
.addAsResource("clean-and-migrate-at-start-config.properties", "application.properties")); | ||
|
||
@Test | ||
public void test() throws SQLException { | ||
get("/fly") | ||
.then() | ||
.statusCode(200) | ||
.body(is("2/1.0.2")); | ||
|
||
config.modifySourceFile(FlywayExtensionWithJavaMigrationDevModeTestEndpoint.class, s -> s.replace("/fly", "/flyway")); | ||
|
||
get("/flyway") | ||
.then() | ||
.statusCode(200) | ||
.body(is("2/1.0.2")); | ||
} | ||
|
||
} |
37 changes: 37 additions & 0 deletions
37
...test/java/io/quarkus/flyway/test/FlywayExtensionWithJavaMigrationDevModeTestEndpoint.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,37 @@ | ||
package io.quarkus.flyway.test; | ||
|
||
import java.sql.Connection; | ||
import java.sql.ResultSet; | ||
import java.sql.Statement; | ||
|
||
import jakarta.inject.Inject; | ||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.Path; | ||
|
||
import org.flywaydb.core.Flyway; | ||
|
||
import io.agroal.api.AgroalDataSource; | ||
|
||
@Path("/fly") | ||
public class FlywayExtensionWithJavaMigrationDevModeTestEndpoint { | ||
|
||
@Inject | ||
AgroalDataSource defaultDataSource; | ||
|
||
@Inject | ||
Flyway flyway; | ||
|
||
@GET | ||
public String result() throws Exception { | ||
int count = 0; | ||
try (Connection connection = defaultDataSource.getConnection(); Statement stat = connection.createStatement()) { | ||
try (ResultSet countQuery = stat.executeQuery("select count(1) from quarked_flyway")) { | ||
countQuery.first(); | ||
count = countQuery.getInt(1); | ||
} | ||
} | ||
String currentVersion = flyway.info().current().getVersion().toString(); | ||
|
||
return count + "/" + currentVersion; | ||
} | ||
} |