[LOGBack-dev] svn commit: r517 - in logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net: . testObjectBuilders

noreply.seb at qos.ch noreply.seb at qos.ch
Wed Sep 6 17:42:22 CEST 2006


Author: seb
Date: Wed Sep  6 17:42:21 2006
New Revision: 517

Modified:
   logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SerializationPerfsTest.java
   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/testObjectBuilders/LoggingEventBuilder.java

Log:
work in progress: modified tests

Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SerializationPerfsTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SerializationPerfsTest.java	(original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SerializationPerfsTest.java	Wed Sep  6 17:42:21 2006
@@ -5,19 +5,22 @@
 import java.net.Socket;
 
 import junit.framework.TestCase;
+import ch.qos.logback.classic.Level;
+import ch.qos.logback.classic.LoggerContext;
 import ch.qos.logback.classic.net.testObjectBuilders.Builder;
 import ch.qos.logback.classic.net.testObjectBuilders.LoggingEventExtBuilder;
 import ch.qos.logback.classic.net.testObjectBuilders.LoggingEventBuilder;
 import ch.qos.logback.classic.net.testObjectBuilders.MinimalExtBuilder;
 import ch.qos.logback.classic.net.testObjectBuilders.MinimalSerBuilder;
+import ch.qos.logback.classic.spi.LoggingEvent;
 
 public class SerializationPerfsTest extends TestCase {
 
 	ObjectOutputStream oos;
 
 	int loopNumber = 10000;
-	int resetFrequency = 100;
-	int pauseFrequency = 200;
+	int resetFrequency = 500;
+	int pauseFrequency = 500;
 	long pauseLengthInMillis = 20;
 
 	/**
@@ -69,7 +72,7 @@
 	 *	 pauseFrequency = 200 and pauseLengthInMillis = 50
 	 *
 	 * External MockServer with 45 letters-long message:
-	 * WARNING: This test was done by sending _always the same_ logger object.
+	 * This test was done by sending always the _same_ loggerEvent object.
 	 * 	 |                |  Runs | Avg time | Data sent |
 	 *   | MinimalObj Ext | 10000 |  28739   |  123604   |
 	 *   | MinimalObj Ser | 10000 |  27431   |  129604   |
@@ -98,7 +101,7 @@
 		// long time1 = System.nanoTime();
 
 		// Object builtObject = builder.build(1);
-
+		
 		// first run for just in time compiler
 		int resetCounter = 0;
 		int pauseCounter = 0;
@@ -154,20 +157,20 @@
 		// Long.toString(time2-time1));
 	}
 
-	public void testWithMinimalExternalization() throws Exception {
-		Builder builder = new MinimalExtBuilder();
-		runPerfTest(builder, "Minimal object externalization");
-	}
+//	public void testWithMinimalExternalization() throws Exception {
+//		Builder builder = new MinimalExtBuilder();
+//		runPerfTest(builder, "Minimal object externalization");
+//	}
 
 	public void testWithMinimalSerialization() throws Exception {
 		Builder builder = new MinimalSerBuilder();
 		runPerfTest(builder, "Minimal object serialization");
 	}
 
-	public void testWithExternalization() throws Exception {
-		Builder builder = new LoggingEventExtBuilder();
-		runPerfTest(builder, "LoggingEvent object externalization");
-	}
+//	public void testWithExternalization() throws Exception {
+//		Builder builder = new LoggingEventExtBuilder();
+//		runPerfTest(builder, "LoggingEvent object externalization");
+//	}
 
 	public void testWithSerialization() throws Exception {
 		Builder builder = new LoggingEventBuilder();

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	Wed Sep  6 17:42:21 2006
@@ -5,6 +5,8 @@
 import junit.framework.TestCase;
 import ch.qos.logback.classic.Logger;
 import ch.qos.logback.classic.LoggerContext;
+import ch.qos.logback.classic.LoggerContextSer;
+import ch.qos.logback.classic.LoggerSer;
 import ch.qos.logback.classic.spi.LoggingEvent;
 
 public class SocketAppenderTest extends TestCase {
@@ -45,9 +47,11 @@
 		assertTrue(mockServer.finished);
 		assertEquals(1, mockServer.loggingEventList.size());
 		LoggingEvent remoteEvent = mockServer.loggingEventList.get(0);
-		assertEquals("test", remoteEvent.getLogger().getLoggerContext().getName());
-		assertEquals("root", remoteEvent.getLogger().getName());
-		Map<String, String> props = remoteEvent.getLogger().getLoggerContext().getPropertyMap();
+		LoggerSer loggerSer = (LoggerSer)remoteEvent.getLogger();
+		LoggerContextSer loggerContextSer = (LoggerContextSer)loggerSer.getLoggerContext();
+		assertEquals("test", loggerContextSer.getName());
+		assertEquals("root", loggerSer.getName());
+		Map<String, String> props = loggerContextSer.getPropertyMap();
 		assertEquals("testValue", props.get("testKey"));
 	}
 }

Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/testObjectBuilders/LoggingEventBuilder.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/testObjectBuilders/LoggingEventBuilder.java	(original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/testObjectBuilders/LoggingEventBuilder.java	Wed Sep  6 17:42:21 2006
@@ -1,15 +1,19 @@
 package ch.qos.logback.classic.net.testObjectBuilders;
 
 import ch.qos.logback.classic.Level;
+import ch.qos.logback.classic.Logger;
 import ch.qos.logback.classic.LoggerContext;
 import ch.qos.logback.classic.spi.LoggingEvent;
 
 public class LoggingEventBuilder implements Builder {
 
+	private Logger logger = new LoggerContext().getLogger(LoggerContext.ROOT_NAME);
+	
 	public Object build(int i) {
 		LoggingEvent le = new LoggingEvent();
 		le.setLevel(Level.DEBUG);
-		le.setLogger(new LoggerContext().getLogger(LoggerContext.ROOT_NAME));
+		le.setLogger(logger);
+		//le.setLogger(new LoggerContext().getLogger(LoggerContext.ROOT_NAME));
 		le.setMessage(MSG_PREFIX + i);
 		le.setThreadName("threadName");
 		return le;



More information about the logback-dev mailing list