|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.hamcrest.BaseMatcher<T>
org.hamcrest.TypeSafeMatcher<ch.qos.logback.classic.spi.ILoggingEvent>
com.codereligion.cherry.test.hamcrest.logback.LoggingEventHasMessage
public class LoggingEventHasMessage
A matcher which expects the ILoggingEvent to have a formatted message which matches the given Matcher.
| Method Summary | |
|---|---|
protected void |
describeExpectation(org.hamcrest.Description description)
Describes the expected data. |
protected void |
describeMismatchSafely(ch.qos.logback.classic.spi.ILoggingEvent item,
org.hamcrest.Description mismatchDescription)
|
protected void |
describeNegatedExpectation(org.hamcrest.Description description)
Describes the expected data when the matcher has been negated. |
void |
describeTo(org.hamcrest.Description description)
|
static org.hamcrest.Matcher<ch.qos.logback.classic.spi.ILoggingEvent> |
doesNotHaveMessage(org.hamcrest.Matcher<String> matcher)
Creates a new matcher for ILoggingEvents that only matches when the examined event does not have a
formattedMessage which is matched by the given Matcher. |
static org.hamcrest.Matcher<ch.qos.logback.classic.spi.ILoggingEvent> |
doesNotHaveMessage(String substring,
Object... args)
Creates a new matcher for ILoggingEvents that only matches when the examined event does not have a
formattedMessage which contains the given substring. |
static org.hamcrest.Matcher<ch.qos.logback.classic.spi.ILoggingEvent> |
hasMessage(org.hamcrest.Matcher<String> matcher)
Creates a new matcher for ILoggingEvents that only matches when the examined event has a formattedMessage which is matched by the given Matcher. |
static org.hamcrest.Matcher<ch.qos.logback.classic.spi.ILoggingEvent> |
hasMessage(String substring,
Object... args)
Creates a new matcher for ILoggingEvents that only matches when the examined event has a formattedMessage which contains the given substring. |
protected boolean |
internalMatches(ch.qos.logback.classic.spi.ILoggingEvent event)
This method must return true when the given event matches. |
boolean |
matchesSafely(ch.qos.logback.classic.spi.ILoggingEvent event)
|
static org.hamcrest.Matcher<ch.qos.logback.classic.spi.ILoggingEvent> |
withMessage(org.hamcrest.Matcher<String> matcher)
Creates a new matcher for ILoggingEvents that only matches when the examined event has a formattedMessage which contains the given substring. |
static org.hamcrest.Matcher<ch.qos.logback.classic.spi.ILoggingEvent> |
withMessage(String substring,
Object... args)
Creates a new matcher for ILoggingEvents that only matches when the examined event has a formattedMessage which is matched by the given Matcher. |
| Methods inherited from class org.hamcrest.TypeSafeMatcher |
|---|
describeMismatch, matches |
| Methods inherited from class org.hamcrest.BaseMatcher |
|---|
_dont_implement_Matcher___instead_extend_BaseMatcher_, toString |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Method Detail |
|---|
public static org.hamcrest.Matcher<ch.qos.logback.classic.spi.ILoggingEvent> hasMessage(String substring,
Object... args)
ILoggingEvents that only matches when the examined event has a formattedMessage which contains the given substring. This matcher is doing the same assertion as withMessage(String, Object...), with the difference that this matcher's output is optimized for usage on single events.
Example usage: assertThat(event, hasMessage("oh %s", "no!"));
Example output: Expected: an ILoggingEvent with a formattedMessage matching: a string containing "oh no!" but: was ILoggingEvent{level=INFO,
formattedMessage='some Message', loggedBy=SomeLogger, throwable=null}
substring - the which is expected to be contained in the given events formattedMessageargs - the arguments to use for formatting the given substring
IllegalArgumentException - when the given substring is nullpublic static org.hamcrest.Matcher<ch.qos.logback.classic.spi.ILoggingEvent> hasMessage(org.hamcrest.Matcher<String> matcher)
ILoggingEvents that only matches when the examined event has a formattedMessage which is matched by the given Matcher. This matcher is doing the same assertion as withMessage(Matcher), with the difference that this matcher's output is optimized for usage on single events.
Example usage: assertThat(event, hasMessage(containsString("ohoh")));
Example output: Expected: an ILoggingEvent with a formattedMessage matching: a string containing "ohoh" but: was ILoggingEvent{level=INFO,
formattedMessage='some Message', loggedBy=SomeLogger, throwable=null}
matcher - the string Matcher to check the formattedMessage against
IllegalArgumentException - when the given parameter is null
public static org.hamcrest.Matcher<ch.qos.logback.classic.spi.ILoggingEvent> doesNotHaveMessage(String substring,
Object... args)
ILoggingEvents that only matches when the examined event does not have a
formattedMessage which contains the given substring. This matcher is the negation of hasMessage(String,
Object...). It is recommended to use this specific matcher instead of just combining the other matcher with CoreMatchers.not(Matcher) because of the improved error output.
Example usage: assertThat(event, doesNotHaveMessage("oh %s", "no!"));
Example output: Expected: an ILoggingEvent with a formattedMessage not matching: a string containing "oh no!" but: was ILoggingEvent{level=ERROR,
formattedMessage='ohoh', loggedBy=SomeLogger, throwable=null}
substring - the which is expected to be contained in the given events formattedMessageargs - the arguments to use for formatting the given substring
IllegalArgumentException - when the given substring is nullpublic static org.hamcrest.Matcher<ch.qos.logback.classic.spi.ILoggingEvent> doesNotHaveMessage(org.hamcrest.Matcher<String> matcher)
ILoggingEvents that only matches when the examined event does not have a
formattedMessage which is matched by the given Matcher. This matcher is the negation of hasMessage(Matcher). It is recommended to use this specific matcher instead of just combining the other matcher with CoreMatchers.not(Matcher) because of the improved error output.
Example usage: assertThat(event, doesNotHaveMessage(containsString("ohoh")));
Example output: Expected: an ILoggingEvent with a formattedMessage not matching: a string containing "ohoh" but: was ILoggingEvent{level=ERROR,
formattedMessage='ohoh', loggedBy=SomeLogger, throwable=null}
matcher - the string Matcher to check the formattedMessage against
IllegalArgumentException - when the given parameter is null
public static org.hamcrest.Matcher<ch.qos.logback.classic.spi.ILoggingEvent> withMessage(String substring,
Object... args)
ILoggingEvents that only matches when the examined event has a formattedMessage which is matched by the given Matcher. This matcher is doing the same assertion as hasMessage(Matcher), with the difference that this matcher's output is optimized for usage on iterables of events.
Example usage: assertThat(events, hasItem(withMessage(containsString("ohoh"))));
Example output: Expected: an iterable containing an ILoggingEvent with a formattedMessage matching: a string containing "ohoh" but: iterable
contained [ILoggingEvent{level=INFO, formattedMessage='some Message', loggedBy=SomeLogger, throwable=null}]
substring - the which is expected to be contained in the given events formattedMessageargs - the arguments to use for formatting the given substring
IllegalArgumentException - when the given substring is nullpublic static org.hamcrest.Matcher<ch.qos.logback.classic.spi.ILoggingEvent> withMessage(org.hamcrest.Matcher<String> matcher)
ILoggingEvents that only matches when the examined event has a formattedMessage which contains the given substring. This matcher is doing the same assertion as hasMessage(String, Object...), with the difference that this matcher's output is optimized for usage on iterables of events.
Example usage: assertThat(events, hasItem(withMessage("oh %s", "no!")));
Example output: Expected: an iterable containing an ILoggingEvent with a formattedMessage matching: a string containing "oh no!" but: iterable
contained [ILoggingEvent{level=INFO, formattedMessage='some Message', loggedBy=SomeLogger, throwable=null}]
matcher - the string Matcher to check the formattedMessage against
IllegalArgumentException - when the given parameter is nullprotected boolean internalMatches(ch.qos.logback.classic.spi.ILoggingEvent event)
event matches. Proper negation is handled by the caller of this method.
event - the ILoggingEvent to be checked
true if the event matchesprotected void describeExpectation(org.hamcrest.Description description)
description - the Description to amend the textprotected void describeNegatedExpectation(org.hamcrest.Description description)
description - the Description to amend the textpublic boolean matchesSafely(ch.qos.logback.classic.spi.ILoggingEvent event)
matchesSafely in class org.hamcrest.TypeSafeMatcher<ch.qos.logback.classic.spi.ILoggingEvent>public void describeTo(org.hamcrest.Description description)
protected void describeMismatchSafely(ch.qos.logback.classic.spi.ILoggingEvent item,
org.hamcrest.Description mismatchDescription)
describeMismatchSafely in class org.hamcrest.TypeSafeMatcher<ch.qos.logback.classic.spi.ILoggingEvent>
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||