Search in sources :

Example 41 with DriverDataSource

use of org.flywaydb.core.internal.util.jdbc.DriverDataSource in project flyway by flyway.

the class PostgreSQLDbSupportMediumTest 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("postgresql.user", "flyway");
    String password = customProperties.getProperty("postgresql.password", "flyway");
    String url = customProperties.getProperty("postgresql.url", "jdbc:postgresql://localhost/flyway_db");
    return new DriverDataSource(Thread.currentThread().getContextClassLoader(), null, url, user, password, null);
}
Also used : DriverDataSource(org.flywaydb.core.internal.util.jdbc.DriverDataSource) Properties(java.util.Properties) File(java.io.File) FileInputStream(java.io.FileInputStream)

Example 42 with DriverDataSource

use of org.flywaydb.core.internal.util.jdbc.DriverDataSource in project flyway by flyway.

the class PostgreSQLSuperUserMigrationMediumTest 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("postgresql.password", "flyway");
    String url = customProperties.getProperty("postgresql.url", "jdbc:postgresql://localhost/flyway_db");
    flyway = new Flyway();
    flyway.setSchemas("super_user_test");
    flyway.setDataSource(new DriverDataSource(Thread.currentThread().getContextClassLoader(), null, url, "postgres", password, null));
    flyway.setValidateOnMigrate(true);
    flyway.clean();
}
Also used : Flyway(org.flywaydb.core.Flyway) DriverDataSource(org.flywaydb.core.internal.util.jdbc.DriverDataSource) Properties(java.util.Properties) File(java.io.File) FileInputStream(java.io.FileInputStream) Before(org.junit.Before)

Example 43 with DriverDataSource

use of org.flywaydb.core.internal.util.jdbc.DriverDataSource in project flyway by flyway.

the class RedshiftDbSupportMediumTest 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("postgresql.user", "flyway");
    // Password must be at least 8 characters, with upper and lower case:
    String password = customProperties.getProperty("postgresql.password", "Flyway123");
    // Create an ssh tunnel on port 5439 to your Redshift instance before running this test!
    String url = customProperties.getProperty("postgresql.url", "jdbc:postgresql://localhost:5439/flyway");
    return new DriverDataSource(Thread.currentThread().getContextClassLoader(), null, url, user, password, null);
}
Also used : DriverDataSource(org.flywaydb.core.internal.util.jdbc.DriverDataSource) Properties(java.util.Properties) File(java.io.File) FileInputStream(java.io.FileInputStream)

Example 44 with DriverDataSource

use of org.flywaydb.core.internal.util.jdbc.DriverDataSource in project flyway by flyway.

the class RedshiftMigrationMediumTest 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(), null) {

        @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();
}
Also used : Flyway(org.flywaydb.core.Flyway) DriverDataSource(org.flywaydb.core.internal.util.jdbc.DriverDataSource) SQLException(java.sql.SQLException) Statement(java.sql.Statement) Connection(java.sql.Connection) Test(org.junit.Test)

Example 45 with DriverDataSource

use of org.flywaydb.core.internal.util.jdbc.DriverDataSource in project flyway by flyway.

the class PhoenixMigrationMediumTest method beforeClassSetUp.

@BeforeClass
public static void beforeClassSetUp() throws Exception {
    // Startup HBase in-memory cluster
    LOG.info("Starting mini-cluster");
    testUtility = new HBaseTestingUtility();
    testUtility.startMiniCluster();
    // Set up Phoenix schema
    String server = testUtility.getConfiguration().get("hbase.zookeeper.quorum");
    String port = testUtility.getConfiguration().get("hbase.zookeeper.property.clientPort");
    String zkServer = server + ":" + port;
    dataSource = new DriverDataSource(Thread.currentThread().getContextClassLoader(), null, "jdbc:phoenix:" + zkServer, "", "", null);
}
Also used : DriverDataSource(org.flywaydb.core.internal.util.jdbc.DriverDataSource) HBaseTestingUtility(org.apache.hadoop.hbase.HBaseTestingUtility) BeforeClass(org.junit.BeforeClass)

Aggregations

DriverDataSource (org.flywaydb.core.internal.util.jdbc.DriverDataSource)45 Test (org.junit.Test)29 Properties (java.util.Properties)11 File (java.io.File)6 FileInputStream (java.io.FileInputStream)6 Connection (java.sql.Connection)6 Flyway (org.flywaydb.core.Flyway)6 MigrationInfo (org.flywaydb.core.api.MigrationInfo)5 SQLException (java.sql.SQLException)4 Statement (java.sql.Statement)4 FlywayException (org.flywaydb.core.api.FlywayException)4 DataSource (javax.sql.DataSource)3 HashMap (java.util.HashMap)2 JdbcTemplate (org.flywaydb.core.internal.dbsupport.JdbcTemplate)2 Before (org.junit.Before)2 LocalRdbmsServiceTestConfig (com.google.appengine.tools.development.testing.LocalRdbmsServiceTestConfig)1 LocalServiceTestHelper (com.google.appengine.tools.development.testing.LocalServiceTestHelper)1 PrintWriter (java.io.PrintWriter)1 Map (java.util.Map)1 HBaseTestingUtility (org.apache.hadoop.hbase.HBaseTestingUtility)1