You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ro...@apache.org on 2010/09/01 17:06:24 UTC

svn commit: r991561 [1/2] - in /qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid: management/jmx/ server/ server/logging/ server/queue/

Author: robbie
Date: Wed Sep  1 15:06:24 2010
New Revision: 991561

URL: http://svn.apache.org/viewvc?rev=991561&view=rev
Log:
QPID-2838: add common code for repeated validations within test classes, helper methods for log scraping/dumping

Modified:
    qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/ManagementActorLoggingTest.java
    qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/BrokerStartupTest.java
    qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/AbstractTestLogging.java
    qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/AccessControlLoggingTest.java
    qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/AlertingTest.java
    qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/BindingLoggingTest.java
    qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/BrokerLoggingTest.java
    qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ChannelLoggingTest.java
    qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ConnectionLoggingTest.java
    qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/DerbyMessageStoreLoggingTest.java
    qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/DurableQueueLoggingTest.java
    qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ExchangeLoggingTest.java
    qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ManagementLoggingTest.java
    qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/MemoryMessageStoreLoggingTest.java
    qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/QueueLoggingTest.java
    qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/SubscriptionLoggingTest.java
    qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/VirtualHostLoggingTest.java
    qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/ProducerFlowControlTest.java

Modified: qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/ManagementActorLoggingTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/ManagementActorLoggingTest.java?rev=991561&r1=991560&r2=991561&view=diff
==============================================================================
--- qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/ManagementActorLoggingTest.java (original)
+++ qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/ManagementActorLoggingTest.java Wed Sep  1 15:06:24 2010
@@ -93,11 +93,11 @@ public class ManagementActorLoggingTest 
      */
     public void testJMXManagementConsoleConnection() throws IOException
     {
-        List<String> results = _monitor.waitAndFindMatches("MNG-1007", DEFAULT_LOG_WAIT);
+        List<String> results = waitAndFindMatches("MNG-1007");
 
         assertEquals("Unexpected Management Connection count", 1, results.size());
 
-        String log = getLog(results.get(0));
+        String log = getLogMessage(results, 0);
 
         validateMessageID("MNG-1007", log);
 
@@ -106,14 +106,14 @@ public class ManagementActorLoggingTest 
         //  MESSAGE [mng:1(rmi://169.24.29.116)] MNG-1007 : Open : User admin
         int connectionID = Integer.parseInt(fromActor(getLog(results.get(0))).charAt(4) + "");
 
-        results = _monitor.findMatches("MNG-1008");
+        results = findMatches("MNG-1008");
 
         assertEquals("Unexpected Management Connection close count", 0, results.size());
 
         _jmxUtils.close();
         _closed  = true;
         
-        results = _monitor.waitAndFindMatches("MNG-1008", DEFAULT_LOG_WAIT);
+        results = waitAndFindMatches("MNG-1008");
 
         assertEquals("Unexpected Management Connection count", 1, results.size());
 
@@ -174,7 +174,7 @@ public class ManagementActorLoggingTest 
                    exceptionReceived.await(2, TimeUnit.SECONDS));
 
         //Validate results
-        List<String> results = _monitor.waitAndFindMatches("CON-1002", DEFAULT_LOG_WAIT);
+        List<String> results = waitAndFindMatches("CON-1002");
 
         assertEquals("Unexpected Connection Close count", 1, results.size());
     }
@@ -209,11 +209,11 @@ public class ManagementActorLoggingTest 
         // Validate
 
         //1 - ID is correct
-        List<String> results = _monitor.waitAndFindMatches("EXH-1001", DEFAULT_LOG_WAIT);
+        List<String> results = waitAndFindMatches("EXH-1001");
 
         assertEquals("More than one exchange creation found", 1, results.size());
 
-        String log = getLog(results.get(0));
+        String log = getLogMessage(results, 0);
 
         // Validate correct exchange name
         assertTrue("Incorrect exchange name created:" + log, log.endsWith(getName()));
@@ -233,11 +233,11 @@ public class ManagementActorLoggingTest 
         // Validate
 
         //1 - ID is correct
-        List<String> results = _monitor.waitAndFindMatches("EXH-1001", DEFAULT_LOG_WAIT);
+        List<String> results = waitAndFindMatches("EXH-1001");
 
         assertEquals("More than one exchange creation found", 1, results.size());
 
-        String log = getLog(results.get(0));
+        String log = getLogMessage(results, 0);
 
         // Validate correct exchange name
         assertTrue("Incorrect exchange name created:" + log, log.endsWith(getName()));
@@ -258,11 +258,11 @@ public class ManagementActorLoggingTest 
         // Validate
 
         //1 - ID is correct
-        List<String> results = _monitor.waitAndFindMatches("EXH-1001", DEFAULT_LOG_WAIT);
+        List<String> results = waitAndFindMatches("EXH-1001");
 
         assertEquals("More than one exchange creation found", 1, results.size());
 
-        String log = getLog(results.get(0));
+        String log = getLogMessage(results, 0);
 
         // Validate correct exchange name
         assertTrue("Incorrect exchange name created:" + log, log.endsWith(getName()));
@@ -283,11 +283,11 @@ public class ManagementActorLoggingTest 
         // Validate
 
         //1 - ID is correct
-        List<String> results = _monitor.waitAndFindMatches("EXH-1001", DEFAULT_LOG_WAIT);
+        List<String> results = waitAndFindMatches("EXH-1001");
 
         assertEquals("More than one exchange creation found", 1, results.size());
 
-        String log = getLog(results.get(0));
+        String log = getLogMessage(results, 0);
 
         // Validate correct exchange name
         assertTrue("Incorrect exchange name created:" + log, log.endsWith(getName()));
@@ -326,11 +326,11 @@ public class ManagementActorLoggingTest 
 
         // Validate
 
-        List<String> results = _monitor.waitAndFindMatches("QUE-1001", DEFAULT_LOG_WAIT);
+        List<String> results = waitAndFindMatches("QUE-1001");
 
         assertEquals("More than one queue creation found", 1, results.size());
 
-        String log = getLog(results.get(0));
+        String log = getLogMessage(results, 0);
 
         // Validate correct queue name
         String subject = fromSubject(log);
@@ -371,7 +371,7 @@ public class ManagementActorLoggingTest 
 
         managedBroker.deleteQueue(getName());
 
-        List<String> results = _monitor.waitAndFindMatches("QUE-1002", DEFAULT_LOG_WAIT);
+        List<String> results = waitAndFindMatches("QUE-1002");
 
         assertEquals("More than one queue deletion found", 1, results.size());
 
@@ -417,11 +417,11 @@ public class ManagementActorLoggingTest 
 
         managedExchange.createNewBinding(getName(), getName());
 
-        List<String> results = _monitor.waitAndFindMatches("BND-1001", DEFAULT_LOG_WAIT);
+        List<String> results = waitAndFindMatches("BND-1001");
 
         assertEquals("More than one bind creation found", 1, results.size());
 
-        String log = getLog(results.get(0));
+        String log = getLogMessage(results, 0);
 
         // Validate correct binding
         String subject = fromSubject(log);
@@ -444,11 +444,11 @@ public class ManagementActorLoggingTest 
 
         managedExchange.createNewBinding(getName(), getName());
 
-        List<String> results = _monitor.waitAndFindMatches("BND-1001", DEFAULT_LOG_WAIT);
+        List<String> results = waitAndFindMatches("BND-1001");
 
         assertEquals("More than one bind creation found", 1, results.size());
 
-        String log = getLog(results.get(0));
+        String log = getLogMessage(results, 0);
 
         // Validate correct binding
         String subject = fromSubject(log);
@@ -471,11 +471,11 @@ public class ManagementActorLoggingTest 
 
         managedExchange.createNewBinding(getName(), getName());
 
-        List<String> results = _monitor.waitAndFindMatches("BND-1001", DEFAULT_LOG_WAIT);
+        List<String> results = waitAndFindMatches("BND-1001");
 
         assertEquals("More than one bind creation found", 1, results.size());
 
-        String log = getLog(results.get(0));
+        String log = getLogMessage(results, 0);
 
         // Validate correct binding
         String subject = fromSubject(log);
@@ -518,7 +518,7 @@ public class ManagementActorLoggingTest 
 
         managedBroker.unregisterExchange(getName());
 
-        List<String> results = _monitor.waitAndFindMatches("EXH-1002", DEFAULT_LOG_WAIT);
+        List<String> results = waitAndFindMatches("EXH-1002");
 
         assertEquals("More than one exchange deletion found", 1, results.size());
 

Modified: qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/BrokerStartupTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/BrokerStartupTest.java?rev=991561&r1=991560&r2=991561&view=diff
==============================================================================
--- qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/BrokerStartupTest.java (original)
+++ qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/BrokerStartupTest.java Wed Sep  1 15:06:24 2010
@@ -99,10 +99,10 @@ public class BrokerStartupTest extends A
             startBroker();
 
             assertEquals("Log4j could not load desired configruation.",
-                         0, _monitor.findMatches("log4j:ERROR Could not read configuration file from URL").size());
+                         0, findMatches("log4j:ERROR Could not read configuration file from URL").size());
 
             assertEquals("Logging did not error as expected",
-                         1, _monitor.waitAndFindMatches("Logging configuration error: unable to read file ", DEFAULT_LOG_WAIT).size());
+                         1, waitAndFindMatches("Logging configuration error: unable to read file ").size());
 
 
             // Perfom some action on the broker to ensure that we hit the DEBUG
@@ -120,7 +120,7 @@ public class BrokerStartupTest extends A
 
             assertEquals(COUNT,drainQueue(queue));
 
