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/03 09:34:25 UTC

[1/8] git commit: More literate assertions.

Repository: logging-log4j2
Updated Branches:
  refs/heads/master 0bf8ead30 -> d37276d47


More literate assertions.


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

Branch: refs/heads/master
Commit: c3414fa3401ad4213f4ce51419ab9940029f8d9e
Parents: 0bf8ead
Author: Matt Sicker <ma...@apache.org>
Authored: Thu Oct 2 23:18:18 2014 -0500
Committer: Matt Sicker <ma...@apache.org>
Committed: Thu Oct 2 23:18:18 2014 -0500

----------------------------------------------------------------------
 .../appender/rewrite/MapRewritePolicyTest.java  | 53 ++++++++++----------
 1 file changed, 27 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/c3414fa3/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rewrite/MapRewritePolicyTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rewrite/MapRewritePolicyTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rewrite/MapRewritePolicyTest.java
index e9fd41e..1e6805b 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rewrite/MapRewritePolicyTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rewrite/MapRewritePolicyTest.java
@@ -30,10 +30,13 @@ import org.apache.logging.log4j.message.SimpleMessage;
 import org.apache.logging.log4j.message.StructuredDataMessage;
 import org.apache.logging.log4j.spi.MutableThreadContextStack;
 import org.apache.logging.log4j.spi.ThreadContextStack;
