当前位置: 首页>>代码示例>>Java>>正文


Java FileAssert类代码示例

本文整理汇总了Java中junitx.framework.FileAssert的典型用法代码示例。如果您正苦于以下问题:Java FileAssert类的具体用法?Java FileAssert怎么用?Java FileAssert使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


FileAssert类属于junitx.framework包,在下文中一共展示了FileAssert类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testActivatePropertyFileExistsOverwriteDisabled

import junitx.framework.FileAssert; //导入依赖的package包/类
@Test
public void testActivatePropertyFileExistsOverwriteDisabled() throws IOException, URISyntaxException {
	/* Prepare data. */
	assertEquals(0, this.baseDir.list().length);
	createTempFiles(SYNC_CONFIG_FN);
	this.props.remove(InitialRegistrationImpl.PROP_SYNC_ONCE_TYPE);
	this.props.put(InitialRegistrationImpl.PROP_OVERWRITE_CONFIG_FILES, true);

	/* Invoke method. */
	this.initialRegistration.activate(this.props);

	/* Check its results. */
	FileAssert.assertEquals(getResource("data3-config.properties"), this.generatedConfigFile);
	FileAssert.assertEquals(getResource("data1-filter.xml"), this.generatedFilterFile);
	verify(this.serviceSettings, times(1)).addSyncRoot(this.baseDir, 3000l);
}
 
开发者ID:daniel-lima,项目名称:aem-vltsync,代码行数:17,代码来源:InitialRegistrationImplTest.java

示例2: testActivatePropertyFileExistsDirWithContentsOverwrite

import junitx.framework.FileAssert; //导入依赖的package包/类
@Test
public void testActivatePropertyFileExistsDirWithContentsOverwrite() throws IOException, URISyntaxException {
	/* Prepare data. */
	assertEquals(0, this.baseDir.list().length);
	createTempFiles("README.md", SYNC_CONFIG_FN);
	this.props.put(InitialRegistrationImpl.PROP_OVERWRITE_CONFIG_FILES, true);
	this.props.put(InitialRegistrationImpl.PROP_SYNC_ONCE_EXPECTED_TIME, 3001l);

	/* Invoke method. */
	this.initialRegistration.activate(this.props);

	/* Check its results. */
	FileAssert.assertEquals(getResource("data2-config.properties"), this.generatedConfigFile);
	FileAssert.assertEquals(getResource("data1-filter.xml"), this.generatedFilterFile);
	verify(this.serviceSettings, times(1)).addSyncRoot(this.baseDir, 3001l);
}
 
开发者ID:daniel-lima,项目名称:aem-vltsync,代码行数:17,代码来源:InitialRegistrationImplTest.java

示例3: assertDirectoriesEqual

