flink-instrumentation/workspace/flink-1.4.1-instrumented/flink-1.4.1/flink-runtime/src/test/java/org/apache/flink/runtime/state/filesystem/FsCheckpointStateOutputStreamTest.java
/**
	 * Tests that the underlying stream file is deleted upon calling close.
	 */
Tests that the underlying stream file is deleted upon calling close.
Tests that the underlying stream file is deleted upon calling close .
@Test
	public void testCleanupWhenClosingStream() throws IOException {
		final FileSystem fs = mock(FileSystem.class);
		final FSDataOutputStream outputStream = mock(FSDataOutputStream.class);
		final ArgumentCaptor<Path> pathCaptor = ArgumentCaptor.forClass(Path.class);
		when(fs.create(pathCaptor.capture(), any(FileSystem.WriteMode.class))).thenReturn(outputStream);
		CheckpointStreamFactory.CheckpointStateOutputStream stream = new FsCheckpointStreamFactory.FsCheckpointStateOutputStream(
			TEMP_DIR_PATH,
			fs,
			4,
			0);
		stream.write(new byte[]{1,2,3,4,5});
		verify(fs).create(any(Path.class), any(FileSystem.WriteMode.class));
		stream.close();
		verify(fs).delete(eq(pathCaptor.getValue()), anyBoolean());
	}
@ Test public void testCleanupWhenClosingStream ( ) throws IOException { final FileSystem fs = mock ( FileSystem . class ) ; final FSDataOutputStream outputStream = mock ( FSDataOutputStream . class ) ; final ArgumentCaptor < Path > pathCaptor = ArgumentCaptor . forClass ( Path . class ) ; when ( fs . create ( pathCaptor . capture ( ) , any ( FileSystem . WriteMode . class ) ) ) . thenReturn ( outputStream ) ; CheckpointStreamFactory . CheckpointStateOutputStream stream = new FsCheckpointStreamFactory . FsCheckpointStateOutputStream ( TEMP_DIR_PATH , fs , 4 , 0 ) ; stream . write ( new byte [ ] { 1 , 2 , 3 , 4 , 5 } ) ; verify ( fs ) . create ( any ( Path . class ) , any ( FileSystem . WriteMode . class ) ) ; stream . close ( ) ; verify ( fs ) . delete ( eq ( pathCaptor . getValue ( ) ) , anyBoolean ( ) ) ; }
Tests that the underlying stream file is deleted upon calling close.
Tests that the underlying stream file is deleted upon calling close .
// this should create the underlying file stream