@Then("^The downloaded file should have the same content as the local file \"([^\"]*)\"$") public void The_downloaded_file_should_have_the_same_content_as_the_local_file(String localFilePath) throws Throwable { FileAssert.assertEquals(new File(Context.LOCAL_TEST_DATA_PATH.resolve(localFilePath).toString()), new File(CURRENT_DOWNLOADED_FILE_PATH)); }
@Test public void test() { this.jdbc.execute(conn, "INSERT INTO " + schema + "." + table + " (INT1, STR1, DATE1, TIMESTAMP1) " + "VALUES (1, 'val1', '2017-01-01', '2016-02-02 22:22:22.2')"); this.jdbc.execute(conn, "INSERT INTO " + schema + "." + table + " (INT1, STR1, DATE1, TIMESTAMP1) " + "VALUES (2, null, '2017-02-02', null)"); this.jdbc.execute(conn, "INSERT INTO " + schema + "." + table + " (INT1, STR1, DATE1, TIMESTAMP1) " + "VALUES (null, 'val\\3', null, '2016-03-03 22:22:22.2')"); AquaRevengArgs args = new AquaRevengArgs(); args.setDbTypeStr("H2"); args.setJdbcUrl(url); args.setDriverClass(org.h2.Driver.class.getName()); args.setDbSchema(schema); args.setTables(new String[] { table }); args.setUsername("sa"); args.setPassword(""); File outputPath = new File("./target/csvoutput"); args.setOutputPath(outputPath); CsvStaticDataWriter.start(args, new File("./target/csvoutputwork")); FileAssert.assertEquals(new File("./src/test/resources/CsvStaticDataWriter/TABLE1.expected.csv"), new File(outputPath, "staticdata/TABLE1.csv")); }
/** * Primitive DB comparison method * We just compare file names, not the subdirecory structure also * (so this would fail if multiple subdirectories had the same file name) */ public static void assertDirectoriesEqual(File expected, File actual) { MutableList<File> expectedFiles = FastList.newList(FileUtils.listFiles(expected, new WildcardFileFilter("*"), DIR_FILE_FILTER)); expectedFiles = expectedFiles.sortThisBy(toRelativePath(expected)); MutableList<File> actualFiles = FastList.newList(FileUtils.listFiles(actual, new WildcardFileFilter("*"), DIR_FILE_FILTER)); actualFiles = actualFiles.sortThisBy(toRelativePath(actual)); assertEquals( String.format("Directories did not have same # of files:\nExpected: %1$s\nbut was: %2$s", expectedFiles.makeString("\n"), actualFiles.makeString("\n")), expectedFiles.size(), actualFiles.size()); for (int i = 0; i < expectedFiles.size(); i++) { File expectedFile = expectedFiles.get(i); File actualFile = actualFiles.get(i); String expectedFilePath = getRelativePath(expectedFile, expected); String actualFilePath = getRelativePath(actualFile, actual); System.out.println("Comparing" + expectedFilePath + " vs " + actualFilePath); assertEquals("File " + i + " [" + expectedFile + " vs " + actualFile + " does not match paths relative from their roots", expectedFilePath, actualFilePath); FileAssert.assertEquals("Mismatch on file " + expectedFile.getAbsolutePath(), expectedFile, actualFile); } }