flink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ches...@apache.org
Subject [4/7] flink git commit: [FLINK-7311][tests] refrain from using fail(Exception#getMessage())
Date Wed, 02 Aug 2017 12:46:55 GMT
http://git-wip-us.apache.org/repos/asf/flink/blob/e83217bd/flink-core/src/test/java/org/apache/flink/core/memory/MemorySegmentUndersizedTest.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/core/memory/MemorySegmentUndersizedTest.java
b/flink-core/src/test/java/org/apache/flink/core/memory/MemorySegmentUndersizedTest.java
index 7b8d996..950da0e 100644
--- a/flink-core/src/test/java/org/apache/flink/core/memory/MemorySegmentUndersizedTest.java
+++ b/flink-core/src/test/java/org/apache/flink/core/memory/MemorySegmentUndersizedTest.java
@@ -35,80 +35,43 @@ public class MemorySegmentUndersizedTest {
 	
 	@Test
 	public void testZeroSizeHeapSegment() {
-		try {
-			MemorySegment segment = new HeapMemorySegment(new byte[0]);
+		MemorySegment segment = new HeapMemorySegment(new byte[0]);
 
-			testZeroSizeBuffer(segment);
-			testSegmentWithSizeLargerZero(segment);
-		}
-		catch (Exception e) {
-			e.printStackTrace();
-			fail(e.getMessage());
-		}
+		testZeroSizeBuffer(segment);
+		testSegmentWithSizeLargerZero(segment);
 	}
 
 	@Test
 	public void testZeroSizeHeapHybridSegment() {
-		try {
-			MemorySegment segment = new HybridMemorySegment(new byte[0]);
+		MemorySegment segment = new HybridMemorySegment(new byte[0]);
 
-			testZeroSizeBuffer(segment);
-			testSegmentWithSizeLargerZero(segment);
-		}
-		catch (Exception e) {
-			e.printStackTrace();
-			fail(e.getMessage());
-		}
+		testZeroSizeBuffer(segment);
+		testSegmentWithSizeLargerZero(segment);
 	}
 
 	@Test
 	public void testZeroSizeOffHeapHybridSegment() {
-		try {
-			MemorySegment segment = new HybridMemorySegment(ByteBuffer.allocateDirect(0));
+		MemorySegment segment = new HybridMemorySegment(ByteBuffer.allocateDirect(0));
 
-			testZeroSizeBuffer(segment);
-			testSegmentWithSizeLargerZero(segment);
-		}
-		catch (Exception e) {
-			e.printStackTrace();
-			fail(e.getMessage());
-		}
+		testZeroSizeBuffer(segment);
+		testSegmentWithSizeLargerZero(segment);
 	}
 
 	@Test
 	public void testSizeOneHeapSegment() {
-		try {
-			testSegmentWithSizeLargerZero(new HeapMemorySegment(new byte[1]));
-		}
-		catch (Exception e) {
-			e.printStackTrace();
-			fail(e.getMessage());
-		}
+		testSegmentWithSizeLargerZero(new HeapMemorySegment(new byte[1]));
 	}
 
 	@Test
 	public void testSizeOneHeapHybridSegment() {
-		try {
-			testSegmentWithSizeLargerZero(new HybridMemorySegment(new byte[1]));
-		}
-		catch (Exception e) {
-			e.printStackTrace();
-			fail(e.getMessage());
-		}
+		testSegmentWithSizeLargerZero(new HybridMemorySegment(new byte[1]));
 	}
 
 	@Test
 	public void testSizeOneOffHeapHybridSegment() {
-		try {
-			testSegmentWithSizeLargerZero(new HybridMemorySegment(ByteBuffer.allocateDirect(1)));
-		}
-		catch (Exception e) {
-			e.printStackTrace();
-			fail(e.getMessage());
-		}
+		testSegmentWithSizeLargerZero(new HybridMemorySegment(ByteBuffer.allocateDirect(1)));
 	}
 
-
 	private static void testZeroSizeBuffer(MemorySegment segment) {
 		// ------ bytes ------
 

http://git-wip-us.apache.org/repos/asf/flink/blob/e83217bd/flink-core/src/test/java/org/apache/flink/core/memory/OperationsOnFreedSegmentTest.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/core/memory/OperationsOnFreedSegmentTest.java
b/flink-core/src/test/java/org/apache/flink/core/memory/OperationsOnFreedSegmentTest.java
index ddbdf72..57f3db1 100644
--- a/flink-core/src/test/java/org/apache/flink/core/memory/OperationsOnFreedSegmentTest.java
+++ b/flink-core/src/test/java/org/apache/flink/core/memory/OperationsOnFreedSegmentTest.java
@@ -35,148 +35,124 @@ public class OperationsOnFreedSegmentTest {
 	private static final int PAGE_SIZE = (int) ((Math.random() * 10000) + 1000);
 	
 	@Test
-	public void testSingleSegmentOperationsHeapSegment() {
-		try {
-			testOpsOnFreedSegment(new HeapMemorySegment(new byte[PAGE_SIZE]));
-			testOpsOnFreedSegment(new HybridMemorySegment(new byte[PAGE_SIZE]));
-			testOpsOnFreedSegment(new HybridMemorySegment(ByteBuffer.allocateDirect(PAGE_SIZE)));
-		}
-		catch (Exception e) {
-			e.printStackTrace();
-			fail(e.getMessage());
-		}
+	public void testSingleSegmentOperationsHeapSegment() throws Exception {
+		testOpsOnFreedSegment(new HeapMemorySegment(new byte[PAGE_SIZE]));
+		testOpsOnFreedSegment(new HybridMemorySegment(new byte[PAGE_SIZE]));
+		testOpsOnFreedSegment(new HybridMemorySegment(ByteBuffer.allocateDirect(PAGE_SIZE)));
 	}
 
 	@Test
 	public void testCompare() {
-		try {
-			MemorySegment aliveHeap = new HeapMemorySegment(new byte[PAGE_SIZE]);
-			MemorySegment aliveHybridHeap = new HybridMemorySegment(new byte[PAGE_SIZE]);
-			MemorySegment aliveHybridOffHeap = new HybridMemorySegment(ByteBuffer.allocateDirect(PAGE_SIZE));
-
-			MemorySegment freedHeap = new HeapMemorySegment(new byte[PAGE_SIZE]);
-			MemorySegment freedHybridHeap = new HybridMemorySegment(new byte[PAGE_SIZE]);
-			MemorySegment freedHybridOffHeap = new HybridMemorySegment(ByteBuffer.allocateDirect(PAGE_SIZE));
-			freedHeap.free();
-			freedHybridHeap.free();
-			freedHybridOffHeap.free();
-			
-			MemorySegment[] alive = { aliveHeap, aliveHybridHeap, aliveHybridOffHeap };
-			MemorySegment[] free = { freedHeap, freedHybridHeap, freedHybridOffHeap };
-			
-			// alive with free
-			for (MemorySegment seg1 : alive) {
-				for (MemorySegment seg2 : free) {
-					testCompare(seg1, seg2);
-				}
+		MemorySegment aliveHeap = new HeapMemorySegment(new byte[PAGE_SIZE]);
+		MemorySegment aliveHybridHeap = new HybridMemorySegment(new byte[PAGE_SIZE]);
+		MemorySegment aliveHybridOffHeap = new HybridMemorySegment(ByteBuffer.allocateDirect(PAGE_SIZE));
+
+		MemorySegment freedHeap = new HeapMemorySegment(new byte[PAGE_SIZE]);
+		MemorySegment freedHybridHeap = new HybridMemorySegment(new byte[PAGE_SIZE]);
+		MemorySegment freedHybridOffHeap = new HybridMemorySegment(ByteBuffer.allocateDirect(PAGE_SIZE));
+		freedHeap.free();
+		freedHybridHeap.free();
+		freedHybridOffHeap.free();
+
+		MemorySegment[] alive = { aliveHeap, aliveHybridHeap, aliveHybridOffHeap };
+		MemorySegment[] free = { freedHeap, freedHybridHeap, freedHybridOffHeap };
+
+		// alive with free
+		for (MemorySegment seg1 : alive) {
+			for (MemorySegment seg2 : free) {
+				testCompare(seg1, seg2);
 			}
+		}
 
-			// free with alive
-			for (MemorySegment seg1 : free) {
-				for (MemorySegment seg2 : alive) {
-					testCompare(seg1, seg2);
-				}
+		// free with alive
+		for (MemorySegment seg1 : free) {
+			for (MemorySegment seg2 : alive) {
+				testCompare(seg1, seg2);
 			}
+		}
 
-			// free with free
-			for (MemorySegment seg1 : free) {
-				for (MemorySegment seg2 : free) {
-					testCompare(seg1, seg2);
-				}
+		// free with free
+		for (MemorySegment seg1 : free) {
+			for (MemorySegment seg2 : free) {
+				testCompare(seg1, seg2);
 			}
 		}
-		catch (Exception e) {
-			e.printStackTrace();
-			fail(e.getMessage());
-		}
 	}
 	
 	@Test
 	public void testCopyTo() {
-		try {
-			MemorySegment aliveHeap = new HeapMemorySegment(new byte[PAGE_SIZE]);
-			MemorySegment aliveHybridHeap = new HybridMemorySegment(new byte[PAGE_SIZE]);
-			MemorySegment aliveHybridOffHeap = new HybridMemorySegment(ByteBuffer.allocateDirect(PAGE_SIZE));
-
-			MemorySegment freedHeap = new HeapMemorySegment(new byte[PAGE_SIZE]);
-			MemorySegment freedHybridHeap = new HybridMemorySegment(new byte[PAGE_SIZE]);
-			MemorySegment freedHybridOffHeap = new HybridMemorySegment(ByteBuffer.allocateDirect(PAGE_SIZE));
-			freedHeap.free();
-			freedHybridHeap.free();
-			freedHybridOffHeap.free();
-
-			MemorySegment[] alive = { aliveHeap, aliveHybridHeap, aliveHybridOffHeap };
-			MemorySegment[] free = { freedHeap, freedHybridHeap, freedHybridOffHeap };
-
-			// alive with free
-			for (MemorySegment seg1 : alive) {
-				for (MemorySegment seg2 : free) {
-					testCopy(seg1, seg2);
-				}
+		MemorySegment aliveHeap = new HeapMemorySegment(new byte[PAGE_SIZE]);
+		MemorySegment aliveHybridHeap = new HybridMemorySegment(new byte[PAGE_SIZE]);
+		MemorySegment aliveHybridOffHeap = new HybridMemorySegment(ByteBuffer.allocateDirect(PAGE_SIZE));
+
+		MemorySegment freedHeap = new HeapMemorySegment(new byte[PAGE_SIZE]);
+		MemorySegment freedHybridHeap = new HybridMemorySegment(new byte[PAGE_SIZE]);
+		MemorySegment freedHybridOffHeap = new HybridMemorySegment(ByteBuffer.allocateDirect(PAGE_SIZE));
+		freedHeap.free();
+		freedHybridHeap.free();
+		freedHybridOffHeap.free();
+
+		MemorySegment[] alive = { aliveHeap, aliveHybridHeap, aliveHybridOffHeap };
+		MemorySegment[] free = { freedHeap, freedHybridHeap, freedHybridOffHeap };
+
+		// alive with free
+		for (MemorySegment seg1 : alive) {
+			for (MemorySegment seg2 : free) {
+				testCopy(seg1, seg2);
 			}
+		}
 
-			// free with alive
-			for (MemorySegment seg1 : free) {
-				for (MemorySegment seg2 : alive) {
-					testCopy(seg1, seg2);
-				}
+		// free with alive
+		for (MemorySegment seg1 : free) {
+			for (MemorySegment seg2 : alive) {
+				testCopy(seg1, seg2);
 			}
+		}
 
-			// free with free
-			for (MemorySegment seg1 : free) {
-				for (MemorySegment seg2 : free) {
-					testCopy(seg1, seg2);
-				}
+		// free with free
+		for (MemorySegment seg1 : free) {
+			for (MemorySegment seg2 : free) {
+				testCopy(seg1, seg2);
 			}
 		}
-		catch (Exception e) {
-			e.printStackTrace();
-			fail(e.getMessage());
-		}
 	}
 
 	@Test
 	public void testSwap() {
-		try {
-			MemorySegment aliveHeap = new HeapMemorySegment(new byte[PAGE_SIZE]);
-			MemorySegment aliveHybridHeap = new HybridMemorySegment(new byte[PAGE_SIZE]);
-			MemorySegment aliveHybridOffHeap = new HybridMemorySegment(ByteBuffer.allocateDirect(PAGE_SIZE));
-
-			MemorySegment freedHeap = new HeapMemorySegment(new byte[PAGE_SIZE]);
-			MemorySegment freedHybridHeap = new HybridMemorySegment(new byte[PAGE_SIZE]);
-			MemorySegment freedHybridOffHeap = new HybridMemorySegment(ByteBuffer.allocateDirect(PAGE_SIZE));
-			freedHeap.free();
-			freedHybridHeap.free();
-			freedHybridOffHeap.free();
-
-			MemorySegment[] alive = { aliveHeap, aliveHybridHeap, aliveHybridOffHeap };
-			MemorySegment[] free = { freedHeap, freedHybridHeap, freedHybridOffHeap };
-
-			// alive with free
-			for (MemorySegment seg1 : alive) {
-				for (MemorySegment seg2 : free) {
-					testSwap(seg1, seg2);
-				}
+		MemorySegment aliveHeap = new HeapMemorySegment(new byte[PAGE_SIZE]);
+		MemorySegment aliveHybridHeap = new HybridMemorySegment(new byte[PAGE_SIZE]);
+		MemorySegment aliveHybridOffHeap = new HybridMemorySegment(ByteBuffer.allocateDirect(PAGE_SIZE));
+
+		MemorySegment freedHeap = new HeapMemorySegment(new byte[PAGE_SIZE]);
+		MemorySegment freedHybridHeap = new HybridMemorySegment(new byte[PAGE_SIZE]);
+		MemorySegment freedHybridOffHeap = new HybridMemorySegment(ByteBuffer.allocateDirect(PAGE_SIZE));
+		freedHeap.free();
+		freedHybridHeap.free();
+		freedHybridOffHeap.free();
+
+		MemorySegment[] alive = { aliveHeap, aliveHybridHeap, aliveHybridOffHeap };
+		MemorySegment[] free = { freedHeap, freedHybridHeap, freedHybridOffHeap };
+
+		// alive with free
+		for (MemorySegment seg1 : alive) {
+			for (MemorySegment seg2 : free) {
+				testSwap(seg1, seg2);
 			}
+		}
 
-			// free with alive
-			for (MemorySegment seg1 : free) {
-				for (MemorySegment seg2 : alive) {
-					testSwap(seg1, seg2);
-				}
+		// free with alive
+		for (MemorySegment seg1 : free) {
+			for (MemorySegment seg2 : alive) {
+				testSwap(seg1, seg2);
 			}
+		}
 
-			// free with free
-			for (MemorySegment seg1 : free) {
-				for (MemorySegment seg2 : free) {
-					testSwap(seg1, seg2);
-				}
+		// free with free
+		for (MemorySegment seg1 : free) {
+			for (MemorySegment seg2 : free) {
+				testSwap(seg1, seg2);
 			}
 		}
-		catch (Exception e) {
-			e.printStackTrace();
-			fail(e.getMessage());
-		}
 	}
 	
 	private void testOpsOnFreedSegment(MemorySegment segment) throws Exception {


Mime
View raw message