Search in sources :

Example 21 with Location

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

the class SqlMigrationResolverSmallTest method resolveMigrations.

@Test
public void resolveMigrations() {
    SqlMigrationResolver sqlMigrationResolver = new SqlMigrationResolver(null, scanner, new Location("migration/subdir"), PlaceholderReplacer.NO_PLACEHOLDERS, FlywayConfigurationForTests.create());
    Collection<ResolvedMigration> migrations = sqlMigrationResolver.resolveMigrations();
    assertEquals(3, migrations.size());
    List<ResolvedMigration> migrationList = new ArrayList<ResolvedMigration>(migrations);
    assertEquals("1", migrationList.get(0).getVersion().toString());
    assertEquals("1.1", migrationList.get(1).getVersion().toString());
    assertEquals("2.0", migrationList.get(2).getVersion().toString());
    assertEquals("dir1/V1__First.sql", migrationList.get(0).getScript());
    assertEquals("V1_1__Populate_table.sql", migrationList.get(1).getScript());
    assertEquals("dir2/V2_0__Add_foreign_key.sql", migrationList.get(2).getScript());
}
Also used : ArrayList(java.util.ArrayList) ResolvedMigration(org.flywaydb.core.api.resolver.ResolvedMigration) Location(org.flywaydb.core.internal.util.Location) Test(org.junit.Test)

Example 22 with Location

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

the class SqlMigrationResolverSmallTest method extractScriptNameFileSystemPrefix.

@Test
public void extractScriptNameFileSystemPrefix() {
    SqlMigrationResolver sqlMigrationResolver = new SqlMigrationResolver(null, scanner, new Location("filesystem:/some/dir"), PlaceholderReplacer.NO_PLACEHOLDERS, FlywayConfigurationForTests.create());
    assertEquals("V3.171__patch.sql", sqlMigrationResolver.extractScriptName(new FileSystemResource("/some/dir/V3.171__patch.sql")));
}
Also used : FileSystemResource(org.flywaydb.core.internal.util.scanner.filesystem.FileSystemResource) Location(org.flywaydb.core.internal.util.Location) Test(org.junit.Test)

Example 23 with Location

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

the class JdbcMigrationResolverSmallTest method resolveMigrations.

@Test
public void resolveMigrations() throws SQLException {
    JdbcMigrationResolver jdbcMigrationResolver = new JdbcMigrationResolver(scanner, new Location("org/flywaydb/core/internal/resolver/jdbc/dummy"), config);
    Collection<ResolvedMigration> migrations = jdbcMigrationResolver.resolveMigrations();
    assertEquals(3, migrations.size());
    List<ResolvedMigration> migrationList = new ArrayList<ResolvedMigration>(migrations);
    ResolvedMigration migrationInfo = migrationList.get(0);
    assertEquals("2", migrationInfo.getVersion().toString());
    assertEquals("InterfaceBasedMigration", migrationInfo.getDescription());
    assertNull(migrationInfo.getChecksum());
    // do a test execute, since the migration does not do anything, we simply test whether the
    // configuration has been set correctly
    migrationInfo.getExecutor().execute(null);
    ResolvedMigration migrationInfo1 = migrationList.get(1);
    assertEquals("3.5", migrationInfo1.getVersion().toString());
    assertEquals("Three Dot Five", migrationInfo1.getDescription());
    assertEquals(35, migrationInfo1.getChecksum().intValue());
    ResolvedMigration migrationInfo2 = migrationList.get(2);
    assertEquals("4", migrationInfo2.getVersion().toString());
}
Also used : ArrayList(java.util.ArrayList) ResolvedMigration(org.flywaydb.core.api.resolver.ResolvedMigration) Location(org.flywaydb.core.internal.util.Location) Test(org.junit.Test)

Example 24 with Location

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

the class SpringJdbcMigrationResolverSmallTest method resolveMigrations.

@Test
public void resolveMigrations() {
    SpringJdbcMigrationResolver springJdbcMigrationResolver = new SpringJdbcMigrationResolver(scanner, new Location("org/flywaydb/core/internal/resolver/spring/dummy"), config);
    Collection<ResolvedMigration> migrations = springJdbcMigrationResolver.resolveMigrations();
    assertEquals(2, migrations.size());
    List<ResolvedMigration> migrationList = new ArrayList<ResolvedMigration>(migrations);
    assertEquals("2", migrationList.get(0).getVersion().toString());
    assertEquals("3.5", migrationList.get(1).getVersion().toString());
    assertEquals("InterfaceBasedMigration", migrationList.get(0).getDescription());
    assertEquals("Three Dot Five", migrationList.get(1).getDescription());
    assertNull(migrationList.get(0).getChecksum());
    assertEquals(35, migrationList.get(1).getChecksum().intValue());
}
Also used : ArrayList(java.util.ArrayList) ResolvedMigration(org.flywaydb.core.api.resolver.ResolvedMigration) Location(org.flywaydb.core.internal.util.Location) Test(org.junit.Test)

Example 25 with Location

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

the class ClassPathScannerSmallTest method scanForResourcesSplitDirectory.

@Test
public void scanForResourcesSplitDirectory() throws Exception {
    Resource[] resources = classPathScanner.scanForResources(new Location("classpath:org/flywaydb/core/internal/dbsupport"), "create", ".sql");
    assertTrue(resources.length > 7);
    assertEquals("org/flywaydb/core/internal/dbsupport/db2/createMetaDataTable.sql", resources[0].getLocation());
}
Also used : Resource(org.flywaydb.core.internal.util.scanner.Resource) Location(org.flywaydb.core.internal.util.Location) Test(org.junit.Test) DB2MigrationMediumTest(org.flywaydb.core.internal.dbsupport.db2.DB2MigrationMediumTest)

Aggregations

Location (org.flywaydb.core.internal.util.Location)29 Test (org.junit.Test)20 DB2MigrationMediumTest (org.flywaydb.core.internal.dbsupport.db2.DB2MigrationMediumTest)11 Resource (org.flywaydb.core.internal.util.scanner.Resource)11 ResolvedMigration (org.flywaydb.core.api.resolver.ResolvedMigration)7 FileSystemResource (org.flywaydb.core.internal.util.scanner.filesystem.FileSystemResource)6 ArrayList (java.util.ArrayList)5 Test (org.testng.annotations.Test)5 Scanner (org.flywaydb.core.internal.util.scanner.Scanner)3 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 List (java.util.List)2 SqlMigrationResolver (org.flywaydb.core.internal.resolver.sql.SqlMigrationResolver)2 ClassPathResource (org.flywaydb.core.internal.util.scanner.classpath.ClassPathResource)2 Lists.newArrayList (com.google.common.collect.Lists.newArrayList)1 Hashing (com.google.common.hash.Hashing)1 ByteSource (com.google.common.io.ByteSource)1 File (java.io.File)1 IOException (java.io.IOException)1 String.format (java.lang.String.format)1