import junitx.framework.FileAssert; //导入依赖的package包/类
/**
 * 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);
    }
}
 
开发者ID:goldmansachs,项目名称:obevo,代码行数:31,代码来源:DirectoryAssert.java

示例4: test

import junitx.framework.FileAssert; //导入依赖的package包/类
@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"));
}
 
开发者ID:goldmansachs,项目名称:obevo,代码行数:24,代码来源:CsvStaticDataWriterTest.java

示例5: testBsonFile

import junitx.framework.FileAssert; //导入依赖的package包/类
private void testBsonFile (String fileName, boolean useDouble) throws IOException
{
	// data1.bson has 0 in Document / Array length
	File file = new File (fileName.replace ('/', File.separatorChar));

	File testFile = testFolder.newFile ();
	BsonParser p = new BsonParser (new FileInputStream (file));
	BsonGenerator g = new BsonGenerator (new FileOutputStream (testFile));
	g.setUseDouble (useDouble);
	Utils.convert (p, g);
	p.close ();
	g.close ();
	BsonFixLength.fix (testFile);

	FileAssert.assertBinaryEquals (file, testFile);
}
 
开发者ID:coconut2015,项目名称:cookjson,代码行数:17,代码来源:BsonGeneratorTest.java

示例6: testJsonBinary

import junitx.framework.FileAssert; //导入依赖的package包/类
@Test
public void testJsonBinary () throws IOException
{
	File bsonFile = testFolder.newFile ();
	BsonGenerator g = new BsonGenerator (new FileOutputStream (bsonFile));
	g.writeStartArray ();
	g.write (new byte[] { (byte) 0xde, (byte) 0xad, (byte) 0xbe, (byte) 0xef });
	g.writeEnd ();
	g.close ();

	// read into a structure which contains CookJsonBinary
	BsonParser p = new BsonParser (new FileInputStream (bsonFile));
	p.setRootAsArray (true);
	p.next ();
	JsonValue value = p.getValue ();
	p.close ();

	// now write to another BSON file;
	File bsonFile2 = testFolder.newFile ();
	BsonGenerator g2 = new BsonGenerator (new FileOutputStream (bsonFile2));
	g2.write (value);
	g2.close ();

	// now verify that our original data written was correct.
	FileAssert.assertBinaryEquals (bsonFile, bsonFile2);
}
 
开发者ID:coconut2015,项目名称:cookjson,代码行数:27,代码来源:BsonGeneratorTest.java

示例7: testBigInteger

import junitx.framework.FileAssert; //导入依赖的package包/类
@Test
public void testBigInteger () throws IOException
{
	File bsonFile = testFolder.newFile ();
	BsonGenerator g = new BsonGenerator (new FileOutputStream (bsonFile));
	g.writeStartArray ();
	g.write (new BigInteger ("123456789012345678901234567890"));
	g.writeEnd ();
	g.close ();

	// now write to another BSON file;
	File bsonFile2 = testFolder.newFile ();
	BsonGenerator g2 = new BsonGenerator (new FileOutputStream (bsonFile2));
	g2.writeStartArray ();
	g2.write (new CookJsonBigDecimal (new BigDecimal ("123456789012345678901234567890")) );
	g2.writeEnd ();
	g2.close ();

	// now verify that our original data written was correct.
	FileAssert.assertBinaryEquals (bsonFile, bsonFile2);
}
 
开发者ID:coconut2015,项目名称:cookjson,代码行数:22,代码来源:BsonGeneratorTest.java

示例8: testJson

import junitx.framework.FileAssert; //导入依赖的package包/类
@Test
public void testJson () throws IOException
{
	File file1 = new File ("../tests/data/binary.bson".replace ('/', File.separatorChar));
	File file2 = new File ("../tests/data/binary.json".replace ('/', File.separatorChar));

	CookJsonProvider provider = new CookJsonProvider ();
	HashMap<String, Object> bsonConfig = new HashMap<String, Object> ();
	bsonConfig.put (CookJsonProvider.FORMAT, CookJsonProvider.FORMAT_BSON);
	bsonConfig.put (CookJsonProvider.ROOT_AS_ARRAY, Boolean.TRUE);

	HashMap<String, Object> jsonConfig = new HashMap<String, Object> ();

	File jsonFile = testFolder.newFile ();
	JsonParser p = provider.createParserFactory (bsonConfig).createParser (new FileInputStream (file1));
	JsonGenerator g = provider.createGeneratorFactory (jsonConfig).createGenerator (new FileOutputStream (jsonFile));
	Utils.convert (p, g);
	p.close ();
	g.close ();

	FileAssert.assertBinaryEquals (file2, jsonFile);
}
 
开发者ID:coconut2015,项目名称:cookjson,代码行数:23,代码来源:BinaryTest.java

示例9: testJsonHex

import junitx.framework.FileAssert; //导入依赖的package包/类
@Test
public void testJsonHex () throws IOException
{
	File file1 = new File ("../tests/data/binary.bson".replace ('/', File.separatorChar));
	File file2 = new File ("../tests/data/binary2.json".replace ('/', File.separatorChar));

	CookJsonProvider provider = new CookJsonProvider ();
	HashMap<String, Object> bsonConfig = new HashMap<String, Object> ();
	bsonConfig.put (CookJsonProvider.FORMAT, CookJsonProvider.FORMAT_BSON);
	bsonConfig.put (CookJsonProvider.ROOT_AS_ARRAY, Boolean.TRUE);

	HashMap<String, Object> jsonConfig = new HashMap<String, Object> ();
	jsonConfig.put (CookJsonProvider.BINARY_FORMAT, CookJsonProvider.BINARY_FORMAT_HEX);

	File jsonFile = testFolder.newFile ();
	JsonParser p = provider.createParserFactory (bsonConfig).createParser (new FileInputStream (file1));
	JsonGenerator g = provider.createGeneratorFactory (jsonConfig).createGenerator (new FileOutputStream (jsonFile));
	Utils.convert (p, g);
	p.close ();
	g.close ();

	FileAssert.assertBinaryEquals (file2, jsonFile);
}
 
开发者ID:coconut2015,项目名称:cookjson,代码行数:24,代码来源:BinaryTest.java

示例10: testBson

import junitx.framework.FileAssert; //导入依赖的package包/类
@Test
public void testBson () throws IOException
{
	File file1 = new File ("../tests/data/binary.bson".replace ('/', File.separatorChar));

	CookJsonProvider provider = new CookJsonProvider ();
	HashMap<String, Object> bsonConfig = new HashMap<String, Object> ();
	bsonConfig.put (CookJsonProvider.FORMAT, CookJsonProvider.FORMAT_BSON);
	bsonConfig.put (CookJsonProvider.ROOT_AS_ARRAY, Boolean.TRUE);

	// first convert from Json to Bson using stream API
	File bsonFile = testFolder.newFile ();
	JsonParser p = provider.createParserFactory (bsonConfig).createParser (new FileInputStream (file1));
	JsonGenerator g = provider.createGeneratorFactory (bsonConfig).createGenerator (new FileOutputStream (bsonFile));
	Utils.convert (p, g);
	p.close ();
	g.close ();

	BsonFixLength.fix (bsonFile);
	FileAssert.assertBinaryEquals (file1, bsonFile);
}
 
开发者ID:coconut2015,项目名称:cookjson,代码行数:22,代码来源:BinaryTest.java

示例11: testJsonValueJson

import junitx.framework.FileAssert; //导入依赖的package包/类
@Test
public void testJsonValueJson () throws IOException
{
	File file1 = new File ("../tests/data/binary.bson".replace ('/', File.separatorChar));
	File file2 = new File ("../tests/data/binary.json".replace ('/', File.separatorChar));

	CookJsonProvider provider = new CookJsonProvider ();
	HashMap<String, Object> bsonConfig = new HashMap<String, Object> ();
	bsonConfig.put (CookJsonProvider.FORMAT, CookJsonProvider.FORMAT_BSON);
	bsonConfig.put (CookJsonProvider.ROOT_AS_ARRAY, Boolean.TRUE);

	HashMap<String, Object> jsonConfig = new HashMap<String, Object> ();

	File jsonFile = testFolder.newFile ();
	CookJsonParser p = (CookJsonParser) provider.createParserFactory (bsonConfig).createParser (new FileInputStream (file1));
	p.next ();
	JsonValue value = p.getValue ();
	JsonGenerator g = provider.createGeneratorFactory (jsonConfig).createGenerator (new FileOutputStream (jsonFile));
	g.write (value);
	p.close ();
	g.close ();

	FileAssert.assertBinaryEquals (file2, jsonFile);
}
 
开发者ID:coconut2015,项目名称:cookjson,代码行数:25,代码来源:BinaryTest.java

示例12: testJsonValueJsonHex

import junitx.framework.FileAssert; //导入依赖的package包/类
@Test
public void testJsonValueJsonHex () throws IOException
{
	File file1 = new File ("../tests/data/binary.bson".replace ('/', File.separatorChar));
	File file2 = new File ("../tests/data/binary2.json".replace ('/', File.separatorChar));

	CookJsonProvider provider = new CookJsonProvider ();
	HashMap<String, Object> bsonConfig = new HashMap<String, Object> ();
	bsonConfig.put (CookJsonProvider.FORMAT, CookJsonProvider.FORMAT_BSON);
	bsonConfig.put (CookJsonProvider.ROOT_AS_ARRAY, Boolean.TRUE);

	HashMap<String, Object> jsonConfig = new HashMap<String, Object> ();
	jsonConfig.put (CookJsonProvider.BINARY_FORMAT, CookJsonProvider.BINARY_FORMAT_HEX);

	File jsonFile = testFolder.newFile ();
	CookJsonParser p = (CookJsonParser) provider.createParserFactory (bsonConfig).createParser (new FileInputStream (file1));
	p.next ();
	JsonValue value = p.getValue ();
	JsonGenerator g = provider.createGeneratorFactory (jsonConfig).createGenerator (new FileOutputStream (jsonFile));
	g.write (value);
	p.close ();
	g.close ();

	FileAssert.assertBinaryEquals (file2, jsonFile);
}
 
开发者ID:coconut2015,项目名称:cookjson,代码行数:26,代码来源:BinaryTest.java

示例13: testRootAsArray

import junitx.framework.FileAssert; //导入依赖的package包/类
@Test
public void testRootAsArray () throws Exception
{
	// test Bson input with rootAsArray option

	File srcFile;
	File dstFile;
	File dstFile2;

	srcFile = new File ("../tests/data/data1.bson".replace ('/', File.separatorChar));
	dstFile = testFolder.newFile ("testroot_1.json");
	ConvertJson.main (new String[]{ "-f", srcFile.getPath (), "-t", dstFile.getPath (), "-a" });

	srcFile = new File ("../tests/data/data3.json".replace ('/', File.separatorChar));
	dstFile2 = testFolder.newFile ("testroot_2.json");
	ConvertJson.main (new String[]{ "-f", srcFile.getPath (), "-t", dstFile2.getPath () });
	FileAssert.assertBinaryEquals (dstFile, dstFile2);
}
 
开发者ID:coconut2015,项目名称:cookjson,代码行数:19,代码来源:ConvertJsonTest.java

示例14: testHexadecimal

import junitx.framework.FileAssert; //导入依赖的package包/类
@Test
public void testHexadecimal () throws Exception
{
	// test Bson input with rootAsArray option

	File srcFile;
	File expectFile;
	File dstFile;

	srcFile = new File ("../tests/data/binary.bson".replace ('/', File.separatorChar));
	dstFile = testFolder.newFile ("testbinary.json");
	ConvertJson.main (new String[]{ "-f", srcFile.getPath (), "-t", dstFile.getPath (), "-a", "-x" });

	expectFile = new File ("../tests/data/binary2.json".replace ('/', File.separatorChar));
	FileAssert.assertBinaryEquals (expectFile, dstFile);
}
 
开发者ID:coconut2015,项目名称:cookjson,代码行数:17,代码来源:ConvertJsonTest.java

示例15: testAccessToSoundFile

import junitx.framework.FileAssert; //导入依赖的package包/类
@Test
public void testAccessToSoundFile() throws IOException {
    //logger.info("working directory: {}", System.getProperty("user.dir") );
    URL url = this
            .getClass()
            .getResource(
                    "/sound_files/hello_world/b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9_processed.wav");
    File expectedHelloWorldWaveFile = new File(url.getFile());
    
    //String usedUrl = "http://localhost:" + port + "/api/generateSpeak?words={words}";
    String usedUrl = eac.getInsideRootUrl() + "/api/generateSpeak?words={words}";
    assertEquals("http://localhost:8085/api/generateSpeak?words={words}", usedUrl);
    
    Map<String, String> helloWorldQueryParameters = ImmutableMap.<String, String>builder().put("words","hello world").build();
    ResponseEntity<String> urlResponse = restTemplate.getForEntity(usedUrl, String.class, helloWorldQueryParameters);
    
    String actualHelloWorldWaveFileUrlString = urlResponse.getBody();
    assertEquals("http://localhost:8085/ext-url-resources/b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9_processed.wav", actualHelloWorldWaveFileUrlString);
    
    URL actualHelloWorldWaveFileUrl = new URL(actualHelloWorldWaveFileUrlString);
    
    File actualHelloWorldWaveFile = tempDirectory.newFile("actualHelloWorldWaveFile.wav");
    FileUtils.copyURLToFile(actualHelloWorldWaveFileUrl, actualHelloWorldWaveFile);
    
    FileAssert.assertBinaryEquals(expectedHelloWorldWaveFile, actualHelloWorldWaveFile);
}
 
开发者ID:Abdull,项目名称:sipgate-io-spring-boot,代码行数:27,代码来源:SipgateIoIntegrationTests.java


注:本文中的junitx.framework.FileAssert类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。