logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgo...@apache.org
Subject svn commit: r1364407 - in /logging/log4j/log4j2/trunk/api/src: main/java/org/apache/logging/log4j/message/ThreadDumpMessage.java test/java/org/apache/logging/log4j/message/ThreadDumpMessageTest.java
Date Sun, 22 Jul 2012 19:40:21 GMT
Author: rgoers
Date: Sun Jul 22 19:40:21 2012
New Revision: 1364407

URL: http://svn.apache.org/viewvc?rev=1364407&view=rev
Log:
Add toString method to ThreadDumpMessage

Modified:
    logging/log4j/log4j2/trunk/api/src/main/java/org/apache/logging/log4j/message/ThreadDumpMessage.java
    logging/log4j/log4j2/trunk/api/src/test/java/org/apache/logging/log4j/message/ThreadDumpMessageTest.java

Modified: logging/log4j/log4j2/trunk/api/src/main/java/org/apache/logging/log4j/message/ThreadDumpMessage.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/api/src/main/java/org/apache/logging/log4j/message/ThreadDumpMessage.java?rev=1364407&r1=1364406&r2=1364407&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/api/src/main/java/org/apache/logging/log4j/message/ThreadDumpMessage.java
(original)
+++ logging/log4j/log4j2/trunk/api/src/main/java/org/apache/logging/log4j/message/ThreadDumpMessage.java
Sun Jul 22 19:40:21 2012
@@ -72,7 +72,17 @@ public class ThreadDumpMessage implement
 
     private ThreadDumpMessage(String formattedMsg, String title) {
         this.formattedMessage = formattedMsg;
-        this.title = title;
+        this.title = title == null ? "" : title;
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder("ThreadDumpMessage[");
+        if (this.title.length() > 0) {
+            sb.append("Title=\"").append(this.title).append("\"");
+        }
+        sb.append("]");
+        return sb.toString();
     }
 
     /**

Modified: logging/log4j/log4j2/trunk/api/src/test/java/org/apache/logging/log4j/message/ThreadDumpMessageTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/api/src/test/java/org/apache/logging/log4j/message/ThreadDumpMessageTest.java?rev=1364407&r1=1364406&r2=1364407&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/api/src/test/java/org/apache/logging/log4j/message/ThreadDumpMessageTest.java
(original)
+++ logging/log4j/log4j2/trunk/api/src/test/java/org/apache/logging/log4j/message/ThreadDumpMessageTest.java
Sun Jul 22 19:40:21 2012
@@ -20,6 +20,7 @@ import org.junit.Test;
 
 import java.util.concurrent.locks.ReentrantLock;
 
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
 /**
@@ -66,6 +67,13 @@ public class ThreadDumpMessageTest {
         //assertTrue("No syncronizers", message.contains("locked syncrhonizers"));
     }
 
+    @Test
+    public void testToString() {
+        ThreadDumpMessage msg = new ThreadDumpMessage("Test");
+        String expected = "ThreadDumpMessage[Title=\"Test\"]";
+        assertEquals(expected, msg.toString());
+    }
+
     private class Thread1 extends Thread {
         private ReentrantLock lock;
 



Mime
View raw message