Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
后端镜像
java镜像
Springside4
提交
ba8abfe2
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,发现更多精彩内容 >>
提交
ba8abfe2
编写于
8月 24, 2012
作者:
C
Calvin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#79 取消DBUnit的使用. DBUnit作用不是非常大,因此取消使用,简化技术。
上级
02e5c8e4
变更
25
显示空白变更内容
内联
并排
Showing
25 changed file
with
67 addition
and
262 deletion
+67
-262
examples/quickstart/pom.xml
examples/quickstart/pom.xml
+5
-23
examples/quickstart/src/main/resources/applicationContext.xml
...ples/quickstart/src/main/resources/applicationContext.xml
+1
-6
examples/quickstart/src/main/webapp/WEB-INF/views/login.jsp
examples/quickstart/src/main/webapp/WEB-INF/views/login.jsp
+1
-1
examples/quickstart/src/test/functional/org/springside/examples/quickstart/functional/BaseFunctionalTestCase.java
...xamples/quickstart/functional/BaseFunctionalTestCase.java
+1
-1
examples/quickstart/src/test/functional/org/springside/examples/quickstart/functional/BaseSeleniumTestCase.java
.../examples/quickstart/functional/BaseSeleniumTestCase.java
+1
-1
examples/quickstart/src/test/functional/org/springside/examples/quickstart/functional/gui/SecurityFT.java
...ngside/examples/quickstart/functional/gui/SecurityFT.java
+1
-1
examples/quickstart/src/test/functional/org/springside/examples/quickstart/functional/gui/TaskGuiFT.java
...ingside/examples/quickstart/functional/gui/TaskGuiFT.java
+3
-3
examples/quickstart/src/test/resources/data/cleanup-data.sql
examples/quickstart/src/test/resources/data/cleanup-data.sql
+2
-0
examples/quickstart/src/test/resources/data/import-data.sql
examples/quickstart/src/test/resources/data/import-data.sql
+6
-0
examples/quickstart/src/test/resources/data/sample-data.xml
examples/quickstart/src/test/resources/data/sample-data.xml
+0
-9
examples/showcase/pom.xml
examples/showcase/pom.xml
+4
-19
examples/showcase/src/main/java/org/springside/examples/showcase/modules/cache/guava/GuavaCacheDemo.java
...examples/showcase/modules/cache/guava/GuavaCacheDemo.java
+1
-1
examples/showcase/src/main/resources/applicationContext.xml
examples/showcase/src/main/resources/applicationContext.xml
+1
-6
examples/showcase/src/main/webapp/WEB-INF/views/login.jsp
examples/showcase/src/main/webapp/WEB-INF/views/login.jsp
+1
-1
examples/showcase/src/test/functional/org/springside/examples/showcase/functional/BaseFunctionalTestCase.java
.../examples/showcase/functional/BaseFunctionalTestCase.java
+1
-1
examples/showcase/src/test/functional/org/springside/examples/showcase/functional/account/UserManagerFT.java
...e/examples/showcase/functional/account/UserManagerFT.java
+3
-3
examples/showcase/src/test/java/org/springside/examples/showcase/repository/jpa/JpaMappingTest.java
...side/examples/showcase/repository/jpa/JpaMappingTest.java
+2
-1
examples/showcase/src/test/resources/data/cleanup-data.sql
examples/showcase/src/test/resources/data/cleanup-data.sql
+4
-0
examples/showcase/src/test/resources/data/import-data.sql
examples/showcase/src/test/resources/data/import-data.sql
+19
-0
examples/showcase/src/test/resources/data/sample-data.xml
examples/showcase/src/test/resources/data/sample-data.xml
+0
-19
modules/parent/pom.xml
modules/parent/pom.xml
+0
-8
modules/test/pom.xml
modules/test/pom.xml
+0
-7
modules/test/src/main/java/org/springside/modules/test/data/DataFixtures.java
...n/java/org/springside/modules/test/data/DataFixtures.java
+10
-92
modules/test/src/main/java/org/springside/modules/test/data/DataInitializer.java
...ava/org/springside/modules/test/data/DataInitializer.java
+0
-30
modules/test/src/test/java/org/springside/modules/test/data/DataFixturesTest.java
...va/org/springside/modules/test/data/DataFixturesTest.java
+0
-29
未找到文件。
examples/quickstart/pom.xml
浏览文件 @
ba8abfe2
...
@@ -364,13 +364,6 @@
...
@@ -364,13 +364,6 @@
<scope>
test
</scope>
<scope>
test
</scope>
</dependency>
</dependency>
<dependency>
<groupId>
org.dbunit
</groupId>
<artifactId>
dbunit
</artifactId>
<version>
2.4.8
</version>
<scope>
test
</scope>
</dependency>
<!-- jetty -->
<!-- jetty -->
<dependency>
<dependency>
<groupId>
org.eclipse.jetty.aggregate
</groupId>
<groupId>
org.eclipse.jetty.aggregate
</groupId>
...
@@ -648,23 +641,12 @@
...
@@ -648,23 +641,12 @@
<property
file=
"src/main/resources/application.properties"
/>
<property
file=
"src/main/resources/application.properties"
/>
<property
name=
"sql.type"
value=
"h2"
/>
<property
name=
"sql.type"
value=
"h2"
/>
<property
name=
"dbunit.datatype"
value=
"org.dbunit.ext.h2.H2DataTypeFactory"
/>
<taskdef
name=
"dbunit"
classname=
"org.dbunit.ant.DbUnitTask"
classpathref=
"maven.test.classpath"
/>
<sql
driver=
"${jdbc.driver}"
url=
"${jdbc.url}"
userid=
"${jdbc.username}"
password=
"${jdbc.password}"
onerror=
"continue"
>
<sql
driver=
"${jdbc.driver}"
url=
"${jdbc.url}"
userid=
"${jdbc.username}"
password=
"${jdbc.password}"
src=
"src/main/resources/sql/${sql.type}/schema.sql"
onerror=
"continue"
>
<classpath
refid=
"maven.test.classpath"
/>
<classpath
refid=
"maven.test.classpath"
/>
<transaction
src=
"src/main/resources/sql/${sql.type}/schema.sql"
/>
<transaction
src=
"src/test/resources/data/import-data.sql"
/>
</sql>
</sql>
<dbunit
driver=
"${jdbc.driver}"
url=
"${jdbc.url}"
userid=
"${jdbc.username}"
password=
"${jdbc.password}"
>
<dbconfig>
<property
name=
"datatypeFactory"
value=
"${dbunit.datatype}"
/>
</dbconfig>
<classpath
refid=
"maven.test.classpath"
/>
<operation
type=
"CLEAN_INSERT"
src=
"src/test/resources/data/sample-data.xml"
format=
"flat"
transaction=
"true"
/>
</dbunit>
</target>
</target>
</configuration>
</configuration>
</plugin>
</plugin>
...
...
examples/quickstart/src/main/resources/applicationContext.xml
浏览文件 @
ba8abfe2
...
@@ -127,12 +127,7 @@
...
@@ -127,12 +127,7 @@
<!-- 嵌入式内存中数据库 -->
<!-- 嵌入式内存中数据库 -->
<jdbc:embedded-database
id=
"dataSource"
type=
"H2"
>
<jdbc:embedded-database
id=
"dataSource"
type=
"H2"
>
<jdbc:script
location=
"classpath:sql/h2/schema.sql"
/>
<jdbc:script
location=
"classpath:sql/h2/schema.sql"
/>
<jdbc:script
location=
"classpath:data/import-data.sql"
/>
</jdbc:embedded-database>
</jdbc:embedded-database>
<!-- 初始化默认数据 -->
<bean
class=
"org.springside.modules.test.data.DataInitializer"
lazy-init=
"false"
>
<property
name=
"dataSource"
ref=
"dataSource"
/>
<property
name=
"dataFile"
value=
"/data/sample-data.xml"
/>
</bean>
</beans>
</beans>
</beans>
</beans>
\ No newline at end of file
examples/quickstart/src/main/webapp/WEB-INF/views/login.jsp
浏览文件 @
ba8abfe2
...
@@ -49,7 +49,7 @@
...
@@ -49,7 +49,7 @@
<div
class=
"control-group"
>
<div
class=
"control-group"
>
<div
class=
"controls"
>
<div
class=
"controls"
>
<label
class=
"checkbox inline"
for=
"rememberMe"
>
<input
type=
"checkbox"
id=
"rememberMe"
name=
"rememberMe"
/>
记住我
</label>
<label
class=
"checkbox inline"
for=
"rememberMe"
>
<input
type=
"checkbox"
id=
"rememberMe"
name=
"rememberMe"
/>
记住我
</label>
<input
id=
"submit"
class=
"btn"
type=
"submit"
value=
"登录"
/>
<input
id=
"submit
_btn
"
class=
"btn"
type=
"submit"
value=
"登录"
/>
<p
class=
"help-block"
>
(登录帐号:
<b>
user/user
</b>
)
</p>
<p
class=
"help-block"
>
(登录帐号:
<b>
user/user
</b>
)
</p>
</div>
</div>
</div>
</div>
...
...
examples/quickstart/src/test/functional/org/springside/examples/quickstart/functional/BaseFunctionalTestCase.java
浏览文件 @
ba8abfe2
...
@@ -87,6 +87,6 @@ public class BaseFunctionalTestCase {
...
@@ -87,6 +87,6 @@ public class BaseFunctionalTestCase {
* 载入测试数据.
* 载入测试数据.
*/
*/
protected
static
void
reloadSampleData
()
throws
Exception
{
protected
static
void
reloadSampleData
()
throws
Exception
{
DataFixtures
.
reloadData
(
dataSource
,
"/data/sample-data.xm
l"
);
DataFixtures
.
executeScript
(
dataSource
,
"classpath:data/cleanup-data.sql"
,
"classpath:data/import-data.sq
l"
);
}
}
}
}
\ No newline at end of file
examples/quickstart/src/test/functional/org/springside/examples/quickstart/functional/BaseSeleniumTestCase.java
浏览文件 @
ba8abfe2
...
@@ -50,7 +50,7 @@ public class BaseSeleniumTestCase extends BaseFunctionalTestCase {
...
@@ -50,7 +50,7 @@ public class BaseSeleniumTestCase extends BaseFunctionalTestCase {
s
.
type
(
By
.
name
(
"username"
),
"user"
);
s
.
type
(
By
.
name
(
"username"
),
"user"
);
s
.
type
(
By
.
name
(
"password"
),
"user"
);
s
.
type
(
By
.
name
(
"password"
),
"user"
);
s
.
check
(
By
.
name
(
"rememberMe"
));
s
.
check
(
By
.
name
(
"rememberMe"
));
s
.
click
(
By
.
id
(
"submit"
));
s
.
click
(
By
.
id
(
"submit
_btn
"
));
assertEquals
(
"QuickStart示例:任务管理"
,
s
.
getTitle
());
assertEquals
(
"QuickStart示例:任务管理"
,
s
.
getTitle
());
}
}
}
}
...
...
examples/quickstart/src/test/functional/org/springside/examples/quickstart/functional/gui/SecurityFT.java
浏览文件 @
ba8abfe2
...
@@ -36,7 +36,7 @@ public class SecurityFT extends BaseSeleniumTestCase {
...
@@ -36,7 +36,7 @@ public class SecurityFT extends BaseSeleniumTestCase {
s
.
type
(
By
.
name
(
"username"
),
"wrongUser"
);
s
.
type
(
By
.
name
(
"username"
),
"wrongUser"
);
s
.
type
(
By
.
name
(
"password"
),
"WrongPassword"
);
s
.
type
(
By
.
name
(
"password"
),
"WrongPassword"
);
s
.
check
(
By
.
name
(
"rememberMe"
));
s
.
check
(
By
.
name
(
"rememberMe"
));
s
.
click
(
By
.
id
(
"submit"
));
s
.
click
(
By
.
id
(
"submit
_btn
"
));
assertEquals
(
"QuickStart示例:登录页"
,
s
.
getTitle
());
assertEquals
(
"QuickStart示例:登录页"
,
s
.
getTitle
());
assertTrue
(
s
.
isTextPresent
(
"登录失败,请重试."
));
assertTrue
(
s
.
isTextPresent
(
"登录失败,请重试."
));
...
...
examples/quickstart/src/test/functional/org/springside/examples/quickstart/functional/gui/TaskGuiFT.java
浏览文件 @
ba8abfe2
...
@@ -42,7 +42,7 @@ public class TaskGuiFT extends BaseSeleniumTestCase {
...
@@ -42,7 +42,7 @@ public class TaskGuiFT extends BaseSeleniumTestCase {
Task
task
=
TaskData
.
randomTask
();
Task
task
=
TaskData
.
randomTask
();
s
.
type
(
By
.
id
(
"task.title"
),
task
.
getTitle
());
s
.
type
(
By
.
id
(
"task.title"
),
task
.
getTitle
());
s
.
click
(
By
.
id
(
"submit"
));
s
.
click
(
By
.
id
(
"submit
_btn
"
));
assertTrue
(
s
.
isTextPresent
(
"创建任务成功"
));
assertTrue
(
s
.
isTextPresent
(
"创建任务成功"
));
...
@@ -52,7 +52,7 @@ public class TaskGuiFT extends BaseSeleniumTestCase {
...
@@ -52,7 +52,7 @@ public class TaskGuiFT extends BaseSeleniumTestCase {
String
newTitle
=
TaskData
.
randomTitle
();
String
newTitle
=
TaskData
.
randomTitle
();
s
.
type
(
By
.
id
(
"task.title"
),
newTitle
);
s
.
type
(
By
.
id
(
"task.title"
),
newTitle
);
s
.
click
(
By
.
id
(
"submit"
));
s
.
click
(
By
.
id
(
"submit
_btn
"
));
assertTrue
(
s
.
isTextPresent
(
"更新任务成功"
));
assertTrue
(
s
.
isTextPresent
(
"更新任务成功"
));
}
}
...
@@ -60,7 +60,7 @@ public class TaskGuiFT extends BaseSeleniumTestCase {
...
@@ -60,7 +60,7 @@ public class TaskGuiFT extends BaseSeleniumTestCase {
public
void
inputInValidateValue
()
{
public
void
inputInValidateValue
()
{
s
.
open
(
"/task/"
);
s
.
open
(
"/task/"
);
s
.
click
(
By
.
linkText
(
"创建任务"
));
s
.
click
(
By
.
linkText
(
"创建任务"
));
s
.
click
(
By
.
id
(
"submit"
));
s
.
click
(
By
.
id
(
"submit
_btn
"
));
assertEquals
(
"必选字段"
,
s
.
getText
(
By
.
xpath
(
"//fieldset/div/div/label"
)));
assertEquals
(
"必选字段"
,
s
.
getText
(
By
.
xpath
(
"//fieldset/div/div/label"
)));
}
}
...
...
examples/quickstart/src/test/resources/data/cleanup-data.sql
0 → 100644
浏览文件 @
ba8abfe2
delete
from
SS_TASK
;
delete
from
SS_USER
;
\ No newline at end of file
examples/quickstart/src/test/resources/data/import-data.sql
0 → 100644
浏览文件 @
ba8abfe2
insert
into
SS_TASK
(
ID
,
TITLE
,
USER_ID
)
values
(
1
,
'Study PlayFramework 2.0'
,
1
);
insert
into
SS_TASK
(
ID
,
TITLE
,
USER_ID
)
values
(
2
,
'Study Grails 2.0'
,
1
);
insert
into
SS_TASK
(
ID
,
TITLE
,
USER_ID
)
values
(
3
,
'Try SpringFuse'
,
1
);
insert
into
SS_TASK
(
ID
,
TITLE
,
USER_ID
)
values
(
4
,
'Try Spring Roo'
,
1
);
insert
into
SS_TASK
(
ID
,
TITLE
,
USER_ID
)
values
(
5
,
'Release SprignSide 4.0'
,
1
);
insert
into
SS_USER
(
ID
,
LOGIN_NAME
,
NAME
,
PASSWORD
,
SALT
)
values
(
1
,
'user'
,
'Calvin'
,
'2488aa0c31c624687bd9928e0a5d29e7d1ed520b'
,
'6d65d24122c30500'
);
\ No newline at end of file
examples/quickstart/src/test/resources/data/sample-data.xml
已删除
100644 → 0
浏览文件 @
02e5c8e4
<?xml version='1.0' encoding='UTF-8'?>
<dataset>
<SS_TASK
ID=
"1"
TITLE=
"Study PlayFramework 2.0"
USER_ID=
"1"
/>
<SS_TASK
ID=
"2"
TITLE=
"Study Grails 2.0"
USER_ID=
"1"
/>
<SS_TASK
ID=
"3"
TITLE=
"Try SpringFuse"
USER_ID=
"1"
/>
<SS_TASK
ID=
"4"
TITLE=
"Try Spring Roo"
USER_ID=
"1"
/>
<SS_TASK
ID=
"5"
TITLE=
"Release SprignSide 4.0"
USER_ID=
"1"
/>
<SS_USER
ID=
"1"
LOGIN_NAME=
"user"
NAME=
"Calvin"
PASSWORD=
"2488aa0c31c624687bd9928e0a5d29e7d1ed520b"
SALT=
"6d65d24122c30500"
/>
</dataset>
examples/showcase/pom.xml
浏览文件 @
ba8abfe2
...
@@ -348,11 +348,6 @@
...
@@ -348,11 +348,6 @@
<artifactId>
selenium-remote-driver
</artifactId>
<artifactId>
selenium-remote-driver
</artifactId>
</dependency>
</dependency>
<dependency>
<groupId>
org.dbunit
</groupId>
<artifactId>
dbunit
</artifactId>
</dependency>
<!-- jetty for functional test and executable war -->
<!-- jetty for functional test and executable war -->
<dependency>
<dependency>
<groupId>
org.eclipse.jetty.aggregate
</groupId>
<groupId>
org.eclipse.jetty.aggregate
</groupId>
...
@@ -505,26 +500,16 @@
...
@@ -505,26 +500,16 @@
<property
file=
"src/main/resources/application.properties"
/>
<property
file=
"src/main/resources/application.properties"
/>
<property
name=
"sql.type"
value=
"h2"
/>
<property
name=
"sql.type"
value=
"h2"
/>
<property
name=
"dbunit.datatype"
value=
"org.dbunit.ext.h2.H2DataTypeFactory"
/>
<taskdef
name=
"dbunit"
classname=
"org.dbunit.ant.DbUnitTask"
classpathref=
"maven.test.classpath"
/>
<sql
driver=
"${jdbc.driver}"
url=
"${jdbc.url}"
userid=
"${jdbc.username}"
password=
"${jdbc.password}"
onerror=
"continue"
>
<sql
driver=
"${jdbc.driver}"
url=
"${jdbc.url}"
userid=
"${jdbc.username}"
password=
"${jdbc.password}"
src=
"src/main/resources/sql/${sql.type}/schema.sql"
onerror=
"continue"
>
<classpath
refid=
"maven.test.classpath"
/>
<classpath
refid=
"maven.test.classpath"
/>
<transaction
src=
"src/main/resources/sql/${sql.type}/schema.sql"
/>
<transaction
src=
"src/test/resources/data/import-data.sql"
/>
</sql>
</sql>
<sql
driver=
"${quartz.jdbc.driver}"
url=
"${quartz.jdbc.url}"
userid=
"${quartz.jdbc.username}"
password=
"${quartz.jdbc.password}"
<sql
driver=
"${quartz.jdbc.driver}"
url=
"${quartz.jdbc.url}"
userid=
"${quartz.jdbc.username}"
password=
"${quartz.jdbc.password}"
src=
"src/main/resources/sql/${sql.type}/quartz.sql"
onerror=
"continue"
>
src=
"src/main/resources/sql/${sql.type}/quartz.sql"
onerror=
"continue"
>
<classpath
refid=
"maven.test.classpath"
/>
<classpath
refid=
"maven.test.classpath"
/>
</sql>
</sql>
<dbunit
driver=
"${jdbc.driver}"
url=
"${jdbc.url}"
userid=
"${jdbc.username}"
password=
"${jdbc.password}"
>
<dbconfig>
<property
name=
"datatypeFactory"
value=
"${dbunit.datatype}"
/>
</dbconfig>
<classpath
refid=
"maven.test.classpath"
/>
<operation
type=
"CLEAN_INSERT"
src=
"src/test/resources/data/sample-data.xml"
format=
"flat"
transaction=
"true"
/>
</dbunit>
</target>
</target>
</configuration>
</configuration>
</plugin>
</plugin>
...
...
examples/showcase/src/main/java/org/springside/examples/showcase/modules/cache/guava/GuavaCacheDemo.java
浏览文件 @
ba8abfe2
...
@@ -47,7 +47,7 @@ public class GuavaCacheDemo extends SpringTransactionalTestCase {
...
@@ -47,7 +47,7 @@ public class GuavaCacheDemo extends SpringTransactionalTestCase {
});
});
//初始化数据
//初始化数据
DataFixtures
.
reloadData
(
dataSource
,
"/data/sample-data.xm
l"
);
DataFixtures
.
executeScript
(
dataSource
,
"classpath:data/cleanup-data.sql"
,
"classpath:data/import-data.sq
l"
);
//插入appender用于assert。
//插入appender用于assert。
Log4jMockAppender
appender
=
new
Log4jMockAppender
();
Log4jMockAppender
appender
=
new
Log4jMockAppender
();
...
...
examples/showcase/src/main/resources/applicationContext.xml
浏览文件 @
ba8abfe2
...
@@ -136,17 +136,12 @@
...
@@ -136,17 +136,12 @@
<!-- 嵌入式内存中数据库 -->
<!-- 嵌入式内存中数据库 -->
<jdbc:embedded-database
id=
"dataSource"
type=
"H2"
>
<jdbc:embedded-database
id=
"dataSource"
type=
"H2"
>
<jdbc:script
location=
"classpath:sql/h2/schema.sql"
/>
<jdbc:script
location=
"classpath:sql/h2/schema.sql"
/>
<jdbc:script
location=
"classpath:data/import-data.sql"
/>
</jdbc:embedded-database>
</jdbc:embedded-database>
<jdbc:embedded-database
id=
"quartzDataSource"
type=
"H2"
>
<jdbc:embedded-database
id=
"quartzDataSource"
type=
"H2"
>
<jdbc:script
location=
"classpath:sql/h2/quartz.sql"
/>
<jdbc:script
location=
"classpath:sql/h2/quartz.sql"
/>
</jdbc:embedded-database>
</jdbc:embedded-database>
<!-- 初始化默认数据 -->
<bean
class=
"org.springside.modules.test.data.DataInitializer"
lazy-init=
"false"
>
<property
name=
"dataSource"
ref=
"dataSource"
/>
<property
name=
"dataFile"
value=
"/data/sample-data.xml"
/>
</bean>
</beans>
</beans>
<!-- functional test环境 -->
<!-- functional test环境 -->
...
...
examples/showcase/src/main/webapp/WEB-INF/views/login.jsp
浏览文件 @
ba8abfe2
...
@@ -61,7 +61,7 @@
...
@@ -61,7 +61,7 @@
<div
class=
"control-group"
>
<div
class=
"control-group"
>
<div
class=
"controls"
>
<div
class=
"controls"
>
<label
class=
"checkbox inline"
for=
"rememberMe"
>
<input
type=
"checkbox"
id=
"rememberMe"
name=
"rememberMe"
/>
记住我
</label>
<label
class=
"checkbox inline"
for=
"rememberMe"
>
<input
type=
"checkbox"
id=
"rememberMe"
name=
"rememberMe"
/>
记住我
</label>
<input
id=
"submit"
class=
"btn"
type=
"submit"
value=
"登录"
/>
<input
id=
"submit
_btn
"
class=
"btn"
type=
"submit"
value=
"登录"
/>
<p
class=
"help-block"
>
(管理员
<b>
admin/admin
</b>
, 普通用户
<b>
user/user
</b>
)
</p>
<p
class=
"help-block"
>
(管理员
<b>
admin/admin
</b>
, 普通用户
<b>
user/user
</b>
)
</p>
</div>
</div>
</div>
</div>
...
...
examples/showcase/src/test/functional/org/springside/examples/showcase/functional/BaseFunctionalTestCase.java
浏览文件 @
ba8abfe2
...
@@ -80,7 +80,7 @@ public class BaseFunctionalTestCase {
...
@@ -80,7 +80,7 @@ public class BaseFunctionalTestCase {
* 载入默认数据.
* 载入默认数据.
*/
*/
protected
static
void
reloadSampleData
()
throws
Exception
{
protected
static
void
reloadSampleData
()
throws
Exception
{
DataFixtures
.
reloadData
(
dataSource
,
"/data/sample-data.xm
l"
);
DataFixtures
.
executeScript
(
dataSource
,
"classpath:data/cleanup-data.sql"
,
"classpath:data/import-data.sq
l"
);
}
}
}
}
examples/showcase/src/test/functional/org/springside/examples/showcase/functional/account/UserManagerFT.java
浏览文件 @
ba8abfe2
...
@@ -36,7 +36,7 @@ public class UserManagerFT extends BaseSeleniumTestCase {
...
@@ -36,7 +36,7 @@ public class UserManagerFT extends BaseSeleniumTestCase {
//点击提交按钮
//点击提交按钮
s
.
type
(
By
.
name
(
"name"
),
"user_foo"
);
s
.
type
(
By
.
name
(
"name"
),
"user_foo"
);
s
.
getSelect
(
By
.
name
(
"status"
)).
selectByValue
(
"disabled"
);
s
.
getSelect
(
By
.
name
(
"status"
)).
selectByValue
(
"disabled"
);
s
.
click
(
By
.
id
(
"submit"
));
s
.
click
(
By
.
id
(
"submit
_btn
"
));
//重新进入用户修改页面, 检查最后修改者
//重新进入用户修改页面, 检查最后修改者
s
.
click
(
By
.
id
(
"editLink-user"
));
s
.
click
(
By
.
id
(
"editLink-user"
));
...
@@ -46,7 +46,7 @@ public class UserManagerFT extends BaseSeleniumTestCase {
...
@@ -46,7 +46,7 @@ public class UserManagerFT extends BaseSeleniumTestCase {
//恢复原有值
//恢复原有值
s
.
type
(
By
.
name
(
"name"
),
"user"
);
s
.
type
(
By
.
name
(
"name"
),
"user"
);
s
.
getSelect
(
By
.
name
(
"status"
)).
selectByValue
(
"enabled"
);
s
.
getSelect
(
By
.
name
(
"status"
)).
selectByValue
(
"enabled"
);
s
.
click
(
By
.
id
(
"submit"
));
s
.
click
(
By
.
id
(
"submit
_btn
"
));
}
}
private
void
loginAsAdminIfNecessary
()
{
private
void
loginAsAdminIfNecessary
()
{
...
@@ -54,7 +54,7 @@ public class UserManagerFT extends BaseSeleniumTestCase {
...
@@ -54,7 +54,7 @@ public class UserManagerFT extends BaseSeleniumTestCase {
if
(
"Showcase示例:登录页"
.
equals
(
s
.
getTitle
()))
{
if
(
"Showcase示例:登录页"
.
equals
(
s
.
getTitle
()))
{
s
.
type
(
By
.
name
(
"username"
),
"admin"
);
s
.
type
(
By
.
name
(
"username"
),
"admin"
);
s
.
type
(
By
.
name
(
"password"
),
"admin"
);
s
.
type
(
By
.
name
(
"password"
),
"admin"
);
s
.
click
(
By
.
id
(
"submit"
));
s
.
click
(
By
.
id
(
"submit
_btn
"
));
}
}
}
}
}
}
examples/showcase/src/test/java/org/springside/examples/showcase/repository/jpa/JpaMappingTest.java
浏览文件 @
ba8abfe2
...
@@ -27,7 +27,8 @@ public class JpaMappingTest extends SpringTransactionalTestCase {
...
@@ -27,7 +27,8 @@ public class JpaMappingTest extends SpringTransactionalTestCase {
@Test
@Test
public
void
allClassMapping
()
throws
Exception
{
public
void
allClassMapping
()
throws
Exception
{
DataFixtures
.
reloadData
(
dataSource
,
"/data/sample-data.xml"
);
DataFixtures
.
executeScript
(
dataSource
,
"classpath:data/cleanup-data.sql"
,
"classpath:data/import-data.sql"
);
Metamodel
model
=
em
.
getEntityManagerFactory
().
getMetamodel
();
Metamodel
model
=
em
.
getEntityManagerFactory
().
getMetamodel
();
for
(
EntityType
entityType
:
model
.
getEntities
())
{
for
(
EntityType
entityType
:
model
.
getEntities
())
{
String
entityName
=
entityType
.
getName
();
String
entityName
=
entityType
.
getName
();
...
...
examples/showcase/src/test/resources/data/cleanup-data.sql
0 → 100644
浏览文件 @
ba8abfe2
delete
from
SS_TEAM
;
delete
from
SS_USER_ROLE
;
delete
from
SS_ROLE
;
delete
from
SS_USER
;
examples/showcase/src/test/resources/data/import-data.sql
0 → 100644
浏览文件 @
ba8abfe2
insert
into
SS_USER
(
ID
,
LOGIN_NAME
,
NAME
,
EMAIL
,
PASSWORD
,
SALT
,
STATUS
,
TEAM_ID
)
values
(
1
,
'admin'
,
'Admin'
,
'admin@springside.org.cn'
,
'691b14d79bf0fa2215f155235df5e670b64394cc'
,
'7efbd59d9741d34f'
,
'enabled'
,
1
);
insert
into
SS_USER
(
ID
,
LOGIN_NAME
,
NAME
,
EMAIL
,
PASSWORD
,
SALT
,
STATUS
,
TEAM_ID
)
values
(
2
,
'user'
,
'Calvin'
,
'user@springside.org.cn'
,
'2488aa0c31c624687bd9928e0a5d29e7d1ed520b'
,
'6d65d24122c30500'
,
'enabled'
,
1
);
insert
into
SS_USER
(
ID
,
LOGIN_NAME
,
NAME
,
EMAIL
,
PASSWORD
,
SALT
,
STATUS
,
TEAM_ID
)
values
(
3
,
'user2'
,
'Jack'
,
'jack@springside.org.cn'
,
'2488aa0c31c624687bd9928e0a5d29e7d1ed520b'
,
'6d65d24122c30500'
,
'enabled'
,
1
);
insert
into
SS_USER
(
ID
,
LOGIN_NAME
,
NAME
,
EMAIL
,
PASSWORD
,
SALT
,
STATUS
,
TEAM_ID
)
values
(
4
,
'user3'
,
'Kate'
,
'kate@springside.org.cn'
,
'2488aa0c31c624687bd9928e0a5d29e7d1ed520b'
,
'6d65d24122c30500'
,
'enabled'
,
1
);
insert
into
SS_USER
(
ID
,
LOGIN_NAME
,
NAME
,
EMAIL
,
PASSWORD
,
SALT
,
STATUS
,
TEAM_ID
)
values
(
5
,
'user4'
,
'Sawyer'
,
'sawyer@springside.org.cn'
,
'2488aa0c31c624687bd9928e0a5d29e7d1ed520b'
,
'6d65d24122c30500'
,
'enabled'
,
1
);
insert
into
SS_USER
(
ID
,
LOGIN_NAME
,
NAME
,
EMAIL
,
PASSWORD
,
SALT
,
STATUS
,
TEAM_ID
)
values
(
6
,
'user5'
,
'Ben'
,
'ben@springside.org.cn'
,
'2488aa0c31c624687bd9928e0a5d29e7d1ed520b'
,
'6d65d24122c30500'
,
'enabled'
,
1
);
insert
into
SS_ROLE
(
ID
,
NAME
,
PERMISSIONS
)
values
(
1
,
'Admin'
,
'user:view,user:edit'
);
insert
into
SS_ROLE
(
ID
,
NAME
,
PERMISSIONS
)
values
(
2
,
'User'
,
'user:view'
);
insert
into
SS_USER_ROLE
(
USER_ID
,
ROLE_ID
)
values
(
1
,
1
);
insert
into
SS_USER_ROLE
(
USER_ID
,
ROLE_ID
)
values
(
1
,
2
);
insert
into
SS_USER_ROLE
(
USER_ID
,
ROLE_ID
)
values
(
2
,
2
);
insert
into
SS_USER_ROLE
(
USER_ID
,
ROLE_ID
)
values
(
3
,
2
);
insert
into
SS_USER_ROLE
(
USER_ID
,
ROLE_ID
)
values
(
4
,
2
);
insert
into
SS_USER_ROLE
(
USER_ID
,
ROLE_ID
)
values
(
5
,
2
);
insert
into
SS_USER_ROLE
(
USER_ID
,
ROLE_ID
)
values
(
6
,
2
);
insert
into
SS_TEAM
(
ID
,
NAME
,
MASTER_ID
)
values
(
1
,
'Dolphin'
,
1
);
\ No newline at end of file
examples/showcase/src/test/resources/data/sample-data.xml
已删除
100644 → 0
浏览文件 @
02e5c8e4
<?xml version='1.0' encoding='UTF-8'?>
<dataset>
<SS_USER
ID=
"1"
EMAIL=
"admin@springside.org.cn"
LOGIN_NAME=
"admin"
NAME=
"Admin"
PASSWORD=
"691b14d79bf0fa2215f155235df5e670b64394cc"
SALT=
"7efbd59d9741d34f"
STATUS=
"enabled"
TEAM_ID=
"1"
/>
<SS_USER
ID=
"2"
EMAIL=
"user@springside.org.cn"
LOGIN_NAME=
"user"
NAME=
"Calvin"
PASSWORD=
"2488aa0c31c624687bd9928e0a5d29e7d1ed520b"
SALT=
"6d65d24122c30500"
STATUS=
"enabled"
TEAM_ID=
"1"
/>
<SS_USER
ID=
"3"
EMAIL=
"jack@springside.org.cn"
LOGIN_NAME=
"user2"
NAME=
"Jack"
PASSWORD=
"2488aa0c31c624687bd9928e0a5d29e7d1ed520b"
SALT=
"6d65d24122c30500"
STATUS=
"enabled"
TEAM_ID=
"1"
/>
<SS_USER
ID=
"4"
EMAIL=
"kate@springside.org.cn"
LOGIN_NAME=
"user3"
NAME=
"Kate"
PASSWORD=
"2488aa0c31c624687bd9928e0a5d29e7d1ed520b"
SALT=
"6d65d24122c30500"
STATUS=
"enabled"
TEAM_ID=
"1"
/>
<SS_USER
ID=
"5"
EMAIL=
"sawyer@springside.org.cn"
LOGIN_NAME=
"user4"
NAME=
"Sawyer"
PASSWORD=
"2488aa0c31c624687bd9928e0a5d29e7d1ed520b"
SALT=
"6d65d24122c30500"
STATUS=
"enabled"
TEAM_ID=
"1"
/>
<SS_USER
ID=
"6"
EMAIL=
"ben@springside.org.cn"
LOGIN_NAME=
"user5"
NAME=
"Ben"
PASSWORD=
"2488aa0c31c624687bd9928e0a5d29e7d1ed520b"
SALT=
"6d65d24122c30500"
STATUS=
"enabled"
TEAM_ID=
"1"
/>
<SS_ROLE
ID=
"1"
NAME=
"Admin"
PERMISSIONS=
"user:view,user:edit"
/>
<SS_ROLE
ID=
"2"
NAME=
"User"
PERMISSIONS=
"user:view"
/>
<SS_USER_ROLE
USER_ID=
"1"
ROLE_ID=
"1"
/>
<SS_USER_ROLE
USER_ID=
"1"
ROLE_ID=
"2"
/>
<SS_USER_ROLE
USER_ID=
"2"
ROLE_ID=
"2"
/>
<SS_USER_ROLE
USER_ID=
"3"
ROLE_ID=
"2"
/>
<SS_USER_ROLE
USER_ID=
"4"
ROLE_ID=
"2"
/>
<SS_USER_ROLE
USER_ID=
"5"
ROLE_ID=
"2"
/>
<SS_USER_ROLE
USER_ID=
"6"
ROLE_ID=
"2"
/>
<SS_TEAM
ID=
"1"
NAME=
"Dolphin"
MASTER_ID=
"1"
/>
</dataset>
modules/parent/pom.xml
浏览文件 @
ba8abfe2
...
@@ -691,14 +691,6 @@
...
@@ -691,14 +691,6 @@
</exclusions>
</exclusions>
</dependency>
</dependency>
<!-- dbunit -->
<dependency>
<groupId>
org.dbunit
</groupId>
<artifactId>
dbunit
</artifactId>
<version>
2.4.8
</version>
<scope>
test
</scope>
</dependency>
<!-- jetty -->
<!-- jetty -->
<dependency>
<dependency>
<groupId>
org.eclipse.jetty.aggregate
</groupId>
<groupId>
org.eclipse.jetty.aggregate
</groupId>
...
...
modules/test/pom.xml
浏览文件 @
ba8abfe2
...
@@ -120,13 +120,6 @@
...
@@ -120,13 +120,6 @@
<scope>
compile
</scope>
<scope>
compile
</scope>
<optional>
true
</optional>
<optional>
true
</optional>
</dependency>
</dependency>
<dependency>
<groupId>
org.dbunit
</groupId>
<artifactId>
dbunit
</artifactId>
<scope>
compile
</scope>
<optional>
true
</optional>
</dependency>
<!-- TEST MODULE end -->
<!-- TEST MODULE end -->
<!-- TEST begin -->
<!-- TEST begin -->
...
...
modules/test/src/main/java/org/springside/modules/test/data/DataFixtures.java
浏览文件 @
ba8abfe2
/**
* Copyright (c) 2005-2012 springside.org.cn
*
* Licensed under the Apache License, Version 2.0 (the "License");
*/
package
org.springside.modules.test.data
;
package
org.springside.modules.test.data
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.sql.Connection
;
import
java.sql.SQLException
;
import
javax.sql.DataSource
;
import
javax.sql.DataSource
;
import
org.apache.commons.lang3.StringUtils
;
import
org.dbunit.DatabaseUnitException
;
import
org.dbunit.database.DatabaseConnection
;
import
org.dbunit.database.IDatabaseConnection
;
import
org.dbunit.dataset.IDataSet
;
import
org.dbunit.dataset.xml.FlatXmlDataSetBuilder
;
import
org.dbunit.ext.h2.H2Connection
;
import
org.dbunit.ext.mysql.MySqlConnection
;
import
org.dbunit.ext.oracle.OracleConnection
;
import
org.dbunit.operation.DatabaseOperation
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.core.io.DefaultResourceLoader
;
import
org.springframework.core.io.DefaultResourceLoader
;
import
org.springframework.core.io.Resource
;
import
org.springframework.core.io.ResourceLoader
;
import
org.springframework.core.io.ResourceLoader
;
import
org.springframework.core.io.support.EncodedResource
;
import
org.springframework.dao.DataAccessException
;
import
org.springframework.jdbc.core.simple.SimpleJdbcTemplate
;
import
org.springframework.test.jdbc.SimpleJdbcTestUtils
;
/**
* 基于DBUnit初始化数据到数据库的工具类.
*/
public
class
DataFixtures
{
public
class
DataFixtures
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
DataFixtures
.
class
);
private
static
ResourceLoader
resourceLoader
=
new
DefaultResourceLoader
();
private
static
ResourceLoader
resourceLoader
=
new
DefaultResourceLoader
();
/**
public
static
void
executeScript
(
DataSource
dataSource
,
String
...
sqlResourcePaths
)
throws
DataAccessException
{
* 先删除数据库中所有表的数据, 再插入XML文件中的数据到数据库.
SimpleJdbcTemplate
simpleJdbcTemplate
=
new
SimpleJdbcTemplate
(
dataSource
);
*
* @param xmlFilePaths 符合Spring Resource路径格式的文件路径列表.
*/
public
static
void
reloadData
(
DataSource
dataSource
,
String
...
xmlFilePaths
)
throws
Exception
{
execute
(
DatabaseOperation
.
CLEAN_INSERT
,
dataSource
,
xmlFilePaths
);
}
/**
* 插入XML文件中的数据到数据库.
*
* @param xmlFilePaths 符合Spring Resource路径格式的文件路径列表.
*/
public
static
void
loadData
(
DataSource
dataSource
,
String
...
xmlFilePaths
)
throws
Exception
{
execute
(
DatabaseOperation
.
INSERT
,
dataSource
,
xmlFilePaths
);
}
/**
* 在数据库中删除XML文件中涉及的表的数据.
*
* @param xmlFilePaths 符合Spring Resource路径格式的文件路径列表.
*/
public
static
void
deleteData
(
DataSource
dataSource
,
String
...
xmlFilePaths
)
throws
Exception
{
execute
(
DatabaseOperation
.
DELETE_ALL
,
dataSource
,
xmlFilePaths
);
}
/**
* 对XML文件中的数据在数据库中执行Operation.
*
* @param xmlFilePaths 符合Spring Resource路径格式的文件列表.
*/
private
static
void
execute
(
DatabaseOperation
operation
,
DataSource
dataSource
,
String
...
xmlFilePaths
)
throws
DatabaseUnitException
,
SQLException
{
IDatabaseConnection
connection
=
getConnection
(
dataSource
);
try
{
for
(
String
xmlPath
:
xmlFilePaths
)
{
try
{
InputStream
input
=
resourceLoader
.
getResource
(
xmlPath
).
getInputStream
();
IDataSet
dataSet
=
new
FlatXmlDataSetBuilder
().
setColumnSensing
(
true
).
build
(
input
);
operation
.
execute
(
connection
,
dataSet
);
}
catch
(
IOException
e
)
{
logger
.
warn
(
xmlPath
+
" file not found"
,
e
);
}
}
}
finally
{
if
(
connection
!=
null
)
{
connection
.
close
();
}
}
}
/**
for
(
String
sqlResourcePath
:
sqlResourcePaths
)
{
* 从DataSource中取得新的Connection(不会参与原有事务),并根据url转换为相应数据库的Connection.
Resource
resource
=
resourceLoader
.
getResource
(
sqlResourcePath
);
*/
SimpleJdbcTestUtils
.
executeSqlScript
(
simpleJdbcTemplate
,
new
EncodedResource
(
resource
,
null
),
true
);
protected
static
IDatabaseConnection
getConnection
(
DataSource
dataSource
)
throws
DatabaseUnitException
,
SQLException
{
Connection
connection
=
dataSource
.
getConnection
();
String
jdbcUrl
=
connection
.
getMetaData
().
getURL
();
if
(
StringUtils
.
contains
(
jdbcUrl
,
":h2:"
))
{
return
new
H2Connection
(
connection
,
null
);
}
else
if
(
StringUtils
.
contains
(
jdbcUrl
,
":mysql:"
))
{
return
new
MySqlConnection
(
connection
,
null
);
}
else
if
(
StringUtils
.
contains
(
jdbcUrl
,
":oracle:"
))
{
return
new
OracleConnection
(
connection
,
null
);
}
else
{
return
new
DatabaseConnection
(
connection
);
}
}
}
}
}
}
modules/test/src/main/java/org/springside/modules/test/data/DataInitializer.java
已删除
100644 → 0
浏览文件 @
02e5c8e4
package
org.springside.modules.test.data
;
import
javax.sql.DataSource
;
import
org.springframework.beans.factory.InitializingBean
;
/**
* 在Spring Context启动时,使用DBUnit一次性初始化数据。
*
* @author calvin
*/
public
class
DataInitializer
implements
InitializingBean
{
private
DataSource
dataSource
;
private
String
dataFile
;
public
void
setDataSource
(
DataSource
dataSource
)
{
this
.
dataSource
=
dataSource
;
}
public
void
setDataFile
(
String
dataFile
)
{
this
.
dataFile
=
dataFile
;
}
@Override
public
void
afterPropertiesSet
()
throws
Exception
{
DataFixtures
.
reloadData
(
dataSource
,
dataFile
);
}
}
modules/test/src/test/java/org/springside/modules/test/data/DataFixturesTest.java
已删除
100644 → 0
浏览文件 @
02e5c8e4
package
org.springside.modules.test.data
;
import
static
org
.
junit
.
Assert
.*;
import
org.junit.Test
;
import
org.springframework.beans.BeansException
;
import
org.springframework.test.context.ContextConfiguration
;
import
org.springside.modules.test.spring.SpringTransactionalTestCase
;
@ContextConfiguration
(
locations
=
{
"/applicationContext-test.xml"
})
public
class
DataFixturesTest
extends
SpringTransactionalTestCase
{
@Test
public
void
normal
()
throws
BeansException
,
Exception
{
simpleJdbcTemplate
.
update
(
"drop all objects"
);
executeSqlScript
(
"classpath:/schema.sql"
,
false
);
DataFixtures
.
loadData
(
dataSource
,
"classpath:/test-data.xml"
);
assertEquals
(
6
,
countRowsInTable
(
"SS_USER"
));
DataFixtures
.
reloadData
(
dataSource
,
"classpath:/test-data.xml"
);
assertEquals
(
6
,
countRowsInTable
(
"SS_USER"
));
DataFixtures
.
deleteData
(
dataSource
,
"classpath:/test-data.xml"
);
assertEquals
(
0
,
countRowsInTable
(
"SS_USER"
));
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录