forked from troyzhxu/okhttps
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTagTests.java
More file actions
41 lines (31 loc) · 1.2 KB
/
TagTests.java
File metadata and controls
41 lines (31 loc) · 1.2 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package cn.zhxu.okhttps;
import cn.zhxu.okhttps.internal.AbstractHttpClient;
import okhttp3.OkHttpClient;
import org.junit.Test;
import java.util.concurrent.TimeUnit;
public class TagTests extends BaseTest {
@Test
public void testTag() {
AbstractHttpClient http = (AbstractHttpClient) HTTP.builder()
.config((OkHttpClient.Builder builder) -> {
builder.connectTimeout(1, TimeUnit.SECONDS);
builder.writeTimeout(1, TimeUnit.SECONDS);
builder.readTimeout(1, TimeUnit.SECONDS);
builder.pingInterval(60, TimeUnit.SECONDS);
})
.build();
http.async("http://www.baidu.com")
.tag("AA")
.setOnResponse((HttpResult result) -> {
throw new RuntimeException("我是一个异常");
})
.get();
println("taskCount = " + http.getTagTaskCount());
sleep(1000);
println("taskCount = " + http.getTagTaskCount());
sleep(1000);
println("taskCount = " + http.getTagTaskCount());
sleep(5000);
println("taskCount = " + http.getTagTaskCount());
}
}