Java 类org.testng.FileAssert 实例源码

项目:ANDS-Vocabs-Toolkit    文件:ArquillianTestUtils.java   
/** Compare two files containing JSON, asserting that they contain
 * the same content.
 * @param testFilename The filename of the file containing the generated
 *      content. An TestNG assertion is made that this file exists.
 * @param correctFilename The filename of the file containing the correct
 *      value.
 * @throws IOException If reading either file fails.
 */
public static void compareJson(final String testFilename,
        final String correctFilename) throws IOException {
    File testFile = new File(testFilename);
    FileAssert.assertFile(testFile,
            "Test file (" + testFilename + ") is not "
                    + "a proper file");
    ObjectMapper mapper = new ObjectMapper();
    JsonNode testJson;
    JsonNode correctJson;
    // IOException not caught here, but allowed to propagate.
    testJson = mapper.readTree(new File(testFilename));
    correctJson = mapper.readTree(new File(correctFilename));
    Assert.assertEquals(testJson, correctJson);
    // NB This uses a top-level equality test done by TestNG.
    // There is also a top-level equality test implemented by Jackson:
    // correctJson.equals(testJson). The TestNG one seems to give
    // the same end result, but gives better diagnostics in case
    // a difference is found.
}
项目:BSPAT    文件:BSPAT_pgmTest.java   
private void demoDataTest(String bismarkInputFileName) throws IOException, InterruptedException, ParseException {
    String[] resultFilenames = {"demoRef-10-96-test-plus_bismark.analysis.txt",
            "demoRef-10-96-test-plus_bismark.analysis_ASM.txt",
            "demoRef-10-96-test-plus_bismark.analysis_Methylation.txt",
            "demoRef-10-96-test-plus_bismark.analysis_MethylationWithSNP.txt",
            "demoRef-10-96-test-plus_bismark.analysis_report.txt"};
    // with default parameter
    String inputFile = testResourcePath + "/demoInput/" + bismarkInputFileName;
    String referenceFile = testResourcePath + "/demoInput/demoReference.fasta";
    String targetRegionFile = testResourcePath + "/demoInput/target.bed";
    String[] args = {referenceFile, inputFile, targetRegionFile, "-o", testResourcePath + "/demoActual"};
    BSPAT_pgm.main(args);
    for (String resultFilename : resultFilenames) {
        String actualResultFilename = testResourcePath + "/demoActual/" + resultFilename;
        String expectedResultFilename = testResourcePath + "/demoExpected/" + resultFilename;
        File actualResultFile = new File(actualResultFilename);
        FileAssert.assertFile(actualResultFile, "Output " + actualResultFile.getAbsolutePath() + " doesn't exist!");
        assertEqualFiles(actualResultFile, new File(expectedResultFilename),
                resultFilename);
        if (!actualResultFile.delete()) {
            throw new IOException(actualResultFilename + " doesn't delete successfully!");
        }
    }
}
项目:BSPAT    文件:BSPAT_pgmTest.java   
@Test
public void integrationTest_halfCpG() throws InterruptedException, ParseException, IOException {
    String[] resultFilenames = {"minusRef-24-80-halfCpG-minus_bismark.analysis.txt",
            "minusRef-24-80-halfCpG-minus_bismark.analysis_Methylation.txt",
            "minusRef-24-80-halfCpG-minus_bismark.analysis_report.txt"};
    // with default parameter
    String inputFile = testResourcePath + "/minusRefInput/minusRef_bismark.bam";
    String referenceFile = testResourcePath + "/minusRefInput/minusRef.fa";
    String targetRegionFile = testResourcePath + "/halfCpGInput/target_halfCpG.bed";
    String[] args = {referenceFile, inputFile, targetRegionFile, "-o", testResourcePath + "/halfCpGActual"};
    BSPAT_pgm.main(args);
    for (String resultFilename : resultFilenames) {
        String actualResultFilename = testResourcePath + "/halfCpGActual/" + resultFilename;
        String expectedResultFilename = testResourcePath + "/halfCpGExpected/" + resultFilename;
        File actualResultFile = new File(actualResultFilename);
        FileAssert.assertFile(actualResultFile, "Output " + resultFilename + " doesn't exist!");
        assertEqualFiles(actualResultFile, new File(expectedResultFilename),
                resultFilename);
        if (!actualResultFile.delete()) {
            throw new IOException(actualResultFilename + " doesn't delete successfully!");
        }
    }
}
项目:BSPAT    文件:BSPAT_pgmTest.java   
@Test
public void integrationTest_minusRef() throws IOException, ParseException, InterruptedException {
    String[] resultFilenames = {"minusRef-5-103-reverse-minus_bismark.analysis.txt",
            "minusRef-5-103-reverse-minus_bismark.analysis_Methylation.txt",
            "minusRef-5-103-reverse-minus_bismark.analysis_report.txt"};
    // with default parameter
    String inputFile = testResourcePath + "/minusRefInput/minusRef_bismark.bam";
    String referenceFile = testResourcePath + "/minusRefInput/minusRef.fa";
    String targetRegionFile = testResourcePath + "/minusRefInput/target_reverse.bed";
    String[] args = {referenceFile, inputFile, targetRegionFile, "-o", testResourcePath + "/minusRefActual"};
    BSPAT_pgm.main(args);
    for (String resultFilename : resultFilenames) {
        String actualResultFilename = testResourcePath + "/minusRefActual/" + resultFilename;
        String expectedResultFilename = testResourcePath + "/minusRefExpected/" + resultFilename;
        File actualResultFile = new File(actualResultFilename);
        FileAssert.assertFile(actualResultFile, "Output " + resultFilename + " doesn't exist!");
        assertEqualFiles(actualResultFile, new File(expectedResultFilename),
                resultFilename);
        if (!actualResultFile.delete()) {
            throw new IOException(actualResultFilename + " doesn't delete successfully!");
        }
    }
}
项目:sqp    文件:CursorTest.java   
@Test
public void SimpleQuerySelectWorks() throws Exception {
    Cursor cursor = connection.execute(Cursor.class,
            "SELECT * FROM " + TEST_TABLE + " WHERE city LIKE '%City' ORDER BY city DESC"
    ).join();

    assertThat(cursor, Is.is(not(nullValue())));

    // check column metadata first
    List<ColumnMetadata> columns = cursor.getColumnMetadata();
    assertThat(columns.size(), Is.is(5));
    assertThat(columns, Matchers.contains(
            ColumnMetadataMatcher.columnMetadataWith(SqpTypeCode.VarChar, "city"),
            ColumnMetadataMatcher.columnMetadataWith(SqpTypeCode.Integer, "temp_lo"),
            ColumnMetadataMatcher.columnMetadataWith(SqpTypeCode.Integer, "temp_hi"),
            ColumnMetadataMatcher.columnMetadataWith(SqpTypeCode.Real, "prob"),
            ColumnMetadataMatcher.columnMetadataWith(SqpTypeCode.Date, "date")
    ));

    // check for data
    assertThat(cursor.nextRow(), is(true));

    // check city field in detail
    SqpValue firstField = cursor.at(0);
    assertThat(firstField, is(instanceOf(SqpVarChar.class)));
    SqpVarChar strField = (SqpVarChar) firstField;
    assertThat(strField.asString(), is("TestCity"));

    // check named date field for correct conversion
    LocalDate date = cursor.at("date").asLocalDate();
    assertThat(date.getYear(), is(1015));
    assertThat(date.getMonth(), is(Month.JULY));
    assertThat(date.getDayOfMonth(), is(12));

    // make sure the next row has different data
    assertThat(cursor.nextRow(), is(true));
    MatcherAssert.assertThat(cursor.at("city").asString(), is("FooCity"));
    assertThat(cursor.nextRow(), is(false)); // should be at end
    // is not scrollable, so previousRow is not available
    try {
        cursor.previousRow();
        FileAssert.fail();
    } catch (CursorProblemException e) {
    }
}