Search in sources :

Example 1 with FileSystemResource

use of org.flywaydb.core.internal.util.scanner.filesystem.FileSystemResource in project che by eclipse.

the class SqlScriptCreatorTest method createsScript.

@Test
public void createsScript() throws Exception {
    final Location location = new Location("filesystem:schema");
    final Resource resource = new FileSystemResource("schema/5.0.0-M7/v1__init.sql");
    final SqlScriptCreator scriptsCreator = new SqlScriptCreator();
    final SqlScript script = scriptsCreator.createScript(location, resource);
    assertEquals(script.name, "v1__init.sql");
    assertEquals(script.location, location);
    assertEquals(script.dir, "5.0.0-M7");
    assertEquals(script.resource.getLocation(), resource.getLocation());
    assertNull(script.vendor);
}
Also used : FileSystemResource(org.flywaydb.core.internal.util.scanner.filesystem.FileSystemResource) Resource(org.flywaydb.core.internal.util.scanner.Resource) FileSystemResource(org.flywaydb.core.internal.util.scanner.filesystem.FileSystemResource) Location(org.flywaydb.core.internal.util.Location) Test(org.testng.annotations.Test)

Example 2 with FileSystemResource

use of org.flywaydb.core.internal.util.scanner.filesystem.FileSystemResource in project che by eclipse.

the class SqlScriptCreatorTest method failsToCreateResourceWhenPathIsInvalid.

@Test(expectedExceptions = FlywayException.class)
public void failsToCreateResourceWhenPathIsInvalid() throws Exception {
    final Location location = new Location("filesystem:schema");
    final Resource resource = new FileSystemResource("schema/v1__init.sql");
    new SqlScriptCreator().createScript(location, resource);
}
Also used : FileSystemResource(org.flywaydb.core.internal.util.scanner.filesystem.FileSystemResource) Resource(org.flywaydb.core.internal.util.scanner.Resource) FileSystemResource(org.flywaydb.core.internal.util.scanner.filesystem.FileSystemResource) Location(org.flywaydb.core.internal.util.Location) Test(org.testng.annotations.Test)

Example 3 with FileSystemResource

use of org.flywaydb.core.internal.util.scanner.filesystem.FileSystemResource in project che by eclipse.

the class SqlScriptCreatorTest method createsVendorScript.

@Test
public void createsVendorScript() throws Exception {
    final Location location = new Location("filesystem:schema");
    final Resource resource = new FileSystemResource("schema/5.0.0-M7/postgresql/v1__init.sql");
    final SqlScriptCreator scriptsCreator = new SqlScriptCreator();
    final SqlScript script = scriptsCreator.createScript(location, resource);
    assertEquals(script.name, "v1__init.sql");
    assertEquals(script.location, location);
    assertEquals(script.dir, "5.0.0-M7");
    assertEquals(script.resource.getLocation(), resource.getLocation());
    assertEquals(script.vendor, "postgresql");
}
Also used : FileSystemResource(org.flywaydb.core.internal.util.scanner.filesystem.FileSystemResource) Resource(org.flywaydb.core.internal.util.scanner.Resource) FileSystemResource(org.flywaydb.core.internal.util.scanner.filesystem.FileSystemResource) Location(org.flywaydb.core.internal.util.Location) Test(org.testng.annotations.Test)

Example 4 with FileSystemResource

use of org.flywaydb.core.internal.util.scanner.filesystem.FileSystemResource in project che by eclipse.

the class VersionResolverTest method failsToResolveVersions.

@Test(dataProvider = "invalidScripts", expectedExceptions = FlywayException.class)
public void failsToResolveVersions(String dir, String name) throws Exception {
    final SqlScript script = new SqlScript(new FileSystemResource("sql/" + dir + "/" + name), new Location("filesystem:sql"), dir, null, name);
    resolver.resolve(script, flyway);
}
Also used : FileSystemResource(org.flywaydb.core.internal.util.scanner.filesystem.FileSystemResource) Location(org.flywaydb.core.internal.util.Location) Test(org.testng.annotations.Test)

Example 5 with FileSystemResource

use of org.flywaydb.core.internal.util.scanner.filesystem.FileSystemResource in project che by eclipse.

the class VersionResolverTest method resolvesVersion.

@Test(dataProvider = "validScripts")
public void resolvesVersion(String dir, String name, String expectedVersion) {
    final SqlScript script = new SqlScript(new FileSystemResource("sql/" + dir + "/" + name), new Location("filesystem:sql"), dir, null, name);
    assertEquals(resolver.resolve(script, flyway), MigrationVersion.fromVersion(expectedVersion));
}
Also used : FileSystemResource(org.flywaydb.core.internal.util.scanner.filesystem.FileSystemResource) Location(org.flywaydb.core.internal.util.Location) Test(org.testng.annotations.Test)

Aggregations

FileSystemResource (org.flywaydb.core.internal.util.scanner.filesystem.FileSystemResource)7 Location (org.flywaydb.core.internal.util.Location)6 Test (org.testng.annotations.Test)5 Resource (org.flywaydb.core.internal.util.scanner.Resource)3 SQLException (java.sql.SQLException)1 FlywayException (org.flywaydb.core.api.FlywayException)1 MigrationVersion (org.flywaydb.core.api.MigrationVersion)1 MigrationExecutor (org.flywaydb.core.api.resolver.MigrationExecutor)1 AppliedMigration (org.flywaydb.core.internal.metadatatable.AppliedMigration)1 Test (org.junit.Test)1