-            List<String> results = _monitor.waitAndFindMatches("DEBUG", DEFAULT_LOG_WAIT);
+            List<String> results = waitAndFindMatches("DEBUG");
             try
             {
                 // Validation

Modified: qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/AbstractTestLogging.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/AbstractTestLogging.java?rev=991561&r1=991560&r2=991561&view=diff
==============================================================================
--- qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/AbstractTestLogging.java (original)
+++ qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/AbstractTestLogging.java Wed Sep  1 15:06:24 2010
@@ -33,12 +33,18 @@ import org.apache.qpid.server.virtualhos
 import org.apache.qpid.test.utils.QpidBrokerTestCase;
 import org.apache.qpid.util.LogMonitor;
 
+import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
 
+/**
+ * Abstract superclass for logging test set up and utility methods.
+ *
+ * So named to prevent it being selected itself as a test to run by the test suite.
+ */
 public class AbstractTestLogging extends QpidBrokerTestCase
 {
     public static final long DEFAULT_LOG_WAIT = 2000;
@@ -131,7 +137,7 @@ public class AbstractTestLogging extends
     {
         // Ensure the alert has not occured yet
         assertEquals("Message has already occured:" + log, 0,
-                     _monitor.findMatches(log).size());
+                     findMatches(log).size());
     }
 
     protected void validateMessageID(String id, String log)
@@ -321,6 +327,56 @@ public class AbstractTestLogging extends
         int start = rawLog.indexOf("MESSAGE");
         return rawLog.substring(start);
     }
+    
+    /**
+     * Extract the log entry from the result set. Positions are 0-based.
+     * 
+     * @param results list of log message results to extract from
+     * @param position position in the list of the message to extract
+     * @return the message string
+     */
+    protected String getLogMessage(List<String> results, int position)
+    {
+        return getLog(results.get(position));
+    }
+    
+    /**
+     * Extract the nth-from-last log entry from the result set.
+     * 
+     * @param results list of log message results to extract from
+     * @param positionFromEnd position from end of the message list to extract (eg 0 for last)
+     * @return the message string
+     */
+    protected String getLogMessageFromEnd(List<String> results, int positionFromEnd)
+    {
+        int resultSize = results.size();
+        return getLogMessage(results, resultSize - 1 - positionFromEnd);
+    }
+    
+    protected List<String> findMatches(String toFind) throws IOException
+    {
+        return _monitor.findMatches(toFind);
+    }
+    
+    protected List<String> waitAndFindMatches(String toFind) throws IOException
+    {
+        return waitAndFindMatches(toFind, DEFAULT_LOG_WAIT);
+    }
+
+    protected List<String> waitAndFindMatches(String toFind, long wait) throws IOException
+    {
+        return _monitor.waitAndFindMatches(toFind, wait);
+    }
+
+    public boolean waitForMessage(String message) throws FileNotFoundException, IOException
+    {
+        return waitForMessage(message, DEFAULT_LOG_WAIT);
+    }
+
+    public boolean waitForMessage(String message, long wait) throws FileNotFoundException, IOException
+    {
+        return _monitor.waitForMessage(message, wait, true);
+    }
 
     /**
      * Given a list of messages that have been pulled out of a log file
@@ -389,4 +445,30 @@ public class AbstractTestLogging extends
         return filteredResults;
     }
 
+    /**
+     * Dump the log results.
+     */
+    protected void dumpLogs(List<String> results) throws IOException  
+    {
+        dumpLogs(results, null);
+    }
+    
+    /**
+     * Dump the log results or if there are none, the contents of the 
+     * monitored log file if the monitor is non-null.
+     */
+    protected void dumpLogs(List<String> results, LogMonitor monitor) throws IOException   
+    {
+        System.err.println("Log Dump:");
+        for (String log : results)
+        {
+            System.err.println(log);
+        }
+
+        if (results.size() == 0 && monitor != null)
+        {
+            System.err.println("Monitored file contents:");
+            System.err.println(monitor.readFile());
+        }
+    }
 }

Modified: qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/AccessControlLoggingTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/AccessControlLoggingTest.java?rev=991561&r1=991560&r2=991561&view=diff
==============================================================================
--- qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/AccessControlLoggingTest.java (original)
+++ qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/AccessControlLoggingTest.java Wed Sep  1 15:06:24 2010
@@ -80,7 +80,7 @@ public class AccessControlLoggingTest ex
         conn.start();
         ((AMQSession<?, ?>) sess).createQueue(new AMQShortString("allow"), false, false, false);
         
-        List<String> matches = _monitor.findMatches(ACL_LOG_PREFIX);
+        List<String> matches = findMatches(ACL_LOG_PREFIX);
         
         assertTrue("Should be no ACL log messages", matches.isEmpty());
     }
@@ -95,11 +95,11 @@ public class AccessControlLoggingTest ex
         conn.start();
         ((AMQSession<?, ?>) sess).createQueue(new AMQShortString("allow-log"), false, false, false);
         
-        List<String> matches = _monitor.findMatches(ACL_LOG_PREFIX);
+        List<String> matches = findMatches(ACL_LOG_PREFIX);
         
         assertEquals("Should only be one ACL log message", 1, matches.size());
         
-        String log = getLog(matches.get(0));
+        String log = getLogMessage(matches, 0);
         String actor = fromActor(log);
         String subject = fromSubject(log);
         String message = getMessageString(fromMessage(log));
@@ -131,11 +131,11 @@ public class AccessControlLoggingTest ex
             assertEquals("Expected ACCESS_REFUSED error code", AMQConstant.ACCESS_REFUSED, amqe.getErrorCode());
         }
         
-        List<String> matches = _monitor.findMatches(ACL_LOG_PREFIX);
+        List<String> matches = findMatches(ACL_LOG_PREFIX);
         
         assertEquals("Should only be one ACL log message", 1, matches.size());
         
-        String log = getLog(matches.get(0));
+        String log = getLogMessage(matches, 0);;
         String actor = fromActor(log);
         String subject = fromSubject(log);
         String message = getMessageString(fromMessage(log));
@@ -167,7 +167,7 @@ public class AccessControlLoggingTest ex
             assertEquals("Expected ACCESS_REFUSED error code", AMQConstant.ACCESS_REFUSED, amqe.getErrorCode());
         }
         
-        List<String> matches = _monitor.findMatches(ACL_LOG_PREFIX);
+        List<String> matches = findMatches(ACL_LOG_PREFIX);
         
         assertTrue("Should be no ACL log messages", matches.isEmpty());
     }

