use of org.apache.flink.connector.file.src.testutils.TestingFileSystem in project flink by apache.
the class AdapterTestBase method testClosesStreamIfReaderCreationFails.
// ------------------------------------------------------------------------
@Test
public void testClosesStreamIfReaderCreationFails() throws Exception {
// setup
final Path testPath = new Path("testFs:///testpath-1");
final CloseTestingInputStream in = new CloseTestingInputStream();
final TestingFileSystem testFs = TestingFileSystem.createForFileStatus("testFs", TestingFileSystem.TestFileStatus.forFileWithStream(testPath, 1024, in));
testFs.register();
// test
final BulkFormat<Integer, FileSourceSplit> adapter = wrapWithAdapter(createFormatFailingInInstantiation());
try {
adapter.createReader(new Configuration(), new FileSourceSplit("id", testPath, 0, 1024, 0, 1024));
} catch (IOException ignored) {
}
// assertions
assertTrue(in.closed);
// cleanup
testFs.unregister();
}
use of org.apache.flink.connector.file.src.testutils.TestingFileSystem in project flink by apache.
the class AdapterTestBase method testClosesStreamIfReaderRestoreFails.
@Test
public void testClosesStreamIfReaderRestoreFails() throws Exception {
// setup
final Path testPath = new Path("testFs:///testpath-1");
final CloseTestingInputStream in = new CloseTestingInputStream();
final TestingFileSystem testFs = TestingFileSystem.createForFileStatus("testFs", TestingFileSystem.TestFileStatus.forFileWithStream(testPath, 1024, in));
testFs.register();
// test
final BulkFormat<Integer, FileSourceSplit> adapter = wrapWithAdapter(createFormatFailingInInstantiation());
final FileSourceSplit split = new FileSourceSplit("id", testPath, 0, 1024, 0, 1024, new String[0], new CheckpointedPosition(0L, 5L));
try {
adapter.restoreReader(new Configuration(), split);
} catch (IOException ignored) {
}
// assertions
assertTrue(in.closed);
// cleanup
testFs.unregister();
}
Aggregations