1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 package org.apache.hc.client5.http.impl.classic;
28
29 import java.io.IOException;
30
31 import org.apache.hc.client5.http.async.AsyncExecCallback;
32 import org.apache.hc.client5.http.async.AsyncExecChain;
33 import org.apache.hc.client5.http.async.AsyncExecChainHandler;
34 import org.apache.hc.client5.http.impl.async.HttpAsyncClients;
35 import org.apache.hc.core5.http.HttpException;
36 import org.apache.hc.core5.http.HttpRequest;
37 import org.apache.hc.core5.http.nio.AsyncEntityProducer;
38 import org.junit.jupiter.api.Test;
39
40 class TestHttpAsyncClientBuilder {
41
42 @Test
43 void testAddInterceptorFirstDoesNotThrow() throws IOException {
44 HttpAsyncClients.custom()
45 .addExecInterceptorFirst("first", NopExecChainHandler.INSTANCE)
46 .build()
47 .close();
48 }
49
50 @Test
51 void testAddInterceptorLastDoesNotThrow() throws IOException {
52 HttpAsyncClients.custom()
53 .addExecInterceptorLast("last", NopExecChainHandler.INSTANCE)
54 .build()
55 .close();
56 }
57
58 @Test
59 void testH2AddInterceptorFirstDoesNotThrow() throws IOException {
60 HttpAsyncClients.customHttp2()
61 .addExecInterceptorFirst("first", NopExecChainHandler.INSTANCE)
62 .build()
63 .close();
64 }
65
66 @Test
67 void testH2AddInterceptorLastDoesNotThrow() throws IOException {
68 HttpAsyncClients.customHttp2()
69 .addExecInterceptorLast("last", NopExecChainHandler.INSTANCE)
70 .build()
71 .close();
72 }
73
74 enum NopExecChainHandler implements AsyncExecChainHandler {
75 INSTANCE;
76
77 @Override
78 public void execute(final HttpRequest request, final AsyncEntityProducer entityProducer,
79 final AsyncExecChain.Scope scope, final AsyncExecChain chain,
80 final AsyncExecCallback asyncExecCallback)
81 throws HttpException, IOException {
82 chain.proceed(request, entityProducer, scope, asyncExecCallback);
83 }
84 }
85 }