You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by br...@apache.org on 2015/05/04 21:47:21 UTC
[6/8] [lang] Use hamcrest matchers for better readability of
assertions
Use hamcrest matchers for better readability of assertions
Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/ea1a69d6
Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/ea1a69d6
Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/ea1a69d6
Branch: refs/heads/master
Commit: ea1a69d638d97d5ffc451b32d240479357e02b0a
Parents: f175a24
Author: Benedikt Ritter <br...@apache.org>
Authored: Mon May 4 21:42:50 2015 +0200
Committer: Benedikt Ritter <br...@apache.org>
Committed: Mon May 4 21:42:50 2015 +0200
----------------------------------------------------------------------
...ctionToStringBuilderExcludeWithAnnotationTest.java | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-lang/blob/ea1a69d6/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeWithAnnotationTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeWithAnnotationTest.java b/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeWithAnnotationTest.java
index acf7c2c..f4330a1 100755
--- a/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeWithAnnotationTest.java
+++ b/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeWithAnnotationTest.java
@@ -17,8 +17,10 @@
package org.apache.commons.lang3.builder;
-import org.apache.commons.lang3.ArrayUtils;
-import org.junit.Assert;
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.not;
+import static org.junit.Assert.assertThat;
+
import org.junit.Test;
/**
@@ -47,10 +49,10 @@ public class ReflectionToStringBuilderExcludeWithAnnotationTest {
public void test_toStringExclude() {
final String toString = ReflectionToStringBuilder.toString(new TestFixture());
- Assert.assertEquals(ArrayUtils.INDEX_NOT_FOUND, toString.indexOf(SECRET_FIELD));
- Assert.assertEquals(ArrayUtils.INDEX_NOT_FOUND, toString.indexOf(SECRET_VALUE));
- Assert.assertTrue(toString.indexOf(NOT_SECRET_FIELD) > ArrayUtils.INDEX_NOT_FOUND);
- Assert.assertTrue(toString.indexOf(NOT_SECRET_VALUE) > ArrayUtils.INDEX_NOT_FOUND);
+ assertThat(toString, not(containsString(SECRET_FIELD)));
+ assertThat(toString, not(containsString(SECRET_VALUE)));
+ assertThat(toString, containsString(NOT_SECRET_FIELD));
+ assertThat(toString, containsString(NOT_SECRET_VALUE));
}
}