summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--java/systests/src/main/java/org/apache/qpid/server/logging/AbstractTestLogging.java120
-rw-r--r--java/systests/src/main/java/org/apache/qpid/server/logging/DerbyMessageStoreLoggingTest.java15
2 files changed, 92 insertions, 43 deletions
diff --git a/java/systests/src/main/java/org/apache/qpid/server/logging/AbstractTestLogging.java b/java/systests/src/main/java/org/apache/qpid/server/logging/AbstractTestLogging.java
index ccf3ae76fd..e7d1c8b896 100644
--- a/java/systests/src/main/java/org/apache/qpid/server/logging/AbstractTestLogging.java
+++ b/java/systests/src/main/java/org/apache/qpid/server/logging/AbstractTestLogging.java
@@ -20,13 +20,15 @@
*/
package org.apache.qpid.server.logging;
+import org.apache.qpid.server.logging.subjects.AbstractTestLogSubject;
import org.apache.qpid.test.utils.QpidTestCase;
import org.apache.qpid.util.LogMonitor;
import java.io.IOException;
-import java.util.List;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.LinkedList;
+import java.util.List;
public class AbstractTestLogging extends QpidTestCase
{
@@ -38,7 +40,7 @@ public class AbstractTestLogging extends QpidTestCase
super.setUp();
_monitor = new LogMonitor(_outputFile);
}
-
+
@Override
public void tearDown() throws Exception
{
@@ -46,7 +48,6 @@ public class AbstractTestLogging extends QpidTestCase
super.tearDown();
}
-
/**
* assert that the requested log message has not occured
*
@@ -61,10 +62,9 @@ public class AbstractTestLogging extends QpidTestCase
_monitor.findMatches(log).size());
}
-
protected void validateMessageID(String id, String log)
{
- assertEquals("Incorrect message",id, getMessageID(log));
+ assertEquals("Incorrect message", id, getMessageID(log));
}
protected String getMessageID(String log)
@@ -131,6 +131,7 @@ public class AbstractTestLogging extends QpidTestCase
* The brackets '[ ]' are not included in the returned String.
*
* @param log The log message to process
+ *
* @return the Subject string or the empty string ("") if the subject can't be identified.
*/
protected String fromSubject(String log)
@@ -166,6 +167,7 @@ public class AbstractTestLogging extends QpidTestCase
* The brackets '[ ]' are not included in the returned String.
*
* @param log the Log Message
+ *
* @return the Actor segment or "" if unable to locate '[ ]' section
*/
protected String fromActor(String log)
@@ -184,7 +186,9 @@ public class AbstractTestLogging extends QpidTestCase
/**
* Return the message String from the given message section
+ *
* @param log the Message Section
+ *
* @return the Message String.
*/
protected String getMessageString(String log)
@@ -195,7 +199,6 @@ public class AbstractTestLogging extends QpidTestCase
return log.substring(start).trim();
}
-
/**
* Given our log message extract the connection ID:
*
@@ -211,6 +214,7 @@ public class AbstractTestLogging extends QpidTestCase
* Integer then return -1.
*
* @param log the log String to process
+ *
* @return the connection ID or -1.
*/
protected int getConnectionID(String log)
@@ -235,7 +239,9 @@ public class AbstractTestLogging extends QpidTestCase
* as we know it to be formatted.
*
* This starts with the string MESSAGE
+ *
* @param rawLog the raw log
+ *
* @return the log we are expecting to be printed without the log4j prefixes
*/
protected String getLog(String rawLog)
@@ -245,40 +251,70 @@ public class AbstractTestLogging extends QpidTestCase
}
/**
- * Given a list of messages that have been pulled out of a log file
- * Process the results splitting the log statements in to lists based on the
- * actor's connection ID.
- *
- * So for each log entry extract the Connecition ID from the Actor of the log
- *
- * Then use that as a key to a HashMap storing the list of log messages for
- * that connection.
- *
- * @param logMessages The list of mixed connection log messages
- * @return Map indexed by connection id to a list of log messages just for that connection.
- */
- protected HashMap<Integer,List<String>> splitResultsOnConnectionID(List<String> logMessages)
- {
- HashMap<Integer,List<String>> connectionSplitList = new HashMap<Integer, List<String>>();
-
- for (String log : logMessages)
- {
- // Get the connectionID from the Actor in the Message Log.
- int cID = getConnectionID(fromActor(getLog(log)));
-
- List<String> connectionData = connectionSplitList.get(cID);
-
- // Create the initial List if we don't have one already
- if (connectionData == null)
- {
- connectionData = new LinkedList<String>();
- connectionSplitList.put(cID, connectionData);
- }
-
- // Store the log
- connectionData.add(log);
- }
-
- return connectionSplitList;
- }
+ * Given a list of messages that have been pulled out of a log file
+ * Process the results splitting the log statements in to lists based on the
+ * actor's connection ID.
+ *
+ * So for each log entry extract the Connecition ID from the Actor of the log
+ *
+ * Then use that as a key to a HashMap storing the list of log messages for
+ * that connection.
+ *
+ * @param logMessages The list of mixed connection log messages
+ *
+ * @return Map indexed by connection id to a list of log messages just for that connection.
+ */
+ protected HashMap<Integer, List<String>> splitResultsOnConnectionID(List<String> logMessages)
+ {
+ HashMap<Integer, List<String>> connectionSplitList = new HashMap<Integer, List<String>>();
+
+ for (String log : logMessages)
+ {
+ // Get the connectionID from the Actor in the Message Log.
+ int cID = getConnectionID(fromActor(getLog(log)));
+
+ List<String> connectionData = connectionSplitList.get(cID);
+
+ // Create the initial List if we don't have one already
+ if (connectionData == null)
+ {
+ connectionData = new LinkedList<String>();
+ connectionSplitList.put(cID, connectionData);
+ }
+
+ // Store the log
+ connectionData.add(log);
+ }
+
+ return connectionSplitList;
+ }
+
+ /**
+ * Filter the give result set by the specficifed virtualhost.
+ * This is done using the getSlice to identify the virtualhost (vh) in the
+ * log message
+ *
+ * @param results full list of logs
+ * @param virtualHostName the virtualhostName to filter on
+ *
+ * @return the list of messages only for that virtualhost
+ */
+ protected List<String> filterResultsByVirtualHost(List<String> results, String virtualHostName)
+ {
+ List<String> filteredResults = new LinkedList<String>();
+ Iterator<String> iterator = results.iterator();
+
+ while (iterator.hasNext())
+ {
+ String log = iterator.next();
+
+ if (AbstractTestLogSubject.getSlice("vh", log).equals(virtualHostName))
+ {
+ filteredResults.add(log);
+ }
+ }
+
+ return filteredResults;
+ }
+
}
diff --git a/java/systests/src/main/java/org/apache/qpid/server/logging/DerbyMessageStoreLoggingTest.java b/java/systests/src/main/java/org/apache/qpid/server/logging/DerbyMessageStoreLoggingTest.java
index 9f8146849d..c4e33ade30 100644
--- a/java/systests/src/main/java/org/apache/qpid/server/logging/DerbyMessageStoreLoggingTest.java
+++ b/java/systests/src/main/java/org/apache/qpid/server/logging/DerbyMessageStoreLoggingTest.java
@@ -28,6 +28,8 @@ import javax.jms.Connection;
import javax.jms.Queue;
import javax.jms.Session;
import java.util.List;
+import java.util.LinkedList;
+import java.util.Iterator;
/**
* The MessageStore test suite validates that the follow log messages as
@@ -299,6 +301,11 @@ public class DerbyMessageStoreLoggingTest extends MemoryMessageStoreLoggingTest
//Validate each vhost logs a creation
results = _monitor.findMatches("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
+ // exclude them here.
+ results = filterResultsByVirtualHost(results, "/localhost");
+
assertEquals("Recovered test queue not found.", 1, results.size());
String result = getLog(results.get(0));
@@ -359,6 +366,12 @@ public class DerbyMessageStoreLoggingTest extends MemoryMessageStoreLoggingTest
//Validate each vhost logs a creation
results = _monitor.findMatches("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
+ // exclude them here.
+ results = filterResultsByVirtualHost(results, "/localhost");
+
+
assertEquals("Recovered test queue not found.", 1, results.size());
String result = getLog(results.get(0));
@@ -409,7 +422,7 @@ public class DerbyMessageStoreLoggingTest extends MemoryMessageStoreLoggingTest
{
assertLoggingNotYetOccured(MESSAGES_STORE_PREFIX);
- String queueName = "queueCountTest";
+ String queueName = getTestQueueName();
startBroker();
Connection connetion = getConnection();