Example #1
0
  /** Test method for {@link com.github.ansell.csv.sum.CSVSummariser#main(java.lang.String[])}. */
  @Test
  public final void testMainSingleHeaderTwentyOneLines() throws Exception {
    Path testFile = testDir.resolve("test-single-header-twenty-one-lines.csv");
    Files.copy(
        this.getClass()
            .getResourceAsStream(
                "/com/github/ansell/csvsum/test-single-header-twenty-one-lines.csv"),
        testFile);
    Path testMapping = testDir.resolve("test-mapping-single-header-twenty-one-lines.csv");
    Files.copy(
        this.getClass()
            .getResourceAsStream(
                "/com/github/ansell/csvupload/test-mapping-single-header-twenty-one-lines.csv"),
        testMapping);

    CSVUpload.main(
        "--database",
        databaseConnectionString,
        "--table",
        tableString,
        "--input",
        testFile.toAbsolutePath().toString(),
        "--debug",
        "true",
        "--mapping",
        testMapping.toAbsolutePath().toString());
  }
Example #2
0
  /** Test method for {@link com.github.ansell.csv.db.CSVUpload#main(java.lang.String[])}. */
  @Test
  public final void testMainEmpty() throws Exception {
    Path testFile = testDir.resolve("test-empty.csv");
    Files.copy(
        this.getClass().getResourceAsStream("/com/github/ansell/csvsum/test-empty.csv"), testFile);
    Path testMapping = testDir.resolve("test-mapping-empty.csv");
    Files.copy(
        this.getClass().getResourceAsStream("/com/github/ansell/csvupload/test-mapping-empty.csv"),
        testMapping);

    thrown.expect(RuntimeException.class);
    thrown.expectMessage("CSV file did not contain a valid header line");
    CSVUpload.main(
        "--database",
        databaseConnectionString,
        "--table",
        tableString,
        "--input",
        testFile.toAbsolutePath().toString(),
        "--mapping",
        testMapping.toAbsolutePath().toString());
  }
Example #3
0
  /** Test method for {@link com.github.ansell.csv.sum.CSVSummariser#main(java.lang.String[])}. */
  @Test
  public final void testMainMultiKey() throws Exception {
    Path testFile = testDir.resolve("test-source-multi-key.csv");
    Files.copy(
        this.getClass().getResourceAsStream("/com/github/ansell/csvjoin/test-source-multi-key.csv"),
        testFile);
    Path testMapping = testDir.resolve("test-mapping-source-multi-key.csv");
    Files.copy(
        this.getClass()
            .getResourceAsStream("/com/github/ansell/csvupload/test-mapping-source-multi-key.csv"),
        testMapping);

    CSVUpload.main(
        "--database",
        databaseConnectionString,
        "--table",
        tableString,
        "--input",
        testFile.toAbsolutePath().toString(),
        "--debug",
        "true",
        "--mapping",
        testMapping.toAbsolutePath().toString());
  }
Example #4
0
 /** Test method for {@link com.github.ansell.csv.db.CSVUpload#main(java.lang.String[])}. */
 @Test
 public final void testMainNoArgs() throws Exception {
   thrown.expect(OptionException.class);
   CSVUpload.main();
 }