Class identity comparisons wherever possible (and further polishing)
Issue: SPR-12926
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2015 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.
|
||||
@@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.test.web.client;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -52,7 +53,6 @@ public class MockMvcClientHttpRequestFactory implements ClientHttpRequestFactory
|
||||
@Override
|
||||
public ClientHttpRequest createRequest(final URI uri, final HttpMethod httpMethod) throws IOException {
|
||||
return new MockClientHttpRequest(httpMethod, uri) {
|
||||
|
||||
@Override
|
||||
public ClientHttpResponse executeInternal() throws IOException {
|
||||
try {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2015 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.
|
||||
@@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.test.web.client;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -29,7 +30,6 @@ public interface RequestMatcher {
|
||||
|
||||
/**
|
||||
* Match the given request against some expectations.
|
||||
*
|
||||
* @param request the request to make assertions on
|
||||
* @throws IOException in case of I/O errors
|
||||
* @throws AssertionError if expectations are not met
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2015 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.
|
||||
@@ -46,6 +46,7 @@ class RequestMatcherClientHttpRequest extends MockAsyncClientHttpRequest impleme
|
||||
this.requestMatchers.add(requestMatcher);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ResponseActions andExpect(RequestMatcher requestMatcher) {
|
||||
Assert.notNull(requestMatcher, "RequestMatcher is required");
|
||||
@@ -61,22 +62,19 @@ class RequestMatcherClientHttpRequest extends MockAsyncClientHttpRequest impleme
|
||||
|
||||
@Override
|
||||
public ClientHttpResponse executeInternal() throws IOException {
|
||||
|
||||
if (this.requestMatchers.isEmpty()) {
|
||||
throw new AssertionError("No request expectations to execute");
|
||||
}
|
||||
|
||||
if (this.responseCreator == null) {
|
||||
throw new AssertionError("No ResponseCreator was set up. Add it after request expectations, "
|
||||
+ "e.g. MockRestServiceServer.expect(requestTo(\"/foo\")).andRespond(withSuccess())");
|
||||
throw new AssertionError("No ResponseCreator was set up. Add it after request expectations, " +
|
||||
"e.g. MockRestServiceServer.expect(requestTo(\"/foo\")).andRespond(withSuccess())");
|
||||
}
|
||||
|
||||
for (RequestMatcher requestMatcher : this.requestMatchers) {
|
||||
requestMatcher.match(this);
|
||||
}
|
||||
|
||||
setResponse(this.responseCreator.createResponse(this));
|
||||
|
||||
return super.executeInternal();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2015 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.
|
||||
@@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.test.web.client;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2015 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.
|
||||
@@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.test.web.client;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
Reference in New Issue
Block a user