Skip to content

Commit

Permalink
Update dependency org.flywaydb:flyway-core to v9.20.1 (3.0.x) (#411)
Browse files Browse the repository at this point in the history
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Jochen Schalanda <[email protected]>
  • Loading branch information
renovate[bot] and joschi authored Jul 13, 2023
1 parent 479cda8 commit 1797267
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 16 deletions.
14 changes: 13 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
<sonar.host.url>https://sonarcloud.io</sonar.host.url>

<dropwizard.version>3.0.1</dropwizard.version>
<flyway.version>9.19.4</flyway.version>
<flyway.version>9.20.1</flyway.version>
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -102,6 +102,12 @@
<artifactId>flyway-core</artifactId>
<version>${flyway.version}</version>
</dependency>
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-database-oracle</artifactId>
<version>${flyway.version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.checkerframework</groupId>
<artifactId>checker-qual</artifactId>
Expand Down Expand Up @@ -133,6 +139,12 @@
<artifactId>mockito-junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>2.2.220</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
9 changes: 6 additions & 3 deletions src/main/java/io/dropwizard/flyway/FlywayFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.checkerframework.checker.nullness.qual.Nullable;
import org.flywaydb.core.Flyway;
import org.flywaydb.core.api.configuration.FluentConfiguration;
import org.flywaydb.database.oracle.OracleConfigurationExtension;

import javax.sql.DataSource;
import javax.validation.constraints.NotBlank;
Expand Down Expand Up @@ -574,15 +575,15 @@ public void setErrorOverrides(@Nullable List<String> errorOverrides) {
}

/**
* @see FluentConfiguration#isOracleSqlplus()
* @see OracleConfigurationExtension#getSqlplus()
*/
@Nullable
public Boolean isOracleSqlPlus() {
return oracleSqlPlus;
}

/**
* @see FluentConfiguration#oracleSqlplus(boolean)
* @see OracleConfigurationExtension#setSqlplus(Boolean)
*/
public void setOracleSqlPlus(@Nullable Boolean oracleSqlPlus) {
this.oracleSqlPlus = oracleSqlPlus;
Expand Down Expand Up @@ -705,7 +706,9 @@ private FluentConfiguration createConfiguration() {
flyway.errorOverrides(errorOverrides.toArray(emptyStringArray));
}
if (oracleSqlPlus != null) {
flyway.oracleSqlplus(oracleSqlPlus);
OracleConfigurationExtension oracleConfigurationExtension =
flyway.getPluginRegister().getPlugin(OracleConfigurationExtension.class);
oracleConfigurationExtension.setSqlplus(oracleSqlPlus);
}
if (stream != null) {
flyway.stream(stream);
Expand Down
29 changes: 17 additions & 12 deletions src/test/java/io/dropwizard/flyway/FlywayFactoryTest.java
Original file line number Diff line number Diff line change
@@ -1,43 +1,48 @@
package io.dropwizard.flyway;

import com.google.common.collect.ImmutableMap;
import javax.validation.constraints.NotNull;
import org.flywaydb.core.Flyway;
import org.flywaydb.core.internal.database.postgresql.PostgreSQLConfigurationExtension;
import org.h2.jdbcx.JdbcDataSource;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;

import javax.sql.DataSource;
import javax.validation.constraints.NotNull;
import java.nio.charset.StandardCharsets;
import java.sql.SQLException;
import java.util.Map;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertSame;

@ExtendWith(MockitoExtension.class)
public class FlywayFactoryTest {

@Mock
private DataSource mockDataSource;
private JdbcDataSource dataSource;

@BeforeEach
void setUp() throws SQLException {
dataSource = new JdbcDataSource();
dataSource.setURL("jdbc:h2:mem:testdb");
dataSource.setUser("sa");
}

@Test
public void defaultConfigurationShouldBeValid() {
final FlywayFactory factory = new FlywayFactory();
final Flyway flyway = factory.build(mockDataSource);

final Flyway flyway = factory.build(dataSource);

assertNotNull(flyway);
assertSame(mockDataSource, flyway.getConfiguration().getDataSource());
assertSame(dataSource, flyway.getConfiguration().getDataSource());
assertEquals(StandardCharsets.UTF_8, flyway.getConfiguration().getEncoding());
assertEquals("flyway_schema_history", flyway.getConfiguration().getTable());
assertEquals(0, flyway.getConfiguration().getSchemas().length);
}

@Test
public void checkConfigurationWithOverridedSetting() {
Flyway flyway = new FlywayFactory().build(mockDataSource);
Flyway flyway = new FlywayFactory().build(dataSource);
assertNotNull(flyway);

boolean transactionalLockDefault = getPostgresTransactionLockSettings(flyway);
Expand All @@ -46,7 +51,7 @@ public void checkConfigurationWithOverridedSetting() {
final FlywayFactory factory = new FlywayFactory();
Map<String, String> configuration = ImmutableMap.of("flyway.postgresql.transactional.lock", String.valueOf(transactionalLockOverrided));
factory.setConfiguration(configuration);
flyway = factory.build(mockDataSource);
flyway = factory.build(dataSource);

assertNotNull(flyway);
assertEquals(StandardCharsets.UTF_8, flyway.getConfiguration().getEncoding()); // default value
Expand Down

0 comments on commit 1797267

Please sign in to comment.