Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
后端镜像
java镜像
Springside4
提交
acac42d4
S
Springside4
项目概览
后端镜像
/
java镜像
/
Springside4
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
Springside4
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
acac42d4
编写于
7月 23, 2012
作者:
C
Calvin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#62 补充功能测试
上级
b2aca92b
变更
12
显示空白变更内容
内联
并排
Showing
12 changed file
with
166 addition
and
38 deletion
+166
-38
examples/mini-web/pom.xml
examples/mini-web/pom.xml
+15
-0
examples/mini-web/src/main/java/org/springside/examples/miniweb/rest/TaskRestController.java
.../springside/examples/miniweb/rest/TaskRestController.java
+7
-0
examples/mini-web/src/main/java/org/springside/examples/miniweb/web/TaskController.java
...a/org/springside/examples/miniweb/web/TaskController.java
+3
-3
examples/mini-web/src/main/java/org/springside/examples/miniweb/web/TaskDetailController.java
...springside/examples/miniweb/web/TaskDetailController.java
+1
-1
examples/mini-web/src/main/webapp/WEB-INF/views/taskForm.jsp
examples/mini-web/src/main/webapp/WEB-INF/views/taskForm.jsp
+1
-3
examples/mini-web/src/main/webapp/WEB-INF/views/taskList.jsp
examples/mini-web/src/main/webapp/WEB-INF/views/taskList.jsp
+3
-6
examples/mini-web/src/test/functional/org/springside/examples/miniweb/functional/TaskManageIT.java
.../springside/examples/miniweb/functional/TaskManageIT.java
+0
-22
examples/mini-web/src/test/functional/org/springside/examples/miniweb/functional/gui/TaskGuiIT.java
...springside/examples/miniweb/functional/gui/TaskGuiIT.java
+68
-0
examples/mini-web/src/test/functional/org/springside/examples/miniweb/functional/rest/TaskRestIT.java
...ringside/examples/miniweb/functional/rest/TaskRestIT.java
+60
-0
examples/mini-web/src/test/java/org/springside/examples/miniweb/data/TaskData.java
...t/java/org/springside/examples/miniweb/data/TaskData.java
+6
-3
examples/mini-web/src/test/resources/META-INF/services/javax.ws.rs.ext.MessageBodyReader
...urces/META-INF/services/javax.ws.rs.ext.MessageBodyReader
+1
-0
examples/mini-web/src/test/resources/META-INF/services/javax.ws.rs.ext.MessageBodyWriter
...urces/META-INF/services/javax.ws.rs.ext.MessageBodyWriter
+1
-0
未找到文件。
examples/mini-web/pom.xml
浏览文件 @
acac42d4
...
...
@@ -26,6 +26,7 @@
<junit.version>
4.10
</junit.version>
<mockito.version>
1.9.0
</mockito.version>
<selenium.version>
2.24.1
</selenium.version>
<jersey.version>
1.13
</jersey.version>
<!-- Plugin的属性定义 -->
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
...
...
@@ -303,6 +304,20 @@
<scope>
test
</scope>
</dependency>
<!-- restful client -->
<dependency>
<groupId>
com.sun.jersey
</groupId>
<artifactId>
jersey-client
</artifactId>
<version>
${jersey.version}
</version>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
com.fasterxml.jackson.jaxrs
</groupId>
<artifactId>
jackson-jaxrs-json-provider
</artifactId>
<version>
${jackson.version}
</version>
<scope>
test
</scope>
</dependency>
<!-- jetty -->
<dependency>
<groupId>
org.eclipse.jetty.aggregate
</groupId>
...
...
examples/mini-web/src/main/java/org/springside/examples/miniweb/rest/TaskRestController.java
浏览文件 @
acac42d4
...
...
@@ -5,6 +5,7 @@ import java.util.List;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.Model
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.ResponseBody
;
...
...
@@ -23,4 +24,10 @@ public class TaskRestController {
List
<
Task
>
list
(
Model
model
)
{
return
taskManager
.
getAllTask
();
}
@RequestMapping
(
value
=
"/{id}"
,
method
=
RequestMethod
.
GET
,
produces
=
"application/json"
)
public
@ResponseBody
Task
get
(
@PathVariable
(
"id"
)
Long
id
)
{
return
taskManager
.
getTask
(
id
);
}
}
examples/mini-web/src/main/java/org/springside/examples/miniweb/web/TaskController.java
浏览文件 @
acac42d4
...
...
@@ -20,8 +20,9 @@ import org.springside.examples.miniweb.service.TaskManager;
* Update action : POST /task/save/{id}
* Delete action : POST /task/delete/{id}
*
*
@author calvin
*
其中Update page/action在TaskDetailController,其余在本Controller。
*
* @author calvin
*/
@Controller
@RequestMapping
(
value
=
"/task"
)
...
...
@@ -46,7 +47,7 @@ public class TaskController {
@RequestMapping
(
value
=
"save"
)
public
String
save
(
Task
task
,
RedirectAttributes
redirectAttributes
)
{
taskManager
.
saveTask
(
task
);
redirectAttributes
.
addFlashAttribute
(
"message"
,
"创建任务
"
+
task
.
getTitle
()
+
"
成功"
);
redirectAttributes
.
addFlashAttribute
(
"message"
,
"创建任务成功"
);
return
"redirect:/task/"
;
}
...
...
@@ -56,5 +57,4 @@ public class TaskController {
redirectAttributes
.
addFlashAttribute
(
"message"
,
"删除任务成功"
);
return
"redirect:/task/"
;
}
}
examples/mini-web/src/main/java/org/springside/examples/miniweb/web/TaskDetailController.java
浏览文件 @
acac42d4
...
...
@@ -31,7 +31,7 @@ public class TaskDetailController {
@RequestMapping
(
value
=
"save/{id}"
)
public
String
save
(
@ModelAttribute
(
"task"
)
Task
task
,
RedirectAttributes
redirectAttributes
)
{
taskManager
.
saveTask
(
task
);
redirectAttributes
.
addFlashAttribute
(
"message"
,
"
修改任务"
+
task
.
getTitle
()
+
"
成功"
);
redirectAttributes
.
addFlashAttribute
(
"message"
,
"
更新任务
成功"
);
return
"redirect:/task/"
;
}
...
...
examples/mini-web/src/main/webapp/WEB-INF/views/taskForm.jsp
浏览文件 @
acac42d4
...
...
@@ -21,12 +21,10 @@
<input
type=
"hidden"
name=
"id"
value=
"${task.id}"
/>
<fieldset>
<legend><small>
管理任务
</small></legend>
<div
id=
"messageBox"
class=
"alert alert-error"
style=
"display:none"
>
输入有误,请先更正。
</div>
<div
class=
"control-group"
>
<label
for=
"title"
class=
"control-label"
>
任务名称:
</label>
<div
class=
"controls"
>
<input
type=
"text"
id=
"title"
name=
"title"
size=
"50"
value=
"${task.title}"
class=
"required"
/>
<input
type=
"text"
id=
"t
ask.t
itle"
name=
"title"
size=
"50"
value=
"${task.title}"
class=
"required"
/>
</div>
</div>
<div
class=
"form-actions"
>
...
...
examples/mini-web/src/main/webapp/WEB-INF/views/taskList.jsp
浏览文件 @
acac42d4
...
...
@@ -12,15 +12,12 @@
</c:if>
<table
id=
"contentTable"
class=
"table table-striped table-bordered table-condensed"
>
<thead><tr><th>
任务
编号
</th><th>
任务标题
</th><th>
操作
</th></tr></thead>
<thead><tr><th>
任务
标题
</th><th>
管理
</th></tr></thead>
<tbody>
<c:forEach
items=
"
${
tasks
}
"
var=
"task"
>
<tr>
<td>
${task.id}
</td>
<td>
${task.title}
</td>
<td>
<a
href=
"update/${task.id}"
id=
"update-${task.id}-btn"
>
修改
</a>
<a
href=
"delete/${task.id}"
>
删除
</a>
</td>
<td><a
href=
"update/${task.id}"
>
${task.title}
</a></td>
<td><a
href=
"delete/${task.id}"
>
删除
</a></td>
</tr>
</c:forEach>
</tbody>
...
...
examples/mini-web/src/test/functional/org/springside/examples/miniweb/functional/TaskManageIT.java
已删除
100644 → 0
浏览文件 @
b2aca92b
package
org.springside.examples.miniweb.functional
;
import
org.junit.Test
;
import
org.junit.experimental.categories.Category
;
import
org.springside.modules.test.category.Smoke
;
/**
* 任务管理的功能测试, 测试页面JavaScript及主要用户故事流程.
*
* @author calvin
*/
public
class
TaskManageIT
extends
BaseFunctionalTestCase
{
/**
* 查看任务列表.
*/
@Test
@Category
(
Smoke
.
class
)
public
void
viewTaskList
()
{
s
.
open
(
"/task/"
);
}
}
examples/mini-web/src/test/functional/org/springside/examples/miniweb/functional/gui/TaskGuiIT.java
0 → 100644
浏览文件 @
acac42d4
package
org.springside.examples.miniweb.functional.gui
;
import
static
org
.
junit
.
Assert
.*;
import
org.junit.Test
;
import
org.junit.experimental.categories.Category
;
import
org.openqa.selenium.By
;
import
org.openqa.selenium.WebElement
;
import
org.springside.examples.miniweb.data.TaskData
;
import
org.springside.examples.miniweb.entity.Task
;
import
org.springside.examples.miniweb.functional.BaseFunctionalTestCase
;
import
org.springside.modules.test.category.Smoke
;
/**
* 任务管理的功能测试, 测试页面JavaScript及主要用户故事流程.
*
* @author calvin
*/
public
class
TaskGuiIT
extends
BaseFunctionalTestCase
{
/**
* 浏览用户列表.
*/
@Test
@Category
(
Smoke
.
class
)
public
void
viewTaskList
()
{
s
.
open
(
"/task/"
);
WebElement
table
=
s
.
findElement
(
By
.
id
(
"contentTable"
));
assertEquals
(
"Study PlayFramework 2.0"
,
s
.
getTable
(
table
,
0
,
0
));
}
/**
* 创建并更新任务.
*/
@Test
@Category
(
Smoke
.
class
)
public
void
createAndUpdateTask
()
{
s
.
open
(
"/task/"
);
//create
s
.
click
(
By
.
linkText
(
"创建任务"
));
Task
task
=
TaskData
.
randomTask
();
s
.
type
(
By
.
id
(
"task.title"
),
task
.
getTitle
());
s
.
click
(
By
.
id
(
"submit"
));
assertTrue
(
s
.
isTextPresent
(
"创建任务成功"
));
//update
s
.
click
(
By
.
linkText
(
task
.
getTitle
()));
assertEquals
(
task
.
getTitle
(),
s
.
getValue
(
By
.
id
(
"task.title"
)));
String
newTitle
=
TaskData
.
randomTitle
();
s
.
type
(
By
.
id
(
"task.title"
),
newTitle
);
s
.
click
(
By
.
id
(
"submit"
));
assertTrue
(
s
.
isTextPresent
(
"更新任务成功"
));
}
@Test
public
void
inputInValidateValue
()
{
s
.
open
(
"/task/"
);
s
.
click
(
By
.
linkText
(
"创建任务"
));
s
.
click
(
By
.
id
(
"submit"
));
assertEquals
(
"必选字段"
,
s
.
getText
(
By
.
xpath
(
"//fieldset/div/div/label"
)));
}
}
examples/mini-web/src/test/functional/org/springside/examples/miniweb/functional/rest/TaskRestIT.java
0 → 100644
浏览文件 @
acac42d4
package
org.springside.examples.miniweb.functional.rest
;
import
static
org
.
junit
.
Assert
.*;
import
java.util.List
;
import
javax.ws.rs.core.MediaType
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.experimental.categories.Category
;
import
org.springside.examples.miniweb.entity.Task
;
import
org.springside.examples.miniweb.functional.BaseFunctionalTestCase
;
import
org.springside.modules.test.category.Smoke
;
import
com.sun.jersey.api.client.Client
;
import
com.sun.jersey.api.client.GenericType
;
import
com.sun.jersey.api.client.WebResource
;
/**
* 任务管理的功能测试, 测试页面JavaScript及主要用户故事流程.
*
* @author calvin
*/
public
class
TaskRestIT
extends
BaseFunctionalTestCase
{
private
WebResource
client
;
private
final
GenericType
<
List
<
Task
>>
taskListType
=
new
GenericType
<
List
<
Task
>>()
{
};
@Before
public
void
setupClient
()
{
client
=
Client
.
create
().
resource
(
baseUrl
);
}
/**
* 查看任务列表.
*/
@Test
@Category
(
Smoke
.
class
)
public
void
listTasks
()
{
WebResource
wr
=
client
.
path
(
"/api/task"
);
List
<
Task
>
tasks
=
wr
.
get
(
taskListType
);
assertEquals
(
5
,
tasks
.
size
());
assertEquals
(
"Study PlayFramework 2.0"
,
tasks
.
get
(
0
).
getTitle
());
}
/**
* 获取任务.
*/
@Test
@Category
(
Smoke
.
class
)
public
void
getTask
()
{
Long
id
=
1L
;
Task
task
=
client
.
path
(
"/api/task/"
+
id
).
accept
(
MediaType
.
APPLICATION_JSON
).
get
(
Task
.
class
);
assertEquals
(
"Study PlayFramework 2.0"
,
task
.
getTitle
());
}
}
examples/mini-web/src/test/java/org/springside/examples/miniweb/data/TaskData.java
浏览文件 @
acac42d4
...
...
@@ -10,11 +10,14 @@ import org.springside.modules.test.data.RandomData;
*/
public
class
TaskData
{
public
static
Task
getR
andomTask
()
{
public
static
Task
r
andomTask
()
{
Task
task
=
new
Task
();
task
.
setTitle
(
RandomData
.
randomName
(
"Task"
));
task
.
setTitle
(
randomTitle
());
return
task
;
}
public
static
String
randomTitle
()
{
return
RandomData
.
randomName
(
"Task"
);
}
}
examples/mini-web/src/test/resources/META-INF/services/javax.ws.rs.ext.MessageBodyReader
0 → 100644
浏览文件 @
acac42d4
com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider
\ No newline at end of file
examples/mini-web/src/test/resources/META-INF/services/javax.ws.rs.ext.MessageBodyWriter
0 → 100644
浏览文件 @
acac42d4
com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录