Search in sources :

Example 36 with Namespace

use of net.sourceforge.argparse4j.inf.Namespace in project dropwizard by dropwizard.

the class DbRollbackCommandTest method testRollbackToDate.

@Test
public void testRollbackToDate() throws Exception {
    // Migrate some DDL changes to the database
    long migrationDate = System.currentTimeMillis();
    migrateCommand.run(null, new Namespace(ImmutableMap.of()), conf);
    // Rollback both changes (they're after the migration date)
    rollbackCommand.run(null, new Namespace(ImmutableMap.of("date", new Date(migrationDate - 1000))), conf);
    // Verify we can creat the table
    dbi.useHandle(h -> h.execute("create table persons(id int, name varchar(255))"));
}
Also used : Namespace(net.sourceforge.argparse4j.inf.Namespace) Date(java.util.Date) Test(org.junit.Test)

Example 37 with Namespace

use of net.sourceforge.argparse4j.inf.Namespace in project dropwizard by dropwizard.

the class DbRollbackCommandTest method testRollbackToTag.

@Test
public void testRollbackToTag() throws Exception {
    // Migrate the first DDL change to the database
    migrateCommand.run(null, new Namespace(ImmutableMap.of("count", 1)), conf);
    // Tag it
    final DbTagCommand<TestMigrationConfiguration> tagCommand = new DbTagCommand<>(new TestMigrationDatabaseConfiguration(), TestMigrationConfiguration.class, migrationsFileName);
    tagCommand.run(null, new Namespace(ImmutableMap.of("tag-name", ImmutableList.of("v1"))), conf);
    // Migrate the second change
    migrateCommand.run(null, new Namespace(ImmutableMap.of()), conf);
    // Rollback to the first change
    rollbackCommand.run(null, new Namespace(ImmutableMap.of("tag", "v1")), conf);
    // Verify we can add the second change manually
    dbi.useHandle(h -> h.execute("alter table persons add column email varchar(128)"));
}
Also used : Namespace(net.sourceforge.argparse4j.inf.Namespace) Test(org.junit.Test)

Example 38 with Namespace

use of net.sourceforge.argparse4j.inf.Namespace in project dropwizard by dropwizard.

the class DbStatusCommandTest method testRun.

@Test
public void testRun() throws Exception {
    statusCommand.run(null, new Namespace(ImmutableMap.of()), conf);
    assertThat(baos.toString(UTF_8)).matches("3 change sets have not been applied to \\S+" + System.lineSeparator());
}
Also used : Namespace(net.sourceforge.argparse4j.inf.Namespace) Test(org.junit.Test)

Example 39 with Namespace

use of net.sourceforge.argparse4j.inf.Namespace in project dropwizard by dropwizard.

the class DbStatusCommandTest method testRunOnMigratedDb.

@Test
public void testRunOnMigratedDb() throws Exception {
    final String existedDbPath = new File(Resources.getResource("test-db.mv.db").toURI()).getAbsolutePath();
    final String existedDbUrl = "jdbc:h2:" + StringUtils.removeEnd(existedDbPath, ".mv.db");
    final TestMigrationConfiguration existedDbConf = createConfiguration(existedDbUrl);
    statusCommand.run(null, new Namespace(ImmutableMap.of()), existedDbConf);
    assertThat(baos.toString(UTF_8)).matches("\\S+ is up to date" + System.lineSeparator());
}
Also used : File(java.io.File) Namespace(net.sourceforge.argparse4j.inf.Namespace) Test(org.junit.Test)

Example 40 with Namespace

use of net.sourceforge.argparse4j.inf.Namespace in project dropwizard by dropwizard.

the class DbStatusCommandTest method testVerbose.

@Test
public void testVerbose() throws Exception {
    statusCommand.run(null, new Namespace(ImmutableMap.of("verbose", (Object) true)), conf);
    assertThat(baos.toString(UTF_8)).matches("3 change sets have not been applied to \\S+" + System.lineSeparator() + "\\s*migrations\\.xml::1::db_dev" + System.lineSeparator() + "\\s*migrations\\.xml::2::db_dev" + System.lineSeparator() + "\\s*migrations\\.xml::3::db_dev" + System.lineSeparator());
}
Also used : Namespace(net.sourceforge.argparse4j.inf.Namespace) Test(org.junit.Test)

Aggregations

Namespace (net.sourceforge.argparse4j.inf.Namespace)46 Test (org.junit.Test)36 PrintStream (java.io.PrintStream)9 Handle (org.skife.jdbi.v2.Handle)7 ByteArrayOutputStream (java.io.ByteArrayOutputStream)6 Liquibase (liquibase.Liquibase)6 ArgumentParserException (net.sourceforge.argparse4j.inf.ArgumentParserException)6 DBI (org.skife.jdbi.v2.DBI)6 ArgumentParser (net.sourceforge.argparse4j.inf.ArgumentParser)5 IOException (java.io.IOException)4 Properties (java.util.Properties)4 ImmutableMap (com.google.common.collect.ImmutableMap)3 File (java.io.File)3 Configuration (io.dropwizard.Configuration)2 Bootstrap (io.dropwizard.setup.Bootstrap)2 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 Element (org.w3c.dom.Element)2