[slf4j-dev] [GIT] SLF4J: Simple Logging Facade for Java branch master updated. v_1.6.6-6-g3fda354

Gitbot git-noreply at pixie.qos.ch
Tue Jun 12 16:14:29 CEST 2012


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "SLF4J: Simple Logging Facade for Java".

The branch, master has been updated
       via  3fda35416bd04d8edd69a210709be329084e6960 (commit)
      from  b3e4f220b80c30c7bb9a462dde5aed17d90950eb (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.qos.ch/gitweb/?p=slf4j.git;a=commit;h=3fda35416bd04d8edd69a210709be329084e6960
http://github.com/ceki/slf4j/commit/3fda35416bd04d8edd69a210709be329084e6960

commit 3fda35416bd04d8edd69a210709be329084e6960
Author: Ceki Gulcu <ceki at qos.ch>
Date:   Tue Jun 12 16:12:52 2012 +0200

    added LoggerSerializationTest

diff --git a/slf4j-jdk14/src/test/java/org/slf4j/issue/LoggerSerializationTest.java b/slf4j-jdk14/src/test/java/org/slf4j/issue/LoggerSerializationTest.java
new file mode 100644
index 0000000..c3dcc77
--- /dev/null
+++ b/slf4j-jdk14/src/test/java/org/slf4j/issue/LoggerSerializationTest.java
@@ -0,0 +1,85 @@
+/**
+ * Copyright (c) 2004-2011 QOS.ch
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free  of charge, to any person obtaining
+ * a  copy  of this  software  and  associated  documentation files  (the
+ * "Software"), to  deal in  the Software without  restriction, including
+ * without limitation  the rights to  use, copy, modify,  merge, publish,
+ * distribute,  sublicense, and/or sell  copies of  the Software,  and to
+ * permit persons to whom the Software  is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The  above  copyright  notice  and  this permission  notice  shall  be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE  SOFTWARE IS  PROVIDED  "AS  IS", WITHOUT  WARRANTY  OF ANY  KIND,
+ * EXPRESS OR  IMPLIED, INCLUDING  BUT NOT LIMITED  TO THE  WARRANTIES OF
+ * MERCHANTABILITY,    FITNESS    FOR    A   PARTICULAR    PURPOSE    AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE,  ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+package org.slf4j.issue;
+
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+
+import junit.framework.Assert;
+
+import junit.framework.TestCase;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * See http://bugzilla.slf4j.org/show_bug.cgi?id=261
+ * @author Thorbjorn Ravn Andersen
+ */
+public class LoggerSerializationTest extends TestCase {
+
+  static class LoggerHolder implements Serializable {
+ 		private static final long serialVersionUID = 1L;
+
+ 		private Logger log = LoggerFactory.getLogger(LoggerHolder.class);
+
+ 		public String toString() {
+ 			return "log=" + getLog();
+ 		}
+
+ 		public Logger getLog() {
+ 			return log;
+ 		}
+ 	}
+
+ 	public void testCanLoggerBeSerialized() throws IOException,
+ 			ClassNotFoundException {
+
+ 		LoggerHolder lh1 = new LoggerHolder();
+
+ 		ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ 		ObjectOutputStream out = new ObjectOutputStream(baos);
+ 		out.writeObject(lh1);
+ 		out.close();
+
+ 		lh1 = null;
+
+ 		byte[] serializedLoggerHolder = baos.toByteArray();
+
+ 		InputStream is = new ByteArrayInputStream(serializedLoggerHolder);
+ 		ObjectInputStream in = new ObjectInputStream(is);
+ 		LoggerHolder lh2 = (LoggerHolder) in.readObject();
+
+ 		Assert.assertNotNull(lh2);
+ 		Assert.assertNotNull(lh2.getLog());
+ 		lh2.getLog().info("You must see this message as a log message");
+ 	}
+
+}

-----------------------------------------------------------------------

Summary of changes:
 .../org/slf4j/issue/LoggerSerializationTest.java   |   85 ++++++++++++++++++++
 1 files changed, 85 insertions(+), 0 deletions(-)
 create mode 100644 slf4j-jdk14/src/test/java/org/slf4j/issue/LoggerSerializationTest.java


hooks/post-receive
-- 
SLF4J: Simple Logging Facade for Java


More information about the slf4j-dev mailing list