flink-instrumentation/workspace/flink-1.4.1-instrumented/flink-1.4.1/flink-runtime/src/test/java/org/apache/flink/runtime/checkpoint/savepoint/SavepointStoreTest.java
/**
	 * Tests that an exception during store cleans up the created savepoint file.
	 */
Tests that an exception during store cleans up the created savepoint file.
Tests that an exception during store cleans up the created savepoint file .
@Test
	public void testCleanupOnStoreFailure() throws Exception {
		Field field = SavepointSerializers.class.getDeclaredField("SERIALIZERS");
		field.setAccessible(true);
		Map<Integer, SavepointSerializer<?>> serializers = (Map<Integer, SavepointSerializer<?>>) field.get(null);
		String target = tmp.getRoot().getAbsolutePath();
		final int version = 123123;
		SavepointSerializer<TestSavepoint> serializer = mock(SavepointSerializer.class);
		doThrow(new RuntimeException("Test Exception")).when(serializer)
				.serialize(Matchers.any(TestSavepoint.class), any(DataOutputStream.class));
		serializers.put(version, serializer);
		Savepoint savepoint = new TestSavepoint(version, 12123123);
		assertEquals(0, tmp.getRoot().listFiles().length);
		try {
			SavepointStore.storeSavepoint(target, savepoint);
		} catch (Throwable ignored) {
		}
		assertEquals("Savepoint file not cleaned up on failure", 0, tmp.getRoot().listFiles().length);
	}
@ Test public void testCleanupOnStoreFailure ( ) throws Exception { Field field = SavepointSerializers . class . getDeclaredField ( "SERIALIZERS" ) ; field . setAccessible ( true ) ; Map < Integer , SavepointSerializer < ? > > serializers = ( Map < Integer , SavepointSerializer < ? > > ) field . get ( null ) ; String target = tmp . getRoot ( ) . getAbsolutePath ( ) ; final int version = 123123 ; SavepointSerializer < TestSavepoint > serializer = mock ( SavepointSerializer . class ) ; doThrow ( new RuntimeException ( "Test Exception" ) ) . when ( serializer ) . serialize ( Matchers . any ( TestSavepoint . class ) , any ( DataOutputStream . class ) ) ; serializers . put ( version , serializer ) ; Savepoint savepoint = new TestSavepoint ( version , 12123123 ) ; assertEquals ( 0 , tmp . getRoot ( ) . listFiles ( ) . length ) ; try { SavepointStore . storeSavepoint ( target , savepoint ) ; } catch ( Throwable ignored ) { } assertEquals ( "Savepoint file not cleaned up on failure" , 0 , tmp . getRoot ( ) . listFiles ( ) . length ) ; }
Tests that an exception during store cleans up the created savepoint file.
Tests that an exception during store cleans up the created savepoint file .