changed repo hostname; added javadoc
This commit is contained in:
parent
b863d3749e
commit
51b2e12bfb
17
pom.xml
17
pom.xml
@ -9,6 +9,21 @@
|
||||
|
||||
<name>Reusable JUnit4 Extensions</name>
|
||||
|
||||
<scm>
|
||||
<url>https://bitbucket.org/inteligr8/junit4-ext</url>
|
||||
</scm>
|
||||
<organization>
|
||||
<name>Inteligr8</name>
|
||||
<url>https://www.inteligr8.com</url>
|
||||
</organization>
|
||||
<developers>
|
||||
<developer>
|
||||
<name>Brian Long</name>
|
||||
<email>brian@inteligr8.com</email>
|
||||
<url>https://twitter.com/brianmlong</url>
|
||||
</developer>
|
||||
</developers>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>1.7</maven.compiler.source>
|
||||
<maven.compiler.target>1.7</maven.compiler.target>
|
||||
@ -26,7 +41,7 @@
|
||||
<repository>
|
||||
<id>inteligr8-releases</id>
|
||||
<name>Inteligr8 Releases</name>
|
||||
<url>http://repos.yateslong.us/nexus/repository/inteligr8-public</url>
|
||||
<url>http://repos.inteligr8.com/nexus/repository/inteligr8-public</url>
|
||||
<layout>default</layout>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
|
@ -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 <T> void assertContains(T expectedElement, Collection<T> 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 <T> void assertContains(Collection<T> expectedElements, Collection<T> 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 <T> void assertContains(String message, T expectedElement, Collection<T> 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 <T> void assertContains(String message, Collection<T> expectedElements, Collection<T> actualCollection) {
|
||||
Assert.assertTrue(message, actualCollection != null && actualCollection.containsAll(expectedElements));
|
||||
}
|
||||
|
@ -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 expectedRegex 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 expectedRegex 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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user