Merge branch '5.1.x'

This commit is contained in:
Juergen Hoeller
2019-04-26 16:56:04 +02:00
28 changed files with 189 additions and 201 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,15 +26,11 @@ import org.junit.rules.ExpectedException;
import org.springframework.http.HttpMethod;
import org.springframework.http.client.ClientHttpRequest;
import static junit.framework.TestCase.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.springframework.http.HttpMethod.GET;
import static org.springframework.http.HttpMethod.POST;
import static org.springframework.test.web.client.ExpectedCount.once;
import static org.springframework.test.web.client.ExpectedCount.twice;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.method;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo;
import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess;
import static org.junit.Assert.*;
import static org.springframework.http.HttpMethod.*;
import static org.springframework.test.web.client.ExpectedCount.*;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.*;
import static org.springframework.test.web.client.response.MockRestResponseCreators.*;
/**
* Unit tests for {@link DefaultRequestExpectation}.
@@ -86,7 +82,6 @@ public class DefaultRequestExpectationTests {
}
@SuppressWarnings("deprecation")
private ClientHttpRequest createRequest(HttpMethod method, String url) {
try {

View File

@@ -126,7 +126,7 @@ public class MockRestServiceServerTests {
try {
this.restTemplate.getForEntity("/some-service/some-endpoint", String.class);
fail("Expected exception to be thrown.");
fail("Expected exception");
}
catch (Exception ex) {
this.restTemplate.postForEntity("/reporting-service/report-error", ex.toString(), String.class);
@@ -135,7 +135,7 @@ public class MockRestServiceServerTests {
server.verify();
}
@Test // gh-21799
@Test // gh-21799
public void verifyShouldFailIfRequestsFailed() {
MockRestServiceServer server = MockRestServiceServer.bindTo(this.restTemplate).build();
server.expect(once(), requestTo("/remoteurl")).andRespond(withSuccess());
@@ -143,7 +143,7 @@ public class MockRestServiceServerTests {
this.restTemplate.postForEntity("/remoteurl", null, String.class);
try {
this.restTemplate.postForEntity("/remoteurl", null, String.class);
fail("Expected error to be thrown.");
fail("Expected assertion error");
}
catch (AssertionError error) {
assertThat(error.getMessage()).startsWith("No further requests expected");
@@ -157,4 +157,5 @@ public class MockRestServiceServerTests {
assertThat(error.getMessage()).startsWith("Some requests did not execute successfully");
}
}
}