11/*
2- * Copyright 2002-2013 the original author or authors.
2+ * Copyright 2002-2015 the original author or authors.
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
2828import static org .springframework .test .util .AssertionErrors .*;
2929
3030/**
31- * Static, factory methods for {@link ResultMatcher}-based result actions.
31+ * Static factory methods for {@link ResultMatcher}-based result actions.
3232 *
33- * <p><strong>Eclipse users:</strong> consider adding this class as a Java editor
34- * favorite. To navigate, open the Preferences and type "favorites".
33+ * <h3>Eclipse Users</h3>
34+ * <p>Consider adding this class as a Java editor favorite. To navigate to
35+ * this setting, open the Preferences and type "favorites".
3536 *
3637 * @author Rossen Stoyanchev
3738 * @author Brian Clozel
39+ * @author Sam Brannen
3840 * @since 3.2
3941 */
4042public abstract class MockMvcResultMatchers {
4143
4244 private static final AntPathMatcher pathMatcher = new AntPathMatcher ();
4345
4446
45- private MockMvcResultMatchers () {
46- }
47-
4847 /**
4948 * Access to request-related assertions.
5049 */
@@ -82,12 +81,11 @@ public static FlashAttributeResultMatchers flash() {
8281
8382 /**
8483 * Asserts the request was forwarded to the given URL.
85- * This methods accepts only exact matches.
84+ * <p> This methods accepts only exact matches.
8685 * @param expectedUrl the exact URL expected
8786 */
8887 public static ResultMatcher forwardedUrl (final String expectedUrl ) {
8988 return new ResultMatcher () {
90-
9189 @ Override
9290 public void match (MvcResult result ) {
9391 assertEquals ("Forwarded URL" , expectedUrl , result .getResponse ().getForwardedUrl ());
@@ -97,14 +95,14 @@ public void match(MvcResult result) {
9795
9896 /**
9997 * Asserts the request was forwarded to the given URL.
100- * This methods accepts {@link org.springframework.util.AntPathMatcher} expressions.
98+ * <p>This methods accepts {@link org.springframework.util.AntPathMatcher}
99+ * expressions.
101100 * @param urlPattern an AntPath expression to match against
102- * @see org.springframework.util.AntPathMatcher
103101 * @since 4.0
102+ * @see org.springframework.util.AntPathMatcher
104103 */
105104 public static ResultMatcher forwardedUrlPattern (final String urlPattern ) {
106105 return new ResultMatcher () {
107-
108106 @ Override
109107 public void match (MvcResult result ) {
110108 assertTrue ("AntPath expression" , pathMatcher .isPattern (urlPattern ));
@@ -116,12 +114,11 @@ public void match(MvcResult result) {
116114
117115 /**
118116 * Asserts the request was redirected to the given URL.
119- * This methods accepts only exact matches.
117+ * <p> This methods accepts only exact matches.
120118 * @param expectedUrl the exact URL expected
121119 */
122120 public static ResultMatcher redirectedUrl (final String expectedUrl ) {
123121 return new ResultMatcher () {
124-
125122 @ Override
126123 public void match (MvcResult result ) {
127124 assertEquals ("Redirected URL" , expectedUrl , result .getResponse ().getRedirectedUrl ());
@@ -131,14 +128,14 @@ public void match(MvcResult result) {
131128
132129 /**
133130 * Asserts the request was redirected to the given URL.
134- * This methods accepts {@link org.springframework.util.AntPathMatcher} expressions.
131+ * <p>This method accepts {@link org.springframework.util.AntPathMatcher}
132+ * expressions.
135133 * @param expectedUrl an AntPath expression to match against
136134 * @see org.springframework.util.AntPathMatcher
137135 * @since 4.0
138136 */
139137 public static ResultMatcher redirectedUrlPattern (final String expectedUrl ) {
140138 return new ResultMatcher () {
141-
142139 @ Override
143140 public void match (MvcResult result ) {
144141 assertTrue ("AntPath expression" ,pathMatcher .isPattern (expectedUrl ));
@@ -170,25 +167,24 @@ public static ContentResultMatchers content() {
170167 }
171168
172169 /**
173- * Access to response body assertions using a <a
174- * href="http://goessner.net/articles/JsonPath/">JSONPath</a> expression to
175- * inspect a specific subset of the body. The JSON path expression can be a
176- * parameterized string using formatting specifiers as defined in
170+ * Access to response body assertions using a
171+ * <a href="https://github.com/jayway/JsonPath">JsonPath</a> expression
172+ * to inspect a specific subset of the body.
173+ * <p>The JSON path expression can be a parameterized string using
174+ * formatting specifiers as defined in
177175 * {@link String#format(String, Object...)}.
178- *
179- * @param expression the JSON path optionally parameterized with arguments
176+ * @param expression the JSON path expression, optionally parameterized with arguments
180177 * @param args arguments to parameterize the JSON path expression with
181178 */
182179 public static JsonPathResultMatchers jsonPath (String expression , Object ... args ) {
183180 return new JsonPathResultMatchers (expression , args );
184181 }
185182
186183 /**
187- * Access to response body assertions using a <a
188- * href="http://goessner.net/articles/JsonPath/">JSONPath</a> expression to
189- * inspect a specific subset of the body and a Hamcrest match for asserting
190- * the value found at the JSON path.
191- *
184+ * Access to response body assertions using a
185+ * <a href="https://github.com/jayway/JsonPath">JsonPath</a> expression
186+ * to inspect a specific subset of the body and a Hamcrest matcher for
187+ * asserting the value found at the JSON path.
192188 * @param expression the JSON path expression
193189 * @param matcher a matcher for the value expected at the JSON path
194190 */
@@ -197,25 +193,23 @@ public static <T> ResultMatcher jsonPath(String expression, Matcher<T> matcher)
197193 }
198194
199195 /**
200- * Access to response body assertions using an XPath to inspect a specific
201- * subset of the body. The XPath expression can be a parameterized string
202- * using formatting specifiers as defined in
203- * {@link String#format(String, Object...)}.
204- *
205- * @param expression the XPath optionally parameterized with arguments
196+ * Access to response body assertions using an XPath expression to
197+ * inspect a specific subset of the body.
198+ * <p>The XPath expression can be a parameterized string using formatting
199+ * specifiers as defined in {@link String#format(String, Object...)}.
200+ * @param expression the XPath expression, optionally parameterized with arguments
206201 * @param args arguments to parameterize the XPath expression with
207202 */
208203 public static XpathResultMatchers xpath (String expression , Object ... args ) throws XPathExpressionException {
209204 return new XpathResultMatchers (expression , null , args );
210205 }
211206
212207 /**
213- * Access to response body assertions using an XPath to inspect a specific
214- * subset of the body. The XPath expression can be a parameterized string
215- * using formatting specifiers as defined in
216- * {@link String#format(String, Object...)}.
217- *
218- * @param expression the XPath optionally parameterized with arguments
208+ * Access to response body assertions using an XPath expression to
209+ * inspect a specific subset of the body.
210+ * <p>The XPath expression can be a parameterized string using formatting
211+ * specifiers as defined in {@link String#format(String, Object...)}.
212+ * @param expression the XPath expression, optionally parameterized with arguments
219213 * @param namespaces namespaces referenced in the XPath expression
220214 * @param args arguments to parameterize the XPath expression with
221215 */
0 commit comments