Commit 1671de36 authored by Liang Ding's avatar Liang Ding

增加后台单元测试

parent 27a90527
......@@ -157,6 +157,12 @@ public class MockHttpServletResponse implements HttpServletResponse {
return null;
}
private long outputBytes;
public long outputBytes() {
return outputBytes;
}
@Override
public ServletOutputStream getOutputStream() {
return new ServletOutputStream() {
......@@ -172,7 +178,7 @@ public class MockHttpServletResponse implements HttpServletResponse {
@Override
public void write(int b) {
outputBytes++;
}
};
}
......
......@@ -49,6 +49,7 @@ public class AdminConsoleTestCase extends AbstractTestCase {
*
* @throws Exception exception
*/
@Test(dependsOnMethods = "init")
public void showAdminIndex() throws Exception {
final MockHttpServletRequest request = mockRequest();
request.setRequestURI("/admin-index.do");
......@@ -61,4 +62,58 @@ public class AdminConsoleTestCase extends AbstractTestCase {
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);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment