Package org.fest.assertions.internal
Class Strings
- java.lang.Object
 - 
- org.fest.assertions.internal.Strings
 
 
- 
public class Strings extends java.lang.ObjectReusable assertions fors.String- Author:
 - Alex Ruiz, Joel Costigliola, Nicolas François
 
 
- 
- 
Constructor Summary
Constructors Constructor Description Strings(ComparisonStrategy comparisonStrategy) 
- 
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidassertContains(AssertionInfo info, java.lang.String actual, java.lang.String sequence)Verifies that the givenStringcontains the given sequence.voidassertContainsIgnoringCase(AssertionInfo info, java.lang.String actual, java.lang.String sequence)Verifies that the givenStringcontains the given sequence, ignoring case considerations.voidassertContainsOnlyOnce(AssertionInfo info, java.lang.String actual, java.lang.String sequence)Verifies that actualStrings contains only once the given sequence.voidassertDoesNotContain(AssertionInfo info, java.lang.String actual, java.lang.String sequence)Verifies that the givenStringdoes not contain the given sequence.voidassertDoesNotMatch(AssertionInfo info, java.lang.String actual, java.lang.String regex)Verifies that the givenStringdoes not match the given regular expression.voidassertDoesNotMatch(AssertionInfo info, java.lang.String actual, java.util.regex.Pattern pattern)Verifies that the givenStringdoes not match the given regular expression.voidassertEmpty(AssertionInfo info, java.lang.String actual)Asserts that the givenStringis empty.voidassertEndsWith(AssertionInfo info, java.lang.String actual, java.lang.String suffix)Verifies that the givenStringends with the given suffix.voidassertEqualsIgnoringCase(AssertionInfo info, java.lang.String actual, java.lang.String expected)Verifies that twoStrings are equal, ignoring case considerations.voidassertHasSameSizeAs(AssertionInfo info, java.lang.String actual, java.lang.Iterable<?> other)Asserts that the number of entries in the givenStringhas the same size as the otherIterable.voidassertHasSameSizeAs(AssertionInfo info, java.lang.String actual, java.lang.Object[] other)Asserts that the number of entries in the givenStringhas the same size as the other array.voidassertHasSize(AssertionInfo info, java.lang.String actual, int expectedSize)Asserts that the size of the givenStringis equal to the expected one.voidassertMatches(AssertionInfo info, java.lang.String actual, java.lang.String regex)Verifies that the givenStringmatches the given regular expression.voidassertMatches(AssertionInfo info, java.lang.String actual, java.util.regex.Pattern pattern)Verifies that the givenStringmatches the given regular expression.voidassertNotEmpty(AssertionInfo info, java.lang.String actual)Asserts that the givenStringis not empty.voidassertNullOrEmpty(AssertionInfo info, java.lang.String actual)Asserts that the givenStringisnullor empty.voidassertStartsWith(AssertionInfo info, java.lang.String actual, java.lang.String prefix)Verifies that the givenStringstarts with the given prefix.java.util.Comparator<?>getComparator()static Stringsinstance()Returns the singleton instance of this class based onStandardComparisonStrategy. 
 - 
 
- 
- 
Constructor Detail
- 
Strings
public Strings(ComparisonStrategy comparisonStrategy)
 
 - 
 
- 
Method Detail
- 
instance
public static Strings instance()
Returns the singleton instance of this class based onStandardComparisonStrategy.- Returns:
 - the singleton instance of this class based on 
StandardComparisonStrategy. 
 
- 
getComparator
public java.util.Comparator<?> getComparator()
 
- 
assertNullOrEmpty
public void assertNullOrEmpty(AssertionInfo info, java.lang.String actual)
Asserts that the givenStringisnullor empty.- Parameters:
 info- contains information about the assertion.actual- the givenString.- Throws:
 java.lang.AssertionError- if the givenStringis notnull*and* it is not empty.
 
- 
assertEmpty
public void assertEmpty(AssertionInfo info, java.lang.String actual)
Asserts that the givenStringis empty.- Parameters:
 info- contains information about the assertion.actual- the givenString.- Throws:
 java.lang.AssertionError- if the givenStringisnull.java.lang.AssertionError- if the givenStringis not empty.
 
- 
assertNotEmpty
public void assertNotEmpty(AssertionInfo info, java.lang.String actual)
Asserts that the givenStringis not empty.- Parameters:
 info- contains information about the assertion.actual- the givenString.- Throws:
 java.lang.AssertionError- if the givenStringisnull.java.lang.AssertionError- if the givenStringis empty.
 
- 
assertHasSize
public void assertHasSize(AssertionInfo info, java.lang.String actual, int expectedSize)
Asserts that the size of the givenStringis equal to the expected one.- Parameters:
 info- contains information about the assertion.actual- the givenString.expectedSize- the expected size ofactual.- Throws:
 java.lang.AssertionError- if the givenStringisnull.java.lang.AssertionError- if the size of the givenStringis different than the expected one.
 
- 
assertHasSameSizeAs
public void assertHasSameSizeAs(AssertionInfo info, java.lang.String actual, java.lang.Iterable<?> other)
Asserts that the number of entries in the givenStringhas the same size as the otherIterable.- Parameters:
 info- contains information about the assertion.actual- the givenString.other- the group to compare- Throws:
 java.lang.AssertionError- if the givenString. isnull.java.lang.AssertionError- if the givenIterableisnull.java.lang.AssertionError- if the number of entries in the givenStringdoes not have the same size.
 
