[LOGBack-dev] svn commit: r526 - logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net
noreply.ceki at qos.ch
noreply.ceki at qos.ch
Thu Sep 7 23:18:45 CEST 2006
Author: ceki
Date: Thu Sep 7 23:18:45 2006
New Revision: 526
Modified:
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/MockSyslogServer.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SyslogAppenderTest.java
Log:
- All tests pass on Linux
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/MockSyslogServer.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/MockSyslogServer.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/MockSyslogServer.java Thu Sep 7 23:18:45 2006
@@ -20,23 +20,26 @@
*/
public class MockSyslogServer extends Thread {
- static final int PORT = 14805;
+ static final int PORT = 14500;
final int loopLen;
-
+ final int port;
+
List<String> msgList = new ArrayList<String>();
boolean finished = false;
- MockSyslogServer(int loopLen) {
+ MockSyslogServer(int loopLen, int port) {
super();
this.loopLen = loopLen;
+ this.port = port;
}
@Override
public void run() {
+ System.out.println("MockSyslogServer listening on port "+port);
DatagramSocket socket = null;
try {
- socket = new DatagramSocket(PORT);
+ socket = new DatagramSocket(port);
for (int i = 0; i < loopLen; i++) {
byte[] buf = new byte[2048];
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SyslogAppenderTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SyslogAppenderTest.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SyslogAppenderTest.java Thu Sep 7 23:18:45 2006
@@ -30,8 +30,12 @@
}
public void testBasic() throws InterruptedException {
- MockSyslogServer mockServer = new MockSyslogServer(1);
+ int port = MockSyslogServer.PORT+1;
+
+ MockSyslogServer mockServer = new MockSyslogServer(1, port);
mockServer.start();
+ // give MockSyslogServer head start
+ Thread.sleep(100);
LoggerContext lc = new LoggerContext();
lc.setName("test");
@@ -39,7 +43,7 @@
sa.setContext(lc);
sa.setSyslogHost("localhost");
sa.setFacility("MAIL");
- sa.setPort(MockSyslogServer.PORT);
+ sa.setPort(port);
sa.start();
assertTrue(sa.isStarted());
@@ -68,8 +72,11 @@
}
public void testExceptoin() throws InterruptedException {
- MockSyslogServer mockServer = new MockSyslogServer(1);
+ int port = MockSyslogServer.PORT+2;
+ MockSyslogServer mockServer = new MockSyslogServer(1, port);
mockServer.start();
+ // give MockSyslogServer head start
+ Thread.sleep(100);
LoggerContext lc = new LoggerContext();
lc.setName("test");
@@ -77,7 +84,7 @@
sa.setContext(lc);
sa.setSyslogHost("localhost");
sa.setFacility("MAIL");
- sa.setPort(MockSyslogServer.PORT);
+ sa.setPort(port);
sa.start();
assertTrue(sa.isStarted());
More information about the logback-dev
mailing list