[LOGBack-dev] svn commit: r500 - logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net

noreply.seb at qos.ch noreply.seb at qos.ch
Thu Aug 31 09:42:49 CEST 2006


Author: seb
Date: Thu Aug 31 09:42:49 2006
New Revision: 500

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/SocketAppenderTest.java

Log:
- improved mock server behaviour

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 Aug 31 09:42:49 2006
@@ -9,11 +9,15 @@
  */
 package ch.qos.logback.classic.net;
 
+import java.io.BufferedInputStream;
+import java.io.ObjectInputStream;
 import java.net.ServerSocket;
 import java.net.Socket;
 import java.util.ArrayList;
 import java.util.List;
 
+import ch.qos.logback.classic.spi.LoggingEvent;
+
 /**
  * 
  * 
@@ -38,12 +42,16 @@
 		try {
 			System.out.println("Listening on port " + PORT);
 			ServerSocket serverSocket = new ServerSocket(PORT);
-			
+			ObjectInputStream ois;
+			LoggingEvent event;
 			for (int i = 0; i < loopLen; i++) {
 				System.out.println("Waiting to accept a new client.");
 				Socket socket = serverSocket.accept();
 				System.out.println("Connected to client at " + socket.getInetAddress());
-				msgList.add(socket.toString());
+				ois = new ObjectInputStream(new BufferedInputStream(socket
+						.getInputStream()));
+				event = (LoggingEvent) ois.readObject();
+				msgList.add(event.getMessage());
 			}
 		} catch (Exception se) {
 			se.printStackTrace();

Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SocketAppenderTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SocketAppenderTest.java	(original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SocketAppenderTest.java	Thu Aug 31 09:42:49 2006
@@ -18,7 +18,7 @@
 	public void testRecieveMessage() throws InterruptedException {
 		MockSocketServer mockServer = new MockSocketServer(1);
 		mockServer.start();
-		mockServer.join(1000);
+		//mockServer.join(1000);
 		
 		// client configuration
 		LoggerContext lc = new LoggerContext();
@@ -38,6 +38,7 @@
     // finish much sooner than that.		
 		mockServer.join(2000);
 		assertTrue(mockServer.finished);
-		assertNotNull(mockServer.msgList.get(0));
+		assertEquals("test", mockServer.msgList.get(0));
+		
 	}
 }



More information about the logback-dev mailing list