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 * This implementation is NOT thread safe. 028 * 029 * @deprecated Use <c>org.apache.juneau.rest.mock2</c> 030 */ 031@Deprecated 032public class MockHttpClientConnectionManager implements HttpClientConnectionManager { 033 034 final ConnectionRequest cr; 035 036 /** 037 * Constructor. 038 * 039 * @param c The mocked connection. 040 */ 041 public MockHttpClientConnectionManager(final MockHttpConnection c) { 042 final HttpClientConnection hcc = new MockHttpClientConnection(c); 043 this.cr = new ConnectionRequest() { 044 @Override 045 public boolean cancel() { 046 return false; 047 } 048 @Override 049 public HttpClientConnection get(long timeout, TimeUnit tunit) throws InterruptedException, ExecutionException, ConnectionPoolTimeoutException { 050 return hcc; 051 } 052 }; 053 } 054 055 @Override /* HttpClientConnectionManager */ 056 public ConnectionRequest requestConnection(HttpRoute route, Object state) { 057 return cr; 058 } 059 060 @Override /* HttpClientConnectionManager */ 061 public void releaseConnection(HttpClientConnection conn, Object newState, long validDuration, TimeUnit timeUnit) {} 062 063 @Override /* HttpClientConnectionManager */ 064 public void connect(HttpClientConnection conn, HttpRoute route, int connectTimeout, HttpContext context) throws IOException {} 065 066 @Override /* HttpClientConnectionManager */ 067 public void upgrade(HttpClientConnection conn, HttpRoute route, HttpContext context) throws IOException {} 068 069 @Override /* HttpClientConnectionManager */ 070 public void routeComplete(HttpClientConnection conn, HttpRoute route, HttpContext context) throws IOException {} 071 072 @Override /* HttpClientConnectionManager */ 073 public void closeIdleConnections(long idletime, TimeUnit tunit) {} 074 075 @Override /* HttpClientConnectionManager */ 076 public void closeExpiredConnections() {} 077 078 @Override /* HttpClientConnectionManager */ 079 public void shutdown() {} 080}