diff --git a/.gitignore b/.gitignore
index a436cfa..67af4db 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,9 +1,9 @@
# Maven
pom.xml.versionsBackup
+target
# Eclipse
.project
.classpath
.settings
-target
diff --git a/pom.xml b/pom.xml
index 876682c..5bef53d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -9,24 +9,61 @@
Reusable JUnit4 Extensions
+
+ https://bitbucket.org/inteligr8/junit4-ext
+
+
+ Inteligr8
+ https://www.inteligr8.com
+
+
+
+ Brian Long
+ brian@inteligr8.com
+ https://twitter.com/brianmlong
+
+
+
+ utf-8
1.7
1.7
+ 4.13
junit
junit
- 4.13
+ ${junit.version}
+
+
+
+
+
+ maven-javadoc-plugin
+ 3.2.0
+
+
+ javadoc
+ package
+ jar
+
+ public
+
+
+
+
+
+
inteligr8-releases
Inteligr8 Releases
- http://repos.yateslong.us/nexus/repository/inteligr8-public
+ http://repos.inteligr8.com/nexus/repository/inteligr8-public
default
diff --git a/src/main/java/com/inteligr8/junit4/AssertCollection.java b/src/main/java/com/inteligr8/junit4/AssertCollection.java
index d35fb34..8ffbd40 100644
--- a/src/main/java/com/inteligr8/junit4/AssertCollection.java
+++ b/src/main/java/com/inteligr8/junit4/AssertCollection.java
@@ -4,29 +4,73 @@ import java.util.Collection;
import org.junit.Assert;
+/**
+ * This class implements JUnit4 assertion methods focused on collections.
+ *
+ * @author brian@inteligr8.com
+ */
public class AssertCollection {
+ /**
+ * This method evaluates the size of a collection.
+ *
+ * @param expectedCount The expected size of the collection
+ * @param actualCollection The collection to evaluate
+ */
public static void assertSize(int expectedCount, Collection> actualCollection) {
assertSize(null, expectedCount, actualCollection);
}
+ /**
+ * This method evaluates the size of a collection.
+ *
+ * @param message A message to record on failure
+ * @param expectedCount The expected size of the collection
+ * @param actualCollection The collection to evaluate
+ */
public static void assertSize(String message, int expectedCount, Collection> actualCollection) {
if (expectedCount == 0) Assert.assertTrue(message, actualCollection == null || actualCollection.isEmpty());
else Assert.assertTrue(message, actualCollection != null && actualCollection.size() == expectedCount);
}
+ /**
+ * This method evaluates the contents of a collection
+ *
+ * @param expectedElement A expected element in the collection
+ * @param actualCollection A collection to search/inspect
+ */
public static void assertContains(T expectedElement, Collection actualCollection) {
assertContains(null, expectedElement, actualCollection);
}
+ /**
+ * This method evaluates the contents of a collection
+ *
+ * @param expectedElements A subset of the expected elements in the collection
+ * @param actualCollection A collection to search/inspect
+ */
public static void assertContains(Collection expectedElements, Collection actualCollection) {
assertContains(null, expectedElements, actualCollection);
}
+ /**
+ * This method evaluates the contents of a collection
+ *
+ * @param message A message to record on failure
+ * @param expectedElement A expected element in the collection
+ * @param actualCollection A collection to search/inspect
+ */
public static void assertContains(String message, T expectedElement, Collection actualCollection) {
Assert.assertTrue(message, actualCollection != null && actualCollection.contains(expectedElement));
}
+ /**
+ * This method evaluates the contents of a collection
+ *
+ * @param message A message to record on failure
+ * @param expectedElements A subset of the expected elements in the collection
+ * @param actualCollection A collection to search/inspect
+ */
public static void assertContains(String message, Collection expectedElements, Collection actualCollection) {
Assert.assertTrue(message, actualCollection != null && actualCollection.containsAll(expectedElements));
}
diff --git a/src/main/java/com/inteligr8/junit4/AssertRegex.java b/src/main/java/com/inteligr8/junit4/AssertRegex.java
index 2e86f54..8f0d5ff 100644
--- a/src/main/java/com/inteligr8/junit4/AssertRegex.java
+++ b/src/main/java/com/inteligr8/junit4/AssertRegex.java
@@ -5,38 +5,111 @@ import java.util.regex.Pattern;
import org.junit.Assert;
+/**
+ * This class implements JUnit4 assertion methods focused on regular expression matching.
+ *
+ * @author brian@inteligr8.com
+ */
public class AssertRegex {
+ /**
+ * This method evaluates the format of the specified value using the
+ * specified regular expression.
+ *
+ * @param expectedRegex A regular expression
+ * @param actual A text value to evaluate
+ * @see AssertRegex#assertNotMatches(String, String)
+ */
public static void assertMatches(String expectedRegex, String actual) {
assertMatches(null, expectedRegex, actual);
}
+ /**
+ * This method evaluates the format of the specified value using the
+ * specified regular expression.
+ *
+ * @param message A message to record on failure
+ * @param expectedRegex A regular expression
+ * @param actual A text value to evaluate
+ * @see AssertRegex#assertNotMatches(String, String, String)
+ */
public static void assertMatches(String message, String expectedRegex, String actual) {
Pattern pattern = Pattern.compile(expectedRegex);
assertMatches(message, pattern, actual);
}
+ /**
+ * This method evaluates the format of the specified value using the
+ * specified regular expression.
+ *
+ * @param expected A regular expression
+ * @param actual A text value to evaluate
+ * @see AssertRegex#assertNotMatches(Pattern, String)
+ */
public static void assertMatches(Pattern expected, String actual) {
assertMatches(null, expected, actual);
}
+ /**
+ * This method evaluates the format of the specified value using the
+ * specified regular expression.
+ *
+ * @param message A message to record on failure
+ * @param expected A regular expression
+ * @param actual A text value to evaluate
+ * @see AssertRegex#assertNotMatches(String, Pattern, String)
+ */
public static void assertMatches(String message, Pattern expected, String actual) {
assertMatches(message, false, expected, actual);
}
+ /**
+ * This method negates the evaluation of the format of the specified value
+ * using the specified regular expression.
+ *
+ * @param expectedRegex A regular expression
+ * @param actual A text value to evaluate
+ * @see AssertRegex#assertMatches(String, String)
+ */
public static void assertNotMatches(String expectedRegex, String actual) {
assertNotMatches(null, expectedRegex, actual);
}
+ /**
+ * This method negates the evaluation of the format of the specified value
+ * using the specified regular expression.
+ *
+ * @param message A message to record on failure
+ * @param expectedRegex A regular expression
+ * @param actual A text value to evaluate
+ * @see AssertRegex#assertMatches(String, String, String)
+ */
public static void assertNotMatches(String message, String expectedRegex, String actual) {
Pattern pattern = Pattern.compile(expectedRegex);
assertNotMatches(message, pattern, actual);
}
+ /**
+ * This method negates the evaluation of the format of the specified value
+ * using the specified regular expression.
+ *
+ * @param expected A regular expression
+ * @param actual A text value to evaluate
+ * @see AssertRegex#assertMatches(Pattern, String)
+ */
public static void assertNotMatches(Pattern expected, String actual) {
assertNotMatches(null, expected, actual);
}
+ /**
+ * This method negates the evaluation of the format of the specified value
+ * using the specified regular expression.
+ *
+ * @param message A message to record on failure
+ * @param expected A regular expression
+ * @param actual A text value to evaluate
+ * @see AssertRegex#assertMatches(String, Pattern, String)
+ */
public static void assertNotMatches(String message, Pattern expected, String actual) {
assertMatches(message, true, expected, actual);
}
@@ -52,19 +125,57 @@ public class AssertRegex {
+ /**
+ * This method counts the matches of the specified value against the
+ * specified regular expression.
+ *
+ * @param expectedRegex A regular expression
+ * @param expectedCount The count of an expected regex match
+ * @param actual A text value to evaluate
+ * @see AssertRegex#assertMatches(String, String)
+ */
public static void assertFind(String expectedRegex, int expectedCount, String actual) {
assertFind(null, expectedRegex, expectedCount, actual);
}
+ /**
+ * This method counts the matches of the specified value against the
+ * specified regular expression.
+ *
+ * @param message A message to record on failure
+ * @param expectedRegex A regular expression
+ * @param expectedCount The count of an expected regex match
+ * @param actual A text value to evaluate
+ * @see AssertRegex#assertMatches(String, String, String)
+ */
public static void assertFind(String message, String expectedRegex, int expectedCount, String actual) {
Pattern pattern = Pattern.compile(expectedRegex);
assertFind(message, pattern, expectedCount, actual);
}
+ /**
+ * This method counts the matches of the specified value against the
+ * specified regular expression.
+ *
+ * @param expected A regular expression
+ * @param expectedCount The count of an expected regex match
+ * @param actual A text value to evaluate
+ * @see AssertRegex#assertMatches(Pattern, String)
+ */
public static void assertFind(Pattern expected, int expectedCount, String actual) {
assertFind(null, expected, expectedCount, actual);
}
+ /**
+ * This method counts the matches of the specified value against the
+ * specified regular expression.
+ *
+ * @param message A message to record on failure
+ * @param expected A regular expression
+ * @param expectedCount The count of an expected regex match
+ * @param actual A text value to evaluate
+ * @see AssertRegex#assertMatches(Pattern, String)
+ */
public static void assertFind(String message, Pattern expected, int expectedCount, String actual) {
Matcher matcher = expected.matcher(actual);
int count = 0;