You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by ma...@apache.org on 2014/10/04 18:38:21 UTC

git commit: Update test to use serializable matcher.

Repository: logging-log4j2
Updated Branches:
  refs/heads/master 408d0a9ab -> 372ebf93c


Update test to use serializable matcher.


Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/372ebf93
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/372ebf93
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/372ebf93

Branch: refs/heads/master
Commit: 372ebf93c7d4e91b851ea2bee95fa9c1e6da5bd0
Parents: 408d0a9
Author: Matt Sicker <ma...@apache.org>
Authored: Sat Oct 4 11:38:17 2014 -0500
Committer: Matt Sicker <ma...@apache.org>
Committed: Sat Oct 4 11:38:17 2014 -0500

----------------------------------------------------------------------
 log4j-slf4j-impl/pom.xml                        | 11 +++++++++++
 .../org/apache/logging/slf4j/SerializeTest.java | 20 +++-----------------
 2 files changed, 14 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/372ebf93/log4j-slf4j-impl/pom.xml
----------------------------------------------------------------------
diff --git a/log4j-slf4j-impl/pom.xml b/log4j-slf4j-impl/pom.xml
index 08e6a6a..ffb71af 100644
--- a/log4j-slf4j-impl/pom.xml
+++ b/log4j-slf4j-impl/pom.xml
@@ -48,6 +48,17 @@
     </dependency>
     <dependency>
       <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-api</artifactId>
+      <type>test-jar</type>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.commons</groupId>
+      <artifactId>commons-lang3</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
       <artifactId>log4j-core</artifactId>
       <scope>test</scope>
     </dependency>

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/372ebf93/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/SerializeTest.java
----------------------------------------------------------------------
diff --git a/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/SerializeTest.java b/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/SerializeTest.java
index f44d8ac..089bef3 100644
--- a/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/SerializeTest.java
+++ b/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/SerializeTest.java
@@ -16,19 +16,15 @@
  */
 package org.apache.logging.slf4j;
 
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
+import java.io.Serializable;
 
 import org.apache.logging.log4j.junit.InitialLoggerContext;
 import org.junit.ClassRule;
 import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.slf4j.ext.XLogger;
-import org.slf4j.ext.XLoggerFactory;
 
+import static org.apache.logging.log4j.SerializableMatchers.serializesRoundTrip;
 import static org.junit.Assert.*;
 
 /**
@@ -43,19 +39,9 @@ public class SerializeTest {
     public static final InitialLoggerContext CTX = new InitialLoggerContext(CONFIG);
 
     Logger logger = LoggerFactory.getLogger("LoggerTest");
-    XLogger xlogger = XLoggerFactory.getXLogger("LoggerTest");
 
     @Test
     public void testLogger() throws Exception {
-        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
-        final ObjectOutputStream oos = new ObjectOutputStream(baos);
-        oos.writeObject(logger);
-        final byte[] data = baos.toByteArray();
-        assertNotNull("No data", data);
-        assertTrue("No data", data.length > 0);
-        final ByteArrayInputStream bais = new ByteArrayInputStream(data);
-        final ObjectInputStream ois = new ObjectInputStream(bais);
-        final Logger copy = (org.slf4j.Logger) ois.readObject();
-        assertNotNull("Unable to restore logger", copy);
+        assertThat((Serializable) logger, serializesRoundTrip());
     }
 }