[FLINK-2235] Fix tests to allow exception in 
'EnvironmentInformationTest.getSizeOfFreeHeapMemory()' if Xmx is not set.


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

Branch: refs/heads/master
Commit: b0b0cb50d63e2f831196fc9219858467a07d8302
Parents: 910e8c4
Author: Stephan Ewen <[email protected]>
Authored: Mon Jul 13 16:22:04 2015 +0200
Committer: Stephan Ewen <[email protected]>
Committed: Mon Jul 13 17:54:31 2015 +0200

----------------------------------------------------------------------
 .../flink/runtime/util/EnvironmentInformationTest.java  | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flink/blob/b0b0cb50/flink-runtime/src/test/java/org/apache/flink/runtime/util/EnvironmentInformationTest.java
----------------------------------------------------------------------
diff --git 
a/flink-runtime/src/test/java/org/apache/flink/runtime/util/EnvironmentInformationTest.java
 
b/flink-runtime/src/test/java/org/apache/flink/runtime/util/EnvironmentInformationTest.java
index 771c57c..3890a81 100644
--- 
a/flink-runtime/src/test/java/org/apache/flink/runtime/util/EnvironmentInformationTest.java
+++ 
b/flink-runtime/src/test/java/org/apache/flink/runtime/util/EnvironmentInformationTest.java
@@ -30,12 +30,20 @@ public class EnvironmentInformationTest {
        public void testJavaMemory() {
                try {
                        long fullHeap = 
EnvironmentInformation.getMaxJvmHeapMemory();
-                       long free = 
EnvironmentInformation.getSizeOfFreeHeapMemory();
                        long freeWithGC = 
EnvironmentInformation.getSizeOfFreeHeapMemoryWithDefrag();
                        
                        assertTrue(fullHeap > 0);
-                       assertTrue(free >= 0);
                        assertTrue(freeWithGC >= 0);
+
+                       try {
+                               long free = 
EnvironmentInformation.getSizeOfFreeHeapMemory();
+                               assertTrue(free >= 0);
+                       }
+                       catch (RuntimeException e) {
+                               // this may only occur if the Xmx is not set
+                               assertEquals(Long.MAX_VALUE, 
EnvironmentInformation.getMaxJvmHeapMemory());
+                       }
+                       
                        
                        // we cannot make these assumptions, because the test 
JVM may grow / shrink during the GC
                        // assertTrue(free <= fullHeap);

Reply via email to