logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgo...@apache.org
Subject svn commit: r1175691 - /logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/test/java/org/apache/logging/log4j/message/ThreadDumpMessageTest.java
Date Mon, 26 Sep 2011 06:48:07 GMT
Author: rgoers
Date: Mon Sep 26 06:48:07 2011
New Revision: 1175691

URL: http://svn.apache.org/viewvc?rev=1175691&view=rev
Log:
Enhance test in preparation for showing locks.

Modified:
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/test/java/org/apache/logging/log4j/message/ThreadDumpMessageTest.java

Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/test/java/org/apache/logging/log4j/message/ThreadDumpMessageTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/test/java/org/apache/logging/log4j/message/ThreadDumpMessageTest.java?rev=1175691&r1=1175690&r2=1175691&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/test/java/org/apache/logging/log4j/message/ThreadDumpMessageTest.java
(original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/test/java/org/apache/logging/log4j/message/ThreadDumpMessageTest.java
Mon Sep 26 06:48:07 2011
@@ -18,6 +18,8 @@ package org.apache.logging.log4j.message
 
 import org.junit.Test;
 
+import java.util.concurrent.locks.ReentrantLock;
+
 import static org.junit.Assert.assertTrue;
 
 /**
@@ -35,4 +37,27 @@ public class ThreadDumpMessageTest {
         assertTrue("No RUNNABLE", message.contains("RUNNABLE"));
         assertTrue("No ThreadDumpMessage", message.contains("ThreadDumpMessage"));
     }
+
+
+    @Test
+    public void testMessageWithLocks() {
+        ReentrantLock lock = new ReentrantLock();
+        lock.lock();
+        ThreadDumpMessage msg;
+        synchronized(this) {
+            try {
+                msg = new ThreadDumpMessage("Testing"/* , true */);
+            } finally {
+                lock.unlock();
+            }
+        }
+
+        String message = msg.getFormattedMessage();
+        //System.out.print(message);
+        assertTrue("No header", message.contains("Testing"));
+        assertTrue("No RUNNABLE", message.contains("RUNNABLE"));
+        assertTrue("No ThreadDumpMessage", message.contains("ThreadDumpMessage"));
+        //assertTrue("No Locks", message.contains("waiting on"));
+        //assertTrue("No syncronizers", message.contains("locked syncrhonizers"));
+    }
 }



Mime
View raw message