use of java.io.FileInputStream in project hadoop by apache.
the class TestShortCircuitShm method testStartupShutdown.
@Test(timeout = 60000)
public void testStartupShutdown() throws Exception {
File path = new File(TEST_BASE, "testStartupShutdown");
path.mkdirs();
SharedFileDescriptorFactory factory = SharedFileDescriptorFactory.create("shm_", new String[] { path.getAbsolutePath() });
FileInputStream stream = factory.createDescriptor("testStartupShutdown", 4096);
ShortCircuitShm shm = new ShortCircuitShm(ShmId.createRandom(), stream);
shm.free();
stream.close();
FileUtil.fullyDelete(path);
}
use of java.io.FileInputStream in project hadoop by apache.
the class TestEnhancedByteBufferAccess method testIndirectFallbackReads.
/**
* Test fallback reads on a stream which does not support the
* ByteBufferReadable * interface.
*/
@Test
public void testIndirectFallbackReads() throws Exception {
final String testPath = GenericTestUtils.getTestDir("indirectFallbackTestFile").getAbsolutePath();
final int TEST_FILE_LENGTH = 16385;
final int RANDOM_SEED = 23453;
FileOutputStream fos = null;
FileInputStream fis = null;
try {
fos = new FileOutputStream(testPath);
Random random = new Random(RANDOM_SEED);
byte[] original = new byte[TEST_FILE_LENGTH];
random.nextBytes(original);
fos.write(original);
fos.close();
fos = null;
fis = new FileInputStream(testPath);
testFallbackImpl(fis, original);
} finally {
IOUtils.cleanup(LOG, fos, fis);
new File(testPath).delete();
}
}
use of java.io.FileInputStream in project hadoop by apache.
the class TestCodec method verifyGzipFile.
private void verifyGzipFile(String filename, String msg) throws IOException {
BufferedReader r = new BufferedReader(new InputStreamReader(new GZIPInputStream(new FileInputStream(filename))));
try {
String line = r.readLine();
assertEquals("Got invalid line back from " + filename, msg, line);
} finally {
r.close();
new File(filename).delete();
}
}
use of java.io.FileInputStream in project hadoop by apache.
the class TestDtUtilShell method testFormatProtoFlag.
@Test
public void testFormatProtoFlag() throws Exception {
args = new String[] { "get", getUrl, "-format", "protobuf", tokenFilenameGet };
rc = dt.run(args);
assertEquals("test mocked get with protobuf format flag exit code", 0, rc);
Credentials creds = new Credentials();
Credentials spyCreds = Mockito.spy(creds);
DataInputStream in = new DataInputStream(new FileInputStream(tokenFilenameGet));
spyCreds.readTokenStorageStream(in);
Mockito.verify(spyCreds).readProto(in);
}
use of java.io.FileInputStream in project hadoop by apache.
the class TestDtUtilShell method testFormatJavaFlag.
@Test
public void testFormatJavaFlag() throws Exception {
args = new String[] { "get", getUrl, "-format", "java", tokenFilenameGet };
rc = dt.run(args);
assertEquals("test mocked get with java format flag exit code", 0, rc);
Credentials creds = new Credentials();
Credentials spyCreds = Mockito.spy(creds);
DataInputStream in = new DataInputStream(new FileInputStream(tokenFilenameGet));
spyCreds.readTokenStorageStream(in);
Mockito.verify(spyCreds).readFields(in);
}
Aggregations