use of org.flywaydb.core.internal.util.jdbc.DriverDataSource in project flyway by flyway.
the class OracleDbSupportMediumTest method checkCurrentSchema.
/**
* Checks the result of the getCurrentSchemaName call.
*
* @param useProxy Flag indicating whether to check it using a proxy user or not.
*/
private void checkCurrentSchema(boolean useProxy) throws Exception {
Properties customProperties = getConnectionProperties();
String user = customProperties.getProperty("oracle.user");
String password = customProperties.getProperty("oracle.password");
String url = customProperties.getProperty("oracle.url");
String dataSourceUser = useProxy ? "\"flyway_proxy\"[" + user + "]" : user;
DataSource dataSource = new DriverDataSource(Thread.currentThread().getContextClassLoader(), null, url, dataSourceUser, password, null);
Connection connection = dataSource.getConnection();
OracleDbSupport dbSupport = new OracleDbSupport(connection);
String currentSchema = dbSupport.getCurrentSchemaName();
connection.close();
assertEquals(user.toUpperCase(), currentSchema);
}
use of org.flywaydb.core.internal.util.jdbc.DriverDataSource in project flyway by flyway.
the class SQLiteMigrationMediumTest method createDataSource.
@Override
protected DataSource createDataSource(Properties customProperties) {
SQLiteConfig config = new SQLiteConfig();
config.setOpenMode(SQLiteOpenMode.CREATE);
config.setOpenMode(SQLiteOpenMode.DELETEONCLOSE);
config.setOpenMode(SQLiteOpenMode.READWRITE);
config.setOpenMode(SQLiteOpenMode.TRANSIENT_DB);
config.enforceForeignKeys(true);
return new DriverDataSource(Thread.currentThread().getContextClassLoader(), null, "jdbc:sqlite:target/sqlite-" + testName.getMethodName(), "", "", config.toProperties());
}
use of org.flywaydb.core.internal.util.jdbc.DriverDataSource in project flyway by flyway.
the class EnterpriseDBSuperUserMigrationMediumTest method setUp.
@Before
public void setUp() throws Exception {
File customPropertiesFile = new File(System.getProperty("user.home") + "/flyway-mediumtests.properties");
Properties customProperties = new Properties();
if (customPropertiesFile.canRead()) {
customProperties.load(new FileInputStream(customPropertiesFile));
}
String password = customProperties.getProperty("enterprisedb.password", "flyway");
String url = customProperties.getProperty("enterprisedb.url", "jdbc:edb://localhost/flyway_db");
flyway = new Flyway();
flyway.setSchemas("super_user_test");
flyway.setDataSource(new DriverDataSource(Thread.currentThread().getContextClassLoader(), null, url, "flyway", password, new Properties()));
flyway.setValidateOnMigrate(true);
flyway.clean();
}
use of org.flywaydb.core.internal.util.jdbc.DriverDataSource in project flyway by flyway.
the class EnterpriseDBDbSupportMediumTest method createDataSource.
/**
* Creates a datasource for use in tests.
*
* @return The new datasource.
*/
private DataSource createDataSource() throws Exception {
File customPropertiesFile = new File(System.getProperty("user.home") + "/flyway-mediumtests.properties");
Properties customProperties = new Properties();
if (customPropertiesFile.canRead()) {
customProperties.load(new FileInputStream(customPropertiesFile));
}
String user = customProperties.getProperty("enterprisedb.user", "flyway");
String password = customProperties.getProperty("enterprisedb.password", "flyway");
String url = customProperties.getProperty("enterprisedb.url", "jdbc:edb://localhost/flyway_db");
return new DriverDataSource(Thread.currentThread().getContextClassLoader(), null, url, user, password, new Properties());
}
use of org.flywaydb.core.internal.util.jdbc.DriverDataSource in project flyway by flyway.
the class EnterpriseDBMigrationMediumTest method emptySearchPath.
@Test
public void emptySearchPath() {
Flyway flyway1 = new Flyway();
DriverDataSource driverDataSource = (DriverDataSource) dataSource;
flyway1.setDataSource(new DriverDataSource(Thread.currentThread().getContextClassLoader(), null, driverDataSource.getUrl(), driverDataSource.getUser(), driverDataSource.getPassword(), new Properties()) {
@Override
public Connection getConnection() throws SQLException {
Connection connection = super.getConnection();
Statement statement = null;
try {
statement = connection.createStatement();
statement.execute("SELECT set_config('search_path', '', false)");
} finally {
JdbcUtils.closeStatement(statement);
}
return connection;
}
});
flyway1.setLocations(getBasedir());
flyway1.setSchemas("public");
flyway1.migrate();
}
Aggregations