-import org.junit.Assert;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
+import static org.apache.logging.log4j.junit.MapMatchers.hasSize;
+import static org.hamcrest.Matchers.hasEntry;
+import static org.junit.Assert.*;
+
 
 public class MapRewritePolicyTest {
     private static Map<String, String> map = new HashMap<String, String>();
@@ -66,7 +69,7 @@ public class MapRewritePolicyTest {
         final MapRewritePolicy addPolicy = MapRewritePolicy.createPolicy("Add", rewrite);
         LogEvent rewritten = addPolicy.rewrite(logEvent0);
         compareLogEvents(logEvent0, rewritten);
-        Assert.assertEquals("Simple log message changed", logEvent0.getMessage(), rewritten.getMessage());
+        assertEquals("Simple log message changed", logEvent0.getMessage(), rewritten.getMessage());
 
         rewritten = addPolicy.rewrite(logEvent1);
         compareLogEvents(logEvent1, rewritten);
@@ -86,7 +89,7 @@ public class MapRewritePolicyTest {
         final MapRewritePolicy updatePolicy = MapRewritePolicy.createPolicy("Update", rewrite);
         LogEvent rewritten = updatePolicy.rewrite(logEvent0);
         compareLogEvents(logEvent0, rewritten);
-        Assert.assertEquals("Simple log message changed", logEvent0.getMessage(), rewritten.getMessage());
+        assertEquals("Simple log message changed", logEvent0.getMessage(), rewritten.getMessage());
 
         rewritten = updatePolicy.rewrite(logEvent1);
         compareLogEvents(logEvent1, rewritten);
@@ -106,7 +109,7 @@ public class MapRewritePolicyTest {
         final MapRewritePolicy addPolicy = MapRewritePolicy.createPolicy(null, rewrite);
         LogEvent rewritten = addPolicy.rewrite(logEvent0);
         compareLogEvents(logEvent0, rewritten);
-        Assert.assertEquals("Simple log message changed", logEvent0.getMessage(), rewritten.getMessage());
+        assertEquals("Simple log message changed", logEvent0.getMessage(), rewritten.getMessage());
 
         rewritten = addPolicy.rewrite(logEvent1);
         compareLogEvents(logEvent1, rewritten);
@@ -122,34 +125,32 @@ public class MapRewritePolicyTest {
     }
 
     private void checkAdded(final Map<String, String> addedMap) {
-        Assert.assertEquals("unwanted entry change", "one", addedMap.get("test1"));
-        Assert.assertEquals("existing entry not updated", "2", addedMap.get("test2"));
-        Assert.assertEquals("new entry not added", "three", addedMap.get("test3"));
-        Assert.assertEquals("wrong size", 3, addedMap.size());
+        assertThat("unwanted entry change", addedMap, hasEntry("test1", "one"));
+        assertThat("existing entry not updated", addedMap, hasEntry("test2", "2"));
+        assertThat("new entry not added", addedMap, hasEntry("test3", "three"));
+        assertThat("wrong size", addedMap, hasSize(3));
     }
 
     private void checkUpdated(final Map<String, String> updatedMap) {
-        Assert.assertEquals("unwanted entry change", "one", updatedMap.get("test1"));
-        Assert.assertEquals("existing entry not updated", "2", updatedMap.get("test2"));
-        Assert.assertEquals("wrong size", 2, updatedMap.size());
+        assertThat("unwanted entry change", updatedMap, hasEntry("test1", "one"));
+        assertThat("existing entry not updated", updatedMap, hasEntry("test2", "2"));
+        assertThat("wrong size", updatedMap, hasSize(2));
     }
 
     private void compareLogEvents(final LogEvent orig, final LogEvent changed) {
         // Ensure that everything but the Mapped Data is still the same
-        Assert.assertEquals("LoggerName changed", orig.getLoggerName(), changed.getLoggerName());
-        Assert.assertEquals("Marker changed", orig.getMarker(), changed.getMarker());
-        Assert.assertEquals("FQCN changed", orig.getLoggerFqcn(), changed.getLoggerFqcn());
-        Assert.assertEquals("Level changed", orig.getLevel(), changed.getLevel());
-        Assert.assertArrayEquals("Throwable changed", orig.getThrown() == null //
-                ? null //
-                : ((Log4jLogEvent) orig).getThrownProxy().getExtendedStackTrace(), //
-                changed.getThrown() == null //
-                        ? null //
-                        : ((Log4jLogEvent) changed).getThrownProxy().getExtendedStackTrace());
-        Assert.assertEquals("ContextMap changed", orig.getContextMap(), changed.getContextMap());
-        Assert.assertEquals("ContextStack changed", orig.getContextStack(), changed.getContextStack());
-        Assert.assertEquals("ThreadName changed", orig.getThreadName(), changed.getThreadName());
-        Assert.assertEquals("Source changed", orig.getSource(), changed.getSource());
-        Assert.assertEquals("Millis changed", orig.getTimeMillis(), changed.getTimeMillis());
+        assertEquals("LoggerName changed", orig.getLoggerName(), changed.getLoggerName());
+        assertEquals("Marker changed", orig.getMarker(), changed.getMarker());
+        assertEquals("FQCN changed", orig.getLoggerFqcn(), changed.getLoggerFqcn());
+        assertEquals("Level changed", orig.getLevel(), changed.getLevel());
+        assertArrayEquals("Throwable changed",
+            orig.getThrown() == null ? null : orig.getThrownProxy().getExtendedStackTrace(),
+            changed.getThrown() == null ? null : changed.getThrownProxy().getExtendedStackTrace()
+        );
+        assertEquals("ContextMap changed", orig.getContextMap(), changed.getContextMap());
+        assertEquals("ContextStack changed", orig.getContextStack(), changed.getContextStack());
+        assertEquals("ThreadName changed", orig.getThreadName(), changed.getThreadName());
+        assertEquals("Source changed", orig.getSource(), changed.getSource());
+        assertEquals("Millis changed", orig.getTimeMillis(), changed.getTimeMillis());
     }
 }


[8/8] git commit: Move grammatical Matcher decorators to own class.

Posted by ma...@apache.org.
Move grammatical Matcher decorators to own class.


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

Branch: refs/heads/master
Commit: d37276d47c9282841b554ded3b69f42126ae6317
Parents: 960fb5f
Author: Matt Sicker <ma...@apache.org>
Authored: Fri Oct 3 02:33:48 2014 -0500
Committer: Matt Sicker <ma...@apache.org>
Committed: Fri Oct 3 02:33:48 2014 -0500

----------------------------------------------------------------------
 .../rolling/RollingAppenderSizeTest.java        |  2 +-
 .../rolling/RollingAppenderTimeAndSizeTest.java |  2 +-
 .../rolling/RollingAppenderTimeTest.java        |  2 +-
 .../RollingAppenderUncompressedTest.java        |  2 +-
 .../logging/log4j/hamcrest/Descriptors.java     | 44 ++++++++++++++++++++
 .../logging/log4j/hamcrest/FileMatchers.java    | 17 --------
 6 files changed, 48 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/d37276d4/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderSizeTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderSizeTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderSizeTest.java
index 3e629f1..726630a 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderSizeTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderSizeTest.java
@@ -32,7 +32,7 @@ import org.junit.runners.Parameterized;
 import static org.apache.logging.log4j.hamcrest.FileMatchers.exists;
 import static org.apache.logging.log4j.hamcrest.FileMatchers.hasFiles;
 import static org.apache.logging.log4j.hamcrest.FileMatchers.hasName;
-import static org.apache.logging.log4j.hamcrest.FileMatchers.that;
+import static org.apache.logging.log4j.hamcrest.Descriptors.that;
 import static org.hamcrest.Matchers.both;
 import static org.hamcrest.Matchers.endsWith;
 import static org.hamcrest.Matchers.hasItemInArray;

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/d37276d4/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderTimeAndSizeTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderTimeAndSizeTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderTimeAndSizeTest.java
index bcf05a4..ff8dde4 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderTimeAndSizeTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderTimeAndSizeTest.java
@@ -28,7 +28,7 @@ import org.junit.Test;
 import static org.apache.logging.log4j.hamcrest.FileMatchers.exists;
 import static org.apache.logging.log4j.hamcrest.FileMatchers.hasFiles;
 import static org.apache.logging.log4j.hamcrest.FileMatchers.hasName;
-import static org.apache.logging.log4j.hamcrest.FileMatchers.that;
+import static org.apache.logging.log4j.hamcrest.Descriptors.that;
 import static org.hamcrest.Matchers.both;
 import static org.hamcrest.Matchers.endsWith;
 import static org.hamcrest.Matchers.hasItemInArray;

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/d37276d4/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderTimeTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderTimeTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderTimeTest.java
index 5c6ed50..2b40af7 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderTimeTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderTimeTest.java
@@ -29,7 +29,7 @@ import org.junit.rules.RuleChain;
 import static org.apache.logging.log4j.hamcrest.FileMatchers.exists;
 import static org.apache.logging.log4j.hamcrest.FileMatchers.hasFiles;
 import static org.apache.logging.log4j.hamcrest.FileMatchers.hasName;
-import static org.apache.logging.log4j.hamcrest.FileMatchers.that;
+import static org.apache.logging.log4j.hamcrest.Descriptors.that;
 import static org.hamcrest.Matchers.both;
 import static org.hamcrest.Matchers.endsWith;
 import static org.hamcrest.Matchers.hasItemInArray;

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/d37276d4/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderUncompressedTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderUncompressedTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderUncompressedTest.java
index 80e9775..b1f14e6 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderUncompressedTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderUncompressedTest.java
@@ -31,7 +31,7 @@ import org.junit.Test;
 import static org.apache.logging.log4j.hamcrest.FileMatchers.exists;
 import static org.apache.logging.log4j.hamcrest.FileMatchers.hasFiles;
 import static org.apache.logging.log4j.hamcrest.FileMatchers.hasName;
-import static org.apache.logging.log4j.hamcrest.FileMatchers.that;
+import static org.apache.logging.log4j.hamcrest.Descriptors.that;
 import static org.hamcrest.Matchers.both;
 import static org.hamcrest.Matchers.endsWith;
 import static org.hamcrest.Matchers.hasItemInArray;

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/d37276d4/log4j-core/src/test/java/org/apache/logging/log4j/hamcrest/Descriptors.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/hamcrest/Descriptors.java b/log4j-core/src/test/java/org/apache/logging/log4j/hamcrest/Descriptors.java
new file mode 100644
index 0000000..5fe486b
--- /dev/null
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/hamcrest/Descriptors.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j.hamcrest;
+
+import org.hamcrest.Description;
+import org.hamcrest.Matcher;
+import org.hamcrest.core.Is;
+
+/**
+ * Grammatical descriptor decorators for Matchers.
+ *
+ * @since 2.1
+ */
+public class Descriptors {
+    /**
+     * Decorating Matcher similar to {@code is()}, but for better grammar.
+     *
+     * @param matcher the Matcher to decorate.
+     * @param <T> the type expected by the Matcher.
+     * @return the decorated Matcher.
+     */
+    public static <T> Matcher<T> that(final Matcher<T> matcher) {
+        return new Is<T>(matcher) {
+            @Override
+            public void describeTo(final Description description) {
+                description.appendText("that ").appendDescriptionOf(matcher);
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/d37276d4/log4j-core/src/test/java/org/apache/logging/log4j/hamcrest/FileMatchers.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/hamcrest/FileMatchers.java b/log4j-core/src/test/java/org/apache/logging/log4j/hamcrest/FileMatchers.java
index 7b4def9..7336e33 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/hamcrest/FileMatchers.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/hamcrest/FileMatchers.java
@@ -18,7 +18,6 @@ package org.apache.logging.log4j.hamcrest;
 
 import java.io.File;
 
-import org.hamcrest.CustomMatcher;
 import org.hamcrest.FeatureMatcher;
 import org.hamcrest.Matcher;
 
@@ -35,22 +34,6 @@ import static org.hamcrest.number.OrderingComparison.lessThanOrEqualTo;
 public final class FileMatchers {
 
     /**
-     * Decorating Matcher similar to {@code is()}, but for better grammar.
-     *
-     * @param matcher the Matcher to decorate.
-     * @param <T> the type expected by the Matcher.
-     * @return the decorated Matcher.
-     */
-    public static <T> Matcher<T> that(final Matcher<T> matcher) {
-        return new CustomMatcher<T>("that") {
-            @Override
-            public boolean matches(final Object item) {
-                return matcher.matches(item);
-            }
-        };
-    }
-
-    /**
      * Matches if the File exists.
      *
      * @return the Matcher.


[5/8] git commit: ILC nit.

Posted by ma...@apache.org.
ILC nit.


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

Branch: refs/heads/master
Commit: 47005497336864a60bc410ae0159891bcc6dd128
Parents: 24c974c
Author: Matt Sicker <ma...@apache.org>
Authored: Fri Oct 3 02:21:34 2014 -0500
Committer: Matt Sicker <ma...@apache.org>
Committed: Fri Oct 3 02:21:34 2014 -0500

----------------------------------------------------------------------
 .../logging/log4j/core/appender/rewrite/RewriteAppenderTest.java | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/47005497/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rewrite/RewriteAppenderTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rewrite/RewriteAppenderTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rewrite/RewriteAppenderTest.java
index fd07963..d0b832c 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rewrite/RewriteAppenderTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rewrite/RewriteAppenderTest.java
@@ -47,8 +47,8 @@ public class RewriteAppenderTest {
 
     @Before
     public void setUp() throws Exception {
-        app = (ListAppender) this.init.getAppender("List");
-        app2 = (ListAppender) this.init.getAppender("List2");
+        app = this.init.getListAppender("List");
+        app2 = this.init.getListAppender("List2");
     }
 
     @After


[3/8] git commit: Add more FileMatchers.

Posted by ma...@apache.org.
Add more FileMatchers.


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

Branch: refs/heads/master
Commit: 5315e2a924d965e43f82bdf7d9516e532360490c
Parents: 135ebe9
Author: Matt Sicker <ma...@apache.org>
Authored: Fri Oct 3 02:20:21 2014 -0500
Committer: Matt Sicker <ma...@apache.org>
Committed: Fri Oct 3 02:20:21 2014 -0500

----------------------------------------------------------------------
 .../logging/log4j/junit/FileMatchers.java       | 122 ++++++++++++++++++-
 1 file changed, 120 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/5315e2a9/log4j-core/src/test/java/org/apache/logging/log4j/junit/FileMatchers.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/junit/FileMatchers.java b/log4j-core/src/test/java/org/apache/logging/log4j/junit/FileMatchers.java
index 3207a4a..609118c 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/junit/FileMatchers.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/junit/FileMatchers.java
@@ -18,10 +18,14 @@ package org.apache.logging.log4j.junit;
 
 import java.io.File;
 
+import org.hamcrest.CustomMatcher;
 import org.hamcrest.FeatureMatcher;
 import org.hamcrest.Matcher;
 
 import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsEqual.equalTo;
+import static org.hamcrest.number.OrderingComparison.greaterThan;
+import static org.hamcrest.number.OrderingComparison.lessThanOrEqualTo;
 
 /**
  * Hamcrest Matchers that operate on File objects.
@@ -31,7 +35,25 @@ import static org.hamcrest.core.Is.is;
 public final class FileMatchers {
 
     /**
-     * Returns a File Matcher that matches if the File exists.
+     * Decorating Matcher similar to {@code is()}, but for better grammar.
+     *
+     * @param matcher the Matcher to decorate.
+     * @param <T> the type expected by the Matcher.
+     * @return the decorated Matcher.
+     */
+    public static <T> Matcher<T> that(final Matcher<T> matcher) {
+        return new CustomMatcher<T>("that") {
+            @Override
+            public boolean matches(final Object item) {
+                return matcher.matches(item);
+            }
+        };
+    }
+
+    /**
+     * Matches if the File exists.
+     *
+     * @return the Matcher.
      */
     public static Matcher<File> exists() {
         return new FeatureMatcher<File, Boolean>(is(true), "file exists", "file exists") {
@@ -43,9 +65,10 @@ public final class FileMatchers {
     }
 
     /**
-     * Returns a File Matcher that matches a Long Matcher against the file length.
+     * Matches a Long Matcher against the file length.
      *
      * @param matcher the Matcher to use on the File length.
+     * @return the Matcher.
      */
     public static Matcher<File> hasLength(final Matcher<Long> matcher) {
         return new FeatureMatcher<File, Long>(matcher, "file with size", "file with size") {
@@ -56,6 +79,101 @@ public final class FileMatchers {
         };
     }
 
+    /**
+     * Matches a specific file length.
+     *
+     * @param length the file length to match
+     * @param <T>    the type of the length.
+     * @return the Matcher.
+     */
+    public static <T extends Number> Matcher<File> hasLength(final T length) {
+        return hasLength(equalTo(length.longValue()));
+    }
+
+    /**
+     * Matches a specific file length.
+     *
+     * @param length the file length to match
+     * @return the Matcher.
+     */
+    public static Matcher<File> hasLength(final long length) {
+        return hasLength(equalTo(length));
+    }
+
+    /**
+     * Matches a file with length equal to zero.
+     *
+     * @return the Matcher.
+     */
+    public static Matcher<File> isEmpty() {
+        return hasLength(0L);
+    }
+
+    /**
+     * Matches against a file's last modification time in milliseconds.
+     *
+     * @param matcher the Matcher to use on the File modification time.
+     * @return the Matcher.
+     */
+    public static Matcher<File> lastModified(final Matcher<Long> matcher) {
+        return new FeatureMatcher<File, Long>(matcher, "was last modified", "was last modified") {
+            @Override
+            protected Long featureValueOf(final File actual) {
+                return actual.lastModified();
+            }
+        };
+    }
+
+    /**
+     * Matches a time in millis before the current time.
+     *
+     * @return the Matcher.
+     */
+    public static Matcher<Long> beforeNow() {
+        return lessThanOrEqualTo(System.currentTimeMillis());
+    }
+
+    /**
+     * Matches the number of files in a directory.
+     *
+     * @param matcher the Matcher to use on the number of files.
+     * @return the Matcher.
+     */
+    public static Matcher<File> hasNumberOfFiles(final Matcher<Integer> matcher) {
+        return new FeatureMatcher<File, Integer>(matcher, "directory with number of files",
+            "directory with number of files") {
+            @Override
+            protected Integer featureValueOf(final File actual) {
+                final File[] files = actual.listFiles();
+                return files == null ? 0 : files.length;
+            }
+        };
+    }
+
+    /**
+     * Matches a directory with at least one file.
+     *
+     * @return the Matcher.
+     */
+    public static Matcher<File> hasFiles() {
+        return hasNumberOfFiles(greaterThan(0));
+    }
+
+    /**
+     * Matches a file name.
+     *
+     * @param matcher the Matcher to use on the file name.
+     * @return the Matcher.
+     */
+    public static Matcher<File> hasName(final Matcher<String> matcher) {
+        return new FeatureMatcher<File, String>(matcher, "file named", "file named") {
+            @Override
+            protected String featureValueOf(final File actual) {
+                return actual.getName();
+            }
+        };
+    }
+
     private FileMatchers() {
     }
 


[6/8] git commit: More literate tests.

Posted by ma...@apache.org.
More literate tests.


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

Branch: refs/heads/master
Commit: f78a1566438522608051696c8e4acba5bab5b0cb
Parents: 4700549
Author: Matt Sicker <ma...@apache.org>
Authored: Fri Oct 3 02:22:51 2014 -0500
Committer: Matt Sicker <ma...@apache.org>
Committed: Fri Oct 3 02:22:51 2014 -0500

----------------------------------------------------------------------
 .../rolling/RollingAppenderSizeTest.java        | 20 +++++++-------
 .../rolling/RollingAppenderTimeAndSizeTest.java | 20 +++++++-------
 .../rolling/RollingAppenderTimeTest.java        | 18 ++++++++----
 .../RollingAppenderUncompressedTest.java        | 25 +++++++++--------
 ...RandomAccessFileManagerHeaderFooterTest.java | 15 +++++-----
 .../RollingRandomAccessFileManagerTest.java     | 29 +++++++++++++-------
 6 files changed, 73 insertions(+), 54 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f78a1566/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderSizeTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderSizeTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderSizeTest.java
index ae4b34f..c490d2c 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderSizeTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderSizeTest.java
@@ -29,6 +29,13 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
 
+import static org.apache.logging.log4j.junit.FileMatchers.exists;
+import static org.apache.logging.log4j.junit.FileMatchers.hasFiles;
+import static org.apache.logging.log4j.junit.FileMatchers.hasName;
+import static org.apache.logging.log4j.junit.FileMatchers.that;
+import static org.hamcrest.Matchers.both;
+import static org.hamcrest.Matchers.endsWith;
+import static org.hamcrest.Matchers.hasItemInArray;
 import static org.junit.Assert.*;
 
 /**
@@ -77,17 +84,10 @@ public class RollingAppenderSizeTest {
             logger.debug("This is test message number " + i);
         }
         final File dir = new File(DIR);
-        assertTrue("Directory not created", dir.exists() && dir.listFiles().length > 0);
+        assertThat(dir, both(exists()).and(hasFiles()));
         final File[] files = dir.listFiles();
-        assertTrue("No files created", files.length > 0);
-        boolean found = false;
-        for (final File file : files) {
-            if (file.getName().endsWith(fileExtension)) {
-                found = true;
-                break;
-            }
-        }
-        assertTrue("No compressed files found", found);
+        assertNotNull(files);
+        assertThat(files, hasItemInArray(that(hasName(that(endsWith(fileExtension))))));
     }
 
     private static void deleteDir() {

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f78a1566/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderTimeAndSizeTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderTimeAndSizeTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderTimeAndSizeTest.java
index 84966b1..067724e 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderTimeAndSizeTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderTimeAndSizeTest.java
@@ -25,6 +25,13 @@ import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 
+import static org.apache.logging.log4j.junit.FileMatchers.exists;
+import static org.apache.logging.log4j.junit.FileMatchers.hasFiles;
+import static org.apache.logging.log4j.junit.FileMatchers.hasName;
+import static org.apache.logging.log4j.junit.FileMatchers.that;
+import static org.hamcrest.Matchers.both;
+import static org.hamcrest.Matchers.endsWith;
+import static org.hamcrest.Matchers.hasItemInArray;
 import static org.junit.Assert.*;
 
 /**
@@ -57,17 +64,10 @@ public class RollingAppenderTimeAndSizeTest {
         }
         Thread.sleep(50);
         final File dir = new File(DIR);
-        assertTrue("Directory not created", dir.exists() && dir.listFiles().length > 0);
+        assertThat(dir, both(exists()).and(hasFiles()));
         final File[] files = dir.listFiles();
-        assertTrue("No files created", files.length > 0);
-        boolean found = false;
-        for (final File file : files) {
-            if (file.getName().endsWith(".gz")) {
-                found = true;
-                break;
-            }
-        }
-        assertTrue("No compressed files found", found);
+        assertNotNull(files);
+        assertThat(files, hasItemInArray(that(hasName(that(endsWith(".gz"))))));
     }
 
     private static void deleteDir() {

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f78a1566/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderTimeTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderTimeTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderTimeTest.java
index 1f4b188..fab6cb1 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderTimeTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderTimeTest.java
@@ -20,11 +20,19 @@ import java.io.File;
 
 import org.apache.logging.log4j.Logger;
 import org.apache.logging.log4j.junit.InitialLoggerContext;
+import org.hamcrest.Matcher;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExternalResource;
 import org.junit.rules.RuleChain;
 
+import static org.apache.logging.log4j.junit.FileMatchers.exists;
+import static org.apache.logging.log4j.junit.FileMatchers.hasFiles;
+import static org.apache.logging.log4j.junit.FileMatchers.hasName;
+import static org.apache.logging.log4j.junit.FileMatchers.that;
+import static org.hamcrest.Matchers.both;
+import static org.hamcrest.Matchers.endsWith;
+import static org.hamcrest.Matchers.hasItemInArray;
 import static org.junit.Assert.*;
 
 /**
@@ -55,16 +63,14 @@ public class RollingAppenderTimeTest {
             logger.debug("This is test message number " + i + 1);
         }
         final File dir = new File(DIR);
-        assertTrue("Directory not created", dir.exists() && dir.listFiles().length > 0);
+        assertThat(dir, both(exists()).and(hasFiles()));
 
         final int MAX_TRIES = 20;
+        final Matcher<File[]> hasGzippedFile = hasItemInArray(that(hasName(that(endsWith(".gz")))));
         for (int i = 0; i < MAX_TRIES; i++) {
             final File[] files = dir.listFiles();
-            assertTrue("No files created", files.length > 0);
-            for (final File file : files) {
-                if (file.getName().endsWith(".gz")) {
-                    return; // test succeeded
-                }
+            if (hasGzippedFile.matches(files)) {
+                return; // test succeeded
             }
             logger.debug("Adding additional event " + i);
             Thread.sleep(100); // Allow time for rollover to complete

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f78a1566/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderUncompressedTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderUncompressedTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderUncompressedTest.java
index d019813..99f23eb 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderUncompressedTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderUncompressedTest.java
@@ -23,10 +23,19 @@ import org.apache.logging.log4j.core.LoggerContext;
 import org.apache.logging.log4j.core.config.Configuration;
 import org.apache.logging.log4j.core.config.ConfigurationFactory;
 import org.apache.logging.log4j.status.StatusLogger;
+import org.hamcrest.Matcher;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
+import static org.apache.logging.log4j.junit.FileMatchers.exists;
+import static org.apache.logging.log4j.junit.FileMatchers.hasFiles;
+import static org.apache.logging.log4j.junit.FileMatchers.hasName;
+import static org.apache.logging.log4j.junit.FileMatchers.that;
+import static org.hamcrest.Matchers.both;
+import static org.hamcrest.Matchers.endsWith;
+import static org.hamcrest.Matchers.hasItemInArray;
+import static org.hamcrest.Matchers.startsWith;
 import static org.junit.Assert.*;
 
 /**
@@ -62,18 +71,12 @@ public class RollingAppenderUncompressedTest {
             logger.debug("This is test message number " + i);
         }
         final File dir = new File(DIR);
-        assertTrue("Directory not created", dir.exists() && dir.listFiles().length > 0);
+        assertThat(dir, both(exists()).and(hasFiles()));
         final File[] files = dir.listFiles();
-        assertTrue("No files created", files.length > 0);
-        boolean found = false;
-        for (final File file : files) {
-            final String name = file.getName();
-            if (name.startsWith("test1") && name.endsWith(".log")) {
-                found = true;
-                break;
-            }
-        }
-        assertTrue("No archived files found", found);
+        assertNotNull(files);
+        final Matcher<File> withCorrectFileName =
+            both(hasName(that(endsWith(".log")))).and(hasName(that(startsWith("test1"))));
+        assertThat(files, hasItemInArray(withCorrectFileName));
     }
 
     private static void deleteDir() {

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f78a1566/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingRandomAccessFileManagerHeaderFooterTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingRandomAccessFileManagerHeaderFooterTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingRandomAccessFileManagerHeaderFooterTest.java
index a663329..40134eb 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingRandomAccessFileManagerHeaderFooterTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingRandomAccessFileManagerHeaderFooterTest.java
@@ -22,12 +22,16 @@ import java.nio.charset.Charset;
 
 import org.apache.logging.log4j.Logger;
 import org.apache.logging.log4j.core.layout.HtmlLayout;
+import org.apache.logging.log4j.core.util.Closer;
 import org.apache.logging.log4j.junit.InitialLoggerContext;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 
+import static org.apache.logging.log4j.junit.FileMatchers.exists;
+import static org.apache.logging.log4j.junit.FileMatchers.hasFiles;
+import static org.hamcrest.Matchers.both;
 import static org.junit.Assert.*;
 
 /**
@@ -61,15 +65,15 @@ public class RollingRandomAccessFileManagerHeaderFooterTest {
         }
         Thread.sleep(50);
         final File dir = new File(DIR);
-        assertTrue("Directory not created", dir.exists() && dir.listFiles().length > 0);
+        assertThat(dir, both(exists()).and(hasFiles()));
         final File[] files = dir.listFiles();
-        assertTrue("No files created", files.length > 0);
+        assertNotNull(files);
         for (final File file : files) {
             assertHeader(file);
             assertFooter(file);
         }
         final File logFile = new File(LOGFILE);
-        assertTrue("Expected logfile to exist: " + LOGFILE, logFile.exists());
+        assertThat(logFile, exists());
         assertHeader(logFile);
     }
 
@@ -102,10 +106,7 @@ public class RollingRandomAccessFileManagerHeaderFooterTest {
             }
             return result;
         } finally {
-            try {
-                in.close();
-            } catch (final Exception ignored) {
-            }
+            Closer.closeSilently(in);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f78a1566/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingRandomAccessFileManagerTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingRandomAccessFileManagerTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingRandomAccessFileManagerTest.java
index 140dab0..d1bc1ad 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingRandomAccessFileManagerTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingRandomAccessFileManagerTest.java
@@ -24,9 +24,19 @@ import java.io.OutputStream;
 import java.io.RandomAccessFile;
 import java.util.concurrent.locks.LockSupport;
 
+import org.apache.logging.log4j.core.util.Closer;
 import org.apache.logging.log4j.util.Strings;
 import org.junit.Test;
 
+import static org.apache.logging.log4j.junit.FileMatchers.beforeNow;
+import static org.apache.logging.log4j.junit.FileMatchers.hasLength;
+import static org.apache.logging.log4j.junit.FileMatchers.isEmpty;
+import static org.apache.logging.log4j.junit.FileMatchers.lastModified;
+import static org.hamcrest.Matchers.both;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.greaterThanOrEqualTo;
+import static org.hamcrest.Matchers.lessThan;
+import static org.hamcrest.Matchers.lessThanOrEqualTo;
 import static org.junit.Assert.*;
 
 /**
@@ -113,7 +123,7 @@ public class RollingRandomAccessFileManagerTest {
         final RollingRandomAccessFileManager manager = new RollingRandomAccessFileManager(raf,
                 file.getName(), Strings.EMPTY, os, append, flushNow, bufferSize, triggerSize, time,
                 triggerPolicy, rolloverStrategy, null, null);
-        
+
         // check the resulting buffer size is what was requested
         assertEquals(bufferSize, manager.getBufferSize());
     }
@@ -123,7 +133,7 @@ public class RollingRandomAccessFileManagerTest {
         final boolean isAppend = true;
         final File file = File.createTempFile("log4j2", "test");
         file.deleteOnExit();
-        assertEquals(0, file.length());
+        assertThat(file, isEmpty());
 
         final byte[] bytes = new byte[4 * 1024];
 
@@ -134,9 +144,9 @@ public class RollingRandomAccessFileManagerTest {
             fos.write(bytes, 0, bytes.length);
             fos.flush();
         } finally {
-            fos.close();
+            Closer.closeSilently(fos);
         }
-        assertEquals("all flushed to disk", bytes.length, file.length());
+        assertThat("all flushed to disk", file, hasLength(bytes.length));
 
         final RollingRandomAccessFileManager manager = RollingRandomAccessFileManager
                 .getRollingRandomAccessFileManager(
@@ -146,7 +156,7 @@ public class RollingRandomAccessFileManagerTest {
                         null, null, null);
         manager.write(bytes, 0, bytes.length);
         final int expected = bytes.length * 2;
-        assertEquals("appended, not overwritten", expected, file.length());
+        assertThat("appended, not overwritten", file, hasLength(expected));
     }
 
     @Test
@@ -160,7 +170,7 @@ public class RollingRandomAccessFileManagerTest {
         final boolean isAppend = false;
         final long expectedMin = System.currentTimeMillis();
         final long expectedMax = expectedMin + 500;
-        assertTrue(file.lastModified() <= expectedMin);
+        assertThat(file, lastModified(lessThanOrEqualTo(expectedMin)));
 
         final RollingRandomAccessFileManager manager = RollingRandomAccessFileManager
                 .getRollingRandomAccessFileManager(
@@ -168,8 +178,7 @@ public class RollingRandomAccessFileManagerTest {
                         file.getAbsolutePath(), Strings.EMPTY, isAppend, true, RollingRandomAccessFileManager.DEFAULT_BUFFER_SIZE,
                         new SizeBasedTriggeringPolicy(Long.MAX_VALUE), //
                         null, null, null);
-        assertTrue(manager.getFileTime() < expectedMax);
-        assertTrue(manager.getFileTime() >= expectedMin);
+        assertThat(manager.getFileTime(), both(lessThan(expectedMax)).and(greaterThanOrEqualTo(expectedMin)));
     }
 
     @Test
@@ -180,7 +189,7 @@ public class RollingRandomAccessFileManagerTest {
         LockSupport.parkNanos(1000000); // 1 millisec
 
         final boolean isAppend = true;
-        assertTrue(file.lastModified() <= System.currentTimeMillis());
+        assertThat(file, lastModified(beforeNow()));
 
         final RollingRandomAccessFileManager manager = RollingRandomAccessFileManager
                 .getRollingRandomAccessFileManager(
@@ -188,7 +197,7 @@ public class RollingRandomAccessFileManagerTest {
                         file.getAbsolutePath(), Strings.EMPTY, isAppend, true, RollingRandomAccessFileManager.DEFAULT_BUFFER_SIZE,
                         new SizeBasedTriggeringPolicy(Long.MAX_VALUE), //
                         null, null, null);
-        assertEquals(file.lastModified(), manager.getFileTime());
+        assertThat(file, lastModified(equalTo(manager.getFileTime())));
     }
 
 }


[7/8] git commit: Move custom Hamcrest classes to new test package.

Posted by ma...@apache.org.
Move custom Hamcrest classes to new test package.


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

Branch: refs/heads/master
Commit: 960fb5fc74c5d1f9adbfca005cb75ebc7db21323
Parents: f78a156
Author: Matt Sicker <ma...@apache.org>
Authored: Fri Oct 3 02:23:42 2014 -0500
Committer: Matt Sicker <ma...@apache.org>
Committed: Fri Oct 3 02:23:42 2014 -0500

----------------------------------------------------------------------
 .../appender/rewrite/MapRewritePolicyTest.java  |   2 +-
 .../rolling/RollingAppenderSizeTest.java        |   8 +-
 .../rolling/RollingAppenderTimeAndSizeTest.java |   8 +-
 .../rolling/RollingAppenderTimeTest.java        |   8 +-
 .../RollingAppenderUncompressedTest.java        |   8 +-
 ...RandomAccessFileManagerHeaderFooterTest.java |   4 +-
 .../RollingRandomAccessFileManagerTest.java     |   8 +-
 .../core/config/CustomConfigurationTest.java    |   4 +-
 .../log4j/core/config/FileOutputTest.java       |   4 +-
 .../core/config/MissingRootLoggerTest.java      |   2 +-
 .../log4j/core/config/TestConfigurator.java     |   2 +-
 .../logging/log4j/core/config/XIncludeTest.java |   2 +-
 .../logging/log4j/hamcrest/FileMatchers.java    | 180 +++++++++++++++++++
 .../logging/log4j/hamcrest/MapMatchers.java     |  62 +++++++
 .../logging/log4j/junit/FileMatchers.java       | 180 -------------------
 .../apache/logging/log4j/junit/MapMatchers.java |  62 -------
 16 files changed, 272 insertions(+), 272 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/960fb5fc/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rewrite/MapRewritePolicyTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rewrite/MapRewritePolicyTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rewrite/MapRewritePolicyTest.java
index 82d3378..ff646e8 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rewrite/MapRewritePolicyTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rewrite/MapRewritePolicyTest.java
@@ -33,7 +33,7 @@ import org.apache.logging.log4j.spi.ThreadContextStack;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
-import static org.apache.logging.log4j.junit.MapMatchers.hasSize;
+import static org.apache.logging.log4j.hamcrest.MapMatchers.hasSize;
 import static org.hamcrest.Matchers.hasEntry;
 import static org.junit.Assert.*;
 

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/960fb5fc/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderSizeTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderSizeTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderSizeTest.java
index c490d2c..3e629f1 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderSizeTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderSizeTest.java
@@ -29,10 +29,10 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
 
-import static org.apache.logging.log4j.junit.FileMatchers.exists;
-import static org.apache.logging.log4j.junit.FileMatchers.hasFiles;
-import static org.apache.logging.log4j.junit.FileMatchers.hasName;
-import static org.apache.logging.log4j.junit.FileMatchers.that;
+import static org.apache.logging.log4j.hamcrest.FileMatchers.exists;
+import static org.apache.logging.log4j.hamcrest.FileMatchers.hasFiles;
+import static org.apache.logging.log4j.hamcrest.FileMatchers.hasName;
+import static org.apache.logging.log4j.hamcrest.FileMatchers.that;
 import static org.hamcrest.Matchers.both;
 import static org.hamcrest.Matchers.endsWith;
 import static org.hamcrest.Matchers.hasItemInArray;

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/960fb5fc/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderTimeAndSizeTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderTimeAndSizeTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderTimeAndSizeTest.java
index 067724e..bcf05a4 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderTimeAndSizeTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderTimeAndSizeTest.java
@@ -25,10 +25,10 @@ import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 
-import static org.apache.logging.log4j.junit.FileMatchers.exists;
-import static org.apache.logging.log4j.junit.FileMatchers.hasFiles;
-import static org.apache.logging.log4j.junit.FileMatchers.hasName;
-import static org.apache.logging.log4j.junit.FileMatchers.that;
+import static org.apache.logging.log4j.hamcrest.FileMatchers.exists;
+import static org.apache.logging.log4j.hamcrest.FileMatchers.hasFiles;
+import static org.apache.logging.log4j.hamcrest.FileMatchers.hasName;
+import static org.apache.logging.log4j.hamcrest.FileMatchers.that;
 import static org.hamcrest.Matchers.both;
 import static org.hamcrest.Matchers.endsWith;
 import static org.hamcrest.Matchers.hasItemInArray;

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/960fb5fc/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderTimeTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderTimeTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderTimeTest.java
index fab6cb1..5c6ed50 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderTimeTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderTimeTest.java
@@ -26,10 +26,10 @@ import org.junit.Test;
 import org.junit.rules.ExternalResource;
 import org.junit.rules.RuleChain;
 
-import static org.apache.logging.log4j.junit.FileMatchers.exists;
-import static org.apache.logging.log4j.junit.FileMatchers.hasFiles;
-import static org.apache.logging.log4j.junit.FileMatchers.hasName;
-import static org.apache.logging.log4j.junit.FileMatchers.that;
+import static org.apache.logging.log4j.hamcrest.FileMatchers.exists;
+import static org.apache.logging.log4j.hamcrest.FileMatchers.hasFiles;
+import static org.apache.logging.log4j.hamcrest.FileMatchers.hasName;
+import static org.apache.logging.log4j.hamcrest.FileMatchers.that;
 import static org.hamcrest.Matchers.both;
 import static org.hamcrest.Matchers.endsWith;
 import static org.hamcrest.Matchers.hasItemInArray;

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/960fb5fc/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderUncompressedTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderUncompressedTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderUncompressedTest.java
index 99f23eb..80e9775 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderUncompressedTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderUncompressedTest.java
@@ -28,10 +28,10 @@ import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
-import static org.apache.logging.log4j.junit.FileMatchers.exists;
-import static org.apache.logging.log4j.junit.FileMatchers.hasFiles;
-import static org.apache.logging.log4j.junit.FileMatchers.hasName;
-import static org.apache.logging.log4j.junit.FileMatchers.that;
+import static org.apache.logging.log4j.hamcrest.FileMatchers.exists;
+import static org.apache.logging.log4j.hamcrest.FileMatchers.hasFiles;
+import static org.apache.logging.log4j.hamcrest.FileMatchers.hasName;
+import static org.apache.logging.log4j.hamcrest.FileMatchers.that;
 import static org.hamcrest.Matchers.both;
 import static org.hamcrest.Matchers.endsWith;
 import static org.hamcrest.Matchers.hasItemInArray;

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/960fb5fc/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingRandomAccessFileManagerHeaderFooterTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingRandomAccessFileManagerHeaderFooterTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingRandomAccessFileManagerHeaderFooterTest.java
index 40134eb..a1d75e2 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingRandomAccessFileManagerHeaderFooterTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingRandomAccessFileManagerHeaderFooterTest.java
@@ -29,8 +29,8 @@ import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 
-import static org.apache.logging.log4j.junit.FileMatchers.exists;
-import static org.apache.logging.log4j.junit.FileMatchers.hasFiles;
+import static org.apache.logging.log4j.hamcrest.FileMatchers.exists;
+import static org.apache.logging.log4j.hamcrest.FileMatchers.hasFiles;
 import static org.hamcrest.Matchers.both;
 import static org.junit.Assert.*;
 

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/960fb5fc/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingRandomAccessFileManagerTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingRandomAccessFileManagerTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingRandomAccessFileManagerTest.java
index d1bc1ad..b80bb72 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingRandomAccessFileManagerTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingRandomAccessFileManagerTest.java
@@ -28,10 +28,10 @@ import org.apache.logging.log4j.core.util.Closer;
 import org.apache.logging.log4j.util.Strings;
 import org.junit.Test;
 
-import static org.apache.logging.log4j.junit.FileMatchers.beforeNow;
-import static org.apache.logging.log4j.junit.FileMatchers.hasLength;
-import static org.apache.logging.log4j.junit.FileMatchers.isEmpty;
-import static org.apache.logging.log4j.junit.FileMatchers.lastModified;
+import static org.apache.logging.log4j.hamcrest.FileMatchers.beforeNow;
+import static org.apache.logging.log4j.hamcrest.FileMatchers.hasLength;
+import static org.apache.logging.log4j.hamcrest.FileMatchers.isEmpty;
+import static org.apache.logging.log4j.hamcrest.FileMatchers.lastModified;
 import static org.hamcrest.Matchers.both;
 import static org.hamcrest.Matchers.equalTo;
 import static org.hamcrest.Matchers.greaterThanOrEqualTo;

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/960fb5fc/log4j-core/src/test/java/org/apache/logging/log4j/core/config/CustomConfigurationTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/CustomConfigurationTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/CustomConfigurationTest.java
index 14af83a..72c81a4 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/CustomConfigurationTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/CustomConfigurationTest.java
@@ -36,8 +36,8 @@ import org.junit.BeforeClass;
 import org.junit.Rule;
 import org.junit.Test;
 
-import static org.apache.logging.log4j.junit.FileMatchers.exists;
-import static org.apache.logging.log4j.junit.FileMatchers.hasLength;
+import static org.apache.logging.log4j.hamcrest.FileMatchers.exists;
+import static org.apache.logging.log4j.hamcrest.FileMatchers.hasLength;
 import static org.hamcrest.Matchers.greaterThan;
 import static org.hamcrest.Matchers.instanceOf;
 import static org.junit.Assert.*;

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/960fb5fc/log4j-core/src/test/java/org/apache/logging/log4j/core/config/FileOutputTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/FileOutputTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/FileOutputTest.java
index df9383a..86efebd 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/FileOutputTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/FileOutputTest.java
@@ -24,8 +24,8 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.RuleChain;
 
-import static org.apache.logging.log4j.junit.FileMatchers.exists;
-import static org.apache.logging.log4j.junit.FileMatchers.hasLength;
+import static org.apache.logging.log4j.hamcrest.FileMatchers.exists;
+import static org.apache.logging.log4j.hamcrest.FileMatchers.hasLength;
 import static org.hamcrest.Matchers.greaterThan;
 import static org.junit.Assert.*;
 

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/960fb5fc/log4j-core/src/test/java/org/apache/logging/log4j/core/config/MissingRootLoggerTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/MissingRootLoggerTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/MissingRootLoggerTest.java
index 14067a5..10fdacf 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/MissingRootLoggerTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/MissingRootLoggerTest.java
@@ -28,7 +28,7 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runners.JUnit4;
 
-import static org.apache.logging.log4j.junit.MapMatchers.hasSize;
+import static org.apache.logging.log4j.hamcrest.MapMatchers.hasSize;
 import static org.hamcrest.Matchers.hasKey;
 import static org.hamcrest.Matchers.instanceOf;
 import static org.hamcrest.Matchers.is;

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/960fb5fc/log4j-core/src/test/java/org/apache/logging/log4j/core/config/TestConfigurator.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/TestConfigurator.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/TestConfigurator.java
index 22908ac..7b028e5 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/TestConfigurator.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/TestConfigurator.java
@@ -36,7 +36,7 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runners.JUnit4;
 
-import static org.apache.logging.log4j.junit.MapMatchers.hasSize;
+import static org.apache.logging.log4j.hamcrest.MapMatchers.hasSize;
 import static org.hamcrest.Matchers.equalTo;
 import static org.hamcrest.Matchers.greaterThan;
 import static org.hamcrest.Matchers.hasKey;

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/960fb5fc/log4j-core/src/test/java/org/apache/logging/log4j/core/config/XIncludeTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/XIncludeTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/XIncludeTest.java
index f2c9579..d5af747 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/XIncludeTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/XIncludeTest.java
@@ -43,7 +43,7 @@ import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
 import org.junit.runners.Parameterized.Parameters;
 
-import static org.apache.logging.log4j.junit.MapMatchers.hasSize;
+import static org.apache.logging.log4j.hamcrest.MapMatchers.hasSize;
 import static org.hamcrest.Matchers.endsWith;
 import static org.hamcrest.Matchers.equalTo;
 import static org.hamcrest.Matchers.instanceOf;

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/960fb5fc/log4j-core/src/test/java/org/apache/logging/log4j/hamcrest/FileMatchers.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/hamcrest/FileMatchers.java b/log4j-core/src/test/java/org/apache/logging/log4j/hamcrest/FileMatchers.java
new file mode 100644
index 0000000..7b4def9
--- /dev/null
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/hamcrest/FileMatchers.java
@@ -0,0 +1,180 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j.hamcrest;
+
+import java.io.File;
+
+import org.hamcrest.CustomMatcher;
+import org.hamcrest.FeatureMatcher;
+import org.hamcrest.Matcher;
+
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsEqual.equalTo;
+import static org.hamcrest.number.OrderingComparison.greaterThan;
+import static org.hamcrest.number.OrderingComparison.lessThanOrEqualTo;
+
+/**
+ * Hamcrest Matchers that operate on File objects.
+ *
+ * @since 2.1
+ */
+public final class FileMatchers {
+
+    /**
+     * Decorating Matcher similar to {@code is()}, but for better grammar.
+     *
+     * @param matcher the Matcher to decorate.
+     * @param <T> the type expected by the Matcher.
+     * @return the decorated Matcher.
+     */
+    public static <T> Matcher<T> that(final Matcher<T> matcher) {
+        return new CustomMatcher<T>("that") {
+            @Override
+            public boolean matches(final Object item) {
+                return matcher.matches(item);
+            }
+        };
+    }
+
+    /**
+     * Matches if the File exists.
+     *
+     * @return the Matcher.
+     */
+    public static Matcher<File> exists() {
+        return new FeatureMatcher<File, Boolean>(is(true), "file exists", "file exists") {
+            @Override
+            protected Boolean featureValueOf(final File actual) {
+                return actual.exists();
+            }
+        };
+    }
+
+    /**
+     * Matches a Long Matcher against the file length.
+     *
+     * @param matcher the Matcher to use on the File length.
+     * @return the Matcher.
+     */
+    public static Matcher<File> hasLength(final Matcher<Long> matcher) {
+        return new FeatureMatcher<File, Long>(matcher, "file with size", "file with size") {
+            @Override
+            protected Long featureValueOf(final File actual) {
+                return actual.length();
+            }
+        };
+    }
+
+    /**
+     * Matches a specific file length.
+     *
+     * @param length the file length to match
+     * @param <T>    the type of the length.
+     * @return the Matcher.
+     */
+    public static <T extends Number> Matcher<File> hasLength(final T length) {
+        return hasLength(equalTo(length.longValue()));
+    }
+
+    /**
+     * Matches a specific file length.
+     *
+     * @param length the file length to match
+     * @return the Matcher.
+     */
+    public static Matcher<File> hasLength(final long length) {
+        return hasLength(equalTo(length));
+    }
+
+    /**
+     * Matches a file with length equal to zero.
+     *
+     * @return the Matcher.
+     */
+    public static Matcher<File> isEmpty() {
+        return hasLength(0L);
+    }
+
+    /**
+     * Matches against a file's last modification time in milliseconds.
+     *
+     * @param matcher the Matcher to use on the File modification time.
+     * @return the Matcher.
+     */
+    public static Matcher<File> lastModified(final Matcher<Long> matcher) {
+        return new FeatureMatcher<File, Long>(matcher, "was last modified", "was last modified") {
+            @Override
+            protected Long featureValueOf(final File actual) {
+                return actual.lastModified();
+            }
+        };
+    }
+
+    /**
+     * Matches a time in millis before the current time.
+     *
+     * @return the Matcher.
+     */
+    public static Matcher<Long> beforeNow() {
+        return lessThanOrEqualTo(System.currentTimeMillis());
+    }
+
+    /**
+     * Matches the number of files in a directory.
+     *
+     * @param matcher the Matcher to use on the number of files.
+     * @return the Matcher.
+     */
+    public static Matcher<File> hasNumberOfFiles(final Matcher<Integer> matcher) {
+        return new FeatureMatcher<File, Integer>(matcher, "directory with number of files",
+            "directory with number of files") {
+            @Override
+            protected Integer featureValueOf(final File actual) {
+                final File[] files = actual.listFiles();
+                return files == null ? 0 : files.length;
+            }
+        };
+    }
+
+    /**
+     * Matches a directory with at least one file.
+     *
+     * @return the Matcher.
+     */
+    public static Matcher<File> hasFiles() {
+        return hasNumberOfFiles(greaterThan(0));
+    }
+
+    /**
+     * Matches a file name.
+     *
+     * @param matcher the Matcher to use on the file name.
+     * @return the Matcher.
+     */
+    public static Matcher<File> hasName(final Matcher<String> matcher) {
+        return new FeatureMatcher<File, String>(matcher, "file named", "file named") {
+            @Override
+            protected String featureValueOf(final File actual) {
+                return actual.getName();
+            }
+        };
+    }
+
+    private FileMatchers() {
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/960fb5fc/log4j-core/src/test/java/org/apache/logging/log4j/hamcrest/MapMatchers.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/hamcrest/MapMatchers.java b/log4j-core/src/test/java/org/apache/logging/log4j/hamcrest/MapMatchers.java
new file mode 100644
index 0000000..805c8a6
--- /dev/null
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/hamcrest/MapMatchers.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j.hamcrest;
+
+import java.util.Map;
+
+import org.hamcrest.FeatureMatcher;
+import org.hamcrest.Matcher;
+
+import static org.hamcrest.core.IsEqual.equalTo;
+
+/**
+ * Hamcrest Matchers for Maps.
+ *
+ * @since 2.1
+ */
+public final class MapMatchers {
+
+    /**
+     * Returns a Map Matcher matching on the size of a Map.
+     *
+     * @param matcher the Matcher to match against the Map size.
+     * @param <K>     the key type.
+     * @param <V>     the value type.
+     */
+    public static <K, V> Matcher<Map<? extends K, ? extends V>> hasSize(final Matcher<Integer> matcher) {
+        return new FeatureMatcher<Map<? extends K, ? extends V>, Integer>(matcher, "map with size", "map with size") {
+            @Override
+            protected Integer featureValueOf(final Map<? extends K, ? extends V> actual) {
+                return actual.size();
+            }
+        };
+    }
+
+    /**
+     * Returns a Map Matcher matching on the exact size of a Map.
+     *
+     * @param size the number of entries to match the Map against.
+     * @param <K>  the key type.
+     * @param <V>  the value type.
+     */
+    public static <K, V> Matcher<Map<? extends K, ? extends V>> hasSize(final int size) {
+        return hasSize(equalTo(size));
+    }
+
+    private MapMatchers() {
+    }
+}

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/960fb5fc/log4j-core/src/test/java/org/apache/logging/log4j/junit/FileMatchers.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/junit/FileMatchers.java b/log4j-core/src/test/java/org/apache/logging/log4j/junit/FileMatchers.java
deleted file mode 100644
index 609118c..0000000
--- a/log4j-core/src/test/java/org/apache/logging/log4j/junit/FileMatchers.java
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-package org.apache.logging.log4j.junit;
-
-import java.io.File;
-
-import org.hamcrest.CustomMatcher;
-import org.hamcrest.FeatureMatcher;
-import org.hamcrest.Matcher;
-
-import static org.hamcrest.core.Is.is;
-import static org.hamcrest.core.IsEqual.equalTo;
-import static org.hamcrest.number.OrderingComparison.greaterThan;
-import static org.hamcrest.number.OrderingComparison.lessThanOrEqualTo;
-
-/**
- * Hamcrest Matchers that operate on File objects.
- *
- * @since 2.1
- */
-public final class FileMatchers {
-
-    /**
-     * Decorating Matcher similar to {@code is()}, but for better grammar.
-     *
-     * @param matcher the Matcher to decorate.
-     * @param <T> the type expected by the Matcher.
-     * @return the decorated Matcher.
-     */
-    public static <T> Matcher<T> that(final Matcher<T> matcher) {
-        return new CustomMatcher<T>("that") {
-            @Override
-            public boolean matches(final Object item) {
-                return matcher.matches(item);
-            }
-        };
-    }
-
-    /**
-     * Matches if the File exists.
-     *
-     * @return the Matcher.
-     */
-    public static Matcher<File> exists() {
-        return new FeatureMatcher<File, Boolean>(is(true), "file exists", "file exists") {
-            @Override
-            protected Boolean featureValueOf(final File actual) {
-                return actual.exists();
-            }
-        };
-    }
-
-    /**
-     * Matches a Long Matcher against the file length.
-     *
-     * @param matcher the Matcher to use on the File length.
-     * @return the Matcher.
-     */
-    public static Matcher<File> hasLength(final Matcher<Long> matcher) {
-        return new FeatureMatcher<File, Long>(matcher, "file with size", "file with size") {
-            @Override
-            protected Long featureValueOf(final File actual) {
-                return actual.length();
-            }
-        };
-    }
-
-    /**
-     * Matches a specific file length.
-     *
-     * @param length the file length to match
-     * @param <T>    the type of the length.
-     * @return the Matcher.
-     */
-    public static <T extends Number> Matcher<File> hasLength(final T length) {
-        return hasLength(equalTo(length.longValue()));
-    }
-
-    /**
-     * Matches a specific file length.
-     *
-     * @param length the file length to match
-     * @return the Matcher.
-     */
-    public static Matcher<File> hasLength(final long length) {
-        return hasLength(equalTo(length));
-    }
-
-    /**
-     * Matches a file with length equal to zero.
-     *
-     * @return the Matcher.
-     */
-    public static Matcher<File> isEmpty() {
-        return hasLength(0L);
-    }
-
-    /**
-     * Matches against a file's last modification time in milliseconds.
-     *
-     * @param matcher the Matcher to use on the File modification time.
-     * @return the Matcher.
-     */
-    public static Matcher<File> lastModified(final Matcher<Long> matcher) {
-        return new FeatureMatcher<File, Long>(matcher, "was last modified", "was last modified") {
-            @Override
-            protected Long featureValueOf(final File actual) {
-                return actual.lastModified();
-            }
-        };
-    }
-
-    /**
-     * Matches a time in millis before the current time.
-     *
-     * @return the Matcher.
-     */
-    public static Matcher<Long> beforeNow() {
-        return lessThanOrEqualTo(System.currentTimeMillis());
-    }
-
-    /**
-     * Matches the number of files in a directory.
-     *
-     * @param matcher the Matcher to use on the number of files.
-     * @return the Matcher.
-     */
-    public static Matcher<File> hasNumberOfFiles(final Matcher<Integer> matcher) {
-        return new FeatureMatcher<File, Integer>(matcher, "directory with number of files",
-            "directory with number of files") {
-            @Override
-            protected Integer featureValueOf(final File actual) {
-                final File[] files = actual.listFiles();
-                return files == null ? 0 : files.length;
-            }
-        };
-    }
-
-    /**
-     * Matches a directory with at least one file.
-     *
-     * @return the Matcher.
-     */
-    public static Matcher<File> hasFiles() {
-        return hasNumberOfFiles(greaterThan(0));
-    }
-
-    /**
-     * Matches a file name.
-     *
-     * @param matcher the Matcher to use on the file name.
-     * @return the Matcher.
-     */
-    public static Matcher<File> hasName(final Matcher<String> matcher) {
-        return new FeatureMatcher<File, String>(matcher, "file named", "file named") {
-            @Override
-            protected String featureValueOf(final File actual) {
-                return actual.getName();
-            }
-        };
-    }
-
-    private FileMatchers() {
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/960fb5fc/log4j-core/src/test/java/org/apache/logging/log4j/junit/MapMatchers.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/junit/MapMatchers.java b/log4j-core/src/test/java/org/apache/logging/log4j/junit/MapMatchers.java
deleted file mode 100644
index 7fd19a8..0000000
--- a/log4j-core/src/test/java/org/apache/logging/log4j/junit/MapMatchers.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-package org.apache.logging.log4j.junit;
-
-import java.util.Map;
-
-import org.hamcrest.FeatureMatcher;
-import org.hamcrest.Matcher;
-
-import static org.hamcrest.core.IsEqual.equalTo;
-
-/**
- * Hamcrest Matchers for Maps.
- *
- * @since 2.1
- */
-public final class MapMatchers {
-
-    /**
-     * Returns a Map Matcher matching on the size of a Map.
-     *
-     * @param matcher the Matcher to match against the Map size.
-     * @param <K>     the key type.
-     * @param <V>     the value type.
-     */
-    public static <K, V> Matcher<Map<? extends K, ? extends V>> hasSize(final Matcher<Integer> matcher) {
-        return new FeatureMatcher<Map<? extends K, ? extends V>, Integer>(matcher, "map with size", "map with size") {
-            @Override
-            protected Integer featureValueOf(final Map<? extends K, ? extends V> actual) {
-                return actual.size();
-            }
-        };
-    }
-
-    /**
-     * Returns a Map Matcher matching on the exact size of a Map.
-     *
-     * @param size the number of entries to match the Map against.
-     * @param <K>  the key type.
-     * @param <V>  the value type.
-     */
-    public static <K, V> Matcher<Map<? extends K, ? extends V>> hasSize(final int size) {
-        return hasSize(equalTo(size));
-    }
-
-    private MapMatchers() {
-    }
-}


[4/8] git commit: Use Calendar constants instead of magic constants.

Posted by ma...@apache.org.
Use Calendar constants instead of magic constants.


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

Branch: refs/heads/master
Commit: 24c974c1b36d90d15d0c6a8da8fad41799d9ff78
Parents: 5315e2a
Author: Matt Sicker <ma...@apache.org>
Authored: Fri Oct 3 02:21:21 2014 -0500
Committer: Matt Sicker <ma...@apache.org>
Committed: Fri Oct 3 02:21:21 2014 -0500

----------------------------------------------------------------------
 .../appender/rolling/PatternProcessorTest.java  | 42 ++++++++++----------
 1 file changed, 21 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/24c974c1/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/PatternProcessorTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/PatternProcessorTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/PatternProcessorTest.java
index a41e68c..75b95a3 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/PatternProcessorTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/PatternProcessorTest.java
@@ -40,12 +40,12 @@ public class PatternProcessorTest {
     public void testGetNextTimeMonthlyReturnsFirstDayOfNextMonth() {
         final PatternProcessor pp = new PatternProcessor("logs/app-%d{yyyy-MM}.log.gz");
         final Calendar initial = Calendar.getInstance();
-        initial.set(2014, 9, 15, 10, 31, 59); // Oct 15th
+        initial.set(2014, Calendar.OCTOBER, 15, 10, 31, 59); // Oct 15th
         final long actual = pp.getNextTime(initial.getTimeInMillis(), 1, false);
 
         // We expect 1st day of next month
         final Calendar expected = Calendar.getInstance();
-        expected.set(2014, 10, 1, 0, 0, 00);
+        expected.set(2014, Calendar.NOVEMBER, 1, 00, 00, 00);
         expected.set(Calendar.MILLISECOND, 0);
         assertEquals(format(expected.getTimeInMillis()), format(actual));
     }
@@ -54,12 +54,12 @@ public class PatternProcessorTest {
     public void testGetNextTimeMonthlyReturnsFirstDayOfNextMonth2() {
         final PatternProcessor pp = new PatternProcessor("logs/app-%d{yyyy-MM}.log.gz");
         final Calendar initial = Calendar.getInstance();
-        initial.set(2014, 0, 31, 10, 31, 59); // 2014 Jan 31st
+        initial.set(2014, Calendar.JANUARY, 31, 10, 31, 59); // 2014 Jan 31st
         final long actual = pp.getNextTime(initial.getTimeInMillis(), 1, false);
 
         // Expect 1st of next month: 2014 Feb 1st
         final Calendar expected = Calendar.getInstance();
-        expected.set(2014, 1, 1, 0, 0, 00);
+        expected.set(2014, Calendar.FEBRUARY, 1, 00, 00, 00);
         expected.set(Calendar.MILLISECOND, 0);
         assertEquals(format(expected.getTimeInMillis()), format(actual));
     }
@@ -68,12 +68,12 @@ public class PatternProcessorTest {
     public void testGetNextTimeMonthlyReturnsFirstDayOfNextMonth3() {
         final PatternProcessor pp = new PatternProcessor("logs/app-%d{yyyy-MM}.log.gz");
         final Calendar initial = Calendar.getInstance();
-        initial.set(2014, 11, 31, 10, 31, 59); // 2014 Dec 31st
+        initial.set(2014, Calendar.DECEMBER, 31, 10, 31, 59); // 2014 Dec 31st
         final long actual = pp.getNextTime(initial.getTimeInMillis(), 1, false);
 
         // Expect 1st of next month: 2015 Jan 1st
         final Calendar expected = Calendar.getInstance();
-        expected.set(2015, 0, 1, 0, 0, 00);
+        expected.set(2015, Calendar.JANUARY, 1, 00, 00, 00);
         expected.set(Calendar.MILLISECOND, 0);
         assertEquals(format(expected.getTimeInMillis()), format(actual));
     }
@@ -86,12 +86,12 @@ public class PatternProcessorTest {
         try {
             final PatternProcessor pp = new PatternProcessor("logs/app-%d{yyyy-MM-W}.log.gz");
             final Calendar initial = Calendar.getInstance();
-            initial.set(2014, 2, 4, 10, 31, 59); // Tue, March 4, 2014
+            initial.set(2014, Calendar.MARCH, 4, 10, 31, 59); // Tue, March 4, 2014
             final long actual = pp.getNextTime(initial.getTimeInMillis(), 1, false);
 
             // expect Sunday, March 9, 2014
             final Calendar expected = Calendar.getInstance();
-            expected.set(2014, 2, 9, 0, 0, 00);
+            expected.set(2014, Calendar.MARCH, 9, 00, 00, 00);
             expected.set(Calendar.MILLISECOND, 0);
             assertEquals(format(expected.getTimeInMillis()), format(actual));
         } finally {
@@ -107,12 +107,12 @@ public class PatternProcessorTest {
         try {
             final PatternProcessor pp = new PatternProcessor("logs/app-%d{yyyy-MM-W}.log.gz");
             final Calendar initial = Calendar.getInstance();
-            initial.set(2014, 2, 4, 10, 31, 59); // Tue, March 4, 2014
+            initial.set(2014, Calendar.MARCH, 4, 10, 31, 59); // Tue, March 4, 2014
             final long actual = pp.getNextTime(initial.getTimeInMillis(), 1, false);
 
             // expect Monday, March 10, 2014
             final Calendar expected = Calendar.getInstance();
-            expected.set(2014, 2, 10, 0, 0, 00);
+            expected.set(2014, Calendar.MARCH, 10, 00, 00, 00);
             expected.set(Calendar.MILLISECOND, 0);
             assertEquals(format(expected.getTimeInMillis()), format(actual));
         } finally {
@@ -124,12 +124,12 @@ public class PatternProcessorTest {
     public void testGetNextTimeHourlyReturnsFirstMinuteOfNextHour() {
         final PatternProcessor pp = new PatternProcessor("logs/app-%d{yyyy-MM-dd-HH}.log.gz");
         final Calendar initial = Calendar.getInstance();
-        initial.set(2014, 2, 4, 10, 31, 59); // Tue, March 4, 2014, 10:31
+        initial.set(2014, Calendar.MARCH, 4, 10, 31, 59); // Tue, March 4, 2014, 10:31
         final long actual = pp.getNextTime(initial.getTimeInMillis(), 1, false);
 
         // expect Wed, March 4, 2014, 11:00
         final Calendar expected = Calendar.getInstance();
-        expected.set(2014, 2, 4, 11, 00, 00);
+        expected.set(2014, Calendar.MARCH, 4, 11, 00, 00);
         expected.set(Calendar.MILLISECOND, 0);
         assertEquals(format(expected.getTimeInMillis()), format(actual));
     }
@@ -138,12 +138,12 @@ public class PatternProcessorTest {
     public void testGetNextTimeHourlyReturnsFirstMinuteOfNextHour2() {
         final PatternProcessor pp = new PatternProcessor("logs/app-%d{yyyy-MM-dd-HH}.log.gz");
         final Calendar initial = Calendar.getInstance();
-        initial.set(2014, 2, 4, 23, 31, 59); // Tue, March 4, 2014, 23:31
+        initial.set(2014, Calendar.MARCH, 4, 23, 31, 59); // Tue, March 4, 2014, 23:31
         final long actual = pp.getNextTime(initial.getTimeInMillis(), 1, false);
 
         // expect Wed, March 5, 2014, 00:00
         final Calendar expected = Calendar.getInstance();
-        expected.set(2014, 2, 5, 00, 00, 00);
+        expected.set(2014, Calendar.MARCH, 5, 00, 00, 00);
         expected.set(Calendar.MILLISECOND, 0);
         assertEquals(format(expected.getTimeInMillis()), format(actual));
     }
@@ -152,14 +152,14 @@ public class PatternProcessorTest {
     public void testGetNextTimeMinutelyReturnsFirstSecondOfNextMinute() {
         final PatternProcessor pp = new PatternProcessor("logs/app-%d{yyyy-MM-dd-HH-mm}.log.gz");
         final Calendar initial = Calendar.getInstance();
-        initial.set(2014, 2, 4, 10, 31, 59); // Tue, March 4, 2014, 10:31
+        initial.set(2014, Calendar.MARCH, 4, 10, 31, 59); // Tue, March 4, 2014, 10:31
         initial.set(Calendar.MILLISECOND, 0);
         assertEquals("2014/03/04 10:31:59.000", format(initial.getTimeInMillis()));
         final long actual = pp.getNextTime(initial.getTimeInMillis(), 1, false);
 
         // expect Tue, March 4, 2014, 10:32
         final Calendar expected = Calendar.getInstance();
-        expected.set(2014, 2, 4, 10, 32, 00);
+        expected.set(2014, Calendar.MARCH, 4, 10, 32, 00);
         expected.set(Calendar.MILLISECOND, 0);
         assertEquals(format(expected.getTimeInMillis()), format(actual));
     }
@@ -168,14 +168,14 @@ public class PatternProcessorTest {
     public void testGetNextTimeSecondlyReturnsFirstMillisecOfNextSecond() {
         final PatternProcessor pp = new PatternProcessor("logs/app-%d{yyyy-MM-dd-HH-mm-ss}.log.gz");
         final Calendar initial = Calendar.getInstance();
-        initial.set(2014, 2, 4, 10, 31, 53); // Tue, March 4, 2014, 10:31:53
+        initial.set(2014, Calendar.MARCH, 4, 10, 31, 53); // Tue, March 4, 2014, 10:31:53
         initial.set(Calendar.MILLISECOND, 123);
         assertEquals("2014/03/04 10:31:53.123", format(initial.getTimeInMillis()));
         final long actual = pp.getNextTime(initial.getTimeInMillis(), 1, false);
 
         // expect Tue, March 4, 2014, 10:31:54
         final Calendar expected = Calendar.getInstance();
-        expected.set(2014, 2, 4, 10, 31, 54);
+        expected.set(2014, Calendar.MARCH, 4, 10, 31, 54);
         expected.set(Calendar.MILLISECOND, 0);
         assertEquals(format(expected.getTimeInMillis()), format(actual));
     }
@@ -184,18 +184,18 @@ public class PatternProcessorTest {
     public void testGetNextTimeMillisecondlyReturnsNextMillisec() {
         final PatternProcessor pp = new PatternProcessor("logs/app-%d{yyyy-MM-dd-HH-mm-ss.SSS}.log.gz");
         final Calendar initial = Calendar.getInstance();
-        initial.set(2014, 2, 4, 10, 31, 53); // Tue, March 4, 2014, 10:31:53.123
+        initial.set(2014, Calendar.MARCH, 4, 10, 31, 53); // Tue, March 4, 2014, 10:31:53.123
         initial.set(Calendar.MILLISECOND, 123);
         assertEquals("2014/03/04 10:31:53.123", format(initial.getTimeInMillis()));
         final long actual = pp.getNextTime(initial.getTimeInMillis(), 1, false);
 
         // expect Tue, March 4, 2014, 10:31:53.124
         final Calendar expected = Calendar.getInstance();
-        expected.set(2014, 2, 4, 10, 31, 53);
+        expected.set(2014, Calendar.MARCH, 4, 10, 31, 53);
         expected.set(Calendar.MILLISECOND, 124);
         assertEquals(format(expected.getTimeInMillis()), format(actual));
     }
-    
+
     @Test
     public void testDontInterpretBackslashAsEscape() {
         final PatternProcessor pp = new PatternProcessor("c:\\test\\new/app-%d{HH-mm-ss}.log");


[2/8] git commit: Reformat setup.

Posted by ma...@apache.org.
Reformat setup.


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

Branch: refs/heads/master
Commit: 135ebe9f21f919e427829236e895c422cc91cb34
Parents: c3414fa
Author: Matt Sicker <ma...@apache.org>
Authored: Thu Oct 2 23:18:43 2014 -0500
Committer: Matt Sicker <ma...@apache.org>
Committed: Thu Oct 2 23:18:43 2014 -0500

----------------------------------------------------------------------
 .../appender/rewrite/MapRewritePolicyTest.java  | 22 ++++++++++----------
 1 file changed, 11 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/135ebe9f/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rewrite/MapRewritePolicyTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rewrite/MapRewritePolicyTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rewrite/MapRewritePolicyTest.java
index 1e6805b..82d3378 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rewrite/MapRewritePolicyTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rewrite/MapRewritePolicyTest.java
@@ -48,20 +48,20 @@ public class MapRewritePolicyTest {
         map.put("test1", "one");
         map.put("test2", "two");
         logEvent0 = new Log4jLogEvent("test", null, "MapRewritePolicyTest.setupClass()", Level.ERROR,
-        new SimpleMessage("Test"), new RuntimeException("test"), map, null, "none",
-        new StackTraceElement("MapRewritePolicyTest", "setupClass", "MapRewritePolicyTest", 28), 2);
+            new SimpleMessage("Test"), new RuntimeException("test"), map, null, "none",
+            new StackTraceElement("MapRewritePolicyTest", "setupClass", "MapRewritePolicyTest", 28), 2);
         logEvent1 = new Log4jLogEvent("test", null, "MapRewritePolicyTest.setupClass()", Level.ERROR,
-        new MapMessage(map), null, map, null, "none",
-        new StackTraceElement("MapRewritePolicyTest", "setupClass", "MapRewritePolicyTest", 29), 2);
-    final ThreadContextStack stack = new MutableThreadContextStack(new ArrayList<String>(map.values()));
+            new MapMessage(map), null, map, null, "none",
+            new StackTraceElement("MapRewritePolicyTest", "setupClass", "MapRewritePolicyTest", 29), 2);
+        final ThreadContextStack stack = new MutableThreadContextStack(new ArrayList<String>(map.values()));
         logEvent2 = new Log4jLogEvent("test", MarkerManager.getMarker("test"), "MapRewritePolicyTest.setupClass()",
-        Level.TRACE, new StructuredDataMessage("test", "Nothing", "test", map), new RuntimeException("test"), null,
-        stack, "none", new StackTraceElement("MapRewritePolicyTest",
-        "setupClass", "MapRewritePolicyTest", 30), 20000000);
+            Level.TRACE, new StructuredDataMessage("test", "Nothing", "test", map), new RuntimeException("test"), null,
+            stack, "none", new StackTraceElement("MapRewritePolicyTest",
+            "setupClass", "MapRewritePolicyTest", 30), 20000000);
         logEvent3 = new Log4jLogEvent("test", null, "MapRewritePolicyTest.setupClass()", Level.ALL, new MapMessage(map),
-        null, map, stack, null, new StackTraceElement("MapRewritePolicyTest",
-        "setupClass", "MapRewritePolicyTest", 31), Long.MAX_VALUE);
-        rewrite = new KeyValuePair[] {new KeyValuePair("test2", "2"), new KeyValuePair("test3", "three")};
+            null, map, stack, null, new StackTraceElement("MapRewritePolicyTest",
+            "setupClass", "MapRewritePolicyTest", 31), Long.MAX_VALUE);
+        rewrite = new KeyValuePair[]{new KeyValuePair("test2", "2"), new KeyValuePair("test3", "three")};
     }
 
     @Test