use of org.flywaydb.core.internal.util.scanner.classpath.ClassPathResource in project flyway by flyway.
the class OracleSqlScriptSmallTest method parseSqlStatements.
@Test
public void parseSqlStatements() throws Exception {
String source = new ClassPathResource("migration/dbsupport/oracle/sql/placeholders/V1__Placeholders.sql", Thread.currentThread().getContextClassLoader()).loadAsString("UTF-8");
SqlScript sqlScript = new SqlScript(source, new OracleDbSupport(null));
List<SqlStatement> sqlStatements = sqlScript.getSqlStatements();
assertEquals(3, sqlStatements.size());
assertEquals(18, sqlStatements.get(0).getLineNumber());
assertEquals(27, sqlStatements.get(1).getLineNumber());
assertEquals(32, sqlStatements.get(2).getLineNumber());
assertEquals("COMMIT", sqlStatements.get(2).getSql());
}
use of org.flywaydb.core.internal.util.scanner.classpath.ClassPathResource in project flyway by flyway.
the class PostgreSQLSqlScriptSmallTest method parseSqlStatementsDo.
@Test
public void parseSqlStatementsDo() throws Exception {
String source = new ClassPathResource("migration/dbsupport/postgresql/sql/dollar/V2__Even_more_dollars.sql", Thread.currentThread().getContextClassLoader()).loadAsString("UTF-8");
SqlScript sqlScript = new SqlScript(source, new PostgreSQLDbSupport(null));
List<SqlStatement> sqlStatements = sqlScript.getSqlStatements();
assertEquals(3, sqlStatements.size());
assertEquals(17, sqlStatements.get(0).getLineNumber());
assertEquals(23, sqlStatements.get(1).getLineNumber());
assertEquals(28, sqlStatements.get(2).getLineNumber());
}
use of org.flywaydb.core.internal.util.scanner.classpath.ClassPathResource in project flyway by flyway.
the class OracleSqlScriptSmallTest method parsePackages.
@Test
public void parsePackages() throws Exception {
String source = new ClassPathResource("migration/dbsupport/oracle/sql/package/V1__Package.sql", Thread.currentThread().getContextClassLoader()).loadAsString("UTF-8");
SqlScript sqlScript = new SqlScript(source, new OracleDbSupport(null));
List<SqlStatement> sqlStatements = sqlScript.getSqlStatements();
assertEquals(2, sqlStatements.size());
assertEquals(17, sqlStatements.get(0).getLineNumber());
assertEquals(33, sqlStatements.get(1).getLineNumber());
}
use of org.flywaydb.core.internal.util.scanner.classpath.ClassPathResource in project flyway by flyway.
the class MainClassLoaderSmallTest method loadConfigurationFileBackslash.
@Test
public void loadConfigurationFileBackslash() throws Exception {
Properties properties = new Properties();
String filename = new ClassPathResource("dynamic/pkg/runtime.conf", getClassLoader()).getLocationOnDisk();
String[] args = new String[] { "-configFile=" + filename, "-configFileEncoding=UTF-8" };
Main.loadConfiguration(properties, args);
assertEquals(1, properties.size());
assertEquals("at\\runtime", properties.getProperty("loaded"));
}
use of org.flywaydb.core.internal.util.scanner.classpath.ClassPathResource in project flyway by flyway.
the class CommandLineLargeTest method runFlywayCommandLine.
/**
* Runs the Flyway Command Line tool.
*
* @param expectedReturnCode The expected return code for this invocation.
* @param configFileName The config file name. {@code null} for default.
* @param operation The operation {@code null} for none.
* @param extraArgs The extra arguments to pass to the tool.
* @return The standard output produced by the tool.
* @throws Exception thrown when the invocation failed.
*/
protected String runFlywayCommandLine(int expectedReturnCode, String configFileName, String operation, String... extraArgs) throws Exception {
List<String> args = new ArrayList<String>();
String installDir = new File(getInstallDir()).getAbsolutePath();
args.add(installDir + "/flyway" + flywayCmdLineExtensionForCurrentSystem());
if (operation != null) {
args.add(operation);
}
if (configFileName != null) {
String configFile = new ClassPathResource(configFileName, Thread.currentThread().getContextClassLoader()).getLocationOnDisk();
args.add("-configFile=" + configFile);
}
args.addAll(Arrays.asList(extraArgs));
//Debug mode
args.add("-X");
ProcessBuilder builder = new ProcessBuilder(args);
builder.directory(new File(installDir));
builder.redirectErrorStream(true);
Process process = builder.start();
String stdOut = FileCopyUtils.copyToString(new InputStreamReader(process.getInputStream(), "UTF-8"));
int returnCode = process.waitFor();
System.out.print(stdOut);
assertEquals("Unexpected return code", expectedReturnCode, returnCode);
// Normalize line endings across platforms
return stdOut.replace("\r", "");
}
Aggregations