File tree Expand file tree Collapse file tree 4 files changed +35
-4
lines changed
spring-test/src/main/java/org/springframework/test/web Expand file tree Collapse file tree 4 files changed +35
-4
lines changed Original file line number Diff line number Diff line change @@ -381,6 +381,11 @@ public ResponseSpec exchange() {
381381 DefaultWebTestClient .this .entityResultConsumer , getResponseTimeout ());
382382 }
383383
384+ @ Override
385+ public ResponseSpec exchangeSuccessfully () {
386+ return exchange ().expectStatus ().is2xxSuccessful ();
387+ }
388+
384389 private ClientRequest .Builder initRequestBuilder () {
385390 return ClientRequest .create (this .httpMethod , initUri ())
386391 .headers (headersToUse -> {
Original file line number Diff line number Diff line change @@ -700,10 +700,21 @@ interface RequestHeadersSpec<S extends RequestHeadersSpec<S>> {
700700 S attributes (Consumer <Map <String , Object >> attributesConsumer );
701701
702702 /**
703- * Perform the exchange without a request body .
704- * @return a spec for decoding the response
703+ * Perform the exchange.
704+ * @return a spec for expectations on the response
705705 */
706706 ResponseSpec exchange ();
707+
708+ /**
709+ * Variant of {@link #exchange()} that expects a successful response.
710+ * Effectively, a shortcut for:
711+ * <pre class="code">
712+ * exchange().is2xxSuccessful()
713+ * </pre>
714+ * @return a spec for expectations on the response
715+ * @since 7.0
716+ */
717+ ResponseSpec exchangeSuccessfully ();
707718 }
708719
709720
Original file line number Diff line number Diff line change @@ -269,6 +269,11 @@ public ResponseSpec exchange() {
269269 }, false ),
270270 DefaultRestTestClient .this .entityResultConsumer );
271271 }
272+
273+ @ Override
274+ public ResponseSpec exchangeSuccessfully () {
275+ return exchange ().expectStatus ().is2xxSuccessful ();
276+ }
272277 }
273278
274279
Original file line number Diff line number Diff line change @@ -514,10 +514,20 @@ interface RequestHeadersSpec<S extends RequestHeadersSpec<S>> {
514514 S attributes (Consumer <Map <String , Object >> attributesConsumer );
515515
516516 /**
517- * Perform the exchange without a request body .
518- * @return a spec for decoding the response
517+ * Perform the exchange.
518+ * @return a spec for expectations on the response
519519 */
520520 ResponseSpec exchange ();
521+
522+ /**
523+ * Variant of {@link #exchange()} that expects a successful response.
524+ * Effectively, a shortcut for:
525+ * <pre class="code">
526+ * exchange().is2xxSuccessful()
527+ * </pre>
528+ * @return a spec for expectations on the response
529+ */
530+ ResponseSpec exchangeSuccessfully ();
521531 }
522532
523533
You can’t perform that action at this time.
0 commit comments