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 loading with unexpected magic number.
	 */
Tests loading with unexpected magic number.
Tests loading with unexpected magic number .
@Test
	public void testUnexpectedSavepoint() throws Exception {
		Path filePath = new Path(tmp.getRoot().getPath(), UUID.randomUUID().toString());
		FSDataOutputStream fdos = FileSystem.get(filePath.toUri()).create(filePath, FileSystem.WriteMode.NO_OVERWRITE);
		DataOutputStream dos = new DataOutputStream(fdos);
		for (int i = 0; i < 10; i++) {
			dos.writeLong(ThreadLocalRandom.current().nextLong());
		}
		try {
			SavepointStore.loadSavepoint(filePath.toString(), Thread.currentThread().getContextClassLoader());
			fail("Did not throw expected Exception");
		} catch (RuntimeException e) {
			assertTrue(e.getMessage().contains("Flink 1.0") && e.getMessage().contains("Unexpected magic number"));
		}
	}
@ Test public void testUnexpectedSavepoint ( ) throws Exception { Path filePath = new Path ( tmp . getRoot ( ) . getPath ( ) , UUID . randomUUID ( ) . toString ( ) ) ; FSDataOutputStream fdos = FileSystem . get ( filePath . toUri ( ) ) . create ( filePath , FileSystem . WriteMode . NO_OVERWRITE ) ; DataOutputStream dos = new DataOutputStream ( fdos ) ; for ( int i = 0 ; i < 10 ; i ++ ) { dos . writeLong ( ThreadLocalRandom . current ( ) . nextLong ( ) ) ; } try { SavepointStore . loadSavepoint ( filePath . toString ( ) , Thread . currentThread ( ) . getContextClassLoader ( ) ) ; fail ( "Did not throw expected Exception" ) ; } catch ( RuntimeException e ) { assertTrue ( e . getMessage ( ) . contains ( "Flink 1.0" ) && e . getMessage ( ) . contains ( "Unexpected magic number" ) ) ; } }
Tests loading with unexpected magic number.
Tests loading with unexpected magic number .
// Random file