You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by ch...@apache.org on 2017/08/02 12:46:52 UTC

[1/7] flink git commit: [FLINK-7305] [checkstyle] Allow imports from org.apache.flink.shaded + add new import block

Repository: flink
Updated Branches:
  refs/heads/master 32bc67e6c -> c376bf136


[FLINK-7305] [checkstyle] Allow imports from org.apache.flink.shaded + add new import block

This closes #4425.


Project: http://git-wip-us.apache.org/repos/asf/flink/repo
Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/c376bf13
Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/c376bf13
Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/c376bf13

Branch: refs/heads/master
Commit: c376bf136d4868c1ba156aa77c9fdf9ee17f2af2
Parents: e83217b
Author: zentol <ch...@apache.org>
Authored: Tue Jun 13 17:02:03 2017 +0200
Committer: zentol <ch...@apache.org>
Committed: Wed Aug 2 14:46:15 2017 +0200

----------------------------------------------------------------------
 tools/maven/checkstyle.xml | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flink/blob/c376bf13/tools/maven/checkstyle.xml
----------------------------------------------------------------------
diff --git a/tools/maven/checkstyle.xml b/tools/maven/checkstyle.xml
index 0c7a24d..897802b 100644
--- a/tools/maven/checkstyle.xml
+++ b/tools/maven/checkstyle.xml
@@ -197,8 +197,7 @@ This file is based on the checkstyle file of Apache Beam.
     <module name="ImportOrder">
       <!-- Checks for out of order import statements. -->
       <property name="severity" value="error"/>
-      <!-- Flink imports first, then other imports, then javax, java and scala imports, then static imports. -->
-      <property name="groups" value="org.apache.flink,*,javax,java,scala"/>
+      <property name="groups" value="org.apache.flink,org.apache.flink.shaded,*,javax,java,scala"/>
       <property name="separated" value="true"/>
       <property name="sortStaticImportsAlphabetically" value="true"/>
       <property name="option" value="bottom"/>
@@ -212,7 +211,7 @@ This file is based on the checkstyle file of Apache Beam.
     </module>
 
     <module name="IllegalImport">
-      <property name="illegalPkgs" value="org.apache.flink.shaded, autovalue.shaded, avro.shaded, com.google.api.client.repackaged, com.google.appengine.repackaged, io.netty.util.internal"/>
+      <property name="illegalPkgs" value="autovalue.shaded, avro.shaded, com.google.api.client.repackaged, com.google.appengine.repackaged, io.netty.util.internal"/>
     </module>
 
     <module name="RedundantModifier">


[3/7] flink git commit: [FLINK-7303] [build] Build elasticsearch5 by default

Posted by ch...@apache.org.
[FLINK-7303] [build] Build elasticsearch5 by default

This closes #4426.


Project: http://git-wip-us.apache.org/repos/asf/flink/repo
Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/3ed18ed1
Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/3ed18ed1
Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/3ed18ed1

Branch: refs/heads/master
Commit: 3ed18ed11b331193d350000580c9f7aa2b588073
Parents: 32bc67e
Author: zentol <ch...@apache.org>
Authored: Mon Jul 31 12:16:05 2017 +0200
Committer: zentol <ch...@apache.org>
Committed: Wed Aug 2 14:46:15 2017 +0200

----------------------------------------------------------------------
 flink-connectors/pom.xml     | 15 +--------------
 tools/travis_mvn_watchdog.sh |  9 +--------
 2 files changed, 2 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flink/blob/3ed18ed1/flink-connectors/pom.xml
----------------------------------------------------------------------
diff --git a/flink-connectors/pom.xml b/flink-connectors/pom.xml
index 5af85b8..bc3f82f 100644
--- a/flink-connectors/pom.xml
+++ b/flink-connectors/pom.xml
@@ -48,6 +48,7 @@ under the License.
 		<module>flink-connector-elasticsearch-base</module>
 		<module>flink-connector-elasticsearch</module>
 		<module>flink-connector-elasticsearch2</module>
+		<module>flink-connector-elasticsearch5</module>
 		<module>flink-connector-rabbitmq</module>
 		<module>flink-connector-twitter</module>
 		<module>flink-connector-nifi</module>
@@ -86,20 +87,6 @@ under the License.
 				<module>flink-connector-kinesis</module>
 			</modules>
 		</profile>
-
-		<!--
-			Since Elasticsearch 5.x requires Java 8 at a minimum, we use this profile
-			to include it as part of Java 8 builds only.
-		-->
-		<profile>
-			<id>include-elasticsearch5</id>
-			<activation>
-				<jdk>1.8</jdk>
-			</activation>
-			<modules>
-				<module>flink-connector-elasticsearch5</module>
-			</modules>
-		</profile>
 	</profiles>
 
 </project>

http://git-wip-us.apache.org/repos/asf/flink/blob/3ed18ed1/tools/travis_mvn_watchdog.sh
----------------------------------------------------------------------
diff --git a/tools/travis_mvn_watchdog.sh b/tools/travis_mvn_watchdog.sh
index c36cecf..a623798 100755
--- a/tools/travis_mvn_watchdog.sh
+++ b/tools/travis_mvn_watchdog.sh
@@ -79,6 +79,7 @@ flink-connectors/flink-jdbc,\
 flink-connectors/flink-connector-cassandra,\
 flink-connectors/flink-connector-elasticsearch,\
 flink-connectors/flink-connector-elasticsearch2,\
+flink-connectors/flink-connector-elasticsearch5,\
 flink-connectors/flink-connector-elasticsearch-base,\
 flink-connectors/flink-connector-filesystem,\
 flink-connectors/flink-connector-kafka-0.8,\
@@ -92,14 +93,6 @@ flink-connectors/flink-connector-twitter"
 MODULES_TESTS="\
 flink-tests"
 
-if [[ $PROFILE == *"jdk8"* ]]; then
-	case $TEST in
-		(connectors)
-			MODULES_CONNECTORS="$MODULES_CONNECTORS,flink-connectors/flink-connector-elasticsearch5"
-		;;
-	esac
-fi
-
 if [[ $PROFILE == *"include-kinesis"* ]]; then
 	case $TEST in
 		(connectors)


[7/7] flink git commit: [FLINK-7304] [scripts] Simplify taskmanager GC configuration

Posted by ch...@apache.org.
[FLINK-7304] [scripts] Simplify taskmanager GC configuration

This closes #4427.


Project: http://git-wip-us.apache.org/repos/asf/flink/repo
Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/6ade949a
Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/6ade949a
Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/6ade949a

Branch: refs/heads/master
Commit: 6ade949a085721d46ba50ec81dfba033c475917c
Parents: 3ed18ed
Author: zentol <ch...@apache.org>
Authored: Mon Jul 31 12:18:07 2017 +0200
Committer: zentol <ch...@apache.org>
Committed: Wed Aug 2 14:46:15 2017 +0200

----------------------------------------------------------------------
 flink-dist/src/main/flink-bin/bin/taskmanager.sh | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flink/blob/6ade949a/flink-dist/src/main/flink-bin/bin/taskmanager.sh
----------------------------------------------------------------------
diff --git a/flink-dist/src/main/flink-bin/bin/taskmanager.sh b/flink-dist/src/main/flink-bin/bin/taskmanager.sh
index 3cf74ca..86ad844 100755
--- a/flink-dist/src/main/flink-bin/bin/taskmanager.sh
+++ b/flink-dist/src/main/flink-bin/bin/taskmanager.sh
@@ -42,17 +42,7 @@ if [[ $STARTSTOP == "start" ]] || [[ $STARTSTOP == "start-foreground" ]]; then
     # if memory allocation mode is lazy and no other JVM options are set,
     # set the 'Concurrent Mark Sweep GC'
     if [[ $FLINK_TM_MEM_PRE_ALLOCATE == "false" ]] && [ -z "${FLINK_ENV_JAVA_OPTS}" ] && [ -z "${FLINK_ENV_JAVA_OPTS_TM}" ]; then
-
-        JAVA_VERSION=$($JAVA_RUN -version 2>&1 | sed 's/.*version "\(.*\)\.\(.*\)\..*"/\1\2/; 1q')
-
-        # set the GC to G1 in Java 8 and to CMS in Java 7
-        if [[ ${JAVA_VERSION} =~ ${IS_NUMBER} ]]; then
-            if [ "$JAVA_VERSION" -lt 18 ]; then
-                export JVM_ARGS="$JVM_ARGS -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled"
-            else
-                export JVM_ARGS="$JVM_ARGS -XX:+UseG1GC"
-            fi
-        fi
+        export JVM_ARGS="$JVM_ARGS -XX:+UseG1GC"
     fi
 
     if [[ ! ${FLINK_TM_HEAP} =~ ${IS_NUMBER} ]] || [[ "${FLINK_TM_HEAP}" -lt "0" ]]; then


[2/7] flink git commit: [FLINK-7346] [tests] EventTimeWindowCheckpointingITCases print progress before each test

Posted by ch...@apache.org.
[FLINK-7346] [tests] EventTimeWindowCheckpointingITCases print progress before each test

Travis checks how long maven did not produce an output and we assume that a
test hangs if no output is produces within 300s.
IncrementalRocksDbBackendEventTimeWindowCheckpointingITCase executes several
tests but output is only generated at the end of the whole suite which may,
under certain circumstances, already take longer than 300s. Therefore, simply
provide some output in the form of progress messages regarding the execution
of test cases.

This closes #4419.


Project: http://git-wip-us.apache.org/repos/asf/flink/repo
Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/223b7b7f
Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/223b7b7f
Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/223b7b7f

Branch: refs/heads/master
Commit: 223b7b7f0504871c2fe9b3c23de8db9f9ad7ba5f
Parents: 6ade949
Author: Nico Kruber <ni...@data-artisans.com>
Authored: Fri Jul 28 15:00:15 2017 +0200
Committer: zentol <ch...@apache.org>
Committed: Wed Aug 2 14:46:15 2017 +0200

----------------------------------------------------------------------
 ...tractEventTimeWindowCheckpointingITCase.java | 23 +++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flink/blob/223b7b7f/flink-tests/src/test/java/org/apache/flink/test/checkpointing/AbstractEventTimeWindowCheckpointingITCase.java
----------------------------------------------------------------------
diff --git a/flink-tests/src/test/java/org/apache/flink/test/checkpointing/AbstractEventTimeWindowCheckpointingITCase.java b/flink-tests/src/test/java/org/apache/flink/test/checkpointing/AbstractEventTimeWindowCheckpointingITCase.java
index 269b126..22ed847 100644
--- a/flink-tests/src/test/java/org/apache/flink/test/checkpointing/AbstractEventTimeWindowCheckpointingITCase.java
+++ b/flink-tests/src/test/java/org/apache/flink/test/checkpointing/AbstractEventTimeWindowCheckpointingITCase.java
@@ -48,12 +48,14 @@ import org.apache.flink.test.util.SuccessException;
 import org.apache.flink.util.Collector;
 import org.apache.flink.util.TestLogger;
 
+import org.junit.After;
 import org.junit.AfterClass;
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.TemporaryFolder;
+import org.junit.rules.TestName;
 
 import java.io.IOException;
 import java.util.Collections;
@@ -88,6 +90,9 @@ public abstract class AbstractEventTimeWindowCheckpointingITCase extends TestLog
 	@Rule
 	public TemporaryFolder tempFolder = new TemporaryFolder();
 
+	@Rule
+	public TestName name = new TestName();
+
 	private StateBackendEnum stateBackendEnum;
 	private AbstractStateBackend stateBackend;
 
@@ -123,7 +128,13 @@ public abstract class AbstractEventTimeWindowCheckpointingITCase extends TestLog
 	}
 
 	@Before
