AdminBizTest.java
2.65 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package com.xxl.job.openapi;
import com.xxl.job.core.constant.RegistType;
import com.xxl.job.core.openapi.AdminBiz;
import com.xxl.job.core.openapi.model.CallbackRequest;
import com.xxl.job.core.openapi.model.RegistryRequest;
import com.xxl.job.core.context.XxlJobContext;
import com.xxl.job.core.constant.Const;
import com.xxl.tool.http.HttpTool;
import com.xxl.tool.response.Response;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Arrays;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* admin api test
*
* @author xuxueli 2017-07-28 22:14:52
*/
public class AdminBizTest {
private static final Logger logger = LoggerFactory.getLogger(AdminBizTest.class);
private static String addressUrl = "http://127.0.0.1:8080/xxl-job-admin";
private static String accessToken = "default_token";
private AdminBiz buildClient(){
String finalUrl = addressUrl + "/api";
return HttpTool.createClient()
.url(finalUrl)
.timeout(3 * 1000)
.header(Const.XXL_JOB_ACCESS_TOKEN, accessToken)
.proxy(AdminBiz.class);
}
@Test
public void callback() throws Exception {
AdminBiz adminBiz = buildClient();
CallbackRequest param = new CallbackRequest();
param.setLogId(1);
param.setHandleCode(XxlJobContext.HANDLE_CODE_SUCCESS);
List<CallbackRequest> callbackParamList = Arrays.asList(param);
Response<String> returnT = adminBiz.callback(callbackParamList);
assertTrue(returnT.isSuccess());
}
/**
* registry executor
*
* @throws Exception
*/
@Test
public void registry() throws Exception {
AdminBiz adminBiz = buildClient();
RegistryRequest registryParam = new RegistryRequest(RegistType.EXECUTOR.name(), "xxl-job-executor-example", "127.0.0.1:9999");
Response<String> returnT = adminBiz.registry(registryParam);
assertTrue(returnT.isSuccess());
}
/**
* registry executor remove
*
* @throws Exception
*/
@Test
public void registryRemove() throws Exception {
AdminBiz adminBiz = buildClient();
RegistryRequest registryParam = new RegistryRequest(RegistType.EXECUTOR.name(), "xxl-job-executor-example", "127.0.0.1:9999");
Response<String> returnT = adminBiz.registryRemove(registryParam);
assertTrue(returnT.isSuccess());
}
// ---------------------- job opt ----------------------
@Test
public void jobManage() throws Exception {
// jobAdd、jobUpdate、jobRemove、jobStart、jobStop
}
}