本文整理汇总了Java中junitx.framework.FileAssert.assertBinaryEquals方法的典型用法代码示例。如果您正苦于以下问题:Java FileAssert.assertBinaryEquals方法的具体用法?Java FileAssert.assertBinaryEquals怎么用?Java FileAssert.assertBinaryEquals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类junitx.framework.FileAssert
的用法示例。
在下文中一共展示了FileAssert.assertBinaryEquals方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: 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);
}
示例3: 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);
}
示例4: 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);
}
示例5: 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);
}
示例6: 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);
}
示例7: 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);
}
示例8: 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);
}
示例9: 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);
}
示例10: testReadEqualsWrite
import junitx.framework.FileAssert; //导入方法依赖的package包/类
@Test
public void testReadEqualsWrite()
throws IOException {
manager.readFile(exampleConf, new ErrorContainer());
InputStream stream = new ByteArrayInputStream(manager.getRawString().getBytes(
HacklaceConfigManager.HACKLACE_CHARSET));
binExporter.write(stream, output);
if (output.length() < 256) {
// pad with zeros
long toWrite = 256 - output.length();
FileOutputStream fos = new FileOutputStream(output, true);
while (toWrite-- > 0) fos.write(0);
fos.close();
}
FileAssert.assertBinaryEquals(exampleFlash, output);
}
示例11: testMarkSupported
import junitx.framework.FileAssert; //导入方法依赖的package包/类
@Test
public void testMarkSupported() throws IOException {
File actualFile = File.createTempFile("FileHandlerWriteToFileTest-", ".txt");
BufferedInputStream inputStream = new BufferedInputStream(new FileInputStream(expectedFile));
sut.writeToFile(actualFile, inputStream);
FileAssert.assertBinaryEquals(expectedFile, actualFile);
}
示例12: testFix
import junitx.framework.FileAssert; //导入方法依赖的package包/类
@Test
public void testFix () throws Exception
{
File dstFile = testFolder.newFile ("output.bson");
runFixBson ("../tests/data/complex1.json", dstFile);
File actualFile = new File ("../tests/data/complex1.bson".replace ('/', File.separatorChar));
FileAssert.assertBinaryEquals (dstFile, actualFile);
}
示例13: testTypes
import junitx.framework.FileAssert; //导入方法依赖的package包/类
@Test
public void testTypes () throws IOException
{
File testFile = testFolder.newFile ();
BsonGenerator g = new BsonGenerator (new FileOutputStream (testFile));
g.setUseDouble (true);
g.writeStartArray ();
g.writeStartObject ();
g.write ("int", 1234);
g.write ("long", 12345678901234L);
g.write ("bigint", new BigInteger ("1234567890123412345678901234"));
g.write ("decimal", 12345.5);
g.write ("string", "asdf");
g.writeNull ("null");
g.write ("true", true);
g.write ("false", false);
g.writeEnd ();
g.write (true);
g.write (false);
g.writeNull ();
g.writeStartArray ();
g.write (1234);
g.write (12345678901234L);
g.write (new BigInteger ("1234567890123412345678901234"));
g.write (12345.5);
g.write ("asdf");
g.write (true);
g.write (false);
g.writeNull ();
g.writeStartObject ();
g.writeEnd ();
g.writeEnd ();
g.write (1);
g.writeEnd ();
g.close ();
BsonFixLength.fix (testFile);
FileAssert.assertBinaryEquals (new File ("../tests/data/types.bson".replace ('/', File.separatorChar)), testFile);
}
示例14: testTypes2
import junitx.framework.FileAssert; //导入方法依赖的package包/类
@Test
public void testTypes2 () throws IOException
{
File testFile = testFolder.newFile ();
BsonGenerator g = new BsonGenerator (new FileOutputStream (testFile));
g.setUseDouble (true);
g.writeStartArray ();
g.writeStartObject ();
g.write ("int", new CookJsonInt (1234));
g.write ("long", new CookJsonLong (12345678901234L));
g.write ("bigint", new CookJsonBigDecimal (new BigInteger ("1234567890123412345678901234")));
g.write ("decimal", new CookJsonDouble (12345.5));
g.write ("string", "asdf");
g.writeNull ("null");
g.write ("true", true);
g.write ("false", false);
g.writeEnd ();
g.write (true);
g.write (false);
g.writeNull ();
g.writeStartArray ();
g.write (1234);
g.write (12345678901234L);
g.write (new BigInteger ("1234567890123412345678901234"));
g.write (12345.5);
g.write ("asdf");
g.write (true);
g.write (false);
g.writeNull ();
g.writeStartObject ();
g.writeEnd ();
g.writeEnd ();
g.write (1);
g.writeEnd ();
g.close ();
BsonFixLength.fix (testFile);
FileAssert.assertBinaryEquals (new File ("../tests/data/types.bson".replace ('/', File.separatorChar)), testFile);
}
示例15: testPrettyJson
import junitx.framework.FileAssert; //导入方法依赖的package包/类
@Test
public void testPrettyJson () 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> ();
jsonConfig.put (JsonGenerator.PRETTY_PRINTING, Boolean.TRUE);
File jsonFile1 = testFolder.newFile ();
JsonParser p = provider.createParserFactory (bsonConfig).createParser (new FileInputStream (file1));
JsonGenerator g = provider.createGeneratorFactory (jsonConfig).createGenerator (new FileOutputStream (jsonFile1));
Utils.convert (p, g);
p.close ();
g.close ();
File jsonFile2 = testFolder.newFile ();
JsonParser p2 = provider.createParserFactory (jsonConfig).createParser (new FileInputStream (file2));
JsonGenerator g2 = provider.createGeneratorFactory (jsonConfig).createGenerator (new FileOutputStream (jsonFile2));
Utils.convert (p2, g2);
p2.close ();
g2.close ();
FileAssert.assertBinaryEquals (jsonFile2, jsonFile1);
}