Search in sources :

Example 6 with Namespace

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

the class DbDumpCommandTest method testDumpSchema.

@Test
public void testDumpSchema() throws Exception {
    final Map<String, Object> attributes = new HashMap<>();
    for (String name : attributeNames) {
        attributes.put(name, true);
    }
    dumpCommand.run(null, new Namespace(attributes), existedDbConf);
    final Element changeSet = getFirstElement(toXmlDocument(baos).getDocumentElement(), "changeSet");
    assertCreateTable(changeSet);
}
Also used : HashMap(java.util.HashMap) Element(org.w3c.dom.Element) Namespace(net.sourceforge.argparse4j.inf.Namespace) Test(org.junit.Test)

Example 7 with Namespace

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

the class DbDumpCommandTest method testDumpSchemaAndData.

@Test
public void testDumpSchemaAndData() throws Exception {
    final Map<String, Object> attributes = new HashMap<>();
    for (String name : Iterables.concat(attributeNames, ImmutableList.of("data"))) {
        attributes.put(name, true);
    }
    dumpCommand.run(null, new Namespace(attributes), existedDbConf);
    final NodeList changeSets = toXmlDocument(baos).getDocumentElement().getElementsByTagName("changeSet");
    assertCreateTable((Element) changeSets.item(0));
    assertInsertData((Element) changeSets.item(1));
}
Also used : HashMap(java.util.HashMap) NodeList(org.w3c.dom.NodeList) Namespace(net.sourceforge.argparse4j.inf.Namespace) Test(org.junit.Test)

Example 8 with Namespace

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

the class DbDumpCommandTest method testWriteToFile.

@Test
public void testWriteToFile() throws Exception {
    final File file = File.createTempFile("migration", ".xml");
    final Map<String, Object> attributes = ImmutableMap.of("output", file.getAbsolutePath());
    dumpCommand.run(null, new Namespace(attributes), existedDbConf);
    // Check that file is exist, and has some XML content (no reason to make a full-blown XML assertion)
    assertThat(Files.toString(file, StandardCharsets.UTF_8)).startsWith("<?xml version=\"1.1\" encoding=\"UTF-8\" standalone=\"no\"?>");
}
Also used : File(java.io.File) Namespace(net.sourceforge.argparse4j.inf.Namespace) Test(org.junit.Test)

Example 9 with Namespace

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

the class DbFastForwardCommandTest method testFastForwardFirstDryRun.

@Test
public void testFastForwardFirstDryRun() throws Exception {
    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    fastForwardCommand.setPrintStream(new PrintStream(baos));
    // Fast-forward one change
    fastForwardCommand.run(null, new Namespace(ImmutableMap.of("all", false, "dry-run", true)), conf);
    assertThat(NEWLINE_PATTERN.splitAsStream(baos.toString(UTF_8)).filter(s -> s.startsWith("INSERT INTO PUBLIC.DATABASECHANGELOG ("))).hasSize(1);
}
Also used : PrintStream(java.io.PrintStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Namespace(net.sourceforge.argparse4j.inf.Namespace) Test(org.junit.Test)

Example 10 with Namespace

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

the class DbFastForwardCommandTest method testFastForwardAllDryRun.

@Test
public void testFastForwardAllDryRun() throws Exception {
    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    fastForwardCommand.setPrintStream(new PrintStream(baos));
    // Fast-forward 3 changes
    fastForwardCommand.run(null, new Namespace(ImmutableMap.of("all", true, "dry-run", true)), conf);
    assertThat(NEWLINE_PATTERN.splitAsStream(baos.toString(UTF_8)).filter(s -> s.startsWith("INSERT INTO PUBLIC.DATABASECHANGELOG ("))).hasSize(3);
}
Also used : PrintStream(java.io.PrintStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) 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