commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From joe...@apache.org
Subject svn commit: r802569 - in /commons/proper/lang/trunk/src: java/org/apache/commons/lang/exception/ test/org/apache/commons/lang/exception/
Date Sun, 09 Aug 2009 18:06:58 GMT
Author: joehni
Date: Sun Aug  9 18:06:58 2009
New Revision: 802569

URL: http://svn.apache.org/viewvc?rev=802569&view=rev
Log:
Fix failing unit test of Contexted(Runtime)Exception, adjust formatted message.

Modified:
    commons/proper/lang/trunk/src/java/org/apache/commons/lang/exception/DefaultExceptionContext.java
    commons/proper/lang/trunk/src/test/org/apache/commons/lang/exception/ContextedExceptionTest.java
    commons/proper/lang/trunk/src/test/org/apache/commons/lang/exception/ContextedRuntimeExceptionTest.java

Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/exception/DefaultExceptionContext.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/exception/DefaultExceptionContext.java?rev=802569&r1=802568&r2=802569&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/java/org/apache/commons/lang/exception/DefaultExceptionContext.java
(original)
+++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/exception/DefaultExceptionContext.java
Sun Aug  9 18:06:58 2009
@@ -93,7 +93,9 @@
         }
         
         if (contextKeyList.size() > 0) {
-            buffer.append(SystemUtils.LINE_SEPARATOR);                 
+            if (buffer.length() > 0l) {
+                buffer.append(SystemUtils.LINE_SEPARATOR);
+            }
             buffer.append("Exception Context:");
             buffer.append(SystemUtils.LINE_SEPARATOR); 
             buffer.append("\t");  
@@ -120,8 +122,7 @@
                 buffer.append(SystemUtils.LINE_SEPARATOR);  
                 buffer.append("\t");  
             }
-            buffer.append(SystemUtils.LINE_SEPARATOR);
-            buffer.append("\t---------------------------------");
+            buffer.append("---------------------------------");
         }
         return buffer.toString();
     }

Modified: commons/proper/lang/trunk/src/test/org/apache/commons/lang/exception/ContextedExceptionTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/org/apache/commons/lang/exception/ContextedExceptionTest.java?rev=802569&r1=802568&r2=802569&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/test/org/apache/commons/lang/exception/ContextedExceptionTest.java
(original)
+++ commons/proper/lang/trunk/src/test/org/apache/commons/lang/exception/ContextedExceptionTest.java
Sun Aug  9 18:06:58 2009
@@ -102,10 +102,6 @@
         assertTrue(message.indexOf("5")>=0);
         assertTrue(message.indexOf("Crap")>=0);
         
-        String contextMessage = contextedException.getFormattedExceptionMessage("");
-        assertTrue(contextMessage.indexOf(TEST_MESSAGE) == -1);
-        assertTrue(message.contains(contextMessage));
-        
         assertTrue(contextedException.getLabeledValue("test1") == null);
         assertTrue(contextedException.getLabeledValue("test2").equals("some value"));
         assertTrue(contextedException.getLabeledValue("crap") == null);
@@ -119,6 +115,12 @@
         assertTrue(contextedException.getLabelSet().contains("test Poorly written obj"));
         
         assertTrue(!contextedException.getLabelSet().contains("crap"));
+
+        contextedException.addLabeledValue("test Poorly written obj", "replacement");
+        
+        String contextMessage = contextedException.getFormattedExceptionMessage(null);
+        assertTrue(contextMessage.indexOf(TEST_MESSAGE) == -1);
+        assertTrue(contextedException.getMessage().endsWith(contextMessage));
     }
     
     public void testNullExceptionPassing() {

Modified: commons/proper/lang/trunk/src/test/org/apache/commons/lang/exception/ContextedRuntimeExceptionTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/org/apache/commons/lang/exception/ContextedRuntimeExceptionTest.java?rev=802569&r1=802568&r2=802569&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/test/org/apache/commons/lang/exception/ContextedRuntimeExceptionTest.java
(original)
+++ commons/proper/lang/trunk/src/test/org/apache/commons/lang/exception/ContextedRuntimeExceptionTest.java
Sun Aug  9 18:06:58 2009
@@ -102,10 +102,6 @@
         assertTrue(message.indexOf("5")>=0);
         assertTrue(message.indexOf("Crap")>=0);
         
-        String contextMessage = contextedRuntimeException.getFormattedExceptionMessage("");
-        assertTrue(contextMessage.indexOf(TEST_MESSAGE) == -1);
-        assertTrue(message.contains(contextMessage));
-        
         assertTrue(contextedRuntimeException.getLabeledValue("test1") == null);
         assertTrue(contextedRuntimeException.getLabeledValue("test2").equals("some value"));
         assertTrue(contextedRuntimeException.getLabeledValue("crap") == null);
@@ -119,6 +115,12 @@
         assertTrue(contextedRuntimeException.getLabelSet().contains("test Poorly written
obj"));
         
         assertTrue(!contextedRuntimeException.getLabelSet().contains("crap"));
+
+        contextedRuntimeException.addLabeledValue("test Poorly written obj", "replacement");
+        
+        String contextMessage = contextedRuntimeException.getFormattedExceptionMessage(null);
+        assertTrue(contextMessage.indexOf(TEST_MESSAGE) == -1);
+        assertTrue(contextedRuntimeException.getMessage().endsWith(contextMessage));
     }
     
     public void testNullExceptionPassing() {



Mime
View raw message