You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by gg...@apache.org on 2005/02/24 21:26:07 UTC

svn commit: r155236 - jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/exception/ExceptionUtilsTestCase.java

Author: ggregory
Date: Thu Feb 24 12:26:06 2005
New Revision: 155236

URL: http://svn.apache.org/viewcvs?view=rev&rev=155236
Log:
Fixes http://issues.apache.org/bugzilla/show_bug.cgi?id=33737.
[lang] ExceptionUtils.addCauseMethodName(String) does not check for duplicates.
Fix adds:
 ExceptionUtils.removeCauseMethodName(String)
 ExceptionUtils.isCauseMethodName(String)

Modified:
    jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/exception/ExceptionUtilsTestCase.java

Modified: jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/exception/ExceptionUtilsTestCase.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/exception/ExceptionUtilsTestCase.java?view=diff&r1=155235&r2=155236
==============================================================================
--- jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/exception/ExceptionUtilsTestCase.java (original)
+++ jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/exception/ExceptionUtilsTestCase.java Thu Feb 24 12:26:06 2005
@@ -22,6 +22,7 @@
 import java.lang.reflect.InvocationTargetException;
 import java.sql.SQLException;
 
+import junit.framework.Assert;
 import junit.framework.Test;
 import junit.framework.TestSuite;
 import org.apache.commons.lang.SystemUtils;
@@ -32,6 +33,7 @@
  * @author <a href="mailto:dlr@finemaltcoding.com">Daniel Rall</a>
  * @author <a href="mailto:steven@caswell.name">Steven Caswell</a>
  * @author Stephen Colebourne
+ * @author <a href="mailto:ggregory@seagullsw.com">Gary Gregory</a>
  * @since 1.0
  */
 public class ExceptionUtilsTestCase extends junit.framework.TestCase {
@@ -76,6 +78,30 @@
     }
 
     //-----------------------------------------------------------------------
+    
+    public void testCauseMethodNameOps() {
+        this.testCauseMethodNameOps(null);
+        this.testCauseMethodNameOps("");
+        this.testCauseMethodNameOps(" ");
+        this.testCauseMethodNameOps("\t\r\n\t");
+        this.testCauseMethodNameOps("testMethodName");
+    }
+    
+    void testCauseMethodNameOps(String name) {
+        String methodName = "testMethodName";
+        try {
+            Assert.assertFalse(ExceptionUtils.isCauseMethodName(methodName));
+            ExceptionUtils.addCauseMethodName(methodName);            
+            ExceptionUtils.addCauseMethodName(methodName);            
+            Assert.assertTrue(ExceptionUtils.isCauseMethodName(methodName));
+        } finally {
+            ExceptionUtils.removeCauseMethodName(methodName);
+            Assert.assertFalse(
+                    "The method name " + methodName + " should not be in the array", 
+                    ExceptionUtils.isCauseMethodName(methodName));
+        }
+    }
+    
     public void testGetCause_Throwable() {
         assertSame(null, ExceptionUtils.getCause(null));
         assertSame(null, ExceptionUtils.getCause(withoutCause));



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org