-
Notifications
You must be signed in to change notification settings - Fork 285
Expand file tree
/
Copy pathDaemonThreadTest.java
More file actions
33 lines (28 loc) · 1.08 KB
/
DaemonThreadTest.java
File metadata and controls
33 lines (28 loc) · 1.08 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
package com.tencentcloudapi.integration.common;
import com.tencentcloudapi.common.CommonClient;
import com.tencentcloudapi.common.Credential;
import org.junit.Test;
import static org.junit.Assert.fail;
public class DaemonThreadTest {
@Test
// ensure OkHttp threads are daemon to allow clean JVM shutdown
public void testOkhttpUseDaemonThread() {
Credential cred = new Credential(
System.getenv("TENCENTCLOUD_SECRET_ID"),
System.getenv("TENCENTCLOUD_SECRET_KEY")
);
CommonClient client = new CommonClient("cvm", "2017-03-12", cred, "ap-guangzhou");
try {
client.call(
"DescribeInstances",
"{\"Limit\": 1, \"Filters\":[{\"Name\":\"zone\",\"Values\":[\"ap-guangzhou-1\"]}]}");
} catch (Exception e) {
fail(e.toString());
}
for (Thread t : Thread.getAllStackTraces().keySet()) {
if (t.getName().startsWith("OkHttp") && !t.isDaemon()) {
fail("thread should be daemon: " + t.getName());
}
}
}
}