Author: stain
Date: Wed Sep 21 14:02:47 2016
New Revision: 1761745

URL: http://svn.apache.org/viewvc?rev=1761745&view=rev
Log:
Use Assume.assumeFalse instead of throwing exception

as having "too much memory" for a test is not a bug :)

Modified:
    
commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/converters/MemoryTestCase.java
    
commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/memoryleaktests/MemoryLeakTestCase.java

Modified: 
commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/converters/MemoryTestCase.java
URL: 
http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/converters/MemoryTestCase.java?rev=1761745&r1=1761744&r2=1761745&view=diff
==============================================================================
--- 
commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/converters/MemoryTestCase.java
 (original)
+++ 
commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/converters/MemoryTestCase.java
 Wed Sep 21 14:02:47 2016
@@ -18,11 +18,10 @@
 package org.apache.commons.beanutils.converters;
 
 import java.lang.ref.WeakReference;
-
-import junit.framework.TestCase;
-
+import static org.junit.Assert.*;
 import org.apache.commons.beanutils.ConvertUtils;
 import org.apache.commons.beanutils.Converter;
+import org.junit.Test;
 
 /**
  * This class provides a number of unit tests related to classloaders and
@@ -30,8 +29,9 @@ import org.apache.commons.beanutils.Conv
  *
  * @version $Id$
  */
-public class MemoryTestCase extends TestCase {
+public class MemoryTestCase {
 
+    @Test
     public void testWeakReference() throws Exception {
         final ClassLoader origContextClassLoader = 
Thread.currentThread().getContextClassLoader();
         try {
@@ -72,6 +72,7 @@ public class MemoryTestCase extends Test
      * </ul>
      *
      */
+    @Test
     public void testComponentRegistersStandardConverter() throws Exception {
 
         final ClassLoader origContextClassLoader = 
Thread.currentThread().getContextClassLoader();
@@ -161,6 +162,7 @@ public class MemoryTestCase extends Test
      * </ul>
      *
      */
+    @Test
     public void testComponentRegistersCustomConverter() throws Exception {
 
         final ClassLoader origContextClassLoader = 
Thread.currentThread().getContextClassLoader();

Modified: 
commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/memoryleaktests/MemoryLeakTestCase.java
URL: 
http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/memoryleaktests/MemoryLeakTestCase.java?rev=1761745&r1=1761744&r2=1761745&view=diff
==============================================================================
--- 
commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/memoryleaktests/MemoryLeakTestCase.java
 (original)
+++ 
commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/memoryleaktests/MemoryLeakTestCase.java
 Wed Sep 21 14:02:47 2016
@@ -34,8 +34,9 @@ import org.apache.commons.beanutils.conv
 import org.apache.commons.beanutils.locale.LocaleBeanUtilsBean;
 import org.apache.commons.beanutils.locale.LocaleConvertUtils;
 import org.apache.commons.beanutils.locale.converters.IntegerLocaleConverter;
-
-import junit.framework.TestCase;
+import org.junit.Assume;
+import org.junit.Test;
+import static org.junit.Assert.*;
 
 /**
  * Tests BeanUtils memory leaks.
@@ -44,11 +45,12 @@ import junit.framework.TestCase;
  *
  * @version $Id$
  */
-public class MemoryLeakTestCase extends TestCase {
+public class MemoryLeakTestCase {
 
     /**
      * Tests that PropertyUtilsBean's descriptorsCache doesn't cause a memory 
leak.
      */
+    @Test
     public void testPropertyUtilsBean_descriptorsCache_memoryLeak() throws 
Exception {
 
         // Clear All BeanUtils caches before the test
@@ -95,6 +97,7 @@ public class MemoryLeakTestCase extends
     /**
      * Tests that PropertyUtilsBean's mappedDescriptorsCache doesn't cause a 
memory leak.
      */
+    @Test
     public void testPropertyUtilsBean_mappedDescriptorsCache_memoryLeak() 
throws Exception {
 
         // Clear All BeanUtils caches before the test
@@ -148,6 +151,7 @@ public class MemoryLeakTestCase extends
      * Tests that MappedPropertyDescriptor can re-create the Method reference 
after it
      * has been garbage collected.
      */
+    @Test
     public void testMappedPropertyDescriptor_MappedMethodReference1() throws 
Exception {
 
         // Clear All BeanUtils caches before the test
@@ -193,6 +197,7 @@ public class MemoryLeakTestCase extends
      * Tests that MappedPropertyDescriptor can re-create the Method reference 
after it
      * has been garbage collected.
      */
+    @Test
     public void testMappedPropertyDescriptor_MappedMethodReference2() throws 
Exception {
 
         // Clear All BeanUtils caches before the test
@@ -242,6 +247,7 @@ public class MemoryLeakTestCase extends
     /**
      * Tests that MethodUtils's cache doesn't cause a memory leak.
      */
+    @Test
     public void testMethodUtils_cache_memoryLeak() throws Exception {
 
         // Clear All BeanUtils caches before the test
@@ -288,6 +294,7 @@ public class MemoryLeakTestCase extends
     /**
      * Tests that WrapDynaClass's dynaClasses doesn't cause a memory leak.
      */
+    @Test
     public void testWrapDynaClass_dynaClasses_memoryLeak() throws Exception {
 
         // Clear All BeanUtils caches before the test
@@ -340,6 +347,7 @@ public class MemoryLeakTestCase extends
     /**
      * Tests that ConvertUtilsBean's converters doesn't cause a memory leak.
      */
+    @Test
     public void testConvertUtilsBean_converters_memoryLeak() throws Exception {
 
         // Clear All BeanUtils caches before the test
@@ -387,6 +395,7 @@ public class MemoryLeakTestCase extends
     /**
      * Tests that LocaleConvertUtilsBean's converters doesn't cause a memory 
leak.
      */
+    @Test
     public void testLocaleConvertUtilsBean_converters_memoryLeak() throws 
Exception {
 
         // Clear All BeanUtils caches before the test
@@ -487,9 +496,8 @@ public class MemoryLeakTestCase extends
 
         final boolean isNotNull = ref.get() != null;
         System.out.println("Count " + count+ " " + isNotNull); // debug for 
Continuum failure
-        if (isNotNull) {
-            throw new IllegalStateException("Your JVM is not releasing 
SoftReference, try running the testcase with less memory (-Xmx)");
-        }
+        String message = "Your JVM is not releasing SoftReference, try running 
the testcase with less memory (-Xmx)";
+        Assume.assumeFalse(message, isNotNull);
     }
 
     /**


Reply via email to