use of org.mortbay.jetty.EofException in project voldemort by voldemort.
the class HdfsFetcherAdvancedTest method testEofExceptionIntermittentDuringFetch.
/*
* Tests that HdfsFetcher can correctly fetch a file when there is an
* IOException, specifically an EofException during the fetch this test case
* is different from the earlier one since it simulates an excpetion midway
* a fetch
*/
@Test
public void testEofExceptionIntermittentDuringFetch() throws Exception {
setUp();
input = fs.open(source);
FileSystem spyfs = Mockito.spy(fs);
FSDataInputStream spyinput = Mockito.spy(input);
Mockito.doAnswer(Mockito.CALLS_REAL_METHODS).doThrow(new EofException()).when(spyinput).read();
Mockito.doReturn(spyinput).doReturn(input).when(spyfs).open(source);
byte[] actualCheckSum = null;
try {
actualCheckSum = copyFileWithCheckSumTest(fetcher, spyfs, source, copyLocation, stats, CheckSumType.MD5, buffer);
} catch (Exception ex) {
if (isCompressed) {
// This is expected
return;
} else {
Assert.fail("Unexpected exption thrown : " + ex.getMessage());
}
}
assertEquals(Arrays.equals(actualCheckSum, checksumCalculated), true);
}
Aggregations