- 
assertHasSameSizeAs
public void assertHasSameSizeAs(AssertionInfo info, java.lang.String actual, java.lang.Object[] other)
Asserts that the number of entries in the givenStringhas the same size as the other array.- Parameters:
 info- contains information about the assertion.actual- the givenString.other- the group to compare- Throws:
 java.lang.AssertionError- if the givenStringisnull.java.lang.AssertionError- if the given array isnull.java.lang.AssertionError- if the number of entries in the givenStringdoes not have the same size.
 
- 
assertContains
public void assertContains(AssertionInfo info, java.lang.String actual, java.lang.String sequence)
Verifies that the givenStringcontains the given sequence.- Parameters:
 info- contains information about the assertion.actual- the actualString.sequence- the sequence to search for.- Throws:
 java.lang.NullPointerException- if the given sequence isnull.java.lang.AssertionError- if the givenStringisnull.java.lang.AssertionError- if the actualStringdoes not contain the given sequence.
 
- 
assertContainsIgnoringCase
public void assertContainsIgnoringCase(AssertionInfo info, java.lang.String actual, java.lang.String sequence)
Verifies that the givenStringcontains the given sequence, ignoring case considerations.- Parameters:
 info- contains information about the assertion.actual- the actualString.sequence- the sequence to search for.- Throws:
 java.lang.NullPointerException- if the given sequence isnull.java.lang.AssertionError- if the givenStringisnull.java.lang.AssertionError- if the actualStringdoes not contain the given sequence.
 
- 
assertDoesNotContain
public void assertDoesNotContain(AssertionInfo info, java.lang.String actual, java.lang.String sequence)
Verifies that the givenStringdoes not contain the given sequence.- Parameters:
 info- contains information about the assertion.actual- the actualString.sequence- the sequence to search for.- Throws:
 java.lang.NullPointerException- if the given sequence isnull.java.lang.AssertionError- if the givenStringisnull.java.lang.AssertionError- if the actualStringcontains the given sequence.
 
- 
assertEqualsIgnoringCase
public void assertEqualsIgnoringCase(AssertionInfo info, java.lang.String actual, java.lang.String expected)
Verifies that twoStrings are equal, ignoring case considerations.- Parameters:
 info- contains information about the assertion.actual- the actualString.expected- the expectedString.- Throws:
 java.lang.AssertionError- if the givenStrings are not equal.
 
- 
assertContainsOnlyOnce
public void assertContainsOnlyOnce(AssertionInfo info, java.lang.String actual, java.lang.String sequence)
Verifies that actualStrings contains only once the given sequence.- Parameters:
 info- contains information about the assertion.actual- the actualString.sequence- the givenString.- Throws:
 java.lang.NullPointerException- if the given sequence isnull.java.lang.AssertionError- if the givenStringisnull.java.lang.AssertionError- if the actualStringdoes not contains only once the givenString.
 
- 
assertStartsWith
public void assertStartsWith(AssertionInfo info, java.lang.String actual, java.lang.String prefix)
Verifies that the givenStringstarts with the given prefix.- Parameters:
 info- contains information about the assertion.actual- the actualString.prefix- the given prefix.- Throws:
 java.lang.NullPointerException- if the given sequence isnull.java.lang.AssertionError- if the givenStringisnull.java.lang.AssertionError- if the actualStringdoes not start with the given prefix.
 
- 
assertEndsWith
public void assertEndsWith(AssertionInfo info, java.lang.String actual, java.lang.String suffix)
Verifies that the givenStringends with the given suffix.- Parameters:
 info- contains information about the assertion.actual- the actualString.suffix- the given suffix.- Throws:
 java.lang.NullPointerException- if the given sequence isnull.java.lang.AssertionError- if the givenStringisnull.java.lang.AssertionError- if the actualStringdoes not end with the given suffix.
 
- 
assertMatches
public void assertMatches(AssertionInfo info, java.lang.String actual, java.lang.String regex)
Verifies that the givenStringmatches the given regular expression.- Parameters:
 info- contains information about the assertion.actual- the givenString.regex- the regular expression to which the actualStringis to be matched.- Throws:
 java.lang.NullPointerException- if the given pattern isnull.java.util.regex.PatternSyntaxException- if the regular expression's syntax is invalid.java.lang.AssertionError- if the givenStringisnull.java.lang.AssertionError- if the actualStringdoes not match the given regular expression.
 
- 
assertDoesNotMatch
public void assertDoesNotMatch(AssertionInfo info, java.lang.String actual, java.lang.String regex)
Verifies that the givenStringdoes not match the given regular expression.- Parameters:
 info- contains information about the assertion.actual- the givenString.regex- the regular expression to which the actualStringis to be matched.- Throws:
 java.lang.NullPointerException- if the given pattern isnull.java.util.regex.PatternSyntaxException- if the regular expression's syntax is invalid.java.lang.AssertionError- if the actualStringmatches the given regular expression.
 
- 
assertMatches
public void assertMatches(AssertionInfo info, java.lang.String actual, java.util.regex.Pattern pattern)
Verifies that the givenStringmatches the given regular expression.- Parameters:
 info- contains information about the assertion.actual- the givenString.pattern- the regular expression to which the actualStringis to be matched.- Throws:
 java.lang.NullPointerException- if the given pattern isnull.java.lang.AssertionError- if the givenStringisnull.java.lang.AssertionError- if the givenStringdoes not match the given regular expression.
 
- 
assertDoesNotMatch
public void assertDoesNotMatch(AssertionInfo info, java.lang.String actual, java.util.regex.Pattern pattern)
Verifies that the givenStringdoes not match the given regular expression.- Parameters:
 info- contains information about the assertion.actual- the givenString.pattern- the regular expression to which the actualStringis to be matched.- Throws:
 java.lang.NullPointerException- if the given pattern isnull.java.lang.AssertionError- if the givenStringmatches the given regular expression.
 
 - 
 
 -