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:32 UTC

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

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.