Search in sources :

Example 6 with Location

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

the class ClassPathScannerSmallTest method scanForClassesSplitPackage.

@Test
public void scanForClassesSplitPackage() throws Exception {
    Class<?>[] classes = classPathScanner.scanForClasses(new Location("classpath:org/flywaydb/core/internal/util"), UrlResolver.class);
    assertTrue(classes.length >= 2);
    assertTrue(Arrays.asList(classes).contains(JBossVFSv2UrlResolver.class));
}
Also used : JBossVFSv2UrlResolver(org.flywaydb.core.internal.util.scanner.classpath.jboss.JBossVFSv2UrlResolver) Location(org.flywaydb.core.internal.util.Location) Test(org.junit.Test) DB2MigrationMediumTest(org.flywaydb.core.internal.dbsupport.db2.DB2MigrationMediumTest)

Example 7 with Location

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

the class ClassPathScannerSmallTest method scanForResources.

@Test
public void scanForResources() throws Exception {
    Resource[] resources = classPathScanner.scanForResources(new Location("classpath:migration/sql"), "V", ".sql");
    assertEquals(4, resources.length);
    assertEquals("migration/sql/V1.1__View.sql", resources[0].getLocation());
    assertEquals("migration/sql/V1_2__Populate_table.sql", resources[1].getLocation());
    assertEquals("migration/sql/V1__First.sql", resources[2].getLocation());
    assertEquals("migration/sql/V2_0__Add_foreign_key_and_super_mega_humongous_padding_to_exceed_the_maximum_column_length_in_the_metadata_table.sql", resources[3].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)

Example 8 with Location

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

the class SqlMigrationResolverSmallTest method extractScriptName.

@Test
public void extractScriptName() {
    SqlMigrationResolver sqlMigrationResolver = new SqlMigrationResolver(null, scanner, new Location("db/migration"), PlaceholderReplacer.NO_PLACEHOLDERS, FlywayConfigurationForTests.createWithPrefix("db_"));
    assertEquals("db_0__init.sql", sqlMigrationResolver.extractScriptName(new ClassPathResource("db/migration/db_0__init.sql", Thread.currentThread().getContextClassLoader())));
}
Also used : ClassPathResource(org.flywaydb.core.internal.util.scanner.classpath.ClassPathResource) Location(org.flywaydb.core.internal.util.Location) Test(org.junit.Test)

Example 9 with Location

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

the class SqlMigrationResolverSmallTest method extractScriptNameRootLocation.

@Test
public void extractScriptNameRootLocation() {
    SqlMigrationResolver sqlMigrationResolver = new SqlMigrationResolver(null, scanner, new Location(""), PlaceholderReplacer.NO_PLACEHOLDERS, FlywayConfigurationForTests.createWithPrefix("db_"));
    assertEquals("db_0__init.sql", sqlMigrationResolver.extractScriptName(new ClassPathResource("db_0__init.sql", Thread.currentThread().getContextClassLoader())));
}
Also used : ClassPathResource(org.flywaydb.core.internal.util.scanner.classpath.ClassPathResource) Location(org.flywaydb.core.internal.util.Location) Test(org.junit.Test)

Example 10 with Location

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

the class SqlMigrationResolverSmallTest method resolveMigrationsRoot.

@Test
public void resolveMigrationsRoot() {
    FlywayConfigurationForTests configuration = FlywayConfigurationForTests.createWithPrefix("CheckValidate");
    configuration.setRepeatableSqlMigrationPrefix("X");
    SqlMigrationResolver sqlMigrationResolver = new SqlMigrationResolver(null, scanner, new Location(""), PlaceholderReplacer.NO_PLACEHOLDERS, configuration);
    // changed to 3 as new test cases are added for SybaseASE and DB2
    assertEquals(3, sqlMigrationResolver.resolveMigrations().size());
}
Also used : FlywayConfigurationForTests(org.flywaydb.core.internal.resolver.FlywayConfigurationForTests) Location(org.flywaydb.core.internal.util.Location) Test(org.junit.Test)

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