View Javadoc
1   /*
2    * ====================================================================
3    * Licensed to the Apache Software Foundation (ASF) under one
4    * or more contributor license agreements.  See the NOTICE file
5    * distributed with this work for additional information
6    * regarding copyright ownership.  The ASF licenses this file
7    * to you under the Apache License, Version 2.0 (the
8    * "License"); you may not use this file except in compliance
9    * with the License.  You may obtain a copy of the License at
10   *
11   *   http://www.apache.org/licenses/LICENSE-2.0
12   *
13   * Unless required by applicable law or agreed to in writing,
14   * software distributed under the License is distributed on an
15   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16   * KIND, either express or implied.  See the License for the
17   * specific language governing permissions and limitations
18   * under the License.
19   * ====================================================================
20   *
21   * This software consists of voluntary contributions made by many
22   * individuals on behalf of the Apache Software Foundation.  For more
23   * information on the Apache Software Foundation, please see
24   * <http://www.apache.org/>.
25   *
26   */
27  
28  package org.apache.hc.client5.testing.extension.sync;
29  
30  import java.util.Collection;
31  
32  import org.apache.hc.client5.http.AuthenticationStrategy;
33  import org.apache.hc.client5.http.HttpRequestRetryStrategy;
34  import org.apache.hc.client5.http.UserTokenHandler;
35  import org.apache.hc.client5.http.auth.AuthSchemeFactory;
36  import org.apache.hc.client5.http.classic.ExecChainHandler;
37  import org.apache.hc.client5.http.io.HttpClientConnectionManager;
38  import org.apache.hc.core5.http.Header;
39  import org.apache.hc.core5.http.HttpRequestInterceptor;
40  import org.apache.hc.core5.http.HttpResponseInterceptor;
41  import org.apache.hc.core5.http.config.Lookup;
42  import org.apache.hc.core5.http.impl.io.HttpRequestExecutor;
43  import org.apache.hc.core5.util.Timeout;
44  
45  public interface TestClientBuilder {
46  
47      ClientProtocolLevel getProtocolLevel();
48  
49      TestClientBuilder setTimeout(Timeout soTimeout);
50  
51      TestClientBuilder setConnectionManager(HttpClientConnectionManager connManager);
52  
53      default TestClientBuilder addResponseInterceptorFirst(final HttpResponseInterceptor interceptor) {
54          return this;
55      }
56  
57      default TestClientBuilder addResponseInterceptorLast(HttpResponseInterceptor interceptor) {
58          throw new UnsupportedOperationException("Operation not supported by " + getProtocolLevel());
59      }
60  
61      default TestClientBuilder addRequestInterceptorFirst(HttpRequestInterceptor interceptor) {
62          throw new UnsupportedOperationException("Operation not supported by " + getProtocolLevel());
63      }
64  
65      default TestClientBuilder addRequestInterceptorLast(HttpRequestInterceptor interceptor) {
66          throw new UnsupportedOperationException("Operation not supported by " + getProtocolLevel());
67      }
68  
69      default TestClientBuilder setUserTokenHandler(UserTokenHandler userTokenHandler) {
70          throw new UnsupportedOperationException("Operation not supported by " + getProtocolLevel());
71      }
72  
73      default TestClientBuilder setDefaultHeaders(Collection<? extends Header> defaultHeaders) {
74          throw new UnsupportedOperationException("Operation not supported by " + getProtocolLevel());
75      }
76  
77      default TestClientBuilder setRetryStrategy(HttpRequestRetryStrategy retryStrategy) {
78          throw new UnsupportedOperationException("Operation not supported by " + getProtocolLevel());
79      }
80  
81      default TestClientBuilder setTargetAuthenticationStrategy(AuthenticationStrategy targetAuthStrategy) {
82          throw new UnsupportedOperationException("Operation not supported by " + getProtocolLevel());
83      }
84  
85      default TestClientBuilder setDefaultAuthSchemeRegistry(Lookup<AuthSchemeFactory> authSchemeRegistry) {
86          throw new UnsupportedOperationException("Operation not supported by " + getProtocolLevel());
87      }
88  
89      default TestClientBuilder setRequestExecutor(HttpRequestExecutor requestExec) {
90          throw new UnsupportedOperationException("Operation not supported by " + getProtocolLevel());
91      }
92  
93      default TestClientBuilder addExecInterceptorFirst(String name, ExecChainHandler interceptor) {
94          throw new UnsupportedOperationException("Operation not supported by " + getProtocolLevel());
95      }
96  
97      default TestClientBuilder  addExecInterceptorLast(String name, ExecChainHandler interceptor) {
98          throw new UnsupportedOperationException("Operation not supported by " + getProtocolLevel());
99      }
100 
101     TestClient build() throws Exception;
102 
103 }