-	public void initStateBackend() throws IOException {
+	public void beforeTest() throws IOException {
+		// print a message when starting a test method to avoid Travis' <tt>"Maven produced no
+		// output for xxx seconds."</tt> messages
+		System.out.println(
+			"Starting " + getClass().getCanonicalName() + "#" + name.getMethodName() + ".");
+
+		// init state back-end
 		switch (stateBackendEnum) {
 			case MEM:
 				this.stateBackend = new MemoryStateBackend(MAX_MEM_STATE_SIZE, false);
@@ -166,6 +177,16 @@ public abstract class AbstractEventTimeWindowCheckpointingITCase extends TestLog
 		}
 	}
 
+	/**
+	 * Prints a message when finishing a test method to avoid Travis' <tt>"Maven produced no output
+	 * for xxx seconds."</tt> messages.
+	 */
+	@After
+	public void afterTest() {
+		System.out.println(
+			"Finished " + getClass().getCanonicalName() + "#" + name.getMethodName() + ".");
+	}
+
 	// ------------------------------------------------------------------------
 
 	@Test


[5/7] flink git commit: [FLINK-7311][tests] refrain from using fail(Exception#getMessage())

Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/flink/blob/e83217bd/flink-core/src/test/java/org/apache/flink/core/memory/MemorySegmentTestBase.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/core/memory/MemorySegmentTestBase.java b/flink-core/src/test/java/org/apache/flink/core/memory/MemorySegmentTestBase.java
index 10c3622..8c10902 100644
--- a/flink-core/src/test/java/org/apache/flink/core/memory/MemorySegmentTestBase.java
+++ b/flink-core/src/test/java/org/apache/flink/core/memory/MemorySegmentTestBase.java
@@ -18,7 +18,6 @@
 
 package org.apache.flink.core.memory;
 
-import org.junit.Assert;
 import org.junit.Test;
 import org.junit.runners.Parameterized;
 
@@ -67,1508 +66,1675 @@ public abstract class MemorySegmentTestBase {
 
 	@Test
 	public void testByteAccess() {
-		try {
-			final MemorySegment segment = createSegment(pageSize);
-
-			// test exceptions
-			try {
-				segment.put(-1, (byte) 0);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		final MemorySegment segment = createSegment(pageSize);
 
-			try {
-				segment.put(pageSize, (byte) 0);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		// test exceptions
+		try {
+			segment.put(-1, (byte) 0);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			try {
-				segment.put(Integer.MAX_VALUE, (byte) 0);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		try {
+			segment.put(pageSize, (byte) 0);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			try {
-				segment.put(Integer.MIN_VALUE, (byte) 0);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		try {
+			segment.put(Integer.MAX_VALUE, (byte) 0);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			try {
-				segment.get(-1);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		try {
+			segment.put(Integer.MIN_VALUE, (byte) 0);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			try {
-				segment.get(pageSize);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		try {
+			segment.get(-1);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			try {
-				segment.get(Integer.MAX_VALUE);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		try {
+			segment.get(pageSize);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			try {
-				segment.get(Integer.MIN_VALUE);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		try {
+			segment.get(Integer.MAX_VALUE);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			// test expected correct behavior, sequential access
+		try {
+			segment.get(Integer.MIN_VALUE);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			long seed = random.nextLong();
+		// test expected correct behavior, sequential access
 
-			random.setSeed(seed);
-			for (int i = 0; i < pageSize; i++) {
-				segment.put(i, (byte) random.nextInt());
-			}
+		long seed = random.nextLong();
 
-			random.setSeed(seed);
-			for (int i = 0; i < pageSize; i++) {
-				assertEquals((byte) random.nextInt(), segment.get(i));
-			}
+		random.setSeed(seed);
+		for (int i = 0; i < pageSize; i++) {
+			segment.put(i, (byte) random.nextInt());
+		}
 
-			// test expected correct behavior, random access
+		random.setSeed(seed);
+		for (int i = 0; i < pageSize; i++) {
+			assertEquals((byte) random.nextInt(), segment.get(i));
+		}
 
-			random.setSeed(seed);
-			boolean[] occupied = new boolean[pageSize];
+		// test expected correct behavior, random access
 
-			for (int i = 0; i < 1000; i++) {
-				int pos = random.nextInt(pageSize);
+		random.setSeed(seed);
+		boolean[] occupied = new boolean[pageSize];
 
-				if (occupied[pos]) {
-					continue;
-				} else {
-					occupied[pos] = true;
-				}
+		for (int i = 0; i < 1000; i++) {
+			int pos = random.nextInt(pageSize);
 
-				segment.put(pos, (byte) random.nextInt());
+			if (occupied[pos]) {
+				continue;
+			} else {
+				occupied[pos] = true;
 			}
 
-			random.setSeed(seed);
-			occupied = new boolean[pageSize];
+			segment.put(pos, (byte) random.nextInt());
+		}
 
-			for (int i = 0; i < 1000; i++) {
-				int pos = random.nextInt(pageSize);
+		random.setSeed(seed);
+		occupied = new boolean[pageSize];
 
-				if (occupied[pos]) {
-					continue;
-				} else {
-					occupied[pos] = true;
-				}
+		for (int i = 0; i < 1000; i++) {
+			int pos = random.nextInt(pageSize);
 
-				assertEquals((byte) random.nextInt(), segment.get(pos));
+			if (occupied[pos]) {
+				continue;
+			} else {
+				occupied[pos] = true;
 			}
-		}
-		catch (Exception e) {
-			e.printStackTrace();
-			fail(e.getMessage());
+
+			assertEquals((byte) random.nextInt(), segment.get(pos));
 		}
 
 	}
 
 	@Test
 	public void testBooleanAccess() {
-		try {
-			final MemorySegment segment = createSegment(pageSize);
-
-			// test exceptions
-			try {
-				segment.putBoolean(-1, false);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		final MemorySegment segment = createSegment(pageSize);
 
-			try {
-				segment.putBoolean(pageSize, false);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		// test exceptions
+		try {
+			segment.putBoolean(-1, false);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			try {
-				segment.putBoolean(Integer.MAX_VALUE, false);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		try {
+			segment.putBoolean(pageSize, false);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			try {
-				segment.putBoolean(Integer.MIN_VALUE, false);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		try {
+			segment.putBoolean(Integer.MAX_VALUE, false);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			try {
-				segment.getBoolean(-1);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		try {
+			segment.putBoolean(Integer.MIN_VALUE, false);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			try {
-				segment.getBoolean(pageSize);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		try {
+			segment.getBoolean(-1);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			try {
-				segment.getBoolean(Integer.MAX_VALUE);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		try {
+			segment.getBoolean(pageSize);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			try {
-				segment.getBoolean(Integer.MIN_VALUE);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		try {
+			segment.getBoolean(Integer.MAX_VALUE);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			// test expected correct behavior, sequential access
+		try {
+			segment.getBoolean(Integer.MIN_VALUE);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			long seed = random.nextLong();
+		// test expected correct behavior, sequential access
 
-			random.setSeed(seed);
-			for (int i = 0; i < pageSize; i++) {
-				segment.putBoolean(i, random.nextBoolean());
-			}
+		long seed = random.nextLong();
 
-			random.setSeed(seed);
-			for (int i = 0; i < pageSize; i++) {
-				assertEquals(random.nextBoolean(), segment.getBoolean(i));
-			}
+		random.setSeed(seed);
+		for (int i = 0; i < pageSize; i++) {
+			segment.putBoolean(i, random.nextBoolean());
+		}
 
-			// test expected correct behavior, random access
+		random.setSeed(seed);
+		for (int i = 0; i < pageSize; i++) {
+			assertEquals(random.nextBoolean(), segment.getBoolean(i));
+		}
 
-			random.setSeed(seed);
-			boolean[] occupied = new boolean[pageSize];
+		// test expected correct behavior, random access
 
-			for (int i = 0; i < 1000; i++) {
-				int pos = random.nextInt(pageSize);
+		random.setSeed(seed);
+		boolean[] occupied = new boolean[pageSize];
 
-				if (occupied[pos]) {
-					continue;
-				} else {
-					occupied[pos] = true;
-				}
+		for (int i = 0; i < 1000; i++) {
+			int pos = random.nextInt(pageSize);
 
-				segment.putBoolean(pos, random.nextBoolean());
+			if (occupied[pos]) {
+				continue;
+			} else {
+				occupied[pos] = true;
 			}
 
-			random.setSeed(seed);
-			occupied = new boolean[pageSize];
+			segment.putBoolean(pos, random.nextBoolean());
+		}
 
-			for (int i = 0; i < 1000; i++) {
-				int pos = random.nextInt(pageSize);
+		random.setSeed(seed);
+		occupied = new boolean[pageSize];
 
-				if (occupied[pos]) {
-					continue;
-				} else {
-					occupied[pos] = true;
-				}
+		for (int i = 0; i < 1000; i++) {
+			int pos = random.nextInt(pageSize);
 
-				assertEquals(random.nextBoolean(), segment.getBoolean(pos));
+			if (occupied[pos]) {
+				continue;
+			} else {
+				occupied[pos] = true;
 			}
-		}
-		catch (Exception e) {
-			e.printStackTrace();
-			fail(e.getMessage());
+
+			assertEquals(random.nextBoolean(), segment.getBoolean(pos));
 		}
 	}
 
 	@Test
 	public void testCharAccess() {
+		final MemorySegment segment = createSegment(pageSize);
+
+		// test exceptions
+
 		try {
-			final MemorySegment segment = createSegment(pageSize);
+			segment.putChar(-1, 'a');
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			// test exceptions
+		try {
+			segment.putChar(pageSize, 'a');
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			try {
-				segment.putChar(-1, 'a');
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		try {
+			segment.putChar(Integer.MIN_VALUE, 'a');
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			try {
-				segment.putChar(pageSize, 'a');
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		try {
+			segment.putChar(Integer.MAX_VALUE, 'a');
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			try {
-				segment.putChar(Integer.MIN_VALUE, 'a');
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		try {
+			segment.putChar(Integer.MAX_VALUE - 1, 'a');
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			try {
-				segment.putChar(Integer.MAX_VALUE, 'a');
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		try {
+			segment.getChar(-1);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			try {
-				segment.putChar(Integer.MAX_VALUE - 1, 'a');
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		try {
+			segment.getChar(pageSize);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			try {
-				segment.getChar(-1);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		try {
+			segment.getChar(Integer.MIN_VALUE);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			try {
-				segment.getChar(pageSize);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		try {
+			segment.getChar(Integer.MAX_VALUE);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			try {
-				segment.getChar(Integer.MIN_VALUE);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		try {
+			segment.getChar(Integer.MAX_VALUE - 1);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			try {
-				segment.getChar(Integer.MAX_VALUE);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		// test expected correct behavior, sequential access
 
-			try {
-				segment.getChar(Integer.MAX_VALUE - 1);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		long seed = random.nextLong();
 
-			// test expected correct behavior, sequential access 
+		random.setSeed(seed);
+		for (int i = 0; i <= pageSize - 2; i += 2) {
+			segment.putChar(i, (char) (random.nextInt(Character.MAX_VALUE)));
+		}
 
-			long seed = random.nextLong();
+		random.setSeed(seed);
+		for (int i = 0; i <= pageSize - 2; i += 2) {
+			assertEquals((char) (random.nextInt(Character.MAX_VALUE)), segment.getChar(i));
+		}
 
-			random.setSeed(seed);
-			for (int i = 0; i <= pageSize - 2; i += 2) {
-				segment.putChar(i, (char) (random.nextInt(Character.MAX_VALUE)));
-			}
+		// test expected correct behavior, random access
 
-			random.setSeed(seed);
-			for (int i = 0; i <= pageSize - 2; i += 2) {
-				assertEquals((char) (random.nextInt(Character.MAX_VALUE)), segment.getChar(i));
-			}
+		random.setSeed(seed);
+		boolean[] occupied = new boolean[pageSize];
 
-			// test expected correct behavior, random access 
+		for (int i = 0; i < 1000; i++) {
+			int pos = random.nextInt(pageSize - 1);
 
-			random.setSeed(seed);
-			boolean[] occupied = new boolean[pageSize];
+			if (occupied[pos] || occupied[pos + 1]) {
+				continue;
+			} else {
+				occupied[pos] = true;
+				occupied[pos+1] = true;
+			}
+
+			segment.putChar(pos, (char) (random.nextInt(Character.MAX_VALUE)));
+		}
 
-			for (int i = 0; i < 1000; i++) {
-				int pos = random.nextInt(pageSize - 1);
+		random.setSeed(seed);
+		occupied = new boolean[pageSize];
 
-				if (occupied[pos] || occupied[pos + 1]) {
-					continue;
-				} else {
-					occupied[pos] = true;
-					occupied[pos+1] = true;
-				}
+		for (int i = 0; i < 1000; i++) {
+			int pos = random.nextInt(pageSize - 1);
 
-				segment.putChar(pos, (char) (random.nextInt(Character.MAX_VALUE)));
+			if (occupied[pos] || occupied[pos + 1]) {
+				continue;
+			} else {
+				occupied[pos] = true;
+				occupied[pos+1] = true;
 			}
 
-			random.setSeed(seed);
-			occupied = new boolean[pageSize];
+			assertEquals((char) (random.nextInt(Character.MAX_VALUE)), segment.getChar(pos));
+		}
+	}
 
-			for (int i = 0; i < 1000; i++) {
-				int pos = random.nextInt(pageSize - 1);
+	@Test
+	public void testShortAccess() {
+		final MemorySegment segment = createSegment(pageSize);
 
-				if (occupied[pos] || occupied[pos + 1]) {
-					continue;
-				} else {
-					occupied[pos] = true;
-					occupied[pos+1] = true;
-				}
+		// test exceptions
 
-				assertEquals((char) (random.nextInt(Character.MAX_VALUE)), segment.getChar(pos));
-			}
+		try {
+			segment.putShort(-1, (short) 0);
+			fail("IndexOutOfBoundsException expected");
 		}
 		catch (Exception e) {
-			e.printStackTrace();
-			fail(e.getMessage());
+			assertTrue(e instanceof IndexOutOfBoundsException);
 		}
-	}
 
-	@Test
-	public void testShortAccess() {
 		try {
-			final MemorySegment segment = createSegment(pageSize);
+			segment.putShort(pageSize, (short) 0);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			// test exceptions
+		try {
+			segment.putShort(Integer.MIN_VALUE, (short) 0);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			try {
-				segment.putShort(-1, (short) 0);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		try {
+			segment.putShort(Integer.MAX_VALUE, (short) 0);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			try {
-				segment.putShort(pageSize, (short) 0);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		try {
+			segment.putShort(Integer.MAX_VALUE - 1, (short) 0);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			try {
-				segment.putShort(Integer.MIN_VALUE, (short) 0);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		try {
+			segment.getShort(-1);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			try {
-				segment.putShort(Integer.MAX_VALUE, (short) 0);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		try {
+			segment.getShort(pageSize);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			try {
-				segment.putShort(Integer.MAX_VALUE - 1, (short) 0);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		try {
+			segment.getShort(Integer.MIN_VALUE);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			try {
-				segment.getShort(-1);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		try {
+			segment.getShort(Integer.MAX_VALUE);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			try {
-				segment.getShort(pageSize);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		try {
+			segment.getShort(Integer.MAX_VALUE - 1);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			try {
-				segment.getShort(Integer.MIN_VALUE);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		// test expected correct behavior, sequential access
 
-			try {
-				segment.getShort(Integer.MAX_VALUE);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		long seed = random.nextLong();
 
-			try {
-				segment.getShort(Integer.MAX_VALUE - 1);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		random.setSeed(seed);
+		for (int i = 0; i <= pageSize - 2; i += 2) {
+			segment.putShort(i, (short) random.nextInt());
+		}
 
-			// test expected correct behavior, sequential access
+		random.setSeed(seed);
+		for (int i = 0; i <= pageSize - 2; i += 2) {
+			assertEquals((short) random.nextInt(), segment.getShort(i));
+		}
 
-			long seed = random.nextLong();
+		// test expected correct behavior, random access
 
-			random.setSeed(seed);
-			for (int i = 0; i <= pageSize - 2; i += 2) {
-				segment.putShort(i, (short) random.nextInt());
-			}
+		random.setSeed(seed);
+		boolean[] occupied = new boolean[pageSize];
 
-			random.setSeed(seed);
-			for (int i = 0; i <= pageSize - 2; i += 2) {
-				assertEquals((short) random.nextInt(), segment.getShort(i));
-			}
+		for (int i = 0; i < 1000; i++) {
+			int pos = random.nextInt(pageSize - 1);
 
-			// test expected correct behavior, random access
+			if (occupied[pos] || occupied[pos + 1]) {
+				continue;
+			} else {
+				occupied[pos] = true;
+				occupied[pos+1] = true;
+			}
 
-			random.setSeed(seed);
-			boolean[] occupied = new boolean[pageSize];
+			segment.putShort(pos, (short) random.nextInt());
+		}
 
-			for (int i = 0; i < 1000; i++) {
-				int pos = random.nextInt(pageSize - 1);
+		random.setSeed(seed);
+		occupied = new boolean[pageSize];
 
-				if (occupied[pos] || occupied[pos + 1]) {
-					continue;
-				} else {
-					occupied[pos] = true;
-					occupied[pos+1] = true;
-				}
+		for (int i = 0; i < 1000; i++) {
+			int pos = random.nextInt(pageSize - 1);
 
-				segment.putShort(pos, (short) random.nextInt());
+			if (occupied[pos] || occupied[pos + 1]) {
+				continue;
+			} else {
+				occupied[pos] = true;
+				occupied[pos+1] = true;
 			}
 
-			random.setSeed(seed);
-			occupied = new boolean[pageSize];
+			assertEquals((short) random.nextInt(), segment.getShort(pos));
+		}
+	}
 
-			for (int i = 0; i < 1000; i++) {
-				int pos = random.nextInt(pageSize - 1);
+	@Test
+	public void testIntAccess() {
+		final MemorySegment segment = createSegment(pageSize);
 
-				if (occupied[pos] || occupied[pos + 1]) {
-					continue;
-				} else {
-					occupied[pos] = true;
-					occupied[pos+1] = true;
-				}
+		// test exceptions
 
-				assertEquals((short) random.nextInt(), segment.getShort(pos));
-			}
+		try {
+			segment.putInt(-1, 0);
+			fail("IndexOutOfBoundsException expected");
 		}
 		catch (Exception e) {
-			e.printStackTrace();
-			fail(e.getMessage());
+			assertTrue(e instanceof IndexOutOfBoundsException);
 		}
-	}
 
-	@Test
-	public void testIntAccess() {
 		try {
-			final MemorySegment segment = createSegment(pageSize);
+			segment.putInt(pageSize, 0);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			// test exceptions
+		try {
+			segment.putInt(pageSize - 3, 0);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			try {
-				segment.putInt(-1, 0);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		try {
+			segment.putInt(Integer.MIN_VALUE, 0);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			try {
-				segment.putInt(pageSize, 0);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		try {
+			segment.putInt(Integer.MAX_VALUE, 0);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			try {
-				segment.putInt(pageSize - 3, 0);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		try {
+			segment.putInt(Integer.MAX_VALUE - 3, 0);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			try {
-				segment.putInt(Integer.MIN_VALUE, 0);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		try {
+			segment.getInt(-1);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			try {
-				segment.putInt(Integer.MAX_VALUE, 0);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		try {
+			segment.getInt(pageSize);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			try {
-				segment.putInt(Integer.MAX_VALUE - 3, 0);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		try {
+			segment.getInt(pageSize - 3);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			try {
-				segment.getInt(-1);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		try {
+			segment.getInt(Integer.MIN_VALUE);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			try {
-				segment.getInt(pageSize);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		try {
+			segment.getInt(Integer.MAX_VALUE);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			try {
-				segment.getInt(pageSize - 3);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		try {
+			segment.getInt(Integer.MAX_VALUE - 3);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			try {
-				segment.getInt(Integer.MIN_VALUE);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		// test expected correct behavior, sequential access
 
-			try {
-				segment.getInt(Integer.MAX_VALUE);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		long seed = random.nextLong();
 
-			try {
-				segment.getInt(Integer.MAX_VALUE - 3);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		random.setSeed(seed);
+		for (int i = 0; i <= pageSize - 4; i += 4) {
+			segment.putInt(i, random.nextInt());
+		}
 
-			// test expected correct behavior, sequential access
+		random.setSeed(seed);
+		for (int i = 0; i <= pageSize - 4; i += 4) {
+			assertEquals(random.nextInt(), segment.getInt(i));
+		}
 
-			long seed = random.nextLong();
+		// test expected correct behavior, random access
 
-			random.setSeed(seed);
-			for (int i = 0; i <= pageSize - 4; i += 4) {
-				segment.putInt(i, random.nextInt());
-			}
+		random.setSeed(seed);
+		boolean[] occupied = new boolean[pageSize];
 
-			random.setSeed(seed);
-			for (int i = 0; i <= pageSize - 4; i += 4) {
-				assertEquals(random.nextInt(), segment.getInt(i));
-			}
+		for (int i = 0; i < 1000; i++) {
+			int pos = random.nextInt(pageSize - 3);
 
-			// test expected correct behavior, random access
+			if (occupied[pos] || occupied[pos + 1] || occupied[pos + 2] || occupied[pos + 3]) {
+				continue;
+			} else {
+				occupied[pos] = true;
+				occupied[pos+1] = true;
+				occupied[pos+2] = true;
+				occupied[pos+3] = true;
+			}
 
-			random.setSeed(seed);
-			boolean[] occupied = new boolean[pageSize];
-
-			for (int i = 0; i < 1000; i++) {
-				int pos = random.nextInt(pageSize - 3);
-
-				if (occupied[pos] || occupied[pos + 1] || occupied[pos + 2] || occupied[pos + 3]) {
-					continue;
-				} else {
-					occupied[pos] = true;
-					occupied[pos+1] = true;
-					occupied[pos+2] = true;
-					occupied[pos+3] = true;
-				}
+			segment.putInt(pos, random.nextInt());
+		}
 
-				segment.putInt(pos, random.nextInt());
-			}
+		random.setSeed(seed);
+		occupied = new boolean[pageSize];
 
-			random.setSeed(seed);
-			occupied = new boolean[pageSize];
-
-			for (int i = 0; i < 1000; i++) {
-				int pos = random.nextInt(pageSize - 3);
-
-				if (occupied[pos] || occupied[pos + 1] || occupied[pos + 2] || occupied[pos + 3]) {
-					continue;
-				} else {
-					occupied[pos] = true;
-					occupied[pos+1] = true;
-					occupied[pos+2] = true;
-					occupied[pos+3] = true;
-				}
+		for (int i = 0; i < 1000; i++) {
+			int pos = random.nextInt(pageSize - 3);
 
-				assertEquals(random.nextInt(), segment.getInt(pos));
+			if (occupied[pos] || occupied[pos + 1] || occupied[pos + 2] || occupied[pos + 3]) {
+				continue;
+			} else {
+				occupied[pos] = true;
+				occupied[pos+1] = true;
+				occupied[pos+2] = true;
+				occupied[pos+3] = true;
 			}
-		}
-		catch (Exception e) {
-			e.printStackTrace();
-			fail(e.getMessage());
+
+			assertEquals(random.nextInt(), segment.getInt(pos));
 		}
 	}
 
 	@Test
 	public void testLongAccess() {
-		try {
-			final MemorySegment segment = createSegment(pageSize);
+		final MemorySegment segment = createSegment(pageSize);
 
-			// test exceptions
-
-			try {
-				segment.putLong(-1, 0L);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		// test exceptions
 
-			try {
-				segment.putLong(pageSize, 0L);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		try {
+			segment.putLong(-1, 0L);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			try {
-				segment.putLong(pageSize - 7, 0L);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		try {
+			segment.putLong(pageSize, 0L);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			try {
-				segment.putLong(Integer.MIN_VALUE, 0L);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		try {
+			segment.putLong(pageSize - 7, 0L);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			try {
-				segment.putLong(Integer.MAX_VALUE, 0L);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		try {
+			segment.putLong(Integer.MIN_VALUE, 0L);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			try {
-				segment.putLong(Integer.MAX_VALUE - 7, 0L);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		try {
+			segment.putLong(Integer.MAX_VALUE, 0L);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			try {
-				segment.getLong(-1);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		try {
+			segment.putLong(Integer.MAX_VALUE - 7, 0L);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			try {
-				segment.getLong(pageSize);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		try {
+			segment.getLong(-1);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			try {
-				segment.getLong(pageSize - 7);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		try {
+			segment.getLong(pageSize);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			try {
-				segment.getLong(Integer.MIN_VALUE);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		try {
+			segment.getLong(pageSize - 7);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			try {
-				segment.getLong(Integer.MAX_VALUE);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		try {
+			segment.getLong(Integer.MIN_VALUE);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			try {
-				segment.getLong(Integer.MAX_VALUE - 7);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		try {
+			segment.getLong(Integer.MAX_VALUE);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			// test expected correct behavior, sequential access
+		try {
+			segment.getLong(Integer.MAX_VALUE - 7);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			long seed = random.nextLong();
+		// test expected correct behavior, sequential access
 
-			random.setSeed(seed);
-			for (int i = 0; i <= pageSize - 8; i += 8) {
-				segment.putLong(i, random.nextLong());
-			}
+		long seed = random.nextLong();
 
-			random.setSeed(seed);
-			for (int i = 0; i <= pageSize - 8; i += 8) {
-				assertEquals(random.nextLong(), segment.getLong(i));
-			}
+		random.setSeed(seed);
+		for (int i = 0; i <= pageSize - 8; i += 8) {
+			segment.putLong(i, random.nextLong());
+		}
 
-			// test expected correct behavior, random access
+		random.setSeed(seed);
+		for (int i = 0; i <= pageSize - 8; i += 8) {
+			assertEquals(random.nextLong(), segment.getLong(i));
+		}
 
-			random.setSeed(seed);
-			boolean[] occupied = new boolean[pageSize];
+		// test expected correct behavior, random access
 
-			for (int i = 0; i < 1000; i++) {
-				int pos = random.nextInt(pageSize - 7);
+		random.setSeed(seed);
+		boolean[] occupied = new boolean[pageSize];
 
-				if (occupied[pos] || occupied[pos + 1] || occupied[pos + 2] || occupied[pos + 3] ||
-						occupied[pos + 4] || occupied[pos + 5] || occupied[pos + 6] || occupied[pos + 7])
-				{
-					continue;
-				}
-				else {
-					occupied[pos] = true;
-					occupied[pos+1] = true;
-					occupied[pos+2] = true;
-					occupied[pos+3] = true;
-					occupied[pos+4] = true;
-					occupied[pos+5] = true;
-					occupied[pos+6] = true;
-					occupied[pos+7] = true;
-				}
+		for (int i = 0; i < 1000; i++) {
+			int pos = random.nextInt(pageSize - 7);
 
-				segment.putLong(pos, random.nextLong());
+			if (occupied[pos] || occupied[pos + 1] || occupied[pos + 2] || occupied[pos + 3] ||
+					occupied[pos + 4] || occupied[pos + 5] || occupied[pos + 6] || occupied[pos + 7])
+			{
+				continue;
+			}
+			else {
+				occupied[pos] = true;
+				occupied[pos+1] = true;
+				occupied[pos+2] = true;
+				occupied[pos+3] = true;
+				occupied[pos+4] = true;
+				occupied[pos+5] = true;
+				occupied[pos+6] = true;
+				occupied[pos+7] = true;
 			}
 
-			random.setSeed(seed);
-			occupied = new boolean[pageSize];
+			segment.putLong(pos, random.nextLong());
+		}
 
-			for (int i = 0; i < 1000; i++) {
-				int pos = random.nextInt(pageSize - 7);
+		random.setSeed(seed);
+		occupied = new boolean[pageSize];
 
-				if (occupied[pos] || occupied[pos + 1] || occupied[pos + 2] || occupied[pos + 3] ||
-						occupied[pos + 4] || occupied[pos + 5] || occupied[pos + 6] || occupied[pos + 7])
-				{
-					continue;
-				}
-				else {
-					occupied[pos] = true;
-					occupied[pos+1] = true;
-					occupied[pos+2] = true;
-					occupied[pos+3] = true;
-					occupied[pos+4] = true;
-					occupied[pos+5] = true;
-					occupied[pos+6] = true;
-					occupied[pos+7] = true;
-				}
+		for (int i = 0; i < 1000; i++) {
+			int pos = random.nextInt(pageSize - 7);
 
-				assertEquals(random.nextLong(), segment.getLong(pos));
+			if (occupied[pos] || occupied[pos + 1] || occupied[pos + 2] || occupied[pos + 3] ||
+					occupied[pos + 4] || occupied[pos + 5] || occupied[pos + 6] || occupied[pos + 7])
+			{
+				continue;
 			}
-		}
-		catch (Exception e) {
-			e.printStackTrace();
-			fail(e.getMessage());
+			else {
+				occupied[pos] = true;
+				occupied[pos+1] = true;
+				occupied[pos+2] = true;
+				occupied[pos+3] = true;
+				occupied[pos+4] = true;
+				occupied[pos+5] = true;
+				occupied[pos+6] = true;
+				occupied[pos+7] = true;
+			}
+
+			assertEquals(random.nextLong(), segment.getLong(pos));
 		}
 	}
 
 	@Test
 	public void testFloatAccess() {
-		try {
-			final MemorySegment segment = createSegment(pageSize);
+		final MemorySegment segment = createSegment(pageSize);
 
-			// test exceptions
+		// test exceptions
 
-			try {
-				segment.putFloat(-1, 0.0f);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		try {
+			segment.putFloat(-1, 0.0f);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			try {
-				segment.putFloat(pageSize, 0.0f);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		try {
+			segment.putFloat(pageSize, 0.0f);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			try {
-				segment.putFloat(pageSize - 3, 0.0f);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		try {
+			segment.putFloat(pageSize - 3, 0.0f);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			try {
-				segment.putFloat(Integer.MIN_VALUE, 0.0f);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		try {
+			segment.putFloat(Integer.MIN_VALUE, 0.0f);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			try {
-				segment.putFloat(Integer.MAX_VALUE, 0.0f);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		try {
+			segment.putFloat(Integer.MAX_VALUE, 0.0f);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			try {
-				segment.putFloat(Integer.MAX_VALUE - 3, 0.0f);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		try {
+			segment.putFloat(Integer.MAX_VALUE - 3, 0.0f);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			try {
-				segment.getFloat(-1);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		try {
+			segment.getFloat(-1);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			try {
-				segment.getFloat(pageSize);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		try {
+			segment.getFloat(pageSize);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			try {
-				segment.getFloat(pageSize - 3);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		try {
+			segment.getFloat(pageSize - 3);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			try {
-				segment.getFloat(Integer.MIN_VALUE);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		try {
+			segment.getFloat(Integer.MIN_VALUE);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			try {
-				segment.getFloat(Integer.MAX_VALUE);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		try {
+			segment.getFloat(Integer.MAX_VALUE);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			try {
-				segment.getFloat(Integer.MAX_VALUE - 3);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		try {
+			segment.getFloat(Integer.MAX_VALUE - 3);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			// test expected correct behavior, sequential access
+		// test expected correct behavior, sequential access
 
-			long seed = random.nextLong();
+		long seed = random.nextLong();
 
-			random.setSeed(seed);
-			for (int i = 0; i <= pageSize - 4; i += 4) {
-				segment.putFloat(i, random.nextFloat());
-			}
+		random.setSeed(seed);
+		for (int i = 0; i <= pageSize - 4; i += 4) {
+			segment.putFloat(i, random.nextFloat());
+		}
 
-			random.setSeed(seed);
-			for (int i = 0; i <= pageSize - 4; i += 4) {
-				assertEquals(random.nextFloat(), segment.getFloat(i), 0.0);
-			}
+		random.setSeed(seed);
+		for (int i = 0; i <= pageSize - 4; i += 4) {
+			assertEquals(random.nextFloat(), segment.getFloat(i), 0.0);
+		}
 
-			// test expected correct behavior, random access
+		// test expected correct behavior, random access
 
-			random.setSeed(seed);
-			boolean[] occupied = new boolean[pageSize];
-
-			for (int i = 0; i < 1000; i++) {
-				int pos = random.nextInt(pageSize - 3);
-
-				if (occupied[pos] || occupied[pos + 1] || occupied[pos + 2] || occupied[pos + 3]) {
-					continue;
-				} else {
-					occupied[pos] = true;
-					occupied[pos+1] = true;
-					occupied[pos+2] = true;
-					occupied[pos+3] = true;
-				}
+		random.setSeed(seed);
+		boolean[] occupied = new boolean[pageSize];
 
-				segment.putFloat(pos, random.nextFloat());
+		for (int i = 0; i < 1000; i++) {
+			int pos = random.nextInt(pageSize - 3);
+
+			if (occupied[pos] || occupied[pos + 1] || occupied[pos + 2] || occupied[pos + 3]) {
+				continue;
+			} else {
+				occupied[pos] = true;
+				occupied[pos+1] = true;
+				occupied[pos+2] = true;
+				occupied[pos+3] = true;
 			}
 
-			random.setSeed(seed);
-			occupied = new boolean[pageSize];
-
-			for (int i = 0; i < 1000; i++) {
-				int pos = random.nextInt(pageSize - 3);
-
-				if (occupied[pos] || occupied[pos + 1] || occupied[pos + 2] || occupied[pos + 3]) {
-					continue;
-				} else {
-					occupied[pos] = true;
-					occupied[pos+1] = true;
-					occupied[pos+2] = true;
-					occupied[pos+3] = true;
-				}
+			segment.putFloat(pos, random.nextFloat());
+		}
+
+		random.setSeed(seed);
+		occupied = new boolean[pageSize];
+
+		for (int i = 0; i < 1000; i++) {
+			int pos = random.nextInt(pageSize - 3);
 
-				assertEquals(random.nextFloat(), segment.getFloat(pos), 0.0);
+			if (occupied[pos] || occupied[pos + 1] || occupied[pos + 2] || occupied[pos + 3]) {
+				continue;
+			} else {
+				occupied[pos] = true;
+				occupied[pos+1] = true;
+				occupied[pos+2] = true;
+				occupied[pos+3] = true;
 			}
-		}
-		catch (Exception e) {
-			e.printStackTrace();
-			fail(e.getMessage());
+
+			assertEquals(random.nextFloat(), segment.getFloat(pos), 0.0);
 		}
 	}
 
 	@Test
 	public void testDoubleAccess() {
+		final MemorySegment segment = createSegment(pageSize);
+
+		// test exceptions
 		try {
-			final MemorySegment segment = createSegment(pageSize);
+			segment.putDouble(-1, 0.0);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			// test exceptions
-			try {
-				segment.putDouble(-1, 0.0);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		try {
+			segment.putDouble(pageSize, 0.0);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			try {
-				segment.putDouble(pageSize, 0.0);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		try {
+			segment.putDouble(pageSize - 7, 0.0);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			try {
-				segment.putDouble(pageSize - 7, 0.0);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		try {
+			segment.putDouble(Integer.MIN_VALUE, 0.0);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			try {
-				segment.putDouble(Integer.MIN_VALUE, 0.0);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		try {
+			segment.putDouble(Integer.MAX_VALUE, 0.0);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			try {
-				segment.putDouble(Integer.MAX_VALUE, 0.0);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		try {
+			segment.putDouble(Integer.MAX_VALUE - 7, 0.0);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			try {
-				segment.putDouble(Integer.MAX_VALUE - 7, 0.0);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		try {
+			segment.getDouble(-1);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			try {
-				segment.getDouble(-1);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		try {
+			segment.getDouble(pageSize);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			try {
-				segment.getDouble(pageSize);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		try {
+			segment.getDouble(pageSize - 7);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			try {
-				segment.getDouble(pageSize - 7);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		try {
+			segment.getDouble(Integer.MIN_VALUE);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			try {
-				segment.getDouble(Integer.MIN_VALUE);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		try {
+			segment.getDouble(Integer.MAX_VALUE);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			try {
-				segment.getDouble(Integer.MAX_VALUE);
-				fail("IndexOutOfBoundsException expected");
+		try {
+			segment.getDouble(Integer.MAX_VALUE - 7);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
+
+		// test expected correct behavior, sequential access
+
+		long seed = random.nextLong();
+
+		random.setSeed(seed);
+		for (int i = 0; i <= pageSize - 8; i += 8) {
+			segment.putDouble(i, random.nextDouble());
+		}
+
+		random.setSeed(seed);
+		for (int i = 0; i <= pageSize - 8; i += 8) {
+			assertEquals(random.nextDouble(), segment.getDouble(i), 0.0);
+		}
+
+		// test expected correct behavior, random access
+
+		random.setSeed(seed);
+		boolean[] occupied = new boolean[pageSize];
+
+		for (int i = 0; i < 1000; i++) {
+			int pos = random.nextInt(pageSize - 7);
+
+			if (occupied[pos] || occupied[pos + 1] || occupied[pos + 2] || occupied[pos + 3] ||
+					occupied[pos + 4] || occupied[pos + 5] || occupied[pos + 6] || occupied[pos + 7])
+			{
+				continue;
 			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
+			else {
+				occupied[pos] = true;
+				occupied[pos+1] = true;
+				occupied[pos+2] = true;
+				occupied[pos+3] = true;
+				occupied[pos+4] = true;
+				occupied[pos+5] = true;
+				occupied[pos+6] = true;
+				occupied[pos+7] = true;
 			}
 
-			try {
-				segment.getDouble(Integer.MAX_VALUE - 7);
-				fail("IndexOutOfBoundsException expected");
+			segment.putDouble(pos, random.nextDouble());
+		}
+
+		random.setSeed(seed);
+		occupied = new boolean[pageSize];
+
+		for (int i = 0; i < 1000; i++) {
+			int pos = random.nextInt(pageSize - 7);
+
+			if (occupied[pos] || occupied[pos + 1] || occupied[pos + 2] || occupied[pos + 3] ||
+					occupied[pos + 4] || occupied[pos + 5] || occupied[pos + 6] || occupied[pos + 7])
+			{
+				continue;
 			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
+			else {
+				occupied[pos] = true;
+				occupied[pos+1] = true;
+				occupied[pos+2] = true;
+				occupied[pos+3] = true;
+				occupied[pos+4] = true;
+				occupied[pos+5] = true;
+				occupied[pos+6] = true;
+				occupied[pos+7] = true;
 			}
 
-			// test expected correct behavior, sequential access
+			assertEquals(random.nextDouble(), segment.getDouble(pos), 0.0);
+		}
+	}
 
-			long seed = random.nextLong();
+	// ------------------------------------------------------------------------
+	//  Bulk Byte Movements
+	// ------------------------------------------------------------------------
 
-			random.setSeed(seed);
-			for (int i = 0; i <= pageSize - 8; i += 8) {
-				segment.putDouble(i, random.nextDouble());
-			}
+	@Test
+	public void testBulkBytePutExceptions() {
+		final MemorySegment segment = createSegment(pageSize);
 
-			random.setSeed(seed);
-			for (int i = 0; i <= pageSize - 8; i += 8) {
-				assertEquals(random.nextDouble(), segment.getDouble(i), 0.0);
-			}
+		byte[] bytes = new byte[pageSize / 4 + (pageSize%4)];
+		random.nextBytes(bytes);
 
-			// test expected correct behavior, random access
+		// wrong positions into memory segment
 
-			random.setSeed(seed);
-			boolean[] occupied = new boolean[pageSize];
+		try {
+			segment.put(-1, bytes);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			for (int i = 0; i < 1000; i++) {
-				int pos = random.nextInt(pageSize - 7);
+		try {
+			segment.put(-1, bytes, 4, 5);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-				if (occupied[pos] || occupied[pos + 1] || occupied[pos + 2] || occupied[pos + 3] ||
-						occupied[pos + 4] || occupied[pos + 5] || occupied[pos + 6] || occupied[pos + 7])
-				{
-					continue;
-				}
-				else {
-					occupied[pos] = true;
-					occupied[pos+1] = true;
-					occupied[pos+2] = true;
-					occupied[pos+3] = true;
-					occupied[pos+4] = true;
-					occupied[pos+5] = true;
-					occupied[pos+6] = true;
-					occupied[pos+7] = true;
-				}
+		try {
+			segment.put(Integer.MIN_VALUE, bytes);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-				segment.putDouble(pos, random.nextDouble());
-			}
+		try {
+			segment.put(Integer.MIN_VALUE, bytes, 4, 5);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			random.setSeed(seed);
-			occupied = new boolean[pageSize];
+		try {
+			segment.put(pageSize, bytes);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			for (int i = 0; i < 1000; i++) {
-				int pos = random.nextInt(pageSize - 7);
+		try {
+			segment.put(pageSize, bytes, 6, 44);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-				if (occupied[pos] || occupied[pos + 1] || occupied[pos + 2] || occupied[pos + 3] ||
-						occupied[pos + 4] || occupied[pos + 5] || occupied[pos + 6] || occupied[pos + 7])
-				{
-					continue;
-				}
-				else {
-					occupied[pos] = true;
-					occupied[pos+1] = true;
-					occupied[pos+2] = true;
-					occupied[pos+3] = true;
-					occupied[pos+4] = true;
-					occupied[pos+5] = true;
-					occupied[pos+6] = true;
-					occupied[pos+7] = true;
-				}
+		try {
+			segment.put(pageSize - bytes.length + 1, bytes);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-				assertEquals(random.nextDouble(), segment.getDouble(pos), 0.0);
-			}
+		try {
+			segment.put(pageSize - 5, bytes, 3, 6);
+			fail("IndexOutOfBoundsException expected");
 		}
 		catch (Exception e) {
-			e.printStackTrace();
-			fail(e.getMessage());
+			assertTrue(e instanceof IndexOutOfBoundsException);
 		}
-	}
 
-	// ------------------------------------------------------------------------
-	//  Bulk Byte Movements
-	// ------------------------------------------------------------------------
+		try {
+			segment.put(Integer.MAX_VALUE, bytes);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
+
+		try {
+			segment.put(Integer.MAX_VALUE, bytes, 10, 20);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
+
+		try {
+			segment.put(Integer.MAX_VALUE - bytes.length + 1, bytes);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
+
+		try {
+			segment.put(Integer.MAX_VALUE - 11, bytes, 11, 11);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
+
+		try {
+			segment.put(3 * (pageSize / 4) + 1, bytes);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
+
+		try {
+			segment.put(3 * (pageSize / 4) + 2, bytes, 0, bytes.length - 1);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
+
+		try {
+			segment.put(7 * (pageSize / 8) + 1, bytes, 0, bytes.length / 2);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
+
+		// wrong source array positions / lengths
+
+		try {
+			segment.put(0, bytes, -1, 1);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
+
+		try {
+			segment.put(0, bytes, -1, bytes.length + 1);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
+
+		try {
+			segment.put(0, bytes, Integer.MIN_VALUE, bytes.length);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
+
+		try {
+			segment.put(0, bytes, Integer.MAX_VALUE, bytes.length);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
+
+		try {
+			segment.put(0, bytes, Integer.MAX_VALUE - bytes.length + 1, bytes.length);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
+
+		// case where negative offset and negative index compensate each other
+		try {
+			segment.put(-2, bytes, -1, bytes.length / 2);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
+	}
 
 	@Test
-	public void testBulkBytePutExceptions() {
+	public void testBulkByteGetExceptions() {
+		final MemorySegment segment = createSegment(pageSize);
+
+		byte[] bytes = new byte[pageSize / 4];
+
+		// wrong positions into memory segment
+
 		try {
-			final MemorySegment segment = createSegment(pageSize);
+			segment.get(-1, bytes);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			byte[] bytes = new byte[pageSize / 4 + (pageSize%4)];
-			random.nextBytes(bytes);
+		try {
+			segment.get(-1, bytes, 4, 5);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			// wrong positions into memory segment
+		try {
+			segment.get(Integer.MIN_VALUE, bytes);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			try {
-				segment.put(-1, bytes);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		try {
+			segment.get(Integer.MIN_VALUE, bytes, 4, 5);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			try {
-				segment.put(-1, bytes, 4, 5);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		try {
+			segment.get(pageSize, bytes);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			try {
-				segment.put(Integer.MIN_VALUE, bytes);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		try {
+			segment.get(pageSize, bytes, 6, 44);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			try {
-				segment.put(Integer.MIN_VALUE, bytes, 4, 5);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		try {
+			segment.get(pageSize - bytes.length + 1, bytes);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			try {
-				segment.put(pageSize, bytes);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		try {
+			segment.get(pageSize - 5, bytes, 3, 6);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			try {
-				segment.put(pageSize, bytes, 6, 44);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		try {
+			segment.get(Integer.MAX_VALUE, bytes);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
 
-			try {
-				segment.put(pageSize - bytes.length + 1, bytes);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		try {
+			segment.get(Integer.MAX_VALUE, bytes, 10, 20);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
+
+		try {
+			segment.get(Integer.MAX_VALUE - bytes.length + 1, bytes);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
+
+		try {
+			segment.get(Integer.MAX_VALUE - 11, bytes, 11, 11);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
+
+		try {
+			segment.get(3 * (pageSize / 4) + 1, bytes);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
+
+		try {
+			segment.get(3 * (pageSize / 4) + 2, bytes, 0, bytes.length - 1);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
+
+		try {
+			segment.get(7 * (pageSize / 8) + 1, bytes, 0, bytes.length / 2);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
+
+		// wrong source array positions / lengths
+
+		try {
+			segment.get(0, bytes, -1, 1);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
+
+		try {
+			segment.get(0, bytes, -1, bytes.length + 1);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
+
+		try {
+			segment.get(0, bytes, Integer.MIN_VALUE, bytes.length);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
+
+		try {
+			segment.get(0, bytes, Integer.MAX_VALUE, bytes.length);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
+
+		try {
+			segment.get(0, bytes, Integer.MAX_VALUE - bytes.length + 1, bytes.length);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
+
+		// case where negative offset and negative index compensate each other
+		try {
+			segment.get(-2, bytes, -1, bytes.length / 2);
+			fail("IndexOutOfBoundsException expected");
+		}
+		catch (Exception e) {
+			assertTrue(e instanceof IndexOutOfBoundsException);
+		}
+	}
+
+	@Test
+	public void testBulkByteAccess() {
+		// test expected correct behavior with default offset / length
+		{
+			final MemorySegment segment = createSegment(pageSize);
+			long seed = random.nextLong();
 
-			try {
-				segment.put(pageSize - 5, bytes, 3, 6);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
+			random.setSeed(seed);
+			byte[] src = new byte[pageSize / 8];
+			for (int i = 0; i < 8; i++) {
+				random.nextBytes(src);
+				segment.put(i * (pageSize / 8), src);
 			}
 
-			try {
-				segment.put(Integer.MAX_VALUE, bytes);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+			random.setSeed(seed);
+			byte[] expected = new byte[pageSize / 8];
+			byte[] actual = new byte[pageSize / 8];
+			for (int i = 0; i < 8; i++) {
+				random.nextBytes(expected);
+				segment.get(i * (pageSize / 8), actual);
 
-			try {
-				segment.put(Integer.MAX_VALUE, bytes, 10, 20);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
+				assertArrayEquals(expected, actual);
 			}
+		}
 
-			try {
-				segment.put(Integer.MAX_VALUE - bytes.length + 1, bytes);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		// test expected correct behavior with specific offset / length
+		{
+			final MemorySegment segment = createSegment(pageSize);
+			byte[] expected = new byte[pageSize];
+			random.nextBytes(expected);
 
-			try {
-				segment.put(Integer.MAX_VALUE - 11, bytes, 11, 11);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
+			for (int i = 0; i < 16; i++) {
+				segment.put(i * (pageSize / 16), expected, i * (pageSize / 16),
+						pageSize / 16);
 			}
 
-			try {
-				segment.put(3 * (pageSize / 4) + 1, bytes);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
+			byte[] actual = new byte[pageSize];
+			for (int i = 0; i < 16; i++) {
+				segment.get(i * (pageSize / 16), actual, i * (pageSize / 16),
+						pageSize / 16);
 			}
 
-			try {
-				segment.put(3 * (pageSize / 4) + 2, bytes, 0, bytes.length - 1);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+			assertArrayEquals(expected, actual);
+		}
 
-			try {
-				segment.put(7 * (pageSize / 8) + 1, bytes, 0, bytes.length / 2);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		// put segments of various lengths to various positions
+		{
+			final MemorySegment segment = createSegment(pageSize);
+			byte[] expected = new byte[pageSize];
 
-			// wrong source array positions / lengths
+			for (int i = 0; i < 200; i++) {
+				int numBytes = random.nextInt(pageSize - 10) + 1;
+				int pos = random.nextInt(pageSize - numBytes + 1);
 
-			try {
-				segment.put(0, bytes, -1, 1);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+				byte[] data = new byte[(random.nextInt(3) + 1) * numBytes];
+				int dataStartPos = random.nextInt(data.length - numBytes + 1);
 
-			try {
-				segment.put(0, bytes, -1, bytes.length + 1);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+				random.nextBytes(data);
 
-			try {
-				segment.put(0, bytes, Integer.MIN_VALUE, bytes.length);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+				// copy to the expected
+				System.arraycopy(data, dataStartPos, expected, pos, numBytes);
 
-			try {
-				segment.put(0, bytes, Integer.MAX_VALUE, bytes.length);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
+				// put to the memory segment
+				segment.put(pos, data, dataStartPos, numBytes);
 			}
 
-			try {
-				segment.put(0, bytes, Integer.MAX_VALUE - bytes.length + 1, bytes.length);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+			byte[] validation = new byte[pageSize];
+			segment.get(0, validation);
 
-			// case where negative offset and negative index compensate each other
-			try {
-				segment.put(-2, bytes, -1, bytes.length / 2);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
-		}
-		catch (Exception e) {
-			e.printStackTrace();
-			fail(e.getMessage());
+			assertArrayEquals(expected, validation);
 		}
-	}
 
-	@Test
-	public void testBulkByteGetExceptions() {
-		try {
+		// get segments with various contents
+		{
 			final MemorySegment segment = createSegment(pageSize);
+			byte[] contents = new byte[pageSize];
+			random.nextBytes(contents);
+			segment.put(0, contents);
 
-			byte[] bytes = new byte[pageSize / 4];
+			for (int i = 0; i < 200; i++) {
+				int numBytes = random.nextInt(pageSize / 8) + 1;
+				int pos = random.nextInt(pageSize - numBytes + 1);
 
-			// wrong positions into memory segment
+				byte[] data = new byte[(random.nextInt(3) + 1) * numBytes];
+				int dataStartPos = random.nextInt(data.length - numBytes + 1);
 
-			try {
-				segment.get(-1, bytes);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+				segment.get(pos, data, dataStartPos, numBytes);
 
-			try {
-				segment.get(-1, bytes, 4, 5);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
+				byte[] expected = Arrays.copyOfRange(contents, pos, pos + numBytes);
+				byte[] validation = Arrays.copyOfRange(data, dataStartPos, dataStartPos + numBytes);
+				assertArrayEquals(expected, validation);
 			}
+		}
+	}
 
-			try {
-				segment.get(Integer.MIN_VALUE, bytes);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+	// ------------------------------------------------------------------------
+	//  Writing / Reading to/from DataInput / DataOutput
+	// ------------------------------------------------------------------------
 
-			try {
-				segment.get(Integer.MIN_VALUE, bytes, 4, 5);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+	@Test
+	public void testDataInputOutput() throws IOException {
+		MemorySegment seg = createSegment(pageSize);
+		byte[] contents = new byte[pageSize];
+		random.nextBytes(contents);
+		seg.put(0, contents);
 
-			try {
-				segment.get(pageSize, bytes);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		ByteArrayOutputStream buffer = new ByteArrayOutputStream(pageSize);
+		DataOutputStream out = new DataOutputStream(buffer);
 
-			try {
-				segment.get(pageSize, bytes, 6, 44);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		// write the segment in chunks into the stream
+		int pos = 0;
+		while (pos < pageSize) {
+			int len = random.nextInt(200);
+			len = Math.min(len, pageSize - pos);
+			seg.get(out, pos, len);
+			pos += len;
+		}
 
-			try {
-				segment.get(pageSize - bytes.length + 1, bytes);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		// verify that we wrote the same bytes
+		byte[] result = buffer.toByteArray();
+		assertArrayEquals(contents, result);
 
-			try {
-				segment.get(pageSize - 5, bytes, 3, 6);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		// re-read the bytes into a new memory segment
+		MemorySegment reader = createSegment(pageSize);
+		DataInputStream in = new DataInputStream(new ByteArrayInputStream(result));
 
-			try {
-				segment.get(Integer.MAX_VALUE, bytes);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		pos = 0;
+		while (pos < pageSize) {
+			int len = random.nextInt(200);
+			len = Math.min(len, pageSize - pos);
+			reader.put(in, pos, len);
+			pos += len;
+		}
 
-			try {
-				segment.get(Integer.MAX_VALUE, bytes, 10, 20);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		byte[] targetBuffer = new byte[pageSize];
+		reader.get(0, targetBuffer);
 
-			try {
-				segment.get(Integer.MAX_VALUE - bytes.length + 1, bytes);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		assertArrayEquals(contents, targetBuffer);
+	}
 
-			try {
-				segment.get(Integer.MAX_VALUE - 11, bytes, 11, 11);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+	@Test
+	public void testDataInputOutputOutOfBounds() {
+		final int segmentSize = 52;
 
-			try {
-				segment.get(3 * (pageSize / 4) + 1, bytes);
-				fail("IndexOutOfBoundsException expected");
-			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
+		// segment with random contents
+		MemorySegment seg = createSegment(segmentSize);
+		byte[] bytes = new byte[segmentSize];
+		random.nextBytes(bytes);
+		seg.put(0, bytes);
+
+		// out of bounds when writing
+		{
+			DataOutputStream out = new DataOutputStream(new ByteArrayOutputStream());
 
 			try {
-				segment.get(3 * (pageSize / 4) + 2, bytes, 0, bytes.length - 1);
+				seg.get(out, -1, segmentSize / 2);
 				fail("IndexOutOfBoundsException expected");
 			}
 			catch (Exception e) {
@@ -1576,17 +1742,15 @@ public abstract class MemorySegmentTestBase {
 			}
 
 			try {
-				segment.get(7 * (pageSize / 8) + 1, bytes, 0, bytes.length / 2);
+				seg.get(out, segmentSize, segmentSize / 2);
 				fail("IndexOutOfBoundsException expected");
 			}
 			catch (Exception e) {
 				assertTrue(e instanceof IndexOutOfBoundsException);
 			}
 
-			// wrong source array positions / lengths
-
 			try {
-				segment.get(0, bytes, -1, 1);
+				seg.get(out, -segmentSize, segmentSize / 2);
 				fail("IndexOutOfBoundsException expected");
 			}
 			catch (Exception e) {
@@ -1594,7 +1758,7 @@ public abstract class MemorySegmentTestBase {
 			}
 
 			try {
-				segment.get(0, bytes, -1, bytes.length + 1);
+				seg.get(out, Integer.MIN_VALUE, segmentSize / 2);
 				fail("IndexOutOfBoundsException expected");
 			}
 			catch (Exception e) {
@@ -1602,15 +1766,20 @@ public abstract class MemorySegmentTestBase {
 			}
 
 			try {
-				segment.get(0, bytes, Integer.MIN_VALUE, bytes.length);
+				seg.get(out, Integer.MAX_VALUE, segmentSize / 2);
 				fail("IndexOutOfBoundsException expected");
 			}
 			catch (Exception e) {
 				assertTrue(e instanceof IndexOutOfBoundsException);
 			}
+		}
+
+		// out of bounds when reading
+		{
+			DataInputStream in = new DataInputStream(new ByteArrayInputStream(new byte[segmentSize]));
 
 			try {
-				segment.get(0, bytes, Integer.MAX_VALUE, bytes.length);
+				seg.put(in, -1, segmentSize / 2);
 				fail("IndexOutOfBoundsException expected");
 			}
 			catch (Exception e) {
@@ -1618,345 +1787,91 @@ public abstract class MemorySegmentTestBase {
 			}
 
 			try {
-				segment.get(0, bytes, Integer.MAX_VALUE - bytes.length + 1, bytes.length);
+				seg.put(in, segmentSize, segmentSize / 2);
 				fail("IndexOutOfBoundsException expected");
 			}
 			catch (Exception e) {
 				assertTrue(e instanceof IndexOutOfBoundsException);
 			}
 
-			// case where negative offset and negative index compensate each other
 			try {
-				segment.get(-2, bytes, -1, bytes.length / 2);
+				seg.put(in, -segmentSize, segmentSize / 2);
 				fail("IndexOutOfBoundsException expected");
 			}
-			catch (Exception e) {
-				assertTrue(e instanceof IndexOutOfBoundsException);
-			}
-		}
-		catch (Exception e) {
-			e.printStackTrace();
-			fail(e.getMessage());
-		}
-	}
-
-	@Test
-	public void testBulkByteAccess() {
-		try {
-			// test expected correct behavior with default offset / length
-			{
-				final MemorySegment segment = createSegment(pageSize);
-				long seed = random.nextLong();
-
-				random.setSeed(seed);
-				byte[] src = new byte[pageSize / 8];
-				for (int i = 0; i < 8; i++) {
-					random.nextBytes(src);
-					segment.put(i * (pageSize / 8), src);
-				}
-
-				random.setSeed(seed);
-				byte[] expected = new byte[pageSize / 8];
-				byte[] actual = new byte[pageSize / 8];
-				for (int i = 0; i < 8; i++) {
-					random.nextBytes(expected);
-					segment.get(i * (pageSize / 8), actual);
-
-					assertArrayEquals(expected, actual);
-				}
-			}
-
-			// test expected correct behavior with specific offset / length
-			{
-				final MemorySegment segment = createSegment(pageSize);
-				byte[] expected = new byte[pageSize];
-				random.nextBytes(expected);
-
-				for (int i = 0; i < 16; i++) {
-					segment.put(i * (pageSize / 16), expected, i * (pageSize / 16),
-							pageSize / 16);
-				}
-
-				byte[] actual = new byte[pageSize];
-				for (int i = 0; i < 16; i++) {
-					segment.get(i * (pageSize / 16), actual, i * (pageSize / 16),
-							pageSize / 16);
-				}
-
-				assertArrayEquals(expected, actual);
-			}
-			
-			// put segments of various lengths to various positions
-			{
-				final MemorySegment segment = createSegment(pageSize);
-				byte[] expected = new byte[pageSize];
-				
-				for (int i = 0; i < 200; i++) {
-					int numBytes = random.nextInt(pageSize - 10) + 1;
-					int pos = random.nextInt(pageSize - numBytes + 1);
-					
-					byte[] data = new byte[(random.nextInt(3) + 1) * numBytes];
-					int dataStartPos = random.nextInt(data.length - numBytes + 1);
-					
-					random.nextBytes(data);
-					
-					// copy to the expected
-					System.arraycopy(data, dataStartPos, expected, pos, numBytes);
-					
-					// put to the memory segment
-					segment.put(pos, data, dataStartPos, numBytes);
-				}
-				
-				byte[] validation = new byte[pageSize];
-				segment.get(0, validation);
-				
-				assertArrayEquals(expected, validation);
-			}
-			
-			// get segments with various contents
-			{
-				final MemorySegment segment = createSegment(pageSize);
-				byte[] contents = new byte[pageSize];
-				random.nextBytes(contents);
-				segment.put(0, contents);
-
-				for (int i = 0; i < 200; i++) {
-					int numBytes = random.nextInt(pageSize / 8) + 1;
-					int pos = random.nextInt(pageSize - numBytes + 1);
-
-					byte[] data = new byte[(random.nextInt(3) + 1) * numBytes];
-					int dataStartPos = random.nextInt(data.length - numBytes + 1);
-
-					segment.get(pos, data, dataStartPos, numBytes);
-					
-					byte[] expected = Arrays.copyOfRange(contents, pos, pos + numBytes);
-					byte[] validation = Arrays.copyOfRange(data, dataStartPos, dataStartPos + numBytes);
-					assertArrayEquals(expected, validation);
-				}
-			}
-		}
-		catch (Exception e) {
-			e.printStackTrace();
-			fail(e.getMessage());
-		}
-	}
-
-	// ------------------------------------------------------------------------
-	//  Writing / Reading to/from DataInput / DataOutput
-	// ------------------------------------------------------------------------
-
-	@Test
-	public void testDataInputOutput() {
-		try {
-			MemorySegment seg = createSegment(pageSize);
-			byte[] contents = new byte[pageSize];
-			random.nextBytes(contents);
-			seg.put(0, contents);
-
-			ByteArrayOutputStream buffer = new ByteArrayOutputStream(pageSize);
-			DataOutputStream out = new DataOutputStream(buffer);
-
-			// write the segment in chunks into the stream
-			int pos = 0;
-			while (pos < pageSize) {
-				int len = random.nextInt(200);
-				len = Math.min(len, pageSize - pos);
-				seg.get(out, pos, len);
-				pos += len;
-			}
-
-			// verify that we wrote the same bytes
-			byte[] result = buffer.toByteArray();
-			assertArrayEquals(contents, result);
-
-			// re-read the bytes into a new memory segment
-			MemorySegment reader = createSegment(pageSize);
-			DataInputStream in = new DataInputStream(new ByteArrayInputStream(result));
+			catch (Exception e) {
+				assertTrue(e instanceof IndexOutOfBoundsException);
+			}
 
-			pos = 0;
-			while (pos < pageSize) {
-				int len = random.nextInt(200);
-				len = Math.min(len, pageSize - pos);
-				reader.put(in, pos, len);
-				pos += len;
+			try {
+				seg.put(in, Integer.MIN_VALUE, segmentSize / 2);
+				fail("IndexOutOfBoundsException expected");
+			}
+			catch (Exception e) {
+				assertTrue(e instanceof IndexOutOfBoundsException);
 			}
 
-			byte[] targetBuffer = new byte[pageSize];
-			reader.get(0, targetBuffer);
-			
-			assertArrayEquals(contents, targetBuffer);
-		}
-		catch (Exception e) {
-			e.printStackTrace();
-			fail(e.getMessage());
+			try {
+				seg.put(in, Integer.MAX_VALUE, segmentSize / 2);
+				fail("IndexOutOfBoundsException expected");
+			}
+			catch (Exception e) {
+				assertTrue(e instanceof IndexOutOfBoundsException);
+			}
 		}
 	}
 
 	@Test
-	public void testDataInputOutputOutOfBounds() {
-		try {
-			final int segmentSize = 52;
-			
-			// segment with random contents
-			MemorySegment seg = createSegment(segmentSize);
-			byte[] bytes = new byte[segmentSize];
-			random.nextBytes(bytes);
-			seg.put(0, bytes);
-			
-			// out of bounds when writing
-			{
-				DataOutputStream out = new DataOutputStream(new ByteArrayOutputStream());
-					
-				try {
-					seg.get(out, -1, segmentSize / 2);
-					fail("IndexOutOfBoundsException expected");
-				}
-				catch (Exception e) {
-					assertTrue(e instanceof IndexOutOfBoundsException);
-				}
-	
-				try {
-					seg.get(out, segmentSize, segmentSize / 2);
-					fail("IndexOutOfBoundsException expected");
-				}
-				catch (Exception e) {
-					assertTrue(e instanceof IndexOutOfBoundsException);
-				}
-	
-				try {
-					seg.get(out, -segmentSize, segmentSize / 2);
-					fail("IndexOutOfBoundsException expected");
-				}
-				catch (Exception e) {
-					assertTrue(e instanceof IndexOutOfBoundsException);
-				}
-	
-				try {
-					seg.get(out, Integer.MIN_VALUE, segmentSize / 2);
-					fail("IndexOutOfBoundsException expected");
-				}
-				catch (Exception e) {
-					assertTrue(e instanceof IndexOutOfBoundsException);
-				}
-	
-				try {
-					seg.get(out, Integer.MAX_VALUE, segmentSize / 2);
-					fail("IndexOutOfBoundsException expected");
-				}
-				catch (Exception e) {
-					assertTrue(e instanceof IndexOutOfBoundsException);
-				}
-			}
-
-			// out of bounds when reading
-			{
-				DataInputStream in = new DataInputStream(new ByteArrayInputStream(new byte[segmentSize]));
-
-				try {
-					seg.put(in, -1, segmentSize / 2);
-					fail("IndexOutOfBoundsException expected");
-				}
-				catch (Exception e) {
-					assertTrue(e instanceof IndexOutOfBoundsException);
-				}
+	public void testDataInputOutputStreamUnderflowOverflow() throws IOException {
+		final int segmentSize = 1337;
 
-				try {
-					seg.put(in, segmentSize, segmentSize / 2);
-					fail("IndexOutOfBoundsException expected");
-				}
-				catch (Exception e) {
-					assertTrue(e instanceof IndexOutOfBoundsException);
-				}
+		// segment with random contents
+		MemorySegment seg = createSegment(segmentSize);
+		byte[] bytes = new byte[segmentSize];
+		random.nextBytes(bytes);
+		seg.put(0, bytes);
 
-				try {
-					seg.put(in, -segmentSize, segmentSize / 2);
-					fail("IndexOutOfBoundsException expected");
-				}
-				catch (Exception e) {
-					assertTrue(e instanceof IndexOutOfBoundsException);
-				}
+		// a stream that we cannot fully write to
+		DataOutputStream out = new DataOutputStream(new OutputStream() {
 
-				try {
-					seg.put(in, Integer.MIN_VALUE, segmentSize / 2);
-					fail("IndexOutOfBoundsException expected");
-				}
-				catch (Exception e) {
-					assertTrue(e instanceof IndexOutOfBoundsException);
+			int bytesSoFar = 0;
+			@Override
+			public void write(int b) throws IOException {
+				bytesSoFar++;
+				if (bytesSoFar > segmentSize / 2) {
+					throw new IOException("overflow");
 				}
+			}
+		});
 
-				try {
-					seg.put(in, Integer.MAX_VALUE, segmentSize / 2);
-					fail("IndexOutOfBoundsException expected");
-				}
-				catch (Exception e) {
-					assertTrue(e instanceof IndexOutOfBoundsException);
-				}
+		// write the segment in chunks into the stream
+		try {
+			int pos = 0;
+			while (pos < pageSize) {
+				int len = random.nextInt(segmentSize / 10);
+				len = Math.min(len, pageSize - pos);
+				seg.get(out, pos, len);
+				pos += len;
 			}
+			fail("Should fail with an IOException");
 		}
-		catch (Exception e) {
-			e.printStackTrace();
-			fail(e.getMessage());
+		catch (IOException e) {
+			// expected
 		}
-	}
-
-	@Test
-	public void testDataInputOutputStreamUnderflowOverflow() {
-		try {
-			final int segmentSize = 1337;
-
-			// segment with random contents
-			MemorySegment seg = createSegment(segmentSize);
-			byte[] bytes = new byte[segmentSize];
-			random.nextBytes(bytes);
-			seg.put(0, bytes);
-			
-			// a stream that we cannot fully write to
-			DataOutputStream out = new DataOutputStream(new OutputStream() {
-	

<TRUNCATED>

[4/7] flink git commit: [FLINK-7311][tests] refrain from using fail(Exception#getMessage())

Posted by ch...@apache.org.
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 {


[6/7] flink git commit: [FLINK-7311][tests] refrain from using fail(Exception#getMessage())

Posted by ch...@apache.org.
[FLINK-7311][tests] refrain from using fail(Exception#getMessage())

This closes #4446.


Project: http://git-wip-us.apache.org/repos/asf/flink/repo
Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/e83217bd
Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/e83217bd
Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/e83217bd

Branch: refs/heads/master
Commit: e83217bd3205768cc6dbdeead3f7334ce409f6a2
Parents: 223b7b7
Author: Nico Kruber <ni...@data-artisans.com>
Authored: Mon Jul 31 14:36:56 2017 +0200
Committer: zentol <ch...@apache.org>
Committed: Wed Aug 2 14:46:15 2017 +0200

----------------------------------------------------------------------
 .../flink/core/memory/CrossSegmentTypeTest.java |  124 +-
 .../core/memory/EndiannessAccessChecks.java     |   24 +-
 .../core/memory/HeapMemorySegmentTest.java      |   34 +-
 .../memory/HybridOffHeapMemorySegmentTest.java  |   50 +-
 .../memory/HybridOnHeapMemorySegmentTest.java   |   48 +-
 .../core/memory/MemorySegmentTestBase.java      | 3585 +++++++++---------
 .../memory/MemorySegmentUndersizedTest.java     |   61 +-
 .../memory/OperationsOnFreedSegmentTest.java    |  200 +-
 8 files changed, 1927 insertions(+), 2199 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flink/blob/e83217bd/flink-core/src/test/java/org/apache/flink/core/memory/CrossSegmentTypeTest.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/core/memory/CrossSegmentTypeTest.java b/flink-core/src/test/java/org/apache/flink/core/memory/CrossSegmentTypeTest.java
index 724a366..0e3fed5 100644
--- a/flink-core/src/test/java/org/apache/flink/core/memory/CrossSegmentTypeTest.java
+++ b/flink-core/src/test/java/org/apache/flink/core/memory/CrossSegmentTypeTest.java
@@ -37,31 +37,25 @@ public class CrossSegmentTypeTest {
 	
 	@Test
 	public void testCompareBytesMixedSegments() {
-		try {
-			MemorySegment[] segs1 = {
-					new HeapMemorySegment(new byte[pageSize]),
-					new HybridMemorySegment(new byte[pageSize]),
-					new HybridMemorySegment(ByteBuffer.allocateDirect(pageSize))
-			};
-
-			MemorySegment[] segs2 = {
-					new HeapMemorySegment(new byte[pageSize]),
-					new HybridMemorySegment(new byte[pageSize]),
-					new HybridMemorySegment(ByteBuffer.allocateDirect(pageSize))
-			};
-		
-			Random rnd = new Random();
-			
-			for (MemorySegment seg1 : segs1) {
-				for (MemorySegment seg2 : segs2) {
-					testCompare(seg1, seg2, rnd);
-				}
+		MemorySegment[] segs1 = {
+				new HeapMemorySegment(new byte[pageSize]),
+				new HybridMemorySegment(new byte[pageSize]),
+				new HybridMemorySegment(ByteBuffer.allocateDirect(pageSize))
+		};
+
+		MemorySegment[] segs2 = {
+				new HeapMemorySegment(new byte[pageSize]),
+				new HybridMemorySegment(new byte[pageSize]),
+				new HybridMemorySegment(ByteBuffer.allocateDirect(pageSize))
+		};
+
+		Random rnd = new Random();
+
+		for (MemorySegment seg1 : segs1) {
+			for (MemorySegment seg2 : segs2) {
+				testCompare(seg1, seg2, rnd);
 			}
 		}
-		catch (Exception e) {
-			e.printStackTrace();
-			fail(e.getMessage());
-		}
 	}
 	
 	private void testCompare(MemorySegment seg1, MemorySegment seg2, Random random) {
@@ -107,33 +101,27 @@ public class CrossSegmentTypeTest {
 
 	@Test
 	public void testSwapBytesMixedSegments() {
-		try {
-			final int HALF_SIZE = pageSize / 2;
-			
-			MemorySegment[] segs1 = {
-					new HeapMemorySegment(new byte[pageSize]),
-					new HybridMemorySegment(new byte[pageSize]),
-					new HybridMemorySegment(ByteBuffer.allocateDirect(pageSize))
-			};
-
-			MemorySegment[] segs2 = {
-					new HeapMemorySegment(new byte[HALF_SIZE]),
-					new HybridMemorySegment(new byte[HALF_SIZE]),
-					new HybridMemorySegment(ByteBuffer.allocateDirect(HALF_SIZE))
-			};
-
-			Random rnd = new Random();
-
-			for (MemorySegment seg1 : segs1) {
-				for (MemorySegment seg2 : segs2) {
-					testSwap(seg1, seg2, rnd, HALF_SIZE);
-				}
+		final int HALF_SIZE = pageSize / 2;
+
+		MemorySegment[] segs1 = {
+				new HeapMemorySegment(new byte[pageSize]),
+				new HybridMemorySegment(new byte[pageSize]),
+				new HybridMemorySegment(ByteBuffer.allocateDirect(pageSize))
+		};
+
+		MemorySegment[] segs2 = {
+				new HeapMemorySegment(new byte[HALF_SIZE]),
+				new HybridMemorySegment(new byte[HALF_SIZE]),
+				new HybridMemorySegment(ByteBuffer.allocateDirect(HALF_SIZE))
+		};
+
+		Random rnd = new Random();
+
+		for (MemorySegment seg1 : segs1) {
+			for (MemorySegment seg2 : segs2) {
+				testSwap(seg1, seg2, rnd, HALF_SIZE);
 			}
 		}
-		catch (Exception e) {
-			e.printStackTrace();
-			fail(e.getMessage());
-		}
 	}
 	
 	private void testSwap(MemorySegment seg1, MemorySegment seg2, Random random, int smallerSize) {
@@ -169,31 +157,25 @@ public class CrossSegmentTypeTest {
 
 	@Test
 	public void testCopyMixedSegments() {
-		try {
-			MemorySegment[] segs1 = {
-					new HeapMemorySegment(new byte[pageSize]),
-					new HybridMemorySegment(new byte[pageSize]),
-					new HybridMemorySegment(ByteBuffer.allocateDirect(pageSize))
-			};
-
-			MemorySegment[] segs2 = {
-					new HeapMemorySegment(new byte[pageSize]),
-					new HybridMemorySegment(new byte[pageSize]),
-					new HybridMemorySegment(ByteBuffer.allocateDirect(pageSize))
-			};
-
-			Random rnd = new Random();
-
-			for (MemorySegment seg1 : segs1) {
-				for (MemorySegment seg2 : segs2) {
-					testCopy(seg1, seg2, rnd);
-				}
+		MemorySegment[] segs1 = {
+				new HeapMemorySegment(new byte[pageSize]),
+				new HybridMemorySegment(new byte[pageSize]),
+				new HybridMemorySegment(ByteBuffer.allocateDirect(pageSize))
+		};
+
+		MemorySegment[] segs2 = {
+				new HeapMemorySegment(new byte[pageSize]),
+				new HybridMemorySegment(new byte[pageSize]),
+				new HybridMemorySegment(ByteBuffer.allocateDirect(pageSize))
+		};
+
+		Random rnd = new Random();
+
+		for (MemorySegment seg1 : segs1) {
+			for (MemorySegment seg2 : segs2) {
+				testCopy(seg1, seg2, rnd);
 			}
 		}
-		catch (Exception e) {
-			e.printStackTrace();
-			fail(e.getMessage());
-		}
 	}
 
 	private void testCopy(MemorySegment seg1, MemorySegment seg2, Random random) {

http://git-wip-us.apache.org/repos/asf/flink/blob/e83217bd/flink-core/src/test/java/org/apache/flink/core/memory/EndiannessAccessChecks.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/core/memory/EndiannessAccessChecks.java b/flink-core/src/test/java/org/apache/flink/core/memory/EndiannessAccessChecks.java
index 4c92234..c06562a 100644
--- a/flink-core/src/test/java/org/apache/flink/core/memory/EndiannessAccessChecks.java
+++ b/flink-core/src/test/java/org/apache/flink/core/memory/EndiannessAccessChecks.java
@@ -28,35 +28,17 @@ public class EndiannessAccessChecks {
 	
 	@Test
 	public void testHeapSegment() {
-		try {
-			testBigAndLittleEndianAccessUnaligned(new HeapMemorySegment(new byte[11111]));
-		}
-		catch (Exception e) {
-			e.printStackTrace();
-			fail(e.getMessage());
-		}
+		testBigAndLittleEndianAccessUnaligned(new HeapMemorySegment(new byte[11111]));
 	}
 
 	@Test
 	public void testHybridOnHeapSegment() {
-		try {
-			testBigAndLittleEndianAccessUnaligned(new HybridMemorySegment(new byte[11111]));
-		}
-		catch (Exception e) {
-			e.printStackTrace();
-			fail(e.getMessage());
-		}
+		testBigAndLittleEndianAccessUnaligned(new HybridMemorySegment(new byte[11111]));
 	}
 
 	@Test
 	public void testHybridOffHeapSegment() {
-		try {
-			testBigAndLittleEndianAccessUnaligned(new HybridMemorySegment(ByteBuffer.allocateDirect(11111)));
-		}
-		catch (Exception e) {
-			e.printStackTrace();
-			fail(e.getMessage());
-		}
+		testBigAndLittleEndianAccessUnaligned(new HybridMemorySegment(ByteBuffer.allocateDirect(11111)));
 	}
 	
 	private void testBigAndLittleEndianAccessUnaligned(MemorySegment segment) {

http://git-wip-us.apache.org/repos/asf/flink/blob/e83217bd/flink-core/src/test/java/org/apache/flink/core/memory/HeapMemorySegmentTest.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/core/memory/HeapMemorySegmentTest.java b/flink-core/src/test/java/org/apache/flink/core/memory/HeapMemorySegmentTest.java
index d7a5b03..b2c16d9 100644
--- a/flink-core/src/test/java/org/apache/flink/core/memory/HeapMemorySegmentTest.java
+++ b/flink-core/src/test/java/org/apache/flink/core/memory/HeapMemorySegmentTest.java
@@ -45,27 +45,21 @@ public class HeapMemorySegmentTest extends MemorySegmentTestBase {
 	
 	@Test
 	public void testHeapSegmentSpecifics() {
-		try {
-			final byte[] buffer = new byte[411];
-			HeapMemorySegment seg = new HeapMemorySegment(buffer);
-			
-			assertFalse(seg.isFreed());
-			assertFalse(seg.isOffHeap());
-			assertEquals(buffer.length, seg.size());
-			assertTrue(buffer == seg.getArray());
+		final byte[] buffer = new byte[411];
+		HeapMemorySegment seg = new HeapMemorySegment(buffer);
 
-			ByteBuffer buf1 = seg.wrap(1, 2);
-			ByteBuffer buf2 = seg.wrap(3, 4);
+		assertFalse(seg.isFreed());
+		assertFalse(seg.isOffHeap());
+		assertEquals(buffer.length, seg.size());
+		assertTrue(buffer == seg.getArray());
 
-			assertTrue(buf1 != buf2);
-			assertEquals(1, buf1.position());
-			assertEquals(3, buf1.limit());
-			assertEquals(3, buf2.position());
-			assertEquals(7, buf2.limit());
-		}
-		catch (Exception e) {
-			e.printStackTrace();
-			fail(e.getMessage());
-		}
+		ByteBuffer buf1 = seg.wrap(1, 2);
+		ByteBuffer buf2 = seg.wrap(3, 4);
+
+		assertTrue(buf1 != buf2);
+		assertEquals(1, buf1.position());
+		assertEquals(3, buf1.limit());
+		assertEquals(3, buf2.position());
+		assertEquals(7, buf2.limit());
 	}
 }

http://git-wip-us.apache.org/repos/asf/flink/blob/e83217bd/flink-core/src/test/java/org/apache/flink/core/memory/HybridOffHeapMemorySegmentTest.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/core/memory/HybridOffHeapMemorySegmentTest.java b/flink-core/src/test/java/org/apache/flink/core/memory/HybridOffHeapMemorySegmentTest.java
index b09697e..cf2d023 100644
--- a/flink-core/src/test/java/org/apache/flink/core/memory/HybridOffHeapMemorySegmentTest.java
+++ b/flink-core/src/test/java/org/apache/flink/core/memory/HybridOffHeapMemorySegmentTest.java
@@ -48,37 +48,31 @@ public class HybridOffHeapMemorySegmentTest extends MemorySegmentTestBase {
 
 	@Test
 	public void testHybridHeapSegmentSpecifics() {
-		try {
-			final ByteBuffer buffer = ByteBuffer.allocateDirect(411);
-			HybridMemorySegment seg = new HybridMemorySegment(buffer);
-
-			assertFalse(seg.isFreed());
-			assertTrue(seg.isOffHeap());
-			assertEquals(buffer.capacity(), seg.size());
-			assertTrue(buffer == seg.getOffHeapBuffer());
-
-			try {
-				seg.getArray();
-				fail("should throw an exception");
-			}
-			catch (IllegalStateException e) {
-				// expected
-			}
+		final ByteBuffer buffer = ByteBuffer.allocateDirect(411);
+		HybridMemorySegment seg = new HybridMemorySegment(buffer);
 
-			ByteBuffer buf1 = seg.wrap(1, 2);
-			ByteBuffer buf2 = seg.wrap(3, 4);
+		assertFalse(seg.isFreed());
+		assertTrue(seg.isOffHeap());
+		assertEquals(buffer.capacity(), seg.size());
+		assertTrue(buffer == seg.getOffHeapBuffer());
 
-			assertTrue(buf1 != buffer);
-			assertTrue(buf2 != buffer);
-			assertTrue(buf1 != buf2);
-			assertEquals(1, buf1.position());
-			assertEquals(3, buf1.limit());
-			assertEquals(3, buf2.position());
-			assertEquals(7, buf2.limit());
+		try {
+			seg.getArray();
+			fail("should throw an exception");
 		}
-		catch (Exception e) {
-			e.printStackTrace();
-			fail(e.getMessage());
+		catch (IllegalStateException e) {
+			// expected
 		}
+
+		ByteBuffer buf1 = seg.wrap(1, 2);
+		ByteBuffer buf2 = seg.wrap(3, 4);
+
+		assertTrue(buf1 != buffer);
+		assertTrue(buf2 != buffer);
+		assertTrue(buf1 != buf2);
+		assertEquals(1, buf1.position());
+		assertEquals(3, buf1.limit());
+		assertEquals(3, buf2.position());
+		assertEquals(7, buf2.limit());
 	}
 }

http://git-wip-us.apache.org/repos/asf/flink/blob/e83217bd/flink-core/src/test/java/org/apache/flink/core/memory/HybridOnHeapMemorySegmentTest.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/core/memory/HybridOnHeapMemorySegmentTest.java b/flink-core/src/test/java/org/apache/flink/core/memory/HybridOnHeapMemorySegmentTest.java
index 55d333e..711326f 100644
--- a/flink-core/src/test/java/org/apache/flink/core/memory/HybridOnHeapMemorySegmentTest.java
+++ b/flink-core/src/test/java/org/apache/flink/core/memory/HybridOnHeapMemorySegmentTest.java
@@ -48,35 +48,29 @@ public class HybridOnHeapMemorySegmentTest extends MemorySegmentTestBase {
 	
 	@Test
 	public void testHybridHeapSegmentSpecifics() {
-		try {
-			final byte[] buffer = new byte[411];
-			HybridMemorySegment seg = new HybridMemorySegment(buffer);
+		final byte[] buffer = new byte[411];
+		HybridMemorySegment seg = new HybridMemorySegment(buffer);
+
+		assertFalse(seg.isFreed());
+		assertFalse(seg.isOffHeap());
+		assertEquals(buffer.length, seg.size());
+		assertTrue(buffer == seg.getArray());
 
-			assertFalse(seg.isFreed());
-			assertFalse(seg.isOffHeap());
-			assertEquals(buffer.length, seg.size());
-			assertTrue(buffer == seg.getArray());
-			
-			try {
-				seg.getOffHeapBuffer();
-				fail("should throw an exception");
-			}
-			catch (IllegalStateException e) {
-				// expected
-			}
-			
-			ByteBuffer buf1 = seg.wrap(1, 2);
-			ByteBuffer buf2 = seg.wrap(3, 4);
-			
-			assertTrue(buf1 != buf2);
-			assertEquals(1, buf1.position());
-			assertEquals(3, buf1.limit());
-			assertEquals(3, buf2.position());
-			assertEquals(7, buf2.limit());
+		try {
+			seg.getOffHeapBuffer();
+			fail("should throw an exception");
 		}
-		catch (Exception e) {
-			e.printStackTrace();
-			fail(e.getMessage());
+		catch (IllegalStateException e) {
+			// expected
 		}
+
+		ByteBuffer buf1 = seg.wrap(1, 2);
+		ByteBuffer buf2 = seg.wrap(3, 4);
+
+		assertTrue(buf1 != buf2);
+		assertEquals(1, buf1.position());
+		assertEquals(3, buf1.limit());
+		assertEquals(3, buf2.position());
+		assertEquals(7, buf2.limit());
 	}
 }