public void testGetFileLength() throws IOException {
FileSystem fs = dfscluster.getFileSystem();
Map conf = new HashMap();
String validKey = "validkeyBasic";
String testString = "testingblob";
TestHdfsBlobStoreImpl hbs = new TestHdfsBlobStoreImpl(blobDir, conf, hadoopConf);
BlobStoreFile pfile = hbs.write(validKey, false);
SettableBlobMeta meta = new SettableBlobMeta();
meta.set_replication_factor(1);
pfile.setMetadata(meta);
OutputStream ios = pfile.getOutputStream();
ios.write(testString.getBytes(Charset.forName("UTF-8")));
ios.close();
assertEquals(testString.getBytes(Charset.forName("UTF-8")).length, pfile.getFileLength());
}
|