private static boolean isDebug(HttpServletRequest req) { return contains(req.getHeader("Debug"), "true"); } }
private static boolean isDebug(HttpServletRequest req) { return contains(req.getHeader("Debug"), "true"); } }
private static boolean isDebug(HttpServletRequest req) { return contains(req.getHeader("Debug"), "true"); } }
/** * Throws an {@link AssertionError} if the response header does not contain all of the expected substrings. * * @param name The header name. * @param substrings The expected substrings. * @return This object (for method chaining). * @throws AssertionError Thrown if the header does not contain one or more of the expected substrings. */ public MockServletResponse assertHeaderContains(String name, String...substrings) { String text = getHeader(name); for (String substring : substrings) if (! contains(text, substring)) throw new MockAssertionError("Response did not have the expected substring in header {0}.\n\tExpected=[{1}]\n\tHeader=[{2}]", name, substring, text); return this; }
/** * Throws an {@link AssertionError} if the response body does not contain all of the expected substrings. * * @param substrings The expected substrings. * @return This object (for method chaining). * @throws AssertionError Thrown if the body does not contain one or more of the expected substrings. */ public MockServletResponse assertBodyContains(String...substrings) throws AssertionError { String text = getBodyAsString(); for (String substring : substrings) if (! contains(text, substring)) throw new MockAssertionError("Response did not have the expected substring.\n\tExpected=[{0}]\n\tBody=[{1}]", substring, text); return this; }
/** * Throws an {@link AssertionError} if the response header does not contain all of the expected substrings. * * @param name The header name. * @param substrings The expected substrings. * @return This object (for method chaining). * @throws AssertionError Thrown if the header does not contain one or more of the expected substrings. */ public MockServletResponse assertHeaderContains(String name, String...substrings) { String text = getHeader(name); for (String substring : substrings) if (! contains(text, substring)) throw new MockAssertionError("Response did not have the expected substring in header {0}.\n\tExpected=[{1}]\n\tHeader=[{2}]", name, substring, text); return this; }
/** * Throws an {@link AssertionError} if the response body does not contain all of the expected substrings. * * @param substrings The expected substrings. * @return This object (for method chaining). * @throws AssertionError Thrown if the body does not contain one or more of the expected substrings. */ public MockServletResponse assertBodyContains(String...substrings) throws AssertionError { String text = getBodyAsString(); for (String substring : substrings) if (! contains(text, substring)) throw new MockAssertionError("Response did not have the expected substring.\n\tExpected=[{0}]\n\tBody=[{1}]", substring, text); return this; }
/** * Throws an {@link AssertionError} if the response body does not contain all of the expected substrings. * * @param substrings The expected substrings. * @return This object (for method chaining). * @throws AssertionError Thrown if the body does not contain one or more of the expected substrings. */ public MockServletResponse assertBodyContains(String...substrings) throws AssertionError { String text = getBodyAsString(); for (String substring : substrings) if (! contains(text, substring)) throw new MockAssertionError("Response did not have the expected substring.\n\tExpected=[{0}]\n\tBody=[{1}]", substring, text); return this; }
/** * Throws an {@link AssertionError} if the response header does not contain all of the expected substrings. * * @param name The header name. * @param substrings The expected substrings. * @return This object (for method chaining). * @throws AssertionError Thrown if the header does not contain one or more of the expected substrings. */ public MockServletResponse assertHeaderContains(String name, String...substrings) { String text = getHeader(name); for (String substring : substrings) if (! contains(text, substring)) throw new MockAssertionError("Response did not have the expected substring in header {0}.\n\tExpected=[{1}]\n\tHeader=[{2}]", name, substring, text); return this; }
public static final void assertContains(Exception e, String...substrings) { for (String substring : substrings) { Throwable e2 = e; boolean found = false; while (e2 != null && ! found) { found |= contains(e2.getMessage(), substring); e2 = e2.getCause(); } if (! found) { e.printStackTrace(); throw new ComparisonFailure("Exception message did not contain expected substring.", toString(substring), StringUtils.getStackTrace(e)); } } }
public static final void assertContains(Object value, String...substrings) { for (String substring : substrings) if (! contains(toString(value), substring)) throw new ComparisonFailure("Text did not contain expected substring.", toString(substring), toString(value)); }