Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
熊鹏飞
/
xxljob220
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
9f77e62f
authored
Dec 14, 2017
by
listening
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
在不改变xxl-job源码的情况下,添加对xxl-job的扩展
parent
d47658b9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
99 additions
and
0 deletions
xxl-job-admin/src/test/java/com/xxl/job/admin/controller/AbstractSpringMvcTest.java
xxl-job-admin/src/test/java/com/xxl/job/admin/controller/IndexControllerTest.java
xxl-job-admin/src/test/java/com/xxl/job/admin/controller/JobInfoControllerTest.java
xxl-job-admin/src/test/java/com/xxl/job/admin/controller/AbstractSpringMvcTest.java
0 → 100644
View file @
9f77e62f
package
com
.
xxl
.
job
.
admin
.
controller
;
import
org.junit.Before
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.test.context.ContextConfiguration
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
org.springframework.test.context.web.WebAppConfiguration
;
import
org.springframework.test.web.servlet.MockMvc
;
import
org.springframework.test.web.servlet.setup.MockMvcBuilders
;
import
org.springframework.web.context.WebApplicationContext
;
@WebAppConfiguration
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@ContextConfiguration
(
locations
=
{
"classpath*:spring/*.xml"
})
public
class
AbstractSpringMvcTest
{
@Autowired
private
WebApplicationContext
applicationContext
;
protected
MockMvc
mockMvc
;
@Before
public
void
setup
()
{
this
.
mockMvc
=
MockMvcBuilders
.
webAppContextSetup
(
this
.
applicationContext
).
build
();
}
}
xxl-job-admin/src/test/java/com/xxl/job/admin/controller/IndexControllerTest.java
0 → 100644
View file @
9f77e62f
package
com
.
xxl
.
job
.
admin
.
controller
;
import
org.junit.Test
;
import
org.springframework.http.MediaType
;
import
org.springframework.test.web.servlet.MvcResult
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
request
.
MockMvcRequestBuilders
.*;
public
class
IndexControllerTest
extends
AbstractSpringMvcTest
{
@Test
public
void
testLogin
()
throws
Exception
{
MvcResult
ret
=
mockMvc
.
perform
(
post
(
"/login"
)
.
contentType
(
MediaType
.
APPLICATION_FORM_URLENCODED
)
.
param
(
"userName"
,
"admin"
)
.
param
(
"password"
,
"123456"
)
).
andReturn
();
System
.
out
.
println
(
ret
.
getResponse
().
getContentAsString
());
}
}
xxl-job-admin/src/test/java/com/xxl/job/admin/controller/JobInfoControllerTest.java
0 → 100644
View file @
9f77e62f
package
com
.
xxl
.
job
.
admin
.
controller
;
import
com.xxl.job.admin.core.model.XxlJobInfo
;
import
org.codehaus.jackson.map.ObjectMapper
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.springframework.http.MediaType
;
import
org.springframework.test.web.servlet.MvcResult
;
import
javax.servlet.http.Cookie
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
request
.
MockMvcRequestBuilders
.*;
public
class
JobInfoControllerTest
extends
AbstractSpringMvcTest
{
Cookie
cookie
;
@Before
public
void
login
()
throws
Exception
{
MvcResult
ret
=
mockMvc
.
perform
(
post
(
"/login"
)
.
contentType
(
MediaType
.
APPLICATION_FORM_URLENCODED
)
.
param
(
"userName"
,
"admin"
)
.
param
(
"password"
,
"123456"
)
).
andReturn
();
cookie
=
ret
.
getResponse
().
getCookie
(
"LOGIN_IDENTITY"
);
}
@Test
public
void
testAdd
()
throws
Exception
{
XxlJobInfo
jobInfo
=
new
XxlJobInfo
();
jobInfo
.
setJobGroup
(
1
);
jobInfo
.
setJobDesc
(
"autoEnquiryStatisPerWeek"
);
jobInfo
.
setExecutorRouteStrategy
(
"FIRST"
);
jobInfo
.
setJobCron
(
"0 0 1 ? * MON"
);
jobInfo
.
setGlueType
(
"BEAN"
);
jobInfo
.
setExecutorHandler
(
"AutoEnquriy"
);
jobInfo
.
setExecutorBlockStrategy
(
"SERIAL_EXECUTION"
);
jobInfo
.
setExecutorFailStrategy
(
"FAIL_ALARM"
);
jobInfo
.
setAuthor
(
"listening"
);
ObjectMapper
mapper
=
new
ObjectMapper
();
String
jobInfoStr
=
mapper
.
writeValueAsString
(
jobInfo
);
MvcResult
ret
=
mockMvc
.
perform
(
post
(
"/jobinfo/add"
)
.
contentType
(
MediaType
.
APPLICATION_FORM_URLENCODED
)
.
content
(
jobInfoStr
)
.
cookie
(
cookie
)
).
andReturn
();
System
.
out
.
println
(
ret
.
getResponse
().
getContentAsString
());
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment