001// ***************************************************************************************************************************
002// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.  See the NOTICE file *
003// * distributed with this work for additional information regarding copyright ownership.  The ASF licenses this file        *
004// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance            *
005// * with the License.  You may obtain a copy of the License at                                                              *
006// *                                                                                                                         *
007// *  http://www.apache.org/licenses/LICENSE-2.0                                                                             *
008// *                                                                                                                         *
009// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an  *
010// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the        *
011// * specific language governing permissions and limitations under the License.                                              *
012// ***************************************************************************************************************************
013package org.apache.juneau.rest.client.mock;
014
015import java.io.*;
016import java.util.concurrent.*;
017
018import org.apache.http.*;
019import org.apache.http.conn.*;
020import org.apache.http.conn.routing.*;
021import org.apache.http.protocol.*;
022import org.apache.juneau.utils.*;
023
024/**
025 * An implementation of {@link HttpClientConnectionManager} specifically for use in mocked connections using the {@link MockHttpConnection} class.
026 *
027 * <div class='warn'>
028 *    <b>Deprecated</b> - Use <c>org.apache.juneau.restmock2</c>
029 * </div>
030 *
031 * This implementation is NOT thread safe.
032 */
033@Deprecated
034public class MockHttpClientConnectionManager implements HttpClientConnectionManager {
035
036   final ConnectionRequest cr;
037
038   /**
039    * Constructor.
040    *
041    * @param c The mocked connection.
042    */
043   public MockHttpClientConnectionManager(final MockHttpConnection c) {
044      final HttpClientConnection hcc = new MockHttpClientConnection(c);
045      this.cr = new ConnectionRequest() {
046         @Override
047         public boolean cancel() {
048            return false;
049         }
050         @Override
051         public HttpClientConnection get(long timeout, TimeUnit tunit) throws InterruptedException, ExecutionException, ConnectionPoolTimeoutException {
052            return hcc;
053         }
054      };
055   }
056
057   @Override /* HttpClientConnectionManager */
058   public ConnectionRequest requestConnection(HttpRoute route, Object state) {
059      return cr;
060   }
061
062   @Override /* HttpClientConnectionManager */
063   public void releaseConnection(HttpClientConnection conn, Object newState, long validDuration, TimeUnit timeUnit) {}
064
065   @Override /* HttpClientConnectionManager */
066   public void connect(HttpClientConnection conn, HttpRoute route, int connectTimeout, HttpContext context) throws IOException {}
067
068   @Override /* HttpClientConnectionManager */
069   public void upgrade(HttpClientConnection conn, HttpRoute route, HttpContext context) throws IOException {}
070
071   @Override /* HttpClientConnectionManager */
072   public void routeComplete(HttpClientConnection conn, HttpRoute route, HttpContext context) throws IOException {}
073
074   @Override /* HttpClientConnectionManager */
075   public void closeIdleConnections(long idletime, TimeUnit tunit) {}
076
077   @Override /* HttpClientConnectionManager */
078   public void closeExpiredConnections() {}
079
080   @Override /* HttpClientConnectionManager */
081   public void shutdown() {}
082}