Exception response for MockRestServiceServer
Closes gh-1954
This commit is contained in:
committed by
Rossen Stoyanchev
parent
f638bfc6a9
commit
cfb7777a07
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.springframework.test.web.client.response;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
|
||||
import org.springframework.core.io.Resource;
|
||||
@@ -116,4 +117,15 @@ public abstract class MockRestResponseCreators {
|
||||
return new DefaultResponseCreator(status);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@code ResponseCreator} with an internal application {@code IOException}. For example,
|
||||
* one could use this to simulate a {@code SocketTimeoutException}.
|
||||
* @param e the {@code Exception} to be thrown at HTTP call time.
|
||||
*/
|
||||
public static ResponseCreator withException(IOException e) {
|
||||
return request -> {
|
||||
throw e;
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user