001/*
002 * Copyright 2002-2017 the original author or authors.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *      https://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package org.springframework.mock.http.client;
018
019import java.io.IOException;
020import java.net.URI;
021
022import org.springframework.http.HttpMethod;
023import org.springframework.http.client.ClientHttpResponse;
024import org.springframework.util.concurrent.ListenableFuture;
025import org.springframework.util.concurrent.SettableListenableFuture;
026
027/**
028 * An extension of {@link MockClientHttpRequest} that also implements
029 * {@link org.springframework.http.client.AsyncClientHttpRequest} by wrapping the response in a
030 * {@link SettableListenableFuture}.
031 *
032 * @author Rossen Stoyanchev
033 * @author Sam Brannen
034 * @since 4.1
035 * @deprecated as of Spring 5.0, with no direct replacement
036 */
037@Deprecated
038public class MockAsyncClientHttpRequest extends MockClientHttpRequest implements org.springframework.http.client.AsyncClientHttpRequest {
039
040        public MockAsyncClientHttpRequest() {
041        }
042
043        public MockAsyncClientHttpRequest(HttpMethod httpMethod, URI uri) {
044                super(httpMethod, uri);
045        }
046
047
048        @Override
049        public ListenableFuture<ClientHttpResponse> executeAsync() throws IOException {
050                SettableListenableFuture<ClientHttpResponse> future = new SettableListenableFuture<>();
051                future.set(execute());
052                return future;
053        }
054
055}