summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Ritchie <ritchiem@apache.org>2009-08-06 17:03:15 +0000
committerMartin Ritchie <ritchiem@apache.org>2009-08-06 17:03:15 +0000
commit884904237fa2dc780081098e3b886cb7d936f304 (patch)
tree788dfd5d3b4b0d059827b484864e1d3bc7135496
parentd2d18f0df41c33e7574b53ff2a34002a33012f6b (diff)
downloadqpid-python-884904237fa2dc780081098e3b886cb7d936f304.tar.gz
QPID-2002 : Improved Channel/ConnectionLogging Test to report that it had no logged messages when that situation occurs. Rather than -1 index exceptions. Update to BrokerLoggingTest to ensure it is monitoring the right file.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@801728 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/server/logging/BrokerLoggingTest.java62
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ChannelLoggingTest.java8
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ConnectionLoggingTest.java2
3 files changed, 59 insertions, 13 deletions
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/BrokerLoggingTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/BrokerLoggingTest.java
index d5f8fadad1..33f4d5402b 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/BrokerLoggingTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/BrokerLoggingTest.java
@@ -49,16 +49,6 @@ public class BrokerLoggingTest extends AbstractTestLogging
{
public void setUp() throws Exception
{
- // set QPID_WORK to be [QPID_WORK|io.tmpdir]/<testName>
- setSystemProperty("QPID_WORK",
- System.getProperty("QPID_WORK",
- System.getProperty("java.io.tmpdir"))
- + File.separator + getName());
-
-// makeVirtualHostPersistent("test");
-
- _monitor = new LogMonitor(_outputFile);
-
//We explicitly do not call super.setUp as starting up the broker is
//part of the test case.
}
@@ -92,6 +82,10 @@ public class BrokerLoggingTest extends AbstractTestLogging
{
startBroker();
+ // Now we can create the monitor as _outputFile will now be defined
+ _monitor = new LogMonitor(_outputFile);
+
+
String configFilePath = _configFile.toString();
List<String> results = _monitor.findMatches("BRK-");
@@ -159,11 +153,12 @@ public class BrokerLoggingTest extends AbstractTestLogging
startBroker();
+ // Now we can create the monitor as _outputFile will now be defined
+ _monitor = new LogMonitor(_outputFile);
+
// Ensure broker has fully started up.
getConnection();
- String configFilePath = _configFile.toString();
-
List<String> results = _monitor.findMatches("BRK-");
try
{
@@ -255,6 +250,10 @@ public class BrokerLoggingTest extends AbstractTestLogging
startBroker();
+ // Now we can create the monitor as _outputFile will now be defined
+ _monitor = new LogMonitor(_outputFile);
+
+
// Ensure broker has fully started up.
getConnection();
@@ -341,6 +340,9 @@ public class BrokerLoggingTest extends AbstractTestLogging
startBroker();
+ // Now we can create the monitor as _outputFile will now be defined
+ _monitor = new LogMonitor(_outputFile);
+
List<String> results = _monitor.findMatches("BRK-");
try
{
@@ -418,6 +420,9 @@ public class BrokerLoggingTest extends AbstractTestLogging
startBroker();
+ // Now we can create the monitor as _outputFile will now be defined
+ _monitor = new LogMonitor(_outputFile);
+
// Ensure broker has fully started up.
getConnection();
@@ -515,6 +520,9 @@ public class BrokerLoggingTest extends AbstractTestLogging
startBroker();
+ // Now we can create the monitor as _outputFile will now be defined
+ _monitor = new LogMonitor(_outputFile);
+
// Ensure broker has fully started up.
getConnection();
@@ -693,6 +701,9 @@ public class BrokerLoggingTest extends AbstractTestLogging
startBroker();
+ // Now we can create the monitor as _outputFile will now be defined
+ _monitor = new LogMonitor(_outputFile);
+
stopBroker();
//Give broker time to shutdown and flush log
@@ -794,6 +805,10 @@ public class BrokerLoggingTest extends AbstractTestLogging
startBroker();
+ // Now we can create the monitor as _outputFile will now be defined
+ _monitor = new LogMonitor(_outputFile);
+
+
// //Clear any startup messages as we don't need them for validation
// _monitor.reset();
//Stop the broker to get the log messages for testing
@@ -874,6 +889,9 @@ public class BrokerLoggingTest extends AbstractTestLogging
startBroker();
+ // Now we can create the monitor as _outputFile will now be defined
+ _monitor = new LogMonitor(_outputFile);
+
getConnection().close();
stopBroker();
@@ -931,6 +949,14 @@ public class BrokerLoggingTest extends AbstractTestLogging
}
}
+ /**
+ * Test that a socket on the given port is closed.
+ *
+ * Does this by attempting to connect to the port and expecting a
+ * ConnectionRefused IOException or a ConnectionException
+ *
+ * @param port the port number
+ */
private void checkSocketClosed(int port)
{
try
@@ -953,6 +979,15 @@ public class BrokerLoggingTest extends AbstractTestLogging
}
}
+ /**
+ * Test that a socket on the given port is open.
+ *
+ * Does this by attempting to connect to the port and expecting a
+ * The connection to succeed.
+ * It then closes the socket and expects that to work cleanly.
+ *
+ * @param port the port number
+ */
private void testSocketOpen(int port)
{
try
@@ -962,7 +997,8 @@ public class BrokerLoggingTest extends AbstractTestLogging
}
catch (IOException e)
{
- fail("Unable to open and close socket to port:" + port + ". Due to:" + e.getMessage());
+ fail("Unable to open and close socket to port:" + port
+ + ". Due to:" + e.getMessage());
}
}
}
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ChannelLoggingTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ChannelLoggingTest.java
index 62904f1bd6..da3f458cef 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ChannelLoggingTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ChannelLoggingTest.java
@@ -119,6 +119,8 @@ public class ChannelLoggingTest extends AbstractTestLogging
List<String> results = _monitor.findMatches(CHANNEL_PREFIX);
+ assertTrue("No CHN messages logged", results.size() > 0);
+
// The last channel message should be:
//
// INFO - MESSAGE [con:0(guest@anonymous(4205299)/test)/ch:1] [con:0(guest@anonymous(4205299)/test)/ch:1] CHN-1002 : Flow Off
@@ -171,6 +173,8 @@ public class ChannelLoggingTest extends AbstractTestLogging
List<String> results = _monitor.findMatches(CHANNEL_PREFIX);
+ assertTrue("No CHN messages logged", results.size() > 0);
+
// The last two channel messages should be:
//
// INFO - MESSAGE [con:0(guest@anonymous(4205299)/test)/ch:1] [con:0(guest@anonymous(4205299)/test)/ch:1] CHN-1002 : Flow On
@@ -218,6 +222,8 @@ public class ChannelLoggingTest extends AbstractTestLogging
List<String> results = _monitor.findMatches(CHANNEL_PREFIX);
+ assertTrue("No CHN messages logged", results.size() > 0);
+
// The last two channel messages should be:
//
// INFO - MESSAGE [con:0(guest@anonymous(4205299)/test)/ch:1] [con:0(guest@anonymous(4205299)/test)/ch:1] CHN-1002 : Flow On
@@ -263,6 +269,8 @@ public class ChannelLoggingTest extends AbstractTestLogging
List<String> results = _monitor.findMatches(CHANNEL_PREFIX);
+ assertTrue("No CHN messages logged", results.size() > 0);
+
// The last two channel messages should be:
//
// INFO - MESSAGE [con:0(guest@anonymous(4205299)/test)/ch:1] [con:0(guest@anonymous(4205299)/test)/ch:1] CHN-1002 : Flow On
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ConnectionLoggingTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ConnectionLoggingTest.java
index 9915d410c5..503129072b 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ConnectionLoggingTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ConnectionLoggingTest.java
@@ -66,6 +66,8 @@ public class ConnectionLoggingTest extends AbstractTestLogging
List<String> results = _monitor.findMatches(CONNECTION_PREFIX);
+ assertTrue("No CON messages logged", results.size() > 0);
+
// Validation
// We should have at least three messages when running InVM but when running External
// we will get 0-10 negotiation on con:0 whcih may close at some random point