提交 | 用户 | 时间
|
e7c126
|
1 |
package com.xxl.job.adminbiz; |
H |
2 |
|
|
3 |
import com.xxl.job.core.biz.AdminBiz; |
|
4 |
import com.xxl.job.core.biz.client.AdminBizClient; |
|
5 |
import com.xxl.job.core.biz.model.HandleCallbackParam; |
|
6 |
import com.xxl.job.core.biz.model.RegistryParam; |
|
7 |
import com.xxl.job.core.biz.model.ReturnT; |
|
8 |
import com.xxl.job.core.context.XxlJobContext; |
|
9 |
import com.xxl.job.core.enums.RegistryConfig; |
|
10 |
import org.junit.jupiter.api.Test; |
|
11 |
|
|
12 |
import java.util.Arrays; |
|
13 |
import java.util.List; |
|
14 |
|
|
15 |
import static org.junit.jupiter.api.Assertions.assertTrue; |
|
16 |
|
|
17 |
/** |
|
18 |
* admin api test |
|
19 |
* |
|
20 |
* @author xuxueli 2017-07-28 22:14:52 |
|
21 |
*/ |
|
22 |
public class AdminBizTest { |
|
23 |
|
|
24 |
// admin-client |
|
25 |
private static String addressUrl = "http://127.0.0.1:8080/xxl-job-admin/"; |
|
26 |
private static String accessToken = null; |
|
27 |
|
|
28 |
|
|
29 |
@Test |
|
30 |
public void callback() throws Exception { |
|
31 |
AdminBiz adminBiz = new AdminBizClient(addressUrl, accessToken); |
|
32 |
|
|
33 |
HandleCallbackParam param = new HandleCallbackParam(); |
|
34 |
param.setLogId(1); |
|
35 |
param.setHandleCode(XxlJobContext.HANDLE_CODE_SUCCESS); |
|
36 |
|
|
37 |
List<HandleCallbackParam> callbackParamList = Arrays.asList(param); |
|
38 |
|
|
39 |
ReturnT<String> returnT = adminBiz.callback(callbackParamList); |
|
40 |
|
|
41 |
assertTrue(returnT.getCode() == ReturnT.SUCCESS_CODE); |
|
42 |
} |
|
43 |
|
|
44 |
/** |
|
45 |
* registry executor |
|
46 |
* |
|
47 |
* @throws Exception |
|
48 |
*/ |
|
49 |
@Test |
|
50 |
public void registry() throws Exception { |
|
51 |
AdminBiz adminBiz = new AdminBizClient(addressUrl, accessToken); |
|
52 |
|
|
53 |
RegistryParam registryParam = new RegistryParam(RegistryConfig.RegistType.EXECUTOR.name(), "xxl-job-executor-example", "127.0.0.1:9999"); |
|
54 |
ReturnT<String> returnT = adminBiz.registry(registryParam); |
|
55 |
|
|
56 |
assertTrue(returnT.getCode() == ReturnT.SUCCESS_CODE); |
|
57 |
} |
|
58 |
|
|
59 |
/** |
|
60 |
* registry executor remove |
|
61 |
* |
|
62 |
* @throws Exception |
|
63 |
*/ |
|
64 |
@Test |
|
65 |
public void registryRemove() throws Exception { |
|
66 |
AdminBiz adminBiz = new AdminBizClient(addressUrl, accessToken); |
|
67 |
|
|
68 |
RegistryParam registryParam = new RegistryParam(RegistryConfig.RegistType.EXECUTOR.name(), "xxl-job-executor-example", "127.0.0.1:9999"); |
|
69 |
ReturnT<String> returnT = adminBiz.registryRemove(registryParam); |
|
70 |
|
|
71 |
assertTrue(returnT.getCode() == ReturnT.SUCCESS_CODE); |
|
72 |
|
|
73 |
} |
|
74 |
|
|
75 |
} |