[LOGBack-dev] svn commit: r525 - 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 22:41:06 CEST 2006


Author: ceki
Date: Thu Sep  7 22:41:05 2006
New Revision: 525

Modified:
   logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/MockSocketServer.java
   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:
attepting to solve problems on Linux



Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/MockSocketServer.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/MockSocketServer.java	(original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/MockSocketServer.java	Thu Sep  7 22:41:05 2006
@@ -39,12 +39,13 @@
 
 	@Override
 	public void run() {
-		ObjectInputStream ois;
+		ObjectInputStream ois = null;
+		ServerSocket serverSocket = null;
 		//Object readObject;
 		LoggingEvent event;
 		try {
 			//System.out.println("Listening on port " + PORT);
-			ServerSocket serverSocket = new ServerSocket(PORT);
+			serverSocket = new ServerSocket(PORT);
 			//System.out.println("Waiting to accept a new client.");
 			Socket socket = serverSocket.accept();
 			//System.out.println("Connected to client at " + socket.getInetAddress());
@@ -56,11 +57,17 @@
 //				System.out.println("* Context Name: " + event.getLogger().getLoggerContext().getName());
 				loggingEventList.add(event);
 			}
-			ois.close();
-			serverSocket.close();
 		} catch (Exception se) {
 			se.printStackTrace();
-		}
+		} finally {
+		    
+		    if(ois != null) {
+			try{ois.close(); } catch(Exception e) {}
+		    }
+		    if(serverSocket != null) {
+  		      try{ serverSocket.close(); } catch(Exception e) {}
+                    }
+                }
 		finished = true;
 	}
 }

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 22:41:05 2006
@@ -39,9 +39,11 @@
       socket = new DatagramSocket(PORT);
 
       for (int i = 0; i < loopLen; i++) {
-        byte[] buf = new byte[1024];
+        byte[] buf = new byte[2048];
         DatagramPacket packet = new DatagramPacket(buf, buf.length);
+	System.out.println("Waiting for message");
         socket.receive(packet);
+	System.out.println("Got message");
         String msg = new String(buf, 0, packet.getLength());
         msgList.add(msg);
       }
@@ -49,7 +51,7 @@
       se.printStackTrace();
     } finally {
       if(socket != null) {
-        socket.close();
+	  try {socket.close();} catch(Exception e) {}
       }
     }
     finished = true;

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 22:41:05 2006
@@ -52,7 +52,7 @@
     
     // wait max 2 seconds for mock server to finish. However, it should
     // much sooner than that.
-    mockServer.join(2000);
+    mockServer.join(8000);
     assertTrue(mockServer.finished);
     assertEquals(1, mockServer.msgList.size());
     String msg = mockServer.msgList.get(0);
@@ -90,7 +90,7 @@
     
     // wait max 2 seconds for mock server to finish. However, it should
     // much sooner than that.
-    mockServer.join(2000);
+    mockServer.join(8000);
     assertTrue(mockServer.finished);
     assertEquals(1, mockServer.msgList.size());
     String msg = mockServer.msgList.get(0);



More information about the logback-dev mailing list