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);
}
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));
}
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\"?>");
}
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);
}
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);
}
Aggregations