Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
后端镜像
java镜像
Springside4
提交
ae004780
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,发现更多精彩内容 >>
提交
ae004780
编写于
4月 08, 2012
作者:
C
Calvin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#29 改进Functional Test不止对嵌入式Jetty执行,也可以对在运行的其他服务器执行, Fixtures改进可适用于多种数据库。
上级
5153c906
变更
17
隐藏空白更改
内联
并排
Showing
17 changed file
with
149 addition
and
87 deletion
+149
-87
examples/mini-service/src/test/functional/org/springside/examples/miniservice/functional/BaseFunctionalTestCase.java
...amples/miniservice/functional/BaseFunctionalTestCase.java
+8
-7
examples/mini-service/src/test/functional/org/springside/examples/miniservice/functional/Start.java
...org/springside/examples/miniservice/functional/Start.java
+1
-1
examples/mini-service/src/test/resources/applicationContext-ws-client.xml
...rvice/src/test/resources/applicationContext-ws-client.xml
+11
-1
examples/mini-web/src/test/functional/org/springside/examples/miniweb/functional/BaseFunctionalTestCase.java
...e/examples/miniweb/functional/BaseFunctionalTestCase.java
+45
-13
examples/mini-web/src/test/functional/org/springside/examples/miniweb/functional/Start.java
...nal/org/springside/examples/miniweb/functional/Start.java
+1
-3
examples/mini-web/src/test/resources/application.functional.properties
...-web/src/test/resources/application.functional.properties
+11
-0
examples/mini-web/src/test/resources/application.test.properties
...s/mini-web/src/test/resources/application.test.properties
+1
-4
examples/showcase/src/main/resources/applicationContext.xml
examples/showcase/src/main/resources/applicationContext.xml
+1
-1
examples/showcase/src/test/functional/org/springside/examples/showcase/functional/BaseFunctionalTestCase.java
.../examples/showcase/functional/BaseFunctionalTestCase.java
+40
-8
examples/showcase/src/test/functional/org/springside/examples/showcase/functional/BaseSeleniumTestCase.java
...de/examples/showcase/functional/BaseSeleniumTestCase.java
+4
-25
examples/showcase/src/test/functional/org/springside/examples/showcase/functional/Start.java
...al/org/springside/examples/showcase/functional/Start.java
+1
-3
examples/showcase/src/test/functional/org/springside/examples/showcase/functional/webservice/rs/UserResourceServiceIT.java
...wcase/functional/webservice/rs/UserResourceServiceIT.java
+1
-2
examples/showcase/src/test/resources/application.functional.properties
...case/src/test/resources/application.functional.properties
+11
-0
examples/showcase/src/test/resources/application.test.properties
...s/showcase/src/test/resources/application.test.properties
+0
-3
modules/core/src/main/java/org/springside/modules/test/data/Fixtures.java
.../main/java/org/springside/modules/test/data/Fixtures.java
+4
-4
modules/core/src/main/java/org/springside/modules/test/functional/JettyFactory.java
.../org/springside/modules/test/functional/JettyFactory.java
+5
-7
modules/core/src/test/java/org/springside/modules/test/functional/JettyFactoryTest.java
.../springside/modules/test/functional/JettyFactoryTest.java
+4
-5
未找到文件。
examples/mini-service/src/test/functional/org/springside/examples/miniservice/functional/BaseFunctionalTestCase.java
浏览文件 @
ae004780
...
...
@@ -24,19 +24,19 @@ import org.springside.modules.utils.PropertiesLoader;
@Ignore
public
class
BaseFunctionalTestCase
{
protected
static
String
baseUrl
;
protected
static
Server
jettyServer
;
protected
static
SimpleDriverDataSource
dataSource
;
protected
static
String
baseUrl
;
protected
static
PropertiesLoader
propertiesLoader
=
new
PropertiesLoader
(
"classpath:/application.functional.properties"
,
"classpath:/application.functional-local.properties"
);
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
BaseFunctionalTestCase
.
class
);
private
static
PropertiesLoader
propertiesLoader
=
new
PropertiesLoader
(
"classpath:/application.functional.properties"
,
"classpath:/application.functional-local.properties"
);
@BeforeClass
public
static
void
startAll
()
throws
Exception
{
public
static
void
beforeClass
()
throws
Exception
{
baseUrl
=
propertiesLoader
.
getProperty
(
"baseUrl"
,
Start
.
BASE_URL
);
Boolean
isEmbedded
=
Boolean
.
valueOf
(
propertiesLoader
.
getProperty
(
"embedded"
,
"true"
));
...
...
@@ -54,8 +54,10 @@ public class BaseFunctionalTestCase {
*/
protected
static
void
startJettyOnce
()
throws
Exception
{
if
(
jettyServer
==
null
)
{
jettyServer
=
JettyFactory
.
buildTestServer
(
new
URL
(
baseUrl
).
getPort
(),
Start
.
CONTEXT
);
jettyServer
=
JettyFactory
.
createServer
(
new
URL
(
baseUrl
).
getPort
(),
Start
.
CONTEXT
,
"src/test/resources/web.xml"
);
jettyServer
.
start
();
logger
.
info
(
"Jetty Server started"
);
}
}
...
...
@@ -68,7 +70,6 @@ public class BaseFunctionalTestCase {
dataSource
.
setUrl
(
propertiesLoader
.
getProperty
(
"jdbc.url"
));
dataSource
.
setUsername
(
propertiesLoader
.
getProperty
(
"jdbc.username"
));
dataSource
.
setPassword
(
propertiesLoader
.
getProperty
(
"jdbc.password"
));
}
}
...
...
examples/mini-service/src/test/functional/org/springside/examples/miniservice/functional/Start.java
浏览文件 @
ae004780
...
...
@@ -15,7 +15,7 @@ public class Start {
public
static
final
String
BASE_URL
=
"http://localhost:8080/mini-service"
;
public
static
void
main
(
String
[]
args
)
throws
Exception
{
Server
server
=
JettyFactory
.
buildNormal
Server
(
PORT
,
CONTEXT
);
Server
server
=
JettyFactory
.
create
Server
(
PORT
,
CONTEXT
);
server
.
start
();
System
.
out
.
println
(
"Server running at "
+
BASE_URL
);
...
...
examples/mini-service/src/test/resources/applicationContext-ws-client.xml
浏览文件 @
ae004780
...
...
@@ -6,6 +6,16 @@
default-lazy-init=
"true"
>
<description>
Apache CXF Web Service Client端配置
</description>
<bean
class=
"org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
>
<property
name=
"ignoreResourceNotFound"
value=
"true"
/>
<property
name=
"locations"
>
<list>
<value>
classpath*:/application.functional.properties
</value>
<value>
classpath*:/application.functional-local.properties
</value>
</list>
</property>
</bean>
<jaxws:client
id=
"accountWebServiceClient"
serviceClass=
"org.springside.examples.miniservice.webservice.ws.AccountWebService"
address=
"
http://localhost:8084/mini-service
/ws/accountservice"
/>
address=
"
${baseUrl}
/ws/accountservice"
/>
</beans>
examples/mini-web/src/test/functional/org/springside/examples/miniweb/functional/BaseFunctionalTestCase.java
浏览文件 @
ae004780
...
...
@@ -2,7 +2,8 @@ package org.springside.examples.miniweb.functional;
import
static
org
.
junit
.
Assert
.*;
import
javax.sql.DataSource
;
import
java.net.URL
;
import
java.sql.Driver
;
import
org.eclipse.jetty.server.Server
;
import
org.junit.AfterClass
;
...
...
@@ -10,51 +11,72 @@ import org.junit.BeforeClass;
import
org.junit.Ignore
;
import
org.openqa.selenium.By
;
import
org.openqa.selenium.WebDriver
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.jdbc.datasource.SimpleDriverDataSource
;
import
org.springside.modules.test.data.Fixtures
;
import
org.springside.modules.test.functional.JettyFactory
;
import
org.springside.modules.test.functional.Selenium2
;
import
org.springside.modules.test.functional.WebDriverFactory
;
import
org.springside.modules.test.spring.SpringContextHolder
;
import
org.springside.modules.utils.PropertiesLoader
;
/**
* 功能测试基类.
*
* 在整个测试期间启动一次Jetty Server, 并在每个TestCase执行前重新载入默认数据, 创建WebDriver.
* 在整个测试期间启动一次Jetty Server, 并在每个TestCase Class执行前重新载入默认数据.
* 在每个TestCase Class执行前创建WebDriver,并在每个TestCase执行后关闭WebDriver.
*
* @author calvin
*/
@Ignore
public
class
BaseFunctionalTestCase
{
protected
static
String
baseUrl
;
protected
static
Server
jettyServer
;
protected
static
DataSource
dataSource
;
protected
static
SimpleDriver
DataSource
dataSource
;
protected
static
Selenium2
s
;
protected
static
PropertiesLoader
propertiesLoader
=
new
PropertiesLoader
(
"classpath:/application.functional.properties"
,
"classpath:/application.functional-local.properties"
);
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
BaseFunctionalTestCase
.
class
);
@BeforeClass
public
static
void
startAll
()
throws
Exception
{
startJetty
();
public
static
void
beforeClass
()
throws
Exception
{
baseUrl
=
propertiesLoader
.
getProperty
(
"baseUrl"
,
Start
.
BASE_URL
);
Boolean
isEmbedded
=
Boolean
.
valueOf
(
propertiesLoader
.
getProperty
(
"embedded"
,
"true"
));
if
(
isEmbedded
)
{
startJettyOnce
();
}
buildDataSourceOnce
();
reloadSampleData
();
createSelenium
();
loginAsAdminIfNecessary
();
}
@AfterClass
public
static
void
stopAll
()
throws
Exception
{
public
static
void
afeterClass
()
throws
Exception
{
quitSelenium
();
}
/**
* 启动Jetty服务器, 仅启动一次.
*/
protected
static
void
startJetty
()
throws
Exception
{
protected
static
void
startJetty
Once
()
throws
Exception
{
if
(
jettyServer
==
null
)
{
jettyServer
=
JettyFactory
.
buildTestServer
(
Start
.
TEST_PORT
,
Start
.
CONTEXT
);
jettyServer
=
JettyFactory
.
createServer
(
new
URL
(
baseUrl
).
getPort
(),
Start
.
CONTEXT
,
"src/test/resources/web.xml"
);
jettyServer
.
start
();
dataSource
=
SpringContextHolder
.
getBean
(
"dataSource
"
);
logger
.
info
(
"Jetty Server started
"
);
}
}
...
...
@@ -69,13 +91,11 @@ public class BaseFunctionalTestCase {
* 创建Selenium.
*/
protected
static
void
createSelenium
()
throws
Exception
{
PropertiesLoader
propertiesLoader
=
new
PropertiesLoader
(
"classpath:/application.test.properties"
,
"classpath:/application.test-local.properties"
);
String
driverName
=
propertiesLoader
.
getProperty
(
"selenium.driver"
);
WebDriver
driver
=
WebDriverFactory
.
createDriver
(
driverName
);
s
=
new
Selenium2
(
driver
,
Start
.
TEST_BASE_URL
);
s
=
new
Selenium2
(
driver
,
baseUrl
);
}
/**
...
...
@@ -109,4 +129,16 @@ public class BaseFunctionalTestCase {
s
.
type
(
By
.
name
(
"password"
),
password
);
s
.
click
(
By
.
id
(
"submit"
));
}
private
static
void
buildDataSourceOnce
()
throws
ClassNotFoundException
{
if
(
dataSource
==
null
)
{
dataSource
=
new
SimpleDriverDataSource
();
dataSource
.
setDriverClass
((
Class
<?
extends
Driver
>)
Class
.
forName
(
propertiesLoader
.
getProperty
(
"jdbc.driver"
)));
dataSource
.
setUrl
(
propertiesLoader
.
getProperty
(
"jdbc.url"
));
dataSource
.
setUsername
(
propertiesLoader
.
getProperty
(
"jdbc.username"
));
dataSource
.
setPassword
(
propertiesLoader
.
getProperty
(
"jdbc.password"
));
}
}
}
\ No newline at end of file
examples/mini-web/src/test/functional/org/springside/examples/miniweb/functional/Start.java
浏览文件 @
ae004780
...
...
@@ -11,13 +11,11 @@ import org.springside.modules.test.functional.JettyFactory;
public
class
Start
{
public
static
final
int
PORT
=
8080
;
public
static
final
int
TEST_PORT
=
8082
;
public
static
final
String
CONTEXT
=
"/mini-web"
;
public
static
final
String
BASE_URL
=
"http://localhost:8080/mini-web"
;
public
static
final
String
TEST_BASE_URL
=
"http://localhost:8082/mini-web"
;
public
static
void
main
(
String
[]
args
)
throws
Exception
{
Server
server
=
JettyFactory
.
buildNormal
Server
(
PORT
,
CONTEXT
);
Server
server
=
JettyFactory
.
create
Server
(
PORT
,
CONTEXT
);
server
.
start
();
System
.
out
.
println
(
"Server running at "
+
BASE_URL
);
...
...
examples/mini-web/src/test/resources/application.functional.properties
0 → 100644
浏览文件 @
ae004780
baseUrl
=
http://localhost:8082/mini-web
embedded
=
true
jdbc.driver
=
org.h2.Driver
jdbc.url
=
jdbc:h2:mem:mini-web4;DB_CLOSE_DELAY=-1
jdbc.username
=
sa
jdbc.password
=
#selenium settings, options include firefox,ie,chrome,remote:localhost:3000:firefox
selenium.driver
=
firefox
examples/mini-web/src/test/resources/application.test.properties
浏览文件 @
ae004780
...
...
@@ -7,7 +7,4 @@ hibernate.dialect=org.hibernate.dialect.H2Dialect
#log4jdbc driver
#jdbc.driver=net.sf.log4jdbc.DriverSpy
#jdbc.url=jdbc:log4jdbc:h2:mem:mini-web4;DB_CLOSE_DELAY=-1
#selenium settings, options include firefox,ie,chrome,remote:localhost:3000:firefox
selenium.driver
=
firefox
\ No newline at end of file
#
jdbc.url
=
jdbc:log4jdbc:h2:mem:mini-web4;DB_CLOSE_DELAY=-1
\ No newline at end of file
examples/showcase/src/main/resources/applicationContext.xml
浏览文件 @
ae004780
...
...
@@ -116,7 +116,7 @@
<!-- 数据源配置,在测试环境使用JDBC直接连接 -->
<bean
id=
"dataSource"
class=
"org.springframework.jdbc.datasource.SimpleDriverDataSource"
>
<!-- Connection Info -->
<property
name=
"driverClass
Name
"
value=
"${jdbc.driver}"
/>
<property
name=
"driverClass"
value=
"${jdbc.driver}"
/>
<property
name=
"url"
value=
"${jdbc.url}"
/>
<property
name=
"username"
value=
"${jdbc.username}"
/>
<property
name=
"password"
value=
"${jdbc.password}"
/>
...
...
examples/showcase/src/test/functional/org/springside/examples/showcase/functional/BaseFunctionalTestCase.java
浏览文件 @
ae004780
package
org.springside.examples.showcase.functional
;
import
javax.sql.DataSource
;
import
java.net.URL
;
import
java.sql.Driver
;
import
org.eclipse.jetty.server.Server
;
import
org.junit.BeforeClass
;
import
org.junit.Ignore
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.jdbc.datasource.SimpleDriverDataSource
;
import
org.springside.modules.test.data.Fixtures
;
import
org.springside.modules.test.functional.JettyFactory
;
import
org.springside.modules.
test.spring.SpringContextHol
der
;
import
org.springside.modules.
utils.PropertiesLoa
der
;
/**
* 功能测试基类.
...
...
@@ -18,25 +22,41 @@ import org.springside.modules.test.spring.SpringContextHolder;
*/
@Ignore
public
class
BaseFunctionalTestCase
{
protected
static
String
baseUrl
;
protected
static
Server
jettyServer
;
protected
static
DataSource
dataSource
;
protected
static
SimpleDriverDataSource
dataSource
;
protected
static
PropertiesLoader
propertiesLoader
=
new
PropertiesLoader
(
"classpath:/application.functional.properties"
,
"classpath:/application.functional-local.properties"
);
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
BaseFunctionalTestCase
.
class
);
@BeforeClass
public
static
void
startAll
()
throws
Exception
{
startJetty
();
public
static
void
beforeClass
()
throws
Exception
{
baseUrl
=
propertiesLoader
.
getProperty
(
"baseUrl"
,
Start
.
BASE_URL
);
Boolean
isEmbedded
=
Boolean
.
valueOf
(
propertiesLoader
.
getProperty
(
"embedded"
,
"true"
));
if
(
isEmbedded
)
{
startJettyOnce
();
}
buildDataSourceOnce
();
reloadSampleData
();
}
/**
* 启动Jetty服务器, 仅启动一次.
*/
protected
static
void
startJetty
()
throws
Exception
{
protected
static
void
startJetty
Once
()
throws
Exception
{
if
(
jettyServer
==
null
)
{
jettyServer
=
JettyFactory
.
buildTestServer
(
Start
.
TEST_PORT
,
Start
.
CONTEXT
);
jettyServer
=
JettyFactory
.
createServer
(
new
URL
(
baseUrl
).
getPort
(),
Start
.
CONTEXT
,
"src/test/resources/web.xml"
);
jettyServer
.
start
();
dataSource
=
SpringContextHolder
.
getBean
(
"dataSource"
);
logger
.
info
(
"Jetty Server started"
);
}
}
...
...
@@ -46,4 +66,16 @@ public class BaseFunctionalTestCase {
protected
static
void
reloadSampleData
()
throws
Exception
{
Fixtures
.
reloadData
(
dataSource
,
"/data/sample-data.xml"
);
}
private
static
void
buildDataSourceOnce
()
throws
ClassNotFoundException
{
if
(
dataSource
==
null
)
{
dataSource
=
new
SimpleDriverDataSource
();
dataSource
.
setDriverClass
((
Class
<?
extends
Driver
>)
Class
.
forName
(
propertiesLoader
.
getProperty
(
"jdbc.driver"
)));
dataSource
.
setUrl
(
propertiesLoader
.
getProperty
(
"jdbc.url"
));
dataSource
.
setUsername
(
propertiesLoader
.
getProperty
(
"jdbc.username"
));
dataSource
.
setPassword
(
propertiesLoader
.
getProperty
(
"jdbc.password"
));
}
}
}
examples/showcase/src/test/functional/org/springside/examples/showcase/functional/BaseSeleniumTestCase.java
浏览文件 @
ae004780
...
...
@@ -4,16 +4,13 @@ import org.junit.AfterClass;
import
org.junit.BeforeClass
;
import
org.junit.Ignore
;
import
org.openqa.selenium.WebDriver
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springside.modules.test.functional.Selenium2
;
import
org.springside.modules.test.functional.WebDriverFactory
;
import
org.springside.modules.utils.PropertiesLoader
;
/**
* 功能测试基类.
*
* 在
整个测试期间启动一次Jetty Server, 并在每个TestCase执行前中重新载入默认数据
.
* 在
BaseFunctionalTestCase的基础上,加入对Selenium WebDriver的启动和关闭
.
*
* @author calvin
*/
...
...
@@ -22,35 +19,17 @@ public class BaseSeleniumTestCase extends BaseFunctionalTestCase {
protected
static
Selenium2
s
;
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
BaseFunctionalTestCase
.
class
);
@BeforeClass
public
static
void
startSelenium
()
throws
Exception
{
createSelenium
();
}
@AfterClass
public
static
void
stopSelenium
()
throws
Exception
{
quitSelenium
();
}
/**
* 创建Selenium.
*/
protected
static
void
createSelenium
()
throws
Exception
{
PropertiesLoader
propertiesLoader
=
new
PropertiesLoader
(
"classpath:/application.test.properties"
,
"classpath:/application.test-local.properties"
);
String
driverName
=
propertiesLoader
.
getProperty
(
"selenium.driver"
);
WebDriver
driver
=
WebDriverFactory
.
createDriver
(
driverName
);
s
=
new
Selenium2
(
driver
,
Start
.
TEST_BASE_URL
);
s
=
new
Selenium2
(
driver
,
baseUrl
);
}
/**
* 关闭Selenium.
*/
protected
static
void
quitSelenium
()
{
@AfterClass
public
static
void
stopSelenium
()
throws
Exception
{
s
.
quit
();
}
}
examples/showcase/src/test/functional/org/springside/examples/showcase/functional/Start.java
浏览文件 @
ae004780
...
...
@@ -11,13 +11,11 @@ import org.springside.modules.test.functional.JettyFactory;
public
class
Start
{
public
static
final
int
PORT
=
8080
;
public
static
final
int
TEST_PORT
=
8083
;
public
static
final
String
CONTEXT
=
"/showcase"
;
public
static
final
String
BASE_URL
=
"http://localhost:8080/showcase"
;
public
static
final
String
TEST_BASE_URL
=
"http://localhost:8083/showcase"
;
public
static
void
main
(
String
[]
args
)
throws
Exception
{
Server
server
=
JettyFactory
.
buildNormal
Server
(
PORT
,
CONTEXT
);
Server
server
=
JettyFactory
.
create
Server
(
PORT
,
CONTEXT
);
server
.
start
();
System
.
out
.
println
(
"Server running at "
+
BASE_URL
);
...
...
examples/showcase/src/test/functional/org/springside/examples/showcase/functional/webservice/rs/UserResourceServiceIT.java
浏览文件 @
ae004780
...
...
@@ -8,7 +8,6 @@ import org.junit.BeforeClass;
import
org.junit.Test
;
import
org.junit.experimental.categories.Category
;
import
org.springside.examples.showcase.functional.BaseFunctionalTestCase
;
import
org.springside.examples.showcase.functional.Start
;
import
org.springside.examples.showcase.functional.category.Smoke
;
import
org.springside.examples.showcase.webservice.rs.client.UserResourceClient
;
import
org.springside.examples.showcase.webservice.rs.dto.UserDTO
;
...
...
@@ -22,7 +21,7 @@ public class UserResourceServiceIT extends BaseFunctionalTestCase {
@BeforeClass
public
static
void
setUpClient
()
{
client
=
new
UserResourceClient
();
client
.
setBaseUrl
(
Start
.
TEST_BASE_URL
+
"/rs"
);
client
.
setBaseUrl
(
baseUrl
+
"/rs"
);
}
/**
...
...
examples/showcase/src/test/resources/application.functional.properties
0 → 100644
浏览文件 @
ae004780
baseUrl
=
http://localhost:8083/showcase
embedded
=
true
jdbc.driver
=
org.h2.Driver
jdbc.url
=
jdbc:h2:mem:showcase4;DB_CLOSE_DELAY=-1
jdbc.username
=
sa
jdbc.password
=
#selenium settings, options include firefox,ie,chrome,remote:localhost:3000:firefox
selenium.driver
=
firefox
examples/showcase/src/test/resources/application.test.properties
浏览文件 @
ae004780
...
...
@@ -12,9 +12,6 @@ quartz.jdbc.url=jdbc:h2:mem:showcase-quartz4;DB_CLOSE_DELAY=-1
quartz.jdbc.username
=
sa
quartz.jdbc.password
=
#selenium settings, options include firefox,ie,chrome,remote:localhost:3000:firefox
selenium.driver
=
firefox
#memcached settings
memcached.url
=
localhost:11311
...
...
modules/core/src/main/java/org/springside/modules/test/data/Fixtures.java
浏览文件 @
ae004780
...
...
@@ -90,12 +90,12 @@ public class Fixtures {
protected
static
IDatabaseConnection
getConnection
(
DataSource
dataSource
)
throws
DatabaseUnitException
,
SQLException
{
Connection
connection
=
dataSource
.
getConnection
();
String
d
riverName
=
connection
.
getMetaData
().
getDriverNam
e
();
if
(
StringUtils
.
contains
(
d
river
Name
,
"h2"
))
{
String
d
bName
=
connection
.
getMetaData
().
getDatabaseProductName
().
toLowerCas
e
();
if
(
StringUtils
.
contains
(
d
b
Name
,
"h2"
))
{
return
new
H2Connection
(
connection
,
null
);
}
else
if
(
StringUtils
.
contains
(
d
river
Name
,
"mysql"
))
{
}
else
if
(
StringUtils
.
contains
(
d
b
Name
,
"mysql"
))
{
return
new
MySqlConnection
(
connection
,
null
);
}
else
if
(
StringUtils
.
contains
(
d
river
Name
,
"oracle"
))
{
}
else
if
(
StringUtils
.
contains
(
d
b
Name
,
"oracle"
))
{
return
new
OracleConnection
(
connection
,
null
);
}
else
{
return
new
DatabaseConnection
(
connection
);
...
...
modules/core/src/main/java/org/springside/modules/test/functional/JettyFactory.java
浏览文件 @
ae004780
...
...
@@ -21,7 +21,7 @@ public class JettyFactory {
/**
* 创建用于开发运行调试的Jetty Server, 以src/main/webapp为Web应用目录.
*/
public
static
Server
buildNormal
Server
(
int
port
,
String
contextPath
)
{
public
static
Server
create
Server
(
int
port
,
String
contextPath
)
{
Server
server
=
new
Server
(
port
);
server
.
setStopAtShutdown
(
true
);
...
...
@@ -33,13 +33,11 @@ public class JettyFactory {
}
/**
* 创建用于Functional Test的Jetty Server:
* 1.以src/main/webapp为Web应用目录.
* 2.以test/resources/web.xml指向applicationContext-test.xml创建测试环境.
* 创建Jetty Server,以 以src/main/webapp为Web应用目录并重新制定web.xml路径。
*/
public
static
Server
buildTestServer
(
int
port
,
String
context
Path
)
{
Server
server
=
buildNormal
Server
(
port
,
contextPath
);
((
WebAppContext
)
server
.
getHandler
()).
setDescriptor
(
"src/test/resources/web.xml"
);
public
static
Server
createServer
(
int
port
,
String
contextPath
,
String
webxml
Path
)
{
Server
server
=
create
Server
(
port
,
contextPath
);
((
WebAppContext
)
server
.
getHandler
()).
setDescriptor
(
webxmlPath
);
return
server
;
}
}
modules/core/src/test/java/org/springside/modules/test/functional/JettyFactoryTest.java
浏览文件 @
ae004780
...
...
@@ -5,13 +5,12 @@ import static org.junit.Assert.*;
import
org.eclipse.jetty.server.Server
;
import
org.eclipse.jetty.webapp.WebAppContext
;
import
org.junit.Test
;
import
org.springside.modules.test.functional.JettyFactory
;
public
class
JettyFactoryTest
{
@Test
public
void
build
NormalServer
()
{
Server
server
=
JettyFactory
.
buildNormal
Server
(
1978
,
"core"
);
public
void
create
NormalServer
()
{
Server
server
=
JettyFactory
.
create
Server
(
1978
,
"core"
);
assertEquals
(
1978
,
server
.
getConnectors
()[
0
].
getPort
());
assertEquals
(
"core"
,
((
WebAppContext
)
server
.
getHandler
()).
getContextPath
());
...
...
@@ -19,8 +18,8 @@ public class JettyFactoryTest {
}
@Test
public
void
build
TestServer
()
{
Server
server
=
JettyFactory
.
buildTestServer
(
1978
,
"core
"
);
public
void
create
TestServer
()
{
Server
server
=
JettyFactory
.
createServer
(
1978
,
"core"
,
"src/test/resources/web.xml
"
);
assertEquals
(
1978
,
server
.
getConnectors
()[
0
].
getPort
());
assertEquals
(
"core"
,
((
WebAppContext
)
server
.
getHandler
()).
getContextPath
());
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录