Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
liyuanzhong001
DolphinScheduler
提交
d6c707d0
DolphinScheduler
项目概览
liyuanzhong001
/
DolphinScheduler
与 Fork 源项目一致
Fork自
apache / DolphinScheduler
通知
11
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
DolphinScheduler
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
d6c707d0
编写于
4月 26, 2019
作者:
journey2018
提交者:
GitHub
4月 26, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #172 from qiaozhanwei/dev-20190415
HttpClientTest update
上级
cefdb298
0641ded3
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
20 addition
and
22 deletion
+20
-22
escheduler-api/src/test/java/cn/escheduler/api/HttpClientTest.java
...r-api/src/test/java/cn/escheduler/api/HttpClientTest.java
+20
-22
未找到文件。
escheduler-api/src/test/java/cn/escheduler/api/HttpClientTest.java
浏览文件 @
d6c707d0
...
...
@@ -34,26 +34,19 @@ import org.apache.http.impl.client.CloseableHttpClient;
import
org.apache.http.impl.client.HttpClients
;
import
org.apache.http.message.BasicNameValuePair
;
import
org.apache.http.util.EntityUtils
;
import
org.junit.Test
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
public
class
HttpClientTest
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
HttpClientTest
.
class
);
public
static
void
main
(
String
[]
args
)
throws
Exception
{
// doGETParamPathVariableAndChinese();
// doGETParam();
// doPOSTParam();
String
md5
=
EncryptionUtils
.
getMd5
(
String
.
valueOf
(
System
.
currentTimeMillis
())
+
"张三"
);
System
.
out
.
println
(
md5
);
System
.
out
.
println
(
md5
.
length
());
}
public
static
void
doPOSTParam
()
throws
Exception
{
// create Httpclient
@Test
public
void
doPOSTParam
()
throws
Exception
{
// create HttpClient
CloseableHttpClient
httpclient
=
HttpClients
.
createDefault
();
// 创建http POST请求
// create http post request
HttpPost
httpPost
=
new
HttpPost
(
"http://127.0.0.1:12345/escheduler/projects/create"
);
httpPost
.
setHeader
(
"token"
,
"123"
);
// set parameters
...
...
@@ -83,23 +76,24 @@ public class HttpClientTest {
}
/**
*
*
do get param path variables chinese
* @throws Exception
*/
public
static
void
doGETParamPathVariableAndChinese
()
throws
Exception
{
@Test
public
void
doGETParamPathVariableAndChinese
()
throws
Exception
{
// create HttpClient
CloseableHttpClient
httpclient
=
HttpClients
.
createDefault
();
List
<
NameValuePair
>
parameters
=
new
ArrayList
<
NameValuePair
>();
//
parameters.add(new BasicNameValuePair("pageSize", "10"));
//
parameters.add(new BasicNameValuePair("pageSize", "10"));
// define the parameters of the request
URI
uri
=
new
URIBuilder
(
"http://1
27.0.0.1
:12345/escheduler/projects/%E5%85%A8%E9%83%A8%E6%B5%81%E7%A8%8B%E6%B5%8B%E8%AF%95/process/list"
)
URI
uri
=
new
URIBuilder
(
"http://1
92.168.220.247
:12345/escheduler/projects/%E5%85%A8%E9%83%A8%E6%B5%81%E7%A8%8B%E6%B5%8B%E8%AF%95/process/list"
)
.
build
();
// create http GET request
HttpGet
httpGet
=
new
HttpGet
(
uri
);
httpGet
.
setHeader
(
"token"
,
"1
23
"
);
httpGet
.
setHeader
(
"token"
,
"1
0f5625a2a1cbf9aa710653796c5d764
"
);
//response object
CloseableHttpResponse
response
=
null
;
try
{
...
...
@@ -122,23 +116,27 @@ public class HttpClientTest {
/**
*
* do get param
* @throws Exception
*/
public
static
void
doGETParam
()
throws
Exception
{
@Test
public
void
doGETParam
()
throws
Exception
{
// create HttpClient
CloseableHttpClient
httpclient
=
HttpClients
.
createDefault
();
List
<
NameValuePair
>
parameters
=
new
ArrayList
<
NameValuePair
>();
parameters
.
add
(
new
BasicNameValuePair
(
"processInstanceId"
,
"41415"
));
parameters
.
add
(
new
BasicNameValuePair
(
"startDate"
,
"2018-04-22 19:30:08"
));
parameters
.
add
(
new
BasicNameValuePair
(
"endDate"
,
"2028-04-22 19:30:08"
));
parameters
.
add
(
new
BasicNameValuePair
(
"projectId"
,
"0"
));
// define the parameters of the request
URI
uri
=
new
URIBuilder
(
"http://1
27.0.0.1:12345/escheduler/projects/%E5%85%A8%E9%83%A8%E6%B5%81%E7%A8%8B%E6%B5%8B%E8%AF%95/instance/view-variables
"
)
URI
uri
=
new
URIBuilder
(
"http://1
92.168.220.247:12345/escheduler/projects/analysis/queue-count
"
)
.
setParameters
(
parameters
)
.
build
();
// create http GET request
HttpGet
httpGet
=
new
HttpGet
(
uri
);
httpGet
.
setHeader
(
"token"
,
"
123
"
);
httpGet
.
setHeader
(
"token"
,
"
2aef24c052c212fab9eec78848c2258b
"
);
//response object
CloseableHttpResponse
response
=
null
;
try
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录