Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
#法外狂徒张三
DolphinScheduler
提交
7992f530
DolphinScheduler
项目概览
#法外狂徒张三
/
DolphinScheduler
与 Fork 源项目一致
Fork自
apache / DolphinScheduler
通知
12
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,发现更多精彩内容 >>
提交
7992f530
编写于
8月 30, 2019
作者:
L
lidongdai
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update escheduler-api unit test
上级
15246d41
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
72 addition
and
216 deletion
+72
-216
escheduler-api/src/main/java/cn/escheduler/api/service/ResourcesService.java
...main/java/cn/escheduler/api/service/ResourcesService.java
+17
-11
escheduler-api/src/test/java/cn/escheduler/api/controller/ProcessDefinitionControllerTest.java
...duler/api/controller/ProcessDefinitionControllerTest.java
+1
-11
escheduler-api/src/test/java/cn/escheduler/api/controller/ProcessInstanceControllerTest.java
...heduler/api/controller/ProcessInstanceControllerTest.java
+7
-27
escheduler-api/src/test/java/cn/escheduler/api/controller/ProjectControllerTest.java
...a/cn/escheduler/api/controller/ProjectControllerTest.java
+1
-18
escheduler-api/src/test/java/cn/escheduler/api/controller/QueueControllerTest.java
...ava/cn/escheduler/api/controller/QueueControllerTest.java
+15
-30
escheduler-api/src/test/java/cn/escheduler/api/controller/ResourcesControllerTest.java
...cn/escheduler/api/controller/ResourcesControllerTest.java
+7
-25
escheduler-api/src/test/java/cn/escheduler/api/controller/SchedulerControllerTest.java
...cn/escheduler/api/controller/SchedulerControllerTest.java
+8
-24
escheduler-api/src/test/java/cn/escheduler/api/controller/TaskInstanceControllerTest.java
...escheduler/api/controller/TaskInstanceControllerTest.java
+5
-23
escheduler-api/src/test/java/cn/escheduler/api/controller/TenantControllerTest.java
...va/cn/escheduler/api/controller/TenantControllerTest.java
+6
-23
escheduler-api/src/test/java/cn/escheduler/api/controller/UsersControllerTest.java
...ava/cn/escheduler/api/controller/UsersControllerTest.java
+5
-22
escheduler-dao/src/test/java/cn/escheduler/dao/mapper/WorkerGroupMapperTest.java
.../java/cn/escheduler/dao/mapper/WorkerGroupMapperTest.java
+0
-2
未找到文件。
escheduler-api/src/main/java/cn/escheduler/api/service/ResourcesService.java
浏览文件 @
7992f530
...
...
@@ -27,6 +27,7 @@ import cn.escheduler.common.utils.HadoopUtils;
import
cn.escheduler.common.utils.PropertyUtils
;
import
cn.escheduler.dao.mapper.*
;
import
cn.escheduler.dao.model.Resource
;
import
cn.escheduler.dao.model.Tenant
;
import
cn.escheduler.dao.model.UdfFunc
;
import
cn.escheduler.dao.model.User
;
import
org.apache.commons.collections.BeanMap
;
...
...
@@ -441,18 +442,23 @@ public class ResourcesService extends BaseService {
putMsg
(
result
,
Status
.
RESOURCE_EXIST
);
}
else
{
// query tenant
String
tenantCode
=
tenantMapper
.
queryById
(
loginUser
.
getTenantId
()).
getTenantCode
();
try
{
String
hdfsFilename
=
getHdfsFileName
(
type
,
tenantCode
,
name
);
if
(
HadoopUtils
.
getInstance
().
exists
(
hdfsFilename
)){
logger
.
error
(
"resource type:{} name:{} has exist in hdfs {}, can't create again."
,
type
,
name
,
hdfsFilename
);
putMsg
(
result
,
Status
.
RESOURCE_FILE_EXIST
,
hdfsFilename
);
Tenant
tenant
=
tenantMapper
.
queryById
(
loginUser
.
getTenantId
());
if
(
tenant
!=
null
){
String
tenantCode
=
tenant
.
getTenantCode
();
try
{
String
hdfsFilename
=
getHdfsFileName
(
type
,
tenantCode
,
name
);
if
(
HadoopUtils
.
getInstance
().
exists
(
hdfsFilename
)){
logger
.
error
(
"resource type:{} name:{} has exist in hdfs {}, can't create again."
,
type
,
name
,
hdfsFilename
);
putMsg
(
result
,
Status
.
RESOURCE_FILE_EXIST
,
hdfsFilename
);
}
}
catch
(
Exception
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
putMsg
(
result
,
Status
.
HDFS_OPERATION_ERROR
);
}
}
catch
(
Exception
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
putMsg
(
result
,
Status
.
HDFS_OPERATION_ERROR
);
}
else
{
putMsg
(
result
,
Status
.
TENANT_NOT_EXIST
);
}
}
...
...
escheduler-api/src/test/java/cn/escheduler/api/controller/ProcessDefinitionControllerTest.java
浏览文件 @
7992f530
...
...
@@ -20,22 +20,13 @@ import cn.escheduler.api.enums.Status;
import
cn.escheduler.api.utils.Result
;
import
cn.escheduler.common.utils.JSONUtils
;
import
org.junit.Assert
;
import
org.junit.Before
;
import
org.junit.Ignore
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.http.MediaType
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
org.springframework.test.web.servlet.MockMvc
;
import
org.springframework.test.web.servlet.MvcResult
;
import
org.springframework.test.web.servlet.setup.MockMvcBuilders
;
import
org.springframework.util.LinkedMultiValueMap
;
import
org.springframework.util.MultiValueMap
;
import
org.springframework.web.context.WebApplicationContext
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
request
.
MockMvcRequestBuilders
.
post
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
result
.
MockMvcResultMatchers
.
content
;
...
...
@@ -44,7 +35,6 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
/**
* process definition controller test
*/
@Ignore
public
class
ProcessDefinitionControllerTest
extends
AbstractControllerTest
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
ProcessDefinitionControllerTest
.
class
);
...
...
@@ -69,7 +59,7 @@ public class ProcessDefinitionControllerTest extends AbstractControllerTest{
.
andReturn
();
Result
result
=
JSONUtils
.
parseObject
(
mvcResult
.
getResponse
().
getContentAsString
(),
Result
.
class
);
Assert
.
assertEquals
(
Status
.
SUCCESS
.
getCode
(),
result
.
getCode
().
intValue
());
Assert
.
assertEquals
(
Status
.
PROJECT_NOT_FOUNT
.
getCode
(),
result
.
getCode
().
intValue
());
logger
.
info
(
mvcResult
.
getResponse
().
getContentAsString
());
}
}
\ No newline at end of file
escheduler-api/src/test/java/cn/escheduler/api/controller/ProcessInstanceControllerTest.java
浏览文件 @
7992f530
...
...
@@ -20,55 +20,35 @@ import cn.escheduler.api.enums.Status;
import
cn.escheduler.api.utils.Result
;
import
cn.escheduler.common.utils.JSONUtils
;
import
org.junit.Assert
;
import
org.junit.Before
;
import
org.junit.Ignore
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.http.MediaType
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
org.springframework.test.web.servlet.MockMvc
;
import
org.springframework.test.web.servlet.MvcResult
;
import
org.springframework.test.web.servlet.setup.MockMvcBuilders
;
import
org.springframework.web.context.WebApplicationContext
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
request
.
MockMvcRequestBuilders
.
get
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
result
.
MockMvcResultMatchers
.
content
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
result
.
MockMvcResultMatchers
.
status
;
@Ignore
@RunWith
(
SpringRunner
.
class
)
@SpringBootTest
public
class
ProcessInstanceControllerTest
{
/**
* process instance controller test
*/
public
class
ProcessInstanceControllerTest
extends
AbstractControllerTest
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
ProcessInstanceControllerTest
.
class
);
private
MockMvc
mockMvc
;
@Autowired
private
WebApplicationContext
webApplicationContext
;
@Before
public
void
setUp
()
{
mockMvc
=
MockMvcBuilders
.
webAppContextSetup
(
webApplicationContext
).
build
();
}
@Test
public
void
queryTaskListByProcessId
()
throws
Exception
{
MvcResult
mvcResult
=
mockMvc
.
perform
(
get
(
"/projects/{projectName}/instance/task-list-by-process-id"
,
"project_test1"
)
.
header
(
"sessionId"
,
"08fae8bf-fe2d-4fc0-8129-23c37fbfac82"
)
.
param
(
"processInstanceId"
,
"
1370
"
))
.
header
(
SESSION_ID
,
sessionId
)
.
param
(
"processInstanceId"
,
"
-1
"
))
.
andExpect
(
status
().
isOk
())
.
andExpect
(
content
().
contentType
(
MediaType
.
APPLICATION_JSON_UTF8
))
.
andReturn
();
Result
result
=
JSONUtils
.
parseObject
(
mvcResult
.
getResponse
().
getContentAsString
(),
Result
.
class
);
Assert
.
assertEquals
(
Status
.
SUCCESS
.
getCode
()
,
result
.
getCode
().
intValue
());
Assert
.
assertEquals
(
Status
.
PROJECT_NOT_FOUNT
,
result
.
getCode
().
intValue
());
logger
.
info
(
mvcResult
.
getResponse
().
getContentAsString
());
}
}
\ No newline at end of file
escheduler-api/src/test/java/cn/escheduler/api/controller/ProjectControllerTest.java
浏览文件 @
7992f530
...
...
@@ -20,22 +20,13 @@ import cn.escheduler.api.enums.Status;
import
cn.escheduler.api.utils.Result
;
import
cn.escheduler.common.utils.JSONUtils
;
import
org.junit.Assert
;
import
org.junit.Before
;
import
org.junit.Ignore
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.http.MediaType
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
org.springframework.test.web.servlet.MockMvc
;
import
org.springframework.test.web.servlet.MvcResult
;
import
org.springframework.test.web.servlet.setup.MockMvcBuilders
;
import
org.springframework.util.LinkedMultiValueMap
;
import
org.springframework.util.MultiValueMap
;
import
org.springframework.web.context.WebApplicationContext
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
request
.
MockMvcRequestBuilders
.
post
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
result
.
MockMvcResultMatchers
.
content
;
...
...
@@ -47,15 +38,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
public
class
ProjectControllerTest
extends
AbstractControllerTest
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
ProcessInstanceControllerTest
.
class
);
private
MockMvc
mockMvc
;
@Autowired
private
WebApplicationContext
webApplicationContext
;
@Before
public
void
setUp
()
{
mockMvc
=
MockMvcBuilders
.
webAppContextSetup
(
webApplicationContext
).
build
();
}
@Test
public
void
createProject
()
throws
Exception
{
...
...
@@ -64,7 +47,7 @@ public class ProjectControllerTest extends AbstractControllerTest{
paramsMap
.
add
(
"desc"
,
"the test project"
);
MvcResult
mvcResult
=
mockMvc
.
perform
(
post
(
"/projects/create"
)
.
header
(
"sessionId"
,
"08fae8bf-fe2d-4fc0-8129-23c37fbfac82"
)
.
header
(
SESSION_ID
,
sessionId
)
.
params
(
paramsMap
))
.
andExpect
(
status
().
isCreated
())
.
andExpect
(
content
().
contentType
(
MediaType
.
APPLICATION_JSON_UTF8
))
...
...
escheduler-api/src/test/java/cn/escheduler/api/controller/QueueControllerTest.java
浏览文件 @
7992f530
...
...
@@ -20,48 +20,31 @@ import cn.escheduler.api.enums.Status;
import
cn.escheduler.api.utils.Result
;
import
cn.escheduler.common.utils.JSONUtils
;
import
org.junit.Assert
;
import
org.junit.Before
;
import
org.junit.Ignore
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.http.MediaType
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
org.springframework.test.web.servlet.MockMvc
;
import
org.springframework.test.web.servlet.MvcResult
;
import
org.springframework.test.web.servlet.setup.MockMvcBuilders
;
import
org.springframework.util.LinkedMultiValueMap
;
import
org.springframework.util.MultiValueMap
;
import
org.springframework.web.context.WebApplicationContext
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
request
.
MockMvcRequestBuilders
.
get
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
request
.
MockMvcRequestBuilders
.
post
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
result
.
MockMvcResultMatchers
.
content
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
result
.
MockMvcResultMatchers
.
status
;
@Ignore
@RunWith
(
SpringRunner
.
class
)
@SpringBootTest
public
class
QueueControllerTest
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
QueueControllerTest
.
class
);
private
MockMvc
mockMvc
;
/**
* queue controller test
*/
public
class
QueueControllerTest
extends
AbstractControllerTest
{
@Autowired
private
WebApplicationContext
webApplicationContext
;
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
QueueControllerTest
.
class
);
@Before
public
void
setUp
()
{
mockMvc
=
MockMvcBuilders
.
webAppContextSetup
(
webApplicationContext
).
build
();
}
@Test
public
void
queryList
()
throws
Exception
{
MvcResult
mvcResult
=
mockMvc
.
perform
(
get
(
"/queue/list"
)
.
header
(
"sessionId"
,
"d199af92-d8e0-4f1b-bacb-5b3414567e5c"
))
.
header
(
SESSION_ID
,
sessionId
))
.
andExpect
(
status
().
isOk
())
.
andExpect
(
content
().
contentType
(
MediaType
.
APPLICATION_JSON_UTF8
))
.
andReturn
();
...
...
@@ -81,7 +64,7 @@ public class QueueControllerTest {
paramsMap
.
add
(
"pageSize"
,
"20"
);
MvcResult
mvcResult
=
mockMvc
.
perform
(
get
(
"/queue/list-paging"
)
.
header
(
"sessionId"
,
"d4541e0d-0349-4f05-9c68-300176cd3c91"
)
.
header
(
SESSION_ID
,
sessionId
)
.
params
(
paramsMap
))
.
andExpect
(
status
().
isOk
())
.
andExpect
(
content
().
contentType
(
MediaType
.
APPLICATION_JSON_UTF8
))
...
...
@@ -95,18 +78,20 @@ public class QueueControllerTest {
public
void
createQueue
()
throws
Exception
{
MultiValueMap
<
String
,
String
>
paramsMap
=
new
LinkedMultiValueMap
<>();
paramsMap
.
add
(
"queue"
,
"ait
111134
"
);
paramsMap
.
add
(
"queueName"
,
"ait
Name1
"
);
paramsMap
.
add
(
"queue"
,
"ait"
);
paramsMap
.
add
(
"queueName"
,
"ait"
);
MvcResult
mvcResult
=
mockMvc
.
perform
(
post
(
"/queue/create"
)
.
header
(
"sessionId"
,
"d4541e0d-0349-4f05-9c68-300176cd3c91"
)
.
header
(
SESSION_ID
,
sessionId
)
.
params
(
paramsMap
))
.
andExpect
(
status
().
isCreated
())
.
andExpect
(
content
().
contentType
(
MediaType
.
APPLICATION_JSON_UTF8
))
.
andReturn
();
Result
result
=
JSONUtils
.
parseObject
(
mvcResult
.
getResponse
().
getContentAsString
(),
Result
.
class
);
//
Assert.assertEquals(Status.SUCCESS.getCode(),result.getCode().intValue());
//
Assert.assertEquals(Status.SUCCESS.getCode(),result.getCode().intValue());
logger
.
info
(
mvcResult
.
getResponse
().
getContentAsString
());
}
@Test
...
...
@@ -118,7 +103,7 @@ public class QueueControllerTest {
paramsMap
.
add
(
"queueName"
,
"aitName"
);
MvcResult
mvcResult
=
mockMvc
.
perform
(
post
(
"/queue/update"
)
.
header
(
"sessionId"
,
"d4541e0d-0349-4f05-9c68-300176cd3c91"
)
.
header
(
SESSION_ID
,
sessionId
)
.
params
(
paramsMap
))
.
andExpect
(
status
().
isCreated
())
.
andExpect
(
content
().
contentType
(
MediaType
.
APPLICATION_JSON_UTF8
))
...
...
@@ -136,7 +121,7 @@ public class QueueControllerTest {
paramsMap
.
add
(
"queueName"
,
"aitName"
);
MvcResult
mvcResult
=
mockMvc
.
perform
(
post
(
"/queue/verify-queue"
)
.
header
(
"sessionId"
,
"d4541e0d-0349-4f05-9c68-300176cd3c91"
)
.
header
(
SESSION_ID
,
sessionId
)
.
params
(
paramsMap
))
.
andExpect
(
status
().
isOk
())
.
andExpect
(
content
().
contentType
(
MediaType
.
APPLICATION_JSON_UTF8
))
...
...
escheduler-api/src/test/java/cn/escheduler/api/controller/ResourcesControllerTest.java
浏览文件 @
7992f530
...
...
@@ -22,47 +22,29 @@ import cn.escheduler.common.enums.ResourceType;
import
cn.escheduler.common.utils.JSONUtils
;
import
com.alibaba.fastjson.JSONObject
;
import
org.junit.Assert
;
import
org.junit.Before
;
import
org.junit.Ignore
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.http.MediaType
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
org.springframework.test.web.servlet.MockMvc
;
import
org.springframework.test.web.servlet.MvcResult
;
import
org.springframework.test.web.servlet.setup.MockMvcBuilders
;
import
org.springframework.util.LinkedMultiValueMap
;
import
org.springframework.util.MultiValueMap
;
import
org.springframework.web.context.WebApplicationContext
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
request
.
MockMvcRequestBuilders
.
get
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
result
.
MockMvcResultMatchers
.
content
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
result
.
MockMvcResultMatchers
.
status
;
@Ignore
@RunWith
(
SpringRunner
.
class
)
@SpringBootTest
public
class
ResourcesControllerTest
{
/**
* resources controller test
*/
public
class
ResourcesControllerTest
extends
AbstractControllerTest
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
ResourcesControllerTest
.
class
);
private
MockMvc
mockMvc
;
@Autowired
private
WebApplicationContext
webApplicationContext
;
@Before
public
void
setUp
()
{
mockMvc
=
MockMvcBuilders
.
webAppContextSetup
(
webApplicationContext
).
build
();
}
@Test
public
void
querytResourceList
()
throws
Exception
{
MvcResult
mvcResult
=
mockMvc
.
perform
(
get
(
"/resources/list"
)
.
header
(
"sessionId"
,
"08fae8bf-fe2d-4fc0-8129-23c37fbfac82"
)
.
header
(
SESSION_ID
,
sessionId
)
.
param
(
"type"
,
ResourceType
.
FILE
.
name
()))
.
andExpect
(
status
().
isOk
())
.
andExpect
(
content
().
contentType
(
MediaType
.
APPLICATION_JSON_UTF8
))
...
...
@@ -84,7 +66,7 @@ public class ResourcesControllerTest {
paramsMap
.
add
(
"type"
,
"FILE"
);
MvcResult
mvcResult
=
mockMvc
.
perform
(
get
(
"/resources/verify-name"
)
.
header
(
"sessionId"
,
"c24ed9d9-1c20-48a0-bd9c-5cfca14a4dcb"
)
.
header
(
SESSION_ID
,
sessionId
)
.
params
(
paramsMap
))
.
andExpect
(
status
().
isOk
())
.
andExpect
(
content
().
contentType
(
MediaType
.
APPLICATION_JSON_UTF8
))
...
...
@@ -92,7 +74,7 @@ public class ResourcesControllerTest {
Result
result
=
JSONUtils
.
parseObject
(
mvcResult
.
getResponse
().
getContentAsString
(),
Result
.
class
);
Assert
.
assertEquals
(
Status
.
SUCCESS
.
getCode
(),
result
.
getCode
().
intValue
());
Assert
.
assertEquals
(
Status
.
TENANT_NOT_EXIST
.
getCode
(),
result
.
getCode
().
intValue
());
logger
.
info
(
mvcResult
.
getResponse
().
getContentAsString
());
}
}
\ No newline at end of file
escheduler-api/src/test/java/cn/escheduler/api/controller/SchedulerControllerTest.java
浏览文件 @
7992f530
...
...
@@ -20,44 +20,26 @@ import cn.escheduler.api.enums.Status;
import
cn.escheduler.api.utils.Result
;
import
cn.escheduler.common.utils.JSONUtils
;
import
org.junit.Assert
;
import
org.junit.Before
;
import
org.junit.Ignore
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.http.MediaType
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
org.springframework.test.web.servlet.MockMvc
;
import
org.springframework.test.web.servlet.MvcResult
;
import
org.springframework.test.web.servlet.setup.MockMvcBuilders
;
import
org.springframework.web.context.WebApplicationContext
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
request
.
MockMvcRequestBuilders
.
post
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
result
.
MockMvcResultMatchers
.
content
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
result
.
MockMvcResultMatchers
.
status
;
@Ignore
@RunWith
(
SpringRunner
.
class
)
@SpringBootTest
public
class
SchedulerControllerTest
{
/**
* scheduler controller test
*/
public
class
SchedulerControllerTest
extends
AbstractControllerTest
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
SchedulerControllerTest
.
class
);
private
MockMvc
mockMvc
;
@Autowired
private
WebApplicationContext
webApplicationContext
;
@Before
public
void
setUp
()
{
mockMvc
=
MockMvcBuilders
.
webAppContextSetup
(
webApplicationContext
).
build
();
}
@Test
public
void
queryScheduleList
()
throws
Exception
{
MvcResult
mvcResult
=
mockMvc
.
perform
(
post
(
"/projects/{projectName}/schedule/list"
,
"project_test1"
)
.
header
(
"sessionId"
,
"08fae8bf-fe2d-4fc0-8129-23c37fbfac82"
))
.
header
(
SESSION_ID
,
sessionId
))
.
andExpect
(
status
().
isOk
())
.
andExpect
(
content
().
contentType
(
MediaType
.
APPLICATION_JSON_UTF8
))
.
andReturn
();
...
...
@@ -66,10 +48,12 @@ public class SchedulerControllerTest {
Assert
.
assertEquals
(
Status
.
SUCCESS
.
getCode
(),
result
.
getCode
().
intValue
());
logger
.
info
(
mvcResult
.
getResponse
().
getContentAsString
());
}
@Test
public
void
previewSchedule
()
throws
Exception
{
MvcResult
mvcResult
=
mockMvc
.
perform
(
post
(
"/projects/{projectName}/schedule/preview"
,
"li_test_1"
)
.
header
(
"sessionId"
,
"c24ed9d9-1c20-48a0-bd9c-5cfca14a4dcb"
)
.
header
(
SESSION_ID
,
sessionId
)
.
param
(
"schedule"
,
"{'startTime':'2019-06-10 00:00:00','endTime':'2019-06-13 00:00:00','crontab':'0 0 3/6 * * ? *'}"
))
.
andExpect
(
status
().
isCreated
())
.
andExpect
(
content
().
contentType
(
MediaType
.
APPLICATION_JSON_UTF8
))
...
...
escheduler-api/src/test/java/cn/escheduler/api/controller/TaskInstanceControllerTest.java
浏览文件 @
7992f530
...
...
@@ -20,42 +20,24 @@ import cn.escheduler.api.enums.Status;
import
cn.escheduler.api.utils.Result
;
import
cn.escheduler.common.utils.JSONUtils
;
import
org.junit.Assert
;
import
org.junit.Before
;
import
org.junit.Ignore
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.http.MediaType
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
org.springframework.test.web.servlet.MockMvc
;
import
org.springframework.test.web.servlet.MvcResult
;
import
org.springframework.test.web.servlet.setup.MockMvcBuilders
;
import
org.springframework.util.LinkedMultiValueMap
;
import
org.springframework.util.MultiValueMap
;
import
org.springframework.web.context.WebApplicationContext
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
request
.
MockMvcRequestBuilders
.
get
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
result
.
MockMvcResultMatchers
.
content
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
result
.
MockMvcResultMatchers
.
status
;
@Ignore
@RunWith
(
SpringRunner
.
class
)
@SpringBootTest
public
class
TaskInstanceControllerTest
{
/**
* task instance controller test
*/
public
class
TaskInstanceControllerTest
extends
AbstractControllerTest
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
SchedulerControllerTest
.
class
);
private
MockMvc
mockMvc
;
@Autowired
private
WebApplicationContext
webApplicationContext
;
@Before
public
void
setUp
()
{
mockMvc
=
MockMvcBuilders
.
webAppContextSetup
(
webApplicationContext
).
build
();
}
@Test
public
void
queryTaskListPaging
()
throws
Exception
{
...
...
@@ -70,7 +52,7 @@ public class TaskInstanceControllerTest {
paramsMap
.
add
(
"pageSize"
,
"20"
);
MvcResult
mvcResult
=
mockMvc
.
perform
(
get
(
"/projects/{projectName}/task-instance/list-paging"
,
"project_test1"
)
.
header
(
"sessionId"
,
"08fae8bf-fe2d-4fc0-8129-23c37fbfac82"
)
.
header
(
SESSION_ID
,
sessionId
)
.
params
(
paramsMap
))
.
andExpect
(
status
().
isOk
())
.
andExpect
(
content
().
contentType
(
MediaType
.
APPLICATION_JSON_UTF8
))
...
...
escheduler-api/src/test/java/cn/escheduler/api/controller/TenantControllerTest.java
浏览文件 @
7992f530
...
...
@@ -20,50 +20,33 @@ import cn.escheduler.api.enums.Status;
import
cn.escheduler.api.utils.Result
;
import
cn.escheduler.common.utils.JSONUtils
;
import
org.junit.Assert
;
import
org.junit.Before
;
import
org.junit.Ignore
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.http.MediaType
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
org.springframework.test.web.servlet.MockMvc
;
import
org.springframework.test.web.servlet.MvcResult
;
import
org.springframework.test.web.servlet.setup.MockMvcBuilders
;
import
org.springframework.web.context.WebApplicationContext
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
request
.
MockMvcRequestBuilders
.
get
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
result
.
MockMvcResultMatchers
.
content
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
result
.
MockMvcResultMatchers
.
status
;
@Ignore
@RunWith
(
SpringRunner
.
class
)
@SpringBootTest
public
class
TenantControllerTest
{
/**
* tenant controller test
*/
public
class
TenantControllerTest
extends
AbstractControllerTest
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
DataAnalysisControllerTest
.
class
);
private
MockMvc
mockMvc
;
@Autowired
private
WebApplicationContext
webApplicationContext
;
@Before
public
void
setUp
()
{
mockMvc
=
MockMvcBuilders
.
webAppContextSetup
(
webApplicationContext
).
build
();
}
@Test
public
void
countTaskState
()
throws
Exception
{
MvcResult
mvcResult
=
mockMvc
.
perform
(
get
(
"/tenant/list"
)
.
header
(
"sessionId"
,
"d199af92-d8e0-4f1b-bacb-5b3414567e5c"
))
.
header
(
SESSION_ID
,
sessionId
))
.
andExpect
(
status
().
isOk
())
.
andExpect
(
content
().
contentType
(
MediaType
.
APPLICATION_JSON_UTF8
))
.
andReturn
();
Result
result
=
JSONUtils
.
parseObject
(
mvcResult
.
getResponse
().
getContentAsString
(),
Result
.
class
);
Assert
.
assertEquals
(
Status
.
SUCCESS
.
getCode
(),
result
.
getCode
().
intValue
());
logger
.
info
(
mvcResult
.
getResponse
().
getContentAsString
());
...
...
escheduler-api/src/test/java/cn/escheduler/api/controller/UsersControllerTest.java
浏览文件 @
7992f530
...
...
@@ -20,45 +20,28 @@ import cn.escheduler.api.enums.Status;
import
cn.escheduler.api.utils.Result
;
import
cn.escheduler.common.utils.JSONUtils
;
import
org.junit.Assert
;
import
org.junit.Before
;
import
org.junit.Ignore
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.http.MediaType
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
org.springframework.test.web.servlet.MockMvc
;
import
org.springframework.test.web.servlet.MvcResult
;
import
org.springframework.test.web.servlet.setup.MockMvcBuilders
;
import
org.springframework.web.context.WebApplicationContext
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
request
.
MockMvcRequestBuilders
.
get
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
result
.
MockMvcResultMatchers
.
content
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
result
.
MockMvcResultMatchers
.
status
;
@Ignore
@RunWith
(
SpringRunner
.
class
)
@SpringBootTest
public
class
UsersControllerTest
{
/**
* users controller test
*/
public
class
UsersControllerTest
extends
AbstractControllerTest
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
QueueControllerTest
.
class
);
private
MockMvc
mockMvc
;
@Autowired
private
WebApplicationContext
webApplicationContext
;
@Before
public
void
setUp
()
{
mockMvc
=
MockMvcBuilders
.
webAppContextSetup
(
webApplicationContext
).
build
();
}
@Test
public
void
queryList
()
throws
Exception
{
MvcResult
mvcResult
=
mockMvc
.
perform
(
get
(
"/users/list"
)
.
header
(
"sessionId"
,
"d199af92-d8e0-4f1b-bacb-5b3414567e5c"
))
.
header
(
SESSION_ID
,
sessionId
))
.
andExpect
(
status
().
isOk
())
.
andExpect
(
content
().
contentType
(
MediaType
.
APPLICATION_JSON_UTF8
))
.
andReturn
();
...
...
escheduler-dao/src/test/java/cn/escheduler/dao/mapper/WorkerGroupMapperTest.java
浏览文件 @
7992f530
...
...
@@ -20,7 +20,6 @@ import cn.escheduler.dao.datasource.ConnectionFactory;
import
cn.escheduler.dao.model.WorkerGroup
;
import
org.junit.Assert
;
import
org.junit.Before
;
import
org.junit.Ignore
;
import
org.junit.Test
;
import
java.util.Date
;
...
...
@@ -29,7 +28,6 @@ import java.util.List;
/**
* worker group mapper test
*/
@Ignore
public
class
WorkerGroupMapperTest
{
WorkerGroupMapper
workerGroupMapper
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录