Modified: qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/AlertingTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/AlertingTest.java?rev=991561&r1=991560&r2=991561&view=diff
==============================================================================
--- qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/AlertingTest.java (original)
+++ qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/AlertingTest.java Wed Sep  1 15:06:24 2010
@@ -99,7 +99,7 @@ public class AlertingTest extends Abstra
      */
     private void wasAlertFired() throws Exception
     {
-        if (!_monitor.waitForMessage(MESSAGE_COUNT_ALERT, ALERT_LOG_WAIT_PERIOD))
+        if (!waitForMessage(MESSAGE_COUNT_ALERT, ALERT_LOG_WAIT_PERIOD))
         {
             StringBuffer message = new StringBuffer("Could not find 'MESSAGE_COUNT_ALERT' in log file: " + _monitor.getMonitoredFile().getAbsolutePath());
             message.append("\n");

Modified: qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/BindingLoggingTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/BindingLoggingTest.java?rev=991561&r1=991560&r2=991561&view=diff
==============================================================================
--- qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/BindingLoggingTest.java (original)
+++ qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/BindingLoggingTest.java Wed Sep  1 15:06:24 2010
@@ -65,15 +65,15 @@ public class BindingLoggingTest extends 
         _topic = (Topic) getInitialContext().lookup(TOPIC);
     }
 
-    private void validateLogMessage(String log, String messageID, String exchange, String message)
+    private void validateLogMessage(String log, String messageID, String message, String exchange, String rkey, String queueName)
     {
         validateMessageID(messageID, log);
 
         String subject = fromSubject(log);
 
-        assertEquals("Queue not correct.", getName(),
+        assertEquals("Queue not correct.", queueName,
                      AbstractTestLogSubject.getSlice("qu", subject));
-        assertEquals("Routing Key not correct.", getName(),
+        assertEquals("Routing Key not correct.", rkey,
                      AbstractTestLogSubject.getSlice("rk", subject));
         assertEquals("Virtualhost not correct.", "/test",
                      AbstractTestLogSubject.getSlice("vh", subject));
@@ -104,7 +104,7 @@ public class BindingLoggingTest extends 
     {
         _session.createConsumer(_queue).close();
 
-        List<String> results = _monitor.waitAndFindMatches(BND_PREFIX, DEFAULT_LOG_WAIT);
+        List<String> results = waitAndFindMatches(BND_PREFIX);
 
         // We will have two binds as we bind all queues to the default exchange
         assertEquals("Result set larger than expected.", 2, results.size());
@@ -112,11 +112,12 @@ public class BindingLoggingTest extends 
         String exchange = "direct/<<default>>";
         String messageID = "BND-1001";
         String message = "Create";
+        String queueName = _queue.getQueueName();
 
-        validateLogMessage(getLog(results.get(0)), messageID, exchange, message);
+        validateLogMessage(getLogMessage(results, 0), messageID, message, exchange, queueName, queueName);
 
         exchange = "direct/amq.direct";
-        validateLogMessage(getLog(results.get(1)), messageID, exchange, message);
+        validateLogMessage(getLogMessage(results, 1), messageID, message, exchange, queueName, queueName);
     }
 
     /**
@@ -141,49 +142,26 @@ public class BindingLoggingTest extends 
 
         _session.createDurableSubscriber(_topic, getName(), SELECTOR, false).close();
 
-        List<String> results = _monitor.waitAndFindMatches(BND_PREFIX, DEFAULT_LOG_WAIT);
+        List<String> results = waitAndFindMatches(BND_PREFIX);
 
         // We will have two binds as we bind all queues to the default exchange
         assertEquals("Result set larger than expected.", 2, results.size());
 
-        String log = getLog(results.get(0));
-
-        //Verify the first entry is the default binding
-        validateMessageID("BND-1001", log);
-
-        String subject = fromSubject(log);
-
-        assertEquals("Queue not correct.", "clientid:" + getName(),
-                     AbstractTestLogSubject.getSlice("qu", subject));
-        // NOTE default binding is the queue name
-        assertEquals("Routing Key not correct.", "clientid:" + getName(),
-                     AbstractTestLogSubject.getSlice("rk", subject));
-        assertEquals("Virtualhost not correct.", "/test",
-                     AbstractTestLogSubject.getSlice("vh", subject));
-        assertEquals("Exchange not correct.", "direct/<<default>>",
-                     AbstractTestLogSubject.getSlice("ex", fromSubject(log)));
-
-        String message = getMessageString(log);
+        //Verify the first entry is the default binding       
+        String messageID = "BND-1001";
+        String message = "Create";
+        
+        validateLogMessage(getLogMessage(results, 0), messageID, message, 
+                "direct/<<default>>", "clientid:" + getName(), "clientid:" + getName());
 
         //Default binding will be without the selector
         assertTrue("JMSSelector identified in binding:"+message, !message.contains("jms-selector"));
 
         // Perform full testing on the second non default binding
-        log = getLog(results.get(1));
-        validateMessageID("BND-1001", log);
-
-        subject = fromSubject(log);
-
-        assertEquals("Queue not correct.", "clientid:" + getName(),
-                     AbstractTestLogSubject.getSlice("qu", subject));
-        assertEquals("Routing Key not correct.", "topic",
-                     AbstractTestLogSubject.getSlice("rk", subject));
-        assertEquals("Virtualhost not correct.", "/test",
-                     AbstractTestLogSubject.getSlice("vh", subject));
-        assertEquals("Exchange not correct.", "topic/amq.topic",
-                     AbstractTestLogSubject.getSlice("ex", subject));
-
-        message = getMessageString(log);
+        message = getMessageString(fromMessage(getLogMessage(results, 1)));
+        
+        validateLogMessage(getLogMessage(results, 1), messageID, message, 
+                "topic/amq.topic", "topic", "clientid:" + getName());
 
         assertTrue("JMSSelector not identified in binding:"+message, message.contains("jms-selector"));
         assertTrue("Selector not part of binding.:"+message, message.contains(SELECTOR));
@@ -212,7 +190,7 @@ public class BindingLoggingTest extends 
         // and so unbind.
         _session.createConsumer(_session.createTemporaryQueue()).close();
 
-        List<String> results = _monitor.waitAndFindMatches(BND_PREFIX, DEFAULT_LOG_WAIT);
+        List<String> results = waitAndFindMatches(BND_PREFIX);
 
         // We will have two binds as we bind all queues to the default exchange
         assertEquals("Result not as expected." + results, 4, results.size());
@@ -221,11 +199,11 @@ public class BindingLoggingTest extends 
         String messageID = "BND-1001";
         String message = "Create";
 
-        String log = getLog(results.get(0));
+        String log = getLogMessage(results, 0);
         validateMessageID(messageID, log);
         assertEquals("Log Message not as expected", message, getMessageString(fromMessage(log)));
 
-        log = getLog(results.get(1));
+        log = getLogMessage(results, 1);
         validateMessageID(messageID, log);
         assertEquals("Log Message not as expected", message, getMessageString(fromMessage(log)));
 
@@ -236,32 +214,26 @@ public class BindingLoggingTest extends 
         messageID = "BND-1002";
         message = "Deleted";
 
-        log = getLog(results.get(2));
+        log = getLogMessage(results, 2);
         validateMessageID(messageID, log);
 
         String subject = fromSubject(log);
-
-        assertTrue("Routing Key does not start with TempQueue:"+AbstractTestLogSubject.getSlice("rk", subject),
-                     AbstractTestLogSubject.getSlice("rk", subject).startsWith("TempQueue"));
-        assertEquals("Virtualhost not correct.", "/test",
-                     AbstractTestLogSubject.getSlice("vh", subject));
+        
+        validateBindingDeleteArguments(subject, "/test");
 
         boolean defaultFirst = DEFAULT.equals(AbstractTestLogSubject.getSlice("ex", subject));
         boolean directFirst = DIRECT.equals(AbstractTestLogSubject.getSlice("ex", subject));
 
         assertEquals("Log Message not as expected", message, getMessageString(fromMessage(log)));
 
-        log = getLog(results.get(3));
+        log = getLogMessage(results, 3);
 
         validateMessageID(messageID, log);
 
         subject = fromSubject(log);
 
-        assertTrue("Routing Key does not start with TempQueue:"+AbstractTestLogSubject.getSlice("rk", subject),
-                     AbstractTestLogSubject.getSlice("rk", subject).startsWith("TempQueue"));
-        assertEquals("Virtualhost not correct.", "/test",
-                     AbstractTestLogSubject.getSlice("vh", subject));
-
+        validateBindingDeleteArguments(subject, "/test");
+        
         if (!defaultFirst)
         {
             assertEquals(DEFAULT, AbstractTestLogSubject.getSlice("ex", subject));
@@ -274,6 +246,15 @@ public class BindingLoggingTest extends 
         }
 
         assertEquals("Log Message not as expected", message, getMessageString(fromMessage(log)));
-
+    }
+    
+    private void validateBindingDeleteArguments(String subject, String vhostName)
+    {
+        String routingKey = AbstractTestLogSubject.getSlice("rk", subject);
+        
+        assertTrue("Routing Key does not start with TempQueue:"+routingKey,
+                routingKey.startsWith("TempQueue"));
+        assertEquals("Virtualhost not correct.", vhostName,
+                AbstractTestLogSubject.getSlice("vh", subject));
     }
 }

Modified: qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/BrokerLoggingTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/BrokerLoggingTest.java?rev=991561&r1=991560&r2=991561&view=diff
==============================================================================
--- qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/BrokerLoggingTest.java (original)
+++ qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/BrokerLoggingTest.java Wed Sep  1 15:06:24 2010
@@ -96,22 +96,22 @@ public class BrokerLoggingTest extends A
             String configFilePath = _configFile.toString();
 
             // Ensure we wait for TESTID to be logged
-            _monitor.waitAndFindMatches(TESTID, DEFAULT_LOG_WAIT);
+            waitAndFindMatches(TESTID);
 
-            List<String> results = _monitor.waitAndFindMatches(BRK_LOG_PREFIX, DEFAULT_LOG_WAIT);
+            List<String> results = waitAndFindMatches(BRK_LOG_PREFIX);
             try
             {
                 // Validation
 
                 assertTrue("BRKer message not logged", results.size() > 0);
 
-                String log = getLog(results.get(0));
+                String log = getLogMessage(results, 0);
 
                 //1
                 validateMessageID(TESTID, log);
 
                 //2
-                results = _monitor.findMatches(TESTID);
+                results = findMatches(TESTID);
                 assertEquals("More than one configuration message found.",
                              1, results.size());
 
@@ -121,11 +121,8 @@ public class BrokerLoggingTest extends A
             }
             catch (AssertionFailedError afe)
             {
-                System.err.println("Log Dump:");
-                for (String log : results)
-                {
-                    System.err.println(log);
-                }
+                dumpLogs(results, _monitor);
+
                 throw afe;
             }
         }
@@ -178,9 +175,9 @@ public class BrokerLoggingTest extends A
             getConnection();
 
             // Ensure we wait for TESTID to be logged
-            _monitor.waitAndFindMatches(TESTID, DEFAULT_LOG_WAIT);
+            waitAndFindMatches(TESTID);
 
-            List<String> results = _monitor.waitAndFindMatches(BRK_LOG_PREFIX, DEFAULT_LOG_WAIT);
+            List<String> results = waitAndFindMatches(BRK_LOG_PREFIX);
             try
             {
                 // Validation
@@ -210,7 +207,7 @@ public class BrokerLoggingTest extends A
 
                     //2
                     assertEquals("More than one log4j configuration message found.",
-                                 1, _monitor.findMatches(TESTID).size());
+                                 1, findMatches(TESTID).size());
 
                     //3
                     String defaultLog4j = _configFile.getParent() + "/" + Main.DEFAULT_LOG_CONFIG_FILENAME;
@@ -224,17 +221,7 @@ public class BrokerLoggingTest extends A
             }
             catch (AssertionFailedError afe)
             {
-                System.err.println("Log Dump:");
-                for (String log : results)
-                {
-                    System.err.println(log);
-                }
-
-                if (results.size() == 0)
-                {
-                    System.err.println("Monitored file contents:");
-                    System.err.println(_monitor.readFile());
-                }
+                dumpLogs(results, _monitor);
 
                 throw afe;
             }
@@ -279,9 +266,9 @@ public class BrokerLoggingTest extends A
             getConnection();
 
             // Ensure we wait for TESTID to be logged
-            _monitor.waitAndFindMatches(TESTID, DEFAULT_LOG_WAIT);
+            waitAndFindMatches(TESTID);
 
-            List<String> results = _monitor.waitAndFindMatches(BRK_LOG_PREFIX, DEFAULT_LOG_WAIT);
+            List<String> results = waitAndFindMatches(BRK_LOG_PREFIX);
             try
             {
                 // Validation
@@ -310,7 +297,7 @@ public class BrokerLoggingTest extends A
 
                     //2
                     assertEquals("More than one log4j configuration message found.",
-                                 1, _monitor.findMatches(TESTID).size());
+                                 1, findMatches(TESTID).size());
 
                     //3
                     assertTrue("Log4j file details not correctly logged:" + getMessageString(log),
@@ -323,17 +310,7 @@ public class BrokerLoggingTest extends A
             }
             catch (AssertionFailedError afe)
             {
-                System.err.println("Log Dump:");
-                for (String log : results)
-                {
-                    System.err.println(log);
-                }
-
-                if (results.size() == 0)
-                {
-                    System.err.println("Monitored file contents:");
-                    System.err.println(_monitor.readFile());
-                }
+                dumpLogs(results, _monitor);
 
                 throw afe;
             }
@@ -368,11 +345,11 @@ public class BrokerLoggingTest extends A
             _monitor = new LogMonitor(_outputFile);
             
             // Ensure we wait for TESTID to be logged
-            _monitor.waitAndFindMatches(TESTID, DEFAULT_LOG_WAIT);
+            waitAndFindMatches(TESTID);
 
             // Retrieve all BRK- log messages so we can check for an erroneous
             // BRK-1002 message.
-            List<String> results = _monitor.findMatches(BRK_LOG_PREFIX);
+            List<String> results = findMatches(BRK_LOG_PREFIX);
 
             try
             {
@@ -402,7 +379,7 @@ public class BrokerLoggingTest extends A
 
                     //2
                     assertEquals("More than one startup message found.",
-                                 1, _monitor.findMatches(TESTID).size());
+                                 1, findMatches(TESTID).size());
 
                     validation = true;
                 }
@@ -411,11 +388,8 @@ public class BrokerLoggingTest extends A
             }
             catch (AssertionFailedError afe)
             {
-                System.err.println("Log Dump:");
-                for (String log : results)
-                {
-                    System.err.println(log);
-                }
+                dumpLogs(results, _monitor);
+                
                 throw afe;
             }
         }
@@ -457,11 +431,11 @@ public class BrokerLoggingTest extends A
             getConnection();
 
             // Ensure we wait for TESTID to be logged
-            _monitor.waitAndFindMatches(TESTID, DEFAULT_LOG_WAIT);
+            waitAndFindMatches(TESTID);
 
             // Retrieve all BRK- log messages so we can check for an erroneous
             // BRK-1002 message.
-            List<String> results = _monitor.findMatches(BRK_LOG_PREFIX);
+            List<String> results = findMatches(BRK_LOG_PREFIX);
             try
             {
                 // Validation
@@ -491,7 +465,7 @@ public class BrokerLoggingTest extends A
 
                     //2
                     assertEquals("More than one listen message found.",
-                                 1, _monitor.findMatches(TESTID).size());
+                                 1, findMatches(TESTID).size());
 
                     //3
                     String message = getMessageString(log);
@@ -505,11 +479,8 @@ public class BrokerLoggingTest extends A
             }
             catch (AssertionFailedError afe)
             {
-                System.err.println("Log Dump:");
-                for (String log : results)
-                {
-                    System.err.println(log);
-                }
+                dumpLogs(results, _monitor);
+                
                 throw afe;
             }
         }
@@ -562,11 +533,11 @@ public class BrokerLoggingTest extends A
             getConnection();
 
             // Ensure we wait for TESTID to be logged
-            _monitor.waitAndFindMatches(TESTID, DEFAULT_LOG_WAIT);
+            waitAndFindMatches(TESTID);
 
             // Retrieve all BRK- log messages so we can check for an erroneous
             // BRK-1002 message.
-            List<String> results = _monitor.findMatches(BRK_LOG_PREFIX);
+            List<String> results = findMatches(BRK_LOG_PREFIX);
             try
             {
                 // Validation
@@ -595,7 +566,7 @@ public class BrokerLoggingTest extends A
                     validateMessageID(TESTID, log);
 
                     //2
-                    List<String> listenMessages  = _monitor.findMatches(TESTID);
+                    List<String> listenMessages  = findMatches(TESTID);
                     assertEquals("Two listen messages should be found.",
                                  2, listenMessages .size());
 
@@ -620,11 +591,8 @@ public class BrokerLoggingTest extends A
             }
             catch (AssertionFailedError afe)
             {
-                System.err.println("Log Dump:");
-                for (String log : results)
-                {
-                    System.err.println(log);
-                }
+                dumpLogs(results, _monitor);
+
                 throw afe;
             }
         }
@@ -660,11 +628,11 @@ public class BrokerLoggingTest extends A
             //Ensure the broker has fully started up.
             getConnection();
             // Ensure we wait for TESTID to be logged
-            _monitor.waitAndFindMatches(TESTID, DEFAULT_LOG_WAIT);
+            waitAndFindMatches(TESTID);
 
             // Retrieve all BRK- log messages so we can check for an erroneous
             // BRK-1001 message.
-            List<String> results = _monitor.findMatches(BRK_LOG_PREFIX);
+            List<String> results = findMatches(BRK_LOG_PREFIX);
             try
             {
                 // Validation
@@ -695,7 +663,7 @@ public class BrokerLoggingTest extends A
 
                     //2
                     assertEquals("More than one ready message found.",
-                                 1, _monitor.findMatches(TESTID).size());
+                                 1, findMatches(TESTID).size());
 
                     //3
                     assertEquals("Ready message not present", "Ready", getMessageString(log));
@@ -707,11 +675,8 @@ public class BrokerLoggingTest extends A
             }
             catch (AssertionFailedError afe)
             {
-                System.err.println("Log Dump:");
-                for (String log : results)
-                {
-                    System.err.println(log);
-                }
+                dumpLogs(results, _monitor);
+
                 throw afe;
             }
         }
@@ -753,7 +718,7 @@ public class BrokerLoggingTest extends A
             //Give broker time to shutdown and flush log
             checkSocketClosed(getPort());
 
-            List<String> results = _monitor.waitAndFindMatches(BRK_LOG_PREFIX, DEFAULT_LOG_WAIT);
+            List<String> results = waitAndFindMatches(BRK_LOG_PREFIX);
             try
             {
                 // Validation
@@ -783,7 +748,7 @@ public class BrokerLoggingTest extends A
 
                     //2
                     assertEquals("More than one listen message found.",
-                                 1, _monitor.findMatches(TESTID).size());
+                                 1, findMatches(TESTID).size());
 
                     //3
                     String message = getMessageString(log);
@@ -800,11 +765,8 @@ public class BrokerLoggingTest extends A
             }
             catch (AssertionFailedError afe)
             {
-                System.err.println("Log Dump:");
-                for (String log : results)
-                {
-                    System.err.println(log);
-                }
+                dumpLogs(results, _monitor);
+
                 throw afe;
             }
         }
@@ -861,7 +823,7 @@ public class BrokerLoggingTest extends A
             //Give broker time to shutdown and flush log
             checkSocketClosed(getPort());
 
-            List<String> results = _monitor.waitAndFindMatches(TESTID, DEFAULT_LOG_WAIT);
+            List<String> results = waitAndFindMatches(TESTID);
             try
             {
                 // Validation
@@ -874,7 +836,7 @@ public class BrokerLoggingTest extends A
                 validateMessageID(TESTID, log);
 
                 //2
-                List<String> listenMessages = _monitor.findMatches(TESTID);
+                List<String> listenMessages = findMatches(TESTID);
                 assertEquals("Two shutdown messages should be found.",
                              2, listenMessages.size());
 
@@ -896,11 +858,8 @@ public class BrokerLoggingTest extends A
             }
             catch (AssertionFailedError afe)
             {
-                System.err.println("Log Dump:");
-                for (String log : results)
-                {
-                    System.err.println(log);
-                }
+                dumpLogs(results, _monitor);
+
                 throw afe;
             }
         }
@@ -943,9 +902,9 @@ public class BrokerLoggingTest extends A
             // Ensure the broker has shutdown before retreving results
             checkSocketClosed(getPort());
 
-            _monitor.waitAndFindMatches(TESTID, DEFAULT_LOG_WAIT);
+            waitAndFindMatches(TESTID);
 
-            List<String> results = _monitor.waitAndFindMatches(BRK_LOG_PREFIX, DEFAULT_LOG_WAIT);
+            List<String> results = waitAndFindMatches(BRK_LOG_PREFIX);
             try
             {
                 // Validation
@@ -969,7 +928,7 @@ public class BrokerLoggingTest extends A
 
                     //2
                     assertEquals("More than one ready message found.",
-                                 1, _monitor.findMatches(TESTID).size());
+                                 1, findMatches(TESTID).size());
 
                     //3
                     assertEquals("Stopped message not present", "Stopped", getMessageString(log));
@@ -981,14 +940,7 @@ public class BrokerLoggingTest extends A
             }
             catch (AssertionFailedError afe)
             {
-                System.err.println("Log Dump:");
-                for (String log : results)
-                {
-                    System.err.println(log);
-                }
-
-                System.err.println("Monitored file contents:");
-                System.err.println(_monitor.readFile());
+                dumpLogs(results, _monitor);
 
                 throw afe;
             }

Modified: qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ChannelLoggingTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ChannelLoggingTest.java?rev=991561&r1=991560&r2=991561&view=diff
==============================================================================
--- qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ChannelLoggingTest.java (original)
+++ qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ChannelLoggingTest.java Wed Sep  1 15:06:24 2010
@@ -65,21 +65,21 @@ public class ChannelLoggingTest extends 
         ((AMQConnection)connection).createSession(false, Session.AUTO_ACKNOWLEDGE,PREFETCH);
 
         // Wait to ensure that the CHN-1004 message is logged
-        _monitor.waitForMessage("CHN-1004", DEFAULT_LOG_WAIT);
+        waitForMessage("CHN-1004");
 
-        List<String> results = _monitor.findMatches(CHANNEL_PREFIX);
+        List<String> results = findMatches(CHANNEL_PREFIX);
 
         // Validation
 
         assertEquals("CHN messages not logged", 2, results.size());
 
-        String log = getLog(results.get(0));
+        String log = getLogMessage(results, 0);
         //  MESSAGE [con:0(guest@anonymous(3273383)/test)/ch:1] CHN-1001 : Create
         //1 & 2
         validateMessageID("CHN-1001", log);
         assertEquals("Incorrect Channel in actor:"+fromActor(log), 1, getChannelID(fromActor(log)));
 
-        log = getLog(results.get(1));
+        log = getLogMessage(results, 1);
         //  MESSAGE [con:0(guest@anonymous(3273383)/test)/ch:1] CHN-1004 : Prefetch Size (bytes) {0,number} : Count {1,number}
         //1 & 2
         validateMessageID("CHN-1004", log);
@@ -123,9 +123,9 @@ public class ChannelLoggingTest extends 
         connection.start();
 
         // Wait to ensure that the CHN-1002 message is logged
-        _monitor.waitForMessage("CHN-1002", DEFAULT_LOG_WAIT);
+        waitForMessage("CHN-1002");
 
-        List<String> results = _monitor.findMatches(CHANNEL_PREFIX);
+        List<String> results = findMatches(CHANNEL_PREFIX);
 
         assertTrue("No CHN messages logged", results.size() > 0);
 
@@ -133,13 +133,17 @@ public class ChannelLoggingTest extends 
         //
         // INFO - MESSAGE [con:0(guest@anonymous(4205299)/test)/ch:1] [con:0(guest@anonymous(4205299)/test)/ch:1] CHN-1002 : Flow Stopped
 
-        // Verify
-        int resultSize = results.size();
-        String log = getLog(results.get(resultSize - 1));
+        // Verify the last channel message is stopped
+        validateChannelStart(results, false);
+    }
 
-        validateMessageID("CHN-1002", log);
-        assertEquals("Message should be Flow Stopped", "Flow Stopped", getMessageString(fromMessage(log)));
+    private void validateChannelStart(List<String> results, boolean flowStarted)
+    {
+        String log = getLogMessageFromEnd(results, 0);
 
+        String flow = flowStarted ? "Started" : "Stopped";
+        validateMessageID("CHN-1002", log);
+        assertEquals("Message should be Flow " + flow, "Flow " + flow, getMessageString(fromMessage(log)));
     }
 
     /**
@@ -185,9 +189,9 @@ public class ChannelLoggingTest extends 
         _monitor.waitForMessage(CHANNEL_PREFIX, 2000);
 
         // Wait to ensure that the CHN-1002 message is logged
-        _monitor.waitForMessage("CHN-1002", DEFAULT_LOG_WAIT);
+        waitForMessage("CHN-1002");
 
-        List<String> results = _monitor.findMatches(CHANNEL_PREFIX);
+        List<String> results = findMatches(CHANNEL_PREFIX);
 
         assertTrue("No CHN messages logged", results.size() > 0);
 
@@ -196,13 +200,8 @@ public class ChannelLoggingTest extends 
         // INFO [qpid.message] MESSAGE [con:1(guest@/127.0.0.1:49869/test)/ch:1] [con:1(guest@/127.0.0.1:49869/test)/ch:1] CHN-1002 : Flow Stopped
         // INFO [qpid.message] MESSAGE [con:1(guest@/127.0.0.1:49869/test)/ch:1] [con:1(guest@/127.0.0.1:49869/test)/ch:1] CHN-1002 : Flow Started
 
-
         // Verify the last channel msg is Started.
-        int resultSize = results.size();
-        String log = getLog(results.get(resultSize - 1));
-
-        validateMessageID("CHN-1002", log);
-        assertEquals("Message should be Flow Started", "Flow Started", getMessageString(fromMessage(log)));
+        validateChannelStart(results, true);
     }
 
     /**
@@ -237,9 +236,9 @@ public class ChannelLoggingTest extends 
         connection.close();
 
         // Wait to ensure that the CHN-1003 message is logged
-        _monitor.waitForMessage("CHN-1003", DEFAULT_LOG_WAIT);
+        waitForMessage("CHN-1003");
 
-        List<String> results = _monitor.findMatches(CHANNEL_PREFIX);
+        List<String> results = findMatches(CHANNEL_PREFIX);
 
         assertTrue("No CHN messages logged", results.size() > 0);
 
@@ -248,14 +247,7 @@ public class ChannelLoggingTest extends 
         // INFO - MESSAGE [con:0(guest@anonymous(4205299)/test)/ch:1] [con:0(guest@anonymous(4205299)/test)/ch:1] CHN-1002 : Flow On
 
         // Verify
-
-        int resultSize = results.size();
-        String log = getLog(results.get(resultSize - 1));
-
-        validateMessageID("CHN-1003", log);
-        assertEquals("Message should be Close", "Close",getMessageString(fromMessage(log)));
-        assertEquals("Incorrect Channel ID closed.", 1, getChannelID(fromActor(log)));
-        assertEquals("Incorrect Channel ID closed.", 1, getChannelID(fromSubject(log)));
+        validateChannelClose(results);
     }
 
     /**
@@ -287,20 +279,23 @@ public class ChannelLoggingTest extends 
         connection.createSession(false, Session.AUTO_ACKNOWLEDGE).close();
 
         // Wait to ensure that the CHN-1003 message is logged
-        _monitor.waitForMessage("CHN-1003", DEFAULT_LOG_WAIT);
+        waitForMessage("CHN-1003");
 
-        List<String> results = _monitor.findMatches(CHANNEL_PREFIX);
+        List<String> results = findMatches(CHANNEL_PREFIX);
 
         assertTrue("No CHN messages logged", results.size() > 0);
 
         // Verify
-        int resultSize = results.size();
-        String log = getLog(results.get(resultSize - 1));
+        validateChannelClose(results);
+    }
+
+    private void validateChannelClose(List<String> results)
+    {
+        String log = getLogMessageFromEnd(results, 0);
 
         validateMessageID("CHN-1003", log);
         assertEquals("Message should be Close", "Close",getMessageString(fromMessage(log)));
         assertEquals("Incorrect Channel ID closed.", 1, getChannelID(fromActor(log)));
         assertEquals("Incorrect Channel ID closed.", 1, getChannelID(fromSubject(log)));
     }
-
 }
\ No newline at end of file

Modified: qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ConnectionLoggingTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ConnectionLoggingTest.java?rev=991561&r1=991560&r2=991561&view=diff
==============================================================================
--- qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ConnectionLoggingTest.java (original)
+++ qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ConnectionLoggingTest.java Wed Sep  1 15:06:24 2010
@@ -21,7 +21,6 @@
 package org.apache.qpid.server.logging;
 
 import javax.jms.Connection;
-import java.io.File;
 import java.util.List;
 import java.util.HashMap;
 import java.util.TreeSet;
@@ -55,7 +54,7 @@ public class ConnectionLoggingTest exten
 
         Connection connection = getConnection();
 
-        List<String> results = _monitor.waitAndFindMatches(CONNECTION_PREFIX, DEFAULT_LOG_WAIT);
+        List<String> results = waitAndFindMatches(CONNECTION_PREFIX);
 
         assertTrue("No CON messages logged", results.size() > 0);        
 
@@ -84,44 +83,46 @@ public class ConnectionLoggingTest exten
         // open and close messages from the failed 0-10 negotiation 
         assertTrue("CON messages not logged:" + results.size(), results.size() >= 3);
 
-        String log = getLog(results.get(0));
+        String log = getLogMessage(results, 0);
         //  MESSAGE [con:1(/127.0.0.1:52540)] CON-1001 : Open
         //1 & 2
         validateMessageID("CON-1001",log);
 
-        //We get the size so that we can validate the last three CON- messages
-        int resultsSize = results.size();
-        // This is because when running externally we will also have logged the failed
-        // 0-10 negotiation messages
+        // validate the last three CON- messages.
+        // This is because when running externally we may also have logged the failed
+        // 0-10 negotiation messages if using 0-8/0-9 on the broker.
 
         // 3 - Assert the options are correct
-        log = getLog(results.get(resultsSize - 1));
         //  MESSAGE [con:1(/127.0.0.1:52540)] CON-1001 : Open : Client ID : clientid : Protocol Version : 0-9
-        validateMessageID("CON-1001",log);
-        assertTrue("Client ID option is not present", fromMessage(log).contains("Client ID :"));
-        assertTrue("Client ID value is not present", fromMessage(log).contains(connection.getClientID()));
-
-        assertTrue("Protocol Version option is not present", fromMessage(log).contains("Protocol Version :"));
-        //fixme there is no way currently to find out the negotiated protocol version
-        // The delegate is the versioned class ((AMQConnection)connection)._delegate
+        validateConnectionOpen(results, 0, true, true, connection.getClientID());
 
-        log = getLog(results.get(resultsSize - 2));
         //  MESSAGE [con:1(/127.0.0.1:52540)] CON-1001 : Open : Protocol Version : 0-9
-        validateMessageID("CON-1001",log);
-        assertTrue("Protocol Version option is not present", fromMessage(log).contains("Protocol Version :"));
-        //fixme agani we should check the version
-        // Check that client ID is not present in log
-        assertTrue("Client ID option is present", !fromMessage(log).contains("Client ID :"));
+        validateConnectionOpen(results, 1, true, false, null);
 
-        log = getLog(results.get(resultsSize - 3));
-        validateMessageID("CON-1001",log);
-        // Check that PV is not present in log
-        assertTrue("Protocol Version option is present", !fromMessage(log).contains("Protocol Version :"));
-        // Check that client ID is not present in log
-        assertTrue("Client ID option is present", !fromMessage(log).contains("Client ID :"));
+        validateConnectionOpen(results, 2, false, false, null);
 
         connection.close();
     }
+    
+    private void validateConnectionOpen(List<String> results, int positionFromEnd,
+                 boolean protocolVersionPresent, boolean clientIdOptionPresent, String clientIdValue)
+    {
+        String log = getLogMessageFromEnd(results, positionFromEnd);
+        
+        validateMessageID("CON-1001",log);
+        
+        assertEquals("unexpected Client ID option state", clientIdOptionPresent, fromMessage(log).contains("Client ID :"));
+        
+        if(clientIdOptionPresent && clientIdValue != null)
+        {
+            assertTrue("Client ID value is not present", fromMessage(log).contains(clientIdValue));
+        }
+        
+        assertEquals("unexpected Protocol Version option state", 
+                protocolVersionPresent, fromMessage(log).contains("Protocol Version :"));
+        //fixme there is no way currently to find out the negotiated protocol version
+        // The delegate is the versioned class ((AMQConnection)connection)._delegate
+    }
 
     /**
      * Description:
@@ -147,20 +148,17 @@ public class ConnectionLoggingTest exten
         getConnection().close();
 
         // Wait to ensure that the desired message is logged
-        _monitor.waitForMessage("CON-1002", DEFAULT_LOG_WAIT);
+        waitForMessage("CON-1002");
 
-        List<String> results = _monitor.findMatches(CONNECTION_PREFIX);
+        List<String> results = findMatches(CONNECTION_PREFIX);
 
         // Validation
 
         // We should have at least four messages
         assertTrue("CON messages not logged:" + results.size(), results.size() >= 4);
 
-        //We get the size so that we can validate the last set of CON- messages
-        int resultsSize = results.size();
-
         // Validate Close message occurs
-        String log = getLog(results.get(resultsSize - 1));
+        String log = getLogMessageFromEnd(results, 0);
         validateMessageID("CON-1002",log);
         assertTrue("Message does not end with close:" + log, log.endsWith("Close"));
 
@@ -168,7 +166,7 @@ public class ConnectionLoggingTest exten
         int connectionID = getConnectionID(log);
 
         //Previous log message should be the open
-        log = getLog(results.get(resultsSize - 2));
+        log = getLogMessageFromEnd(results, 1);
         //  MESSAGE [con:1(/127.0.0.1:52540)] CON-1001 : Open : Client ID : clientid : Protocol Version : 0-9
         validateMessageID("CON-1001",log);
         assertEquals("Connection IDs do not match", connectionID, getConnectionID(fromActor(log)));

Modified: qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/DerbyMessageStoreLoggingTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/DerbyMessageStoreLoggingTest.java?rev=991561&r1=991560&r2=991561&view=diff
==============================================================================
--- qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/DerbyMessageStoreLoggingTest.java (original)
+++ qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/DerbyMessageStoreLoggingTest.java Wed Sep  1 15:06:24 2010
@@ -92,7 +92,7 @@ public class DerbyMessageStoreLoggingTes
 
         startBroker();
 
-        List<String> results = _monitor.waitAndFindMatches(MESSAGES_STORE_PREFIX, DEFAULT_LOG_WAIT);
+        List<String> results = waitAndFindMatches(MESSAGES_STORE_PREFIX);
 
         // Validation
 
@@ -104,13 +104,13 @@ public class DerbyMessageStoreLoggingTes
         List<String> vhosts = configuration.getConfig().getList("virtualhosts.virtualhost.name");
 
         //Validate each vhost logs a creation
-        results = _monitor.waitAndFindMatches("MST-1002", DEFAULT_LOG_WAIT);
+        results = waitAndFindMatches("MST-1002");
 
         assertEquals("Each vhost did not close its store.", vhosts.size(), results.size());
 
         for (int index = 0; index < results.size(); index++)
         {
-            String result = getLog(results.get(index));
+            String result = getLogMessage(results, index);;
 
             // getSlize will return extract the vhost from vh(/test) -> '/test'
             // so remove the '/' to get the name
@@ -156,7 +156,7 @@ public class DerbyMessageStoreLoggingTes
 
         startBroker();
 
-        List<String> results = _monitor.waitAndFindMatches(MESSAGES_STORE_PREFIX, DEFAULT_LOG_WAIT);
+        List<String> results = waitAndFindMatches(MESSAGES_STORE_PREFIX);
 
         // Validation
 
@@ -168,13 +168,13 @@ public class DerbyMessageStoreLoggingTes
         List<String> vhosts = configuration.getConfig().getList("virtualhosts.virtualhost.name");
 
         //Validate each vhost logs a creation
-        results = _monitor.waitAndFindMatches("MST-1004", DEFAULT_LOG_WAIT);
+        results = waitAndFindMatches("MST-1004");
 
         assertTrue("Each vhost did not close its store.", vhosts.size() <= results.size());
 
         for (int index = 0; index < results.size(); index++)
         {
-            String result = getLog(results.get(index));
+            String result = getLogMessage(results, index);;
 
             if (getMessageString(result).contains("Recovery Start :"))
             {
@@ -224,7 +224,7 @@ public class DerbyMessageStoreLoggingTes
 
         startBroker();
 
-        List<String> results = _monitor.waitAndFindMatches(MESSAGES_STORE_PREFIX, DEFAULT_LOG_WAIT);
+        List<String> results = waitAndFindMatches(MESSAGES_STORE_PREFIX);
 
         // Validation
 
@@ -236,13 +236,13 @@ public class DerbyMessageStoreLoggingTes
         List<String> vhosts = configuration.getConfig().getList("virtualhosts.virtualhost.name");
 
         //Validate each vhost logs a creation
-        results = _monitor.waitAndFindMatches("MST-1006", DEFAULT_LOG_WAIT);
+        results = waitAndFindMatches("MST-1006");
 
         assertTrue("Each vhost did not close its store.", vhosts.size() <= results.size());
 
         for (int index = 0; index < results.size(); index++)
         {
-            String result = getLog(results.get(index));
+            String result = getLogMessage(results, index);
 
             if (getMessageString(result).contains("Recovery Complete :"))
             {
@@ -291,7 +291,7 @@ public class DerbyMessageStoreLoggingTes
 
         startBroker();
 
-        List<String> results = _monitor.waitAndFindMatches(MESSAGES_STORE_PREFIX, DEFAULT_LOG_WAIT);
+        List<String> results = waitAndFindMatches(MESSAGES_STORE_PREFIX);
 
         // Validation
 
@@ -303,7 +303,7 @@ public class DerbyMessageStoreLoggingTes
         List<String> vhosts = configuration.getConfig().getList("virtualhosts.virtualhost.name");
 
         //Validate each vhost logs a creation
-        results = _monitor.waitAndFindMatches("MST-1004 : Recovery Start :", DEFAULT_LOG_WAIT);
+        results = waitAndFindMatches("MST-1004 : Recovery Start :");
 
         // We are only looking for the default queue defined in local host being
         // recovered. If other tests have made queues in test then we want to
@@ -312,7 +312,7 @@ public class DerbyMessageStoreLoggingTes
 
         assertEquals("Recovered test queue not found.", 1, results.size());
 
-        String result = getLog(results.get(0));
+        String result = getLogMessage(results, 0);
 
         // getSlize will return extract the vhost from vh(/test) -> '/test'
         // so remove the '/' to get the name
@@ -357,7 +357,7 @@ public class DerbyMessageStoreLoggingTes
 
         startBroker();
 
-        List<String> results = _monitor.waitAndFindMatches(MESSAGES_STORE_PREFIX, DEFAULT_LOG_WAIT);
+        List<String> results = waitAndFindMatches(MESSAGES_STORE_PREFIX);
 
         // Validation
 
@@ -369,7 +369,7 @@ public class DerbyMessageStoreLoggingTes
         List<String> vhosts = configuration.getConfig().getList("virtualhosts.virtualhost.name");
 
         //Validate each vhost logs a creation
-        results = _monitor.waitAndFindMatches("MST-1006 : Recovery Complete :", DEFAULT_LOG_WAIT);
+        results = waitAndFindMatches("MST-1006 : Recovery Complete :");
 
         // We are only looking for the default queue defined in local host being
         // recovered. If other tests have made queues in test then we want to
@@ -378,7 +378,7 @@ public class DerbyMessageStoreLoggingTes
 
         assertEquals("Recovered test queue not found.", 1, results.size());
 
-        String result = getLog(results.get(0));
+        String result = getLogMessage(results, 0);
 
         // getSlize will return extract the vhost from vh(/test) -> '/test'
         // so remove the '/' to get the name
@@ -399,7 +399,7 @@ public class DerbyMessageStoreLoggingTes
         assertEquals("The store name does not match expected value",
                      storeName, AbstractTestLogSubject.getSlice("ms", fromSubject(result)));
 
-        results = _monitor.findMatches("MST-1004 : Recovery Start : test-queue");
+        results = findMatches("MST-1004 : Recovery Start : test-queue");
 
         assertEquals("MST-1004 for test-queue not found", 1, results.size());
     }
@@ -500,7 +500,7 @@ public class DerbyMessageStoreLoggingTes
 
             startBroker();
 
-            List<String> results = _monitor.waitAndFindMatches(MESSAGES_STORE_PREFIX, DEFAULT_LOG_WAIT);
+            List<String> results = waitAndFindMatches(MESSAGES_STORE_PREFIX);
 
             // Validation
 
@@ -512,18 +512,18 @@ public class DerbyMessageStoreLoggingTes
             List<String> vhosts = configuration.getConfig().getList("virtualhosts.virtualhost.name");
 
             //Validate each vhost logs a creation
-            results = _monitor.waitAndFindMatches("MST-1004 : Recovery Start : " + queueName, DEFAULT_LOG_WAIT);
+            results = waitAndFindMatches("MST-1004 : Recovery Start : " + queueName);
 
             assertEquals("Recovered test queue not found.", 1, results.size());
 
-            String result = getLog(results.get(0));
+            String result = getLogMessage(results, 0);
 
             validateMessageID("MST-1004", result);
 
             assertTrue("MST-1004 does end with queue '" + queueName + "':" + getMessageString(result),
                        getMessageString(result).endsWith(queueName));
 
-            results = _monitor.waitAndFindMatches("MST-1005", DEFAULT_LOG_WAIT);
+            results = waitAndFindMatches("MST-1005");
 
             assertTrue("Insufficient MST-1005 logged.", results.size()>0);
 

Modified: qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/DurableQueueLoggingTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/DurableQueueLoggingTest.java?rev=991561&r1=991560&r2=991561&view=diff
==============================================================================
--- qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/DurableQueueLoggingTest.java (original)
+++ qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/DurableQueueLoggingTest.java Wed Sep  1 15:06:24 2010
@@ -45,7 +45,6 @@ import java.util.Map;
  */
 public class DurableQueueLoggingTest extends AbstractTestLogging
 {
-
     protected String DURABLE = "Durable";
     protected String TRANSIENT = "Transient";
     protected boolean _durable;
@@ -53,6 +52,7 @@ public class DurableQueueLoggingTest ext
     protected Connection _connection;
     protected Session _session;
     private static final String QUEUE_PREFIX = "QUE-";
+    private static int PRIORITIES = 6;
 
     public void setUp() throws Exception
     {
@@ -93,29 +93,12 @@ public class DurableQueueLoggingTest ext
 
         _session.createConsumer(queue);
 
-        // Validation
-        // Ensure we have received the QUE log msg.
-        _monitor.waitForMessage("QUE-1001", DEFAULT_LOG_WAIT);
-
-        List<String> results = _monitor.findMatches(QUEUE_PREFIX);
-
-        // Only 1 Queue message should hav been logged
-        assertEquals("Result set size not as expected", 1, results.size());
-
-        String log = getLog(results.get(0));
-
-        // Message Should be a QUE-1001
-        validateMessageID("QUE-1001", log);
-
-        // Queue is Durable
-        assertEquals(DURABLE + " keyword not correct in log entry",
-                     _durable, fromMessage(log).contains(DURABLE));
+        List<String> results = waitForMesssage();
 
-        assertEquals(TRANSIENT + " keyword not correct in log entry.",
-                     !_durable, fromMessage(log).contains(TRANSIENT));
-
-        assertTrue("Queue does not have correct owner value:" + fromMessage(log),
-                   fromMessage(log).contains("Owner: " + _connection.getClientID()));
+        String clientID = _connection.getClientID();
+        assertNotNull("clientID should not be null", clientID);
+        
+        validateQueueProperties(results, false, false, clientID);
     }
 
     /**
@@ -147,29 +130,9 @@ public class DurableQueueLoggingTest ext
 
         _session.createConsumer(queue);
 
-        // Validation
-        // Ensure we have received the QUE log msg.
-        _monitor.waitForMessage("QUE-1001", DEFAULT_LOG_WAIT);
+        List<String> results = waitForMesssage();
 
-        List<String> results = _monitor.findMatches(QUEUE_PREFIX);
-
-        // Only 1 Queue message should hav been logged
-        assertEquals("Result set size not as expected", 1, results.size());
-
-        String log = getLog(results.get(0));
-
-        // Message Should be a QUE-1001
-        validateMessageID("QUE-1001", log);
-
-        // Queue is Durable
-        assertEquals(DURABLE + " keyword not correct in log entry",
-                     _durable, fromMessage(log).contains(DURABLE));
-
-        assertEquals(TRANSIENT + " keyword not correct in log entry.",
-                     !_durable, fromMessage(log).contains(TRANSIENT));
-
-        assertFalse("Queue should not contain Owner tag:" + fromMessage(log),
-                   fromMessage(log).contains("Owner"));
+        validateQueueProperties(results, false, false, null);
     }
 
     /**
@@ -201,33 +164,9 @@ public class DurableQueueLoggingTest ext
 
         _session.createConsumer(queue);
 
-        // Validation
-        // Ensure we have received the QUE log msg.
-        _monitor.waitForMessage("QUE-1001", DEFAULT_LOG_WAIT);
-
-        List<String> results = _monitor.findMatches(QUEUE_PREFIX);
-
-        // Only 1 Queue message should hav been logged
-        assertEquals("Result set size not as expected", 1, results.size());
-
-        String log = getLog(results.get(0));
-
-        // Message Should be a QUE-1001
-        validateMessageID("QUE-1001", log);
-
-        // Queue is Durable
-        assertEquals(DURABLE + " keyword not correct in log entry",
-                     _durable, fromMessage(log).contains(DURABLE));
+        List<String> results = waitForMesssage();
 
-        assertEquals(TRANSIENT + " keyword not correct in log entry.",
-                     !_durable, fromMessage(log).contains(TRANSIENT));
-
-        // Queue is AutoDelete
-        assertTrue("Queue does not have the AutoDelete keyword in log:" + fromMessage(log),
-                   fromMessage(log).contains("AutoDelete"));
-
-        assertFalse("Queue should not contain Owner tag:" + fromMessage(log),
-                   fromMessage(log).contains("Owner"));
+        validateQueueProperties(results, false, true, null);
     }
 
     /**
@@ -254,7 +193,6 @@ public class DurableQueueLoggingTest ext
     public void testCreateQueuePersistentPriority() throws NamingException, JMSException, IOException, AMQException
     {
         // To Create a Priority queue we need to use AMQSession specific code
-        int PRIORITIES = 6;
         final Map<String, Object> arguments = new HashMap<String, Object>();
         arguments.put("x-qpid-priorities", PRIORITIES);
         // Need to create a queue that does not exist so use test name
@@ -268,33 +206,12 @@ public class DurableQueueLoggingTest ext
         // as the above Create is Asynchronous
         _session.createConsumer(queue);
 
-        // Validation
-        // Ensure we have received the QUE log msg.
-        _monitor.waitForMessage("QUE-1001", DEFAULT_LOG_WAIT);
-
-        List<String> results = _monitor.findMatches(QUEUE_PREFIX);
+        List<String> results = waitForMesssage();
 
         // Only 1 Queue message should hav been logged
         assertEquals("Result set size not as expected", 1, results.size());
 
-        String log = getLog(results.get(0));
-
-        // Message Should be a QUE-1001
-        validateMessageID("QUE-1001", log);
-
-        // Queue is Durable
-        assertEquals(DURABLE + " keyword not correct in log entry",
-                     _durable, fromMessage(log).contains(DURABLE));
-
-        assertEquals(TRANSIENT + " keyword not correct in log entry.",
-                     !_durable, fromMessage(log).contains(TRANSIENT));
-
-        // Queue is AutoDelete
-        assertTrue("Queue does not have the right Priority value keyword in log:" + fromMessage(log),
-                   fromMessage(log).contains("Priority: " + PRIORITIES));
-
-        assertFalse("Queue should not contain Owner tag:" + fromMessage(log),
-                   fromMessage(log).contains("Owner"));
+        validateQueueProperties(results, true, false, null);
     }
 
     /**
@@ -322,7 +239,6 @@ public class DurableQueueLoggingTest ext
     public void testCreateQueuePersistentAutoDeletePriority() throws NamingException, JMSException, IOException, AMQException
     {
         // To Create a Priority queue we need to use AMQSession specific code
-        int PRIORITIES = 6;
         final Map<String, Object> arguments = new HashMap<String, Object>();
         arguments.put("x-qpid-priorities", PRIORITIES);
         // Need to create a queue that does not exist so use test name
@@ -336,37 +252,56 @@ public class DurableQueueLoggingTest ext
         // as the above Create is Asynchronous
         _session.createConsumer(queue);
 
+        List<String> results = waitForMesssage();
+
+        validateQueueProperties(results, true, true, null);
+    }
+    
+    private List<String> waitForMesssage() throws IOException
+    {
         // Validation
         // Ensure we have received the QUE log msg.
-        _monitor.waitForMessage("QUE-1001", DEFAULT_LOG_WAIT);
+        waitForMessage("QUE-1001");
 
-        List<String> results = _monitor.findMatches(QUEUE_PREFIX);
+        List<String> results = findMatches(QUEUE_PREFIX);
 
         // Only 1 Queue message should hav been logged
         assertEquals("Result set size not as expected", 1, results.size());
+        
+        return results;
+    }
 
-        String log = getLog(results.get(0));
-
+    public void validateQueueProperties(List<String> results, boolean hasPriority, boolean hasAutodelete, String clientID)
+    {
+        String log = getLogMessage(results, 0);
+        
         // Message Should be a QUE-1001
         validateMessageID("QUE-1001", log);
 
         // Queue is Durable
         assertEquals(DURABLE + " keyword not correct in log entry",
-                     _durable, fromMessage(log).contains(DURABLE));
+                _durable, fromMessage(log).contains(DURABLE));
 
         assertEquals(TRANSIENT + " keyword not correct in log entry.",
-                     !_durable, fromMessage(log).contains(TRANSIENT));
+                !_durable, fromMessage(log).contains(TRANSIENT));
 
-        // Queue is AutoDelete
-        assertTrue("Queue does not have the right Priority value keyword in log:" + fromMessage(log),
-                   fromMessage(log).contains("Priority: " + PRIORITIES));
+        // Queue is Priority
+        assertEquals("Unexpected priority status:" + fromMessage(log), hasPriority,
+                fromMessage(log).contains("Priority: " + PRIORITIES));
 
         // Queue is AutoDelete
-        assertTrue("Queue does not have the AutoDelete keyword in log:" + fromMessage(log),
-                   fromMessage(log).contains("AutoDelete"));
+        assertEquals("Unexpected AutoDelete status:" + fromMessage(log), hasAutodelete, 
+                fromMessage(log).contains("AutoDelete"));
 
-        assertFalse("Queue should not contain Owner tag:" + fromMessage(log),
-                   fromMessage(log).contains("Owner"));
+        if(clientID != null)
+        {
+            assertTrue("Queue does not have correct owner value:" + fromMessage(log),
+                    fromMessage(log).contains("Owner: " + clientID));
+        }
+        else
+        {
+            assertFalse("Queue should not contain Owner tag:" + fromMessage(log),
+                    fromMessage(log).contains("Owner"));
+        }
     }
-
 }

Modified: qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ExchangeLoggingTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ExchangeLoggingTest.java?rev=991561&r1=991560&r2=991561&view=diff
==============================================================================
--- qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ExchangeLoggingTest.java (original)
+++ qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ExchangeLoggingTest.java Wed Sep  1 15:06:24 2010
@@ -95,23 +95,13 @@ public class ExchangeLoggingTest extends
         // They should all be durable
 
         // Ensure we have received the EXH log msg.
-        _monitor.waitForMessage("EXH-1001", DEFAULT_LOG_WAIT);
+        waitForMessage("EXH-1001");
 
-        List<String> results = _monitor.findMatches(EXH_PREFIX);
+        List<String> results = findMatches(EXH_PREFIX);
 
         assertTrue("No Results found for Exchange.", results.size()>0);
 
-        String log = getLog(results.get(0));
-
-        validateMessageID("EXH-1001", log);
-
-        String message = getMessageString(fromMessage(log));
-        assertTrue("Log Message does not start with create:" + message,
-                   message.startsWith("Create"));
-
-        assertTrue("Log Message does not contain Durable:" + message,
-                   message.contains("Durable"));
-
+        validateExchangeCreate(results, true, false);
     }
 
     /**
@@ -135,23 +125,35 @@ public class ExchangeLoggingTest extends
 
         _session.createConsumer(_queue);
         // Ensure we have received the EXH log msg.
-        _monitor.waitForMessage("EXH-1001", DEFAULT_LOG_WAIT);
+        waitForMessage("EXH-1001");
 
-        List<String> results = _monitor.findMatches(EXH_PREFIX);
+        List<String> results = findMatches(EXH_PREFIX);
 
         assertEquals("Result set larger than expected.", 1, results.size());
 
-        String log = getLog(results.get(0));
-
-        validateMessageID("EXH-1001", log);
+        validateExchangeCreate(results, false, true);
+    }
 
+    private void validateExchangeCreate(List<String> results, boolean durable, boolean checkNameAndType)
+    {
+        String log = getLogMessage(results, 0);
         String message = getMessageString(fromMessage(log));
+        
+        validateMessageID("EXH-1001", log);
+        
         assertTrue("Log Message does not start with create:" + message,
                    message.startsWith("Create"));
-        assertTrue("Log Message does not contain Type:" + message,
-                   message.contains("Type: " + _type));
-        assertTrue("Log Message does not contain Name:" + message,
-                   message.contains("Name: " + _name));
+
+        assertEquals("Unexpected Durable state:" + message, durable,
+                message.contains("Durable"));
+        
+        if(checkNameAndType)
+        {
+            assertTrue("Log Message does not contain Type:" + message,
+                    message.contains("Type: " + _type));
+            assertTrue("Log Message does not contain Name:" + message,
+                    message.contains("Name: " + _name));
+        }
     }
 
     /**
@@ -186,24 +188,18 @@ public class ExchangeLoggingTest extends
         ((AMQConnection) _connection).getProtocolHandler().syncWrite(exchangeDeclare, ExchangeDeleteOkBody.class);
 
         //Wait and ensure we get our last EXH-1002 msg
-        _monitor.waitForMessage("EXH-1002", DEFAULT_LOG_WAIT);
+        waitForMessage("EXH-1002");
 
-        List<String> results = _monitor.findMatches(EXH_PREFIX);
+        List<String> results = findMatches(EXH_PREFIX);
 
         assertEquals("Result set larger than expected.", 2, results.size());
 
-        String log = getLog(results.get(0));
-
-        validateMessageID("EXH-1001", log);
+        validateExchangeCreate(results, false, false);
 
-        String message = getMessageString(fromMessage(log));
-        assertTrue("Log Message does start with Create",
-                   message.startsWith("Create"));
-
-        log = getLog(results.get(1));
+        String log = getLogMessage(results, 1);
         validateMessageID("EXH-1002", log);
 
-        message = getMessageString(fromMessage(log));
+        String message = getMessageString(fromMessage(log));
         assertEquals("Log Message not as expected", "Deleted", message);
 
     }

Modified: qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ManagementLoggingTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ManagementLoggingTest.java?rev=991561&r1=991560&r2=991561&view=diff
==============================================================================
--- qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ManagementLoggingTest.java (original)
+++ qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ManagementLoggingTest.java Wed Sep  1 15:06:24 2010
@@ -21,6 +21,7 @@
 package org.apache.qpid.server.logging;
 
 import junit.framework.AssertionFailedError;
+
 import org.apache.qpid.util.LogMonitor;
 
 import java.util.List;
@@ -77,18 +78,12 @@ public class ManagementLoggingTest exten
         // Management is disabled on InVM brokers.
         if (isJavaBroker() && isExternalBroker())
         {
-            //Ensure management is on
-            setConfigurationProperty("management.enabled", "true");
-
-            startBroker();
-
-            // Now we can create the monitor as _outputFile will now be defined
-            _monitor = new LogMonitor(_outputFile);
+            startBrokerAndCreateMonitor(true, false);
 
             // Ensure we have received the MNG log msg.
-            _monitor.waitForMessage("MNG-1001", DEFAULT_LOG_WAIT);
+            waitForMessage("MNG-1001");
 
-            List<String> results = _monitor.findMatches(MNG_PREFIX);
+            List<String> results = findMatches(MNG_PREFIX);
             
             try
             {
@@ -96,13 +91,13 @@ public class ManagementLoggingTest exten
 
                 assertTrue("MNGer message not logged", results.size() > 0);
 
-                String log = getLog(results.get(0));
+                String log = getLogMessage(results, 0);
 
                 //1
                 validateMessageID("MNG-1001", log);
 
                 //2
-                results = _monitor.findMatches("MNG-1001");
+                results = findMatches("MNG-1001");
                 assertEquals("More than one startup message found.",
                              1, results.size());
 
@@ -112,11 +107,7 @@ public class ManagementLoggingTest exten
             }
             catch (AssertionFailedError afe)
             {
-                System.err.println("Log Dump:");
-                for (String log : results)
-                {
-                    System.err.println(log);
-                }
+                dumpLogs(results, _monitor);
                 throw afe;
             }
         }
@@ -140,15 +131,9 @@ public class ManagementLoggingTest exten
         // Management is disabled on InVM brokers.
         if (isJavaBroker() && isExternalBroker())
         {
-            //Ensure management is off
-            setConfigurationProperty("management.enabled", "false");
+            startBrokerAndCreateMonitor(false, false);
 
-            startBroker();
-
-            // Now we can create the monitor as _outputFile will now be defined
-            _monitor = new LogMonitor(_outputFile);
-
-            List<String> results = _monitor.findMatches(MNG_PREFIX);
+            List<String> results = findMatches(MNG_PREFIX);
             try
             {
                 // Validation
@@ -157,11 +142,7 @@ public class ManagementLoggingTest exten
             }
             catch (AssertionFailedError afe)
             {
-                System.err.println("Log Dump:");
-                for (String log : results)
-                {
-                    System.err.println(log);
-                }
+                dumpLogs(results, _monitor);
                 throw afe;
             }
         }
@@ -211,28 +192,22 @@ public class ManagementLoggingTest exten
         // Management is disabled on InVM brokers.
         if (isJavaBroker() && isExternalBroker())
         {
-            //Ensure management is on
-            setConfigurationProperty("management.enabled", "true");
-
-            startBroker();
-
-            // Now we can create the monitor as _outputFile will now be defined
-            _monitor = new LogMonitor(_outputFile);
-
-            List<String> results = _monitor.waitAndFindMatches("MNG-1002", DEFAULT_LOG_WAIT);
+            startBrokerAndCreateMonitor(true, false);
+            
+            List<String> results = waitAndFindMatches("MNG-1002");
             try
             {
                 // Validation
 
                 assertEquals("MNGer message not logged expected message", 2, results.size());
 
-                String log = getLog(results.get(0));
+                String log = getLogMessage(results, 0);
 
                 //1
                 validateMessageID("MNG-1002", log);
 
                 // Validate we only have one MNG-1002
-                results = _monitor.findMatches("MNG-1002");
+                results = findMatches("MNG-1002");
                 assertEquals("More than two RMI entries found.",
                              2, results.size());
 
@@ -242,7 +217,7 @@ public class ManagementLoggingTest exten
                 assertTrue("RMI Registry port not as expected(" + mPort + ").:" + getMessageString(log),
                            getMessageString(log).endsWith(String.valueOf(mPort)));
 
-                log = getLog(results.get(1));
+                log = getLogMessage(results, 1);
 
                 //1
                 validateMessageID("MNG-1002", log);
@@ -255,15 +230,12 @@ public class ManagementLoggingTest exten
             }
             catch (AssertionFailedError afe)
             {
-                System.err.println("Log Dump:");
-                for (String log : results)
-                {
-                    System.err.println(log);
-                }
+                dumpLogs(results, _monitor);
                 throw afe;
             }
         }
     }
+
     /**
      * Description:
      * Using the default configuration with SSL enabled for the management port the SSL Keystore path should be reported via MNG-1006
@@ -284,30 +256,22 @@ public class ManagementLoggingTest exten
         // Management is disabled on InVM brokers.
         if (isJavaBroker() && isExternalBroker())
         {
-            //Ensure management is on
-            setConfigurationProperty("management.enabled", "true");
-            // This test requires we have an ssl connection
-            setConfigurationProperty("management.ssl.enabled", "true");
+            startBrokerAndCreateMonitor(true, true);
 
-            startBroker();
-
-            // Now we can create the monitor as _outputFile will now be defined
-            _monitor = new LogMonitor(_outputFile);
-
-            List<String> results = _monitor.waitAndFindMatches("MNG-1006", DEFAULT_LOG_WAIT);
+            List<String> results = waitAndFindMatches("MNG-1006");
             try
             {
                 // Validation
 
                 assertTrue("MNGer message not logged", results.size() > 0);
 
-                String log = getLog(results.get(0));
+                String log = getLogMessage(results, 0);
 
                 //1
                 validateMessageID("MNG-1006", log);
 
                 // Validate we only have one MNG-1002
-                results = _monitor.findMatches("MNG-1006");
+                results = findMatches("MNG-1006");
                 assertEquals("More than one SSL Keystore entry found.",
                              1, results.size());
 
@@ -318,14 +282,27 @@ public class ManagementLoggingTest exten
             }
             catch (AssertionFailedError afe)
             {
-                System.err.println("Log Dump:");
-                for (String log : results)
-                {
-                    System.err.println(log);
-                }
+                dumpLogs(results, _monitor);
                 throw afe;
             }
         }
 
     }
+    
+    private void startBrokerAndCreateMonitor(boolean managementEnabled, boolean useManagementSSL) throws Exception
+    {
+        //Ensure management is on
+        setConfigurationProperty("management.enabled", String.valueOf(managementEnabled));
+
+        if(useManagementSSL)
+        {
+            // This test requires we have an ssl connection
+            setConfigurationProperty("management.ssl.enabled", "true");
+        }
+
+        startBroker();
+
+        // Now we can create the monitor as _outputFile will now be defined
+        _monitor = new LogMonitor(_outputFile);
+    }
 }



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org