Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
solo-1
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
solo-1
Commits
1671de36
Unverified
Commit
1671de36
authored
Dec 07, 2018
by
Liang Ding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
✅
增加后台单元测试
parent
27a90527
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
62 additions
and
1 deletion
+62
-1
src/test/java/org/b3log/solo/MockHttpServletResponse.java
src/test/java/org/b3log/solo/MockHttpServletResponse.java
+7
-1
src/test/java/org/b3log/solo/processor/console/AdminConsoleTestCase.java
...rg/b3log/solo/processor/console/AdminConsoleTestCase.java
+55
-0
No files found.
src/test/java/org/b3log/solo/MockHttpServletResponse.java
View file @
1671de36
...
@@ -157,6 +157,12 @@ public class MockHttpServletResponse implements HttpServletResponse {
...
@@ -157,6 +157,12 @@ public class MockHttpServletResponse implements HttpServletResponse {
return
null
;
return
null
;
}
}
private
long
outputBytes
;
public
long
outputBytes
()
{
return
outputBytes
;
}
@Override
@Override
public
ServletOutputStream
getOutputStream
()
{
public
ServletOutputStream
getOutputStream
()
{
return
new
ServletOutputStream
()
{
return
new
ServletOutputStream
()
{
...
@@ -172,7 +178,7 @@ public class MockHttpServletResponse implements HttpServletResponse {
...
@@ -172,7 +178,7 @@ public class MockHttpServletResponse implements HttpServletResponse {
@Override
@Override
public
void
write
(
int
b
)
{
public
void
write
(
int
b
)
{
outputBytes
++;
}
}
};
};
}
}
...
...
src/test/java/org/b3log/solo/processor/console/AdminConsoleTestCase.java
View file @
1671de36
...
@@ -49,6 +49,7 @@ public class AdminConsoleTestCase extends AbstractTestCase {
...
@@ -49,6 +49,7 @@ public class AdminConsoleTestCase extends AbstractTestCase {
*
*
* @throws Exception exception
* @throws Exception exception
*/
*/
@Test
(
dependsOnMethods
=
"init"
)
public
void
showAdminIndex
()
throws
Exception
{
public
void
showAdminIndex
()
throws
Exception
{
final
MockHttpServletRequest
request
=
mockRequest
();
final
MockHttpServletRequest
request
=
mockRequest
();
request
.
setRequestURI
(
"/admin-index.do"
);
request
.
setRequestURI
(
"/admin-index.do"
);
...
@@ -61,4 +62,58 @@ public class AdminConsoleTestCase extends AbstractTestCase {
...
@@ -61,4 +62,58 @@ public class AdminConsoleTestCase extends AbstractTestCase {
Assert
.
assertTrue
(
StringUtils
.
contains
(
content
,
"Admin 的个人博客 - 后台管理"
));
Assert
.
assertTrue
(
StringUtils
.
contains
(
content
,
"Admin 的个人博客 - 后台管理"
));
}
}
/**
* showAdminFunctions.
*
* @throws Exception exception
*/
@Test
(
dependsOnMethods
=
"init"
)
public
void
showAdminFunctions
()
throws
Exception
{
final
MockHttpServletRequest
request
=
mockRequest
();
request
.
setRequestURI
(
"/admin-article.do"
);
mockAdminLogin
(
request
);
final
MockHttpServletResponse
response
=
mockResponse
();
mockDispatcherServletService
(
request
,
response
);
final
String
content
=
response
.
body
();
Assert
.
assertTrue
(
StringUtils
.
contains
(
content
,
"<div class=\"form\">"
));
}
/**
* showAdminPreferenceFunction.
*
* @throws Exception exception
*/
@Test
(
dependsOnMethods
=
"init"
)
public
void
showAdminPreferenceFunction
()
throws
Exception
{
final
MockHttpServletRequest
request
=
mockRequest
();
request
.
setRequestURI
(
"/admin-preference.do"
);
mockAdminLogin
(
request
);
final
MockHttpServletResponse
response
=
mockResponse
();
mockDispatcherServletService
(
request
,
response
);
final
String
content
=
response
.
body
();
Assert
.
assertTrue
(
StringUtils
.
contains
(
content
,
"<div id=\"tabPreference\" class=\"sub-tabs fn-clear\">"
));
}
/**
* exportSQL.
*
* @throws Exception exception
*/
@Test
(
dependsOnMethods
=
"init"
)
public
void
exportSQL
()
throws
Exception
{
final
MockHttpServletRequest
request
=
mockRequest
();
request
.
setRequestURI
(
"/console/export/sql"
);
mockAdminLogin
(
request
);
final
MockHttpServletResponse
response
=
mockResponse
();
mockDispatcherServletService
(
request
,
response
);
final
long
outputBytes
=
response
.
outputBytes
();
Assert
.
assertTrue
(
0
<
outputBytes
);
}
}
}
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