Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
guns-vip
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
chenjunxiong
guns-vip
Commits
9d7a005b
Commit
9d7a005b
authored
May 21, 2017
by
fsn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
测试完善
parent
5b1cbf3a
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
56 additions
and
10 deletions
+56
-10
src/main/java/com/stylefeng/guns/modular/system/controller/BlackboardController.java
+4
-8
src/main/resources/application.yml
+2
-2
src/test/java/com/stylefeng/guns/base/BaseTest.java
+22
-0
src/test/java/com/stylefeng/guns/system/BlackBoardTest.java
+28
-0
No files found.
src/main/java/com/stylefeng/guns/modular/system/controller/BlackboardController.java
View file @
9d7a005b
package
com
.
stylefeng
.
guns
.
modular
.
system
.
controller
;
package
com
.
stylefeng
.
guns
.
modular
.
system
.
controller
;
import
com.stylefeng.guns.common.controller.BaseController
;
import
com.stylefeng.guns.common.controller.BaseController
;
import
com.stylefeng.guns.modular.system.dao.NoticeDao
;
import
com.stylefeng.guns.common.persistence.dao.NoticeMapper
;
import
com.stylefeng.guns.common.persistence.dao.NoticeMapper
;
import
com.stylefeng.guns.common.persistence.dao.UserMapper
;
import
com.stylefeng.guns.common.persistence.dao.UserMapper
;
import
com.stylefeng.guns.modular.system.dao.NoticeDao
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.Model
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
com.baomidou.mybatisplus.mapper.EntityWrapper
;
import
com.stylefeng.guns.common.persistence.model.User
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -37,11 +35,9 @@ public class BlackboardController extends BaseController {
...
@@ -37,11 +35,9 @@ public class BlackboardController extends BaseController {
* 跳转到黑板
* 跳转到黑板
*/
*/
@RequestMapping
(
""
)
@RequestMapping
(
""
)
public
String
blackboard
()
{
public
String
blackboard
(
Model
model
)
{
List
<
Map
<
String
,
Object
>>
notices
=
noticeDao
.
list
(
null
);
List
<
Map
<
String
,
Object
>>
notices
=
noticeDao
.
list
(
null
);
super
.
setAttr
(
"noticeList"
,
notices
);
model
.
addAttribute
(
"noticeList"
,
notices
);
super
.
setAttr
(
"userCount"
,
userMapper
.
selectCount
(
new
EntityWrapper
<
User
>().
notLike
(
"status"
,
"5"
)));
super
.
setAttr
(
"systemCount"
,
super
.
getSystemInvokCount
());
return
"/blackboard.html"
;
return
"/blackboard.html"
;
}
}
}
}
src/main/resources/application.yml
View file @
9d7a005b
...
@@ -37,8 +37,8 @@ spring:
...
@@ -37,8 +37,8 @@ spring:
profiles
:
produce
profiles
:
produce
datasource
:
datasource
:
url
:
jdbc:mysql://127.0.0.1:3306/guns?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull
url
:
jdbc:mysql://127.0.0.1:3306/guns?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull
username
:
root
root
username
:
root
password
:
root
root
password
:
root
logging
:
logging
:
level
:
warn
level
:
warn
...
...
src/test/java/com/stylefeng/guns/base/BaseTest.java
View file @
9d7a005b
package
com
.
stylefeng
.
guns
.
base
;
package
com
.
stylefeng
.
guns
.
base
;
import
com.baomidou.mybatisplus.mapper.SqlRunner
;
import
com.stylefeng.guns.GunsApplication
;
import
com.stylefeng.guns.GunsApplication
;
import
org.junit.Before
;
import
org.junit.runner.RunWith
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
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
;
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@SpringBootTest
(
classes
=
GunsApplication
.
class
)
@SpringBootTest
(
classes
=
GunsApplication
.
class
)
@WebAppConfiguration
public
class
BaseTest
{
public
class
BaseTest
{
@Autowired
WebApplicationContext
webApplicationContext
;
protected
MockMvc
mockMvc
;
@Before
public
void
setupMockMvc
(){
mockMvc
=
MockMvcBuilders
.
webAppContextSetup
(
webApplicationContext
).
build
();
}
@Before
public
void
initDatabase
(){
SqlRunner
.
db
().
update
(
""
);
}
}
}
src/test/java/com/stylefeng/guns/system/BlackBoardTest.java
0 → 100644
View file @
9d7a005b
package
com
.
stylefeng
.
guns
.
system
;
import
com.stylefeng.guns.base.BaseTest
;
import
org.junit.Test
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
request
.
MockMvcRequestBuilders
.
get
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
result
.
MockMvcResultMatchers
.
model
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
result
.
MockMvcResultMatchers
.
status
;
/**
* 首页通知展示测试
*
* @author fengshuonan
* @date 2017-05-21 15:02
*/
public
class
BlackBoardTest
extends
BaseTest
{
@Test
public
void
blackBoardTest
()
{
try
{
super
.
mockMvc
.
perform
(
get
(
"/blackboard"
))
.
andExpect
(
status
().
isOk
())
.
andExpect
(
model
().
attributeExists
(
"noticeList"
));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
}
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