提交 45e42e24 编写于 作者: C Calvin

数据初始化的SQL分类型,以支持对远程的真实数据库执行functional test

上级 bc404eb6
...@@ -664,7 +664,6 @@ ...@@ -664,7 +664,6 @@
<profile> <profile>
<id>refresh-db</id> <id>refresh-db</id>
<build> <build>
<plugins> <plugins>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
...@@ -676,7 +675,7 @@ ...@@ -676,7 +675,7 @@
<sql driver="${jdbc.driver}" url="${jdbc.url}" userid="${jdbc.username}" password="${jdbc.password}" onerror="continue" encoding="${project.build.sourceEncoding}"> <sql driver="${jdbc.driver}" url="${jdbc.url}" userid="${jdbc.username}" password="${jdbc.password}" onerror="continue" encoding="${project.build.sourceEncoding}">
<classpath refid="maven.test.classpath" /> <classpath refid="maven.test.classpath" />
<transaction src="src/main/resources/sql/h2/schema.sql"/> <transaction src="src/main/resources/sql/h2/schema.sql"/>
<transaction src="src/test/resources/data/import-data.sql"/> <transaction src="src/test/resources/data/h2/import-data.sql"/>
</sql> </sql>
</target> </target>
</configuration> </configuration>
......
...@@ -115,7 +115,7 @@ ...@@ -115,7 +115,7 @@
<!-- 初始化数据表结构 --> <!-- 初始化数据表结构 -->
<jdbc:initialize-database data-source="dataSource" ignore-failures="ALL"> <jdbc:initialize-database data-source="dataSource" ignore-failures="ALL">
<jdbc:script location="classpath:sql/h2/schema.sql" /> <jdbc:script location="classpath:sql/${db.type}/schema.sql" />
</jdbc:initialize-database> </jdbc:initialize-database>
</beans> </beans>
...@@ -136,7 +136,7 @@ ...@@ -136,7 +136,7 @@
<!-- 初始化数据表结构 与默认数据--> <!-- 初始化数据表结构 与默认数据-->
<jdbc:initialize-database data-source="dataSource" ignore-failures="ALL"> <jdbc:initialize-database data-source="dataSource" ignore-failures="ALL">
<jdbc:script location="classpath:sql/h2/schema.sql" /> <jdbc:script location="classpath:sql/h2/schema.sql" />
<jdbc:script location="classpath:data/import-data.sql" encoding="UTF-8"/> <jdbc:script location="classpath:data/h2/import-data.sql" encoding="UTF-8"/>
</jdbc:initialize-database> </jdbc:initialize-database>
</beans> </beans>
</beans> </beans>
\ No newline at end of file
...@@ -87,6 +87,8 @@ public class BaseFunctionalTestCase { ...@@ -87,6 +87,8 @@ public class BaseFunctionalTestCase {
* 载入测试数据. * 载入测试数据.
*/ */
protected static void reloadSampleData() throws Exception { protected static void reloadSampleData() throws Exception {
DataFixtures.executeScript(dataSource, "classpath:data/cleanup-data.sql", "classpath:data/import-data.sql"); String dbType = propertiesLoader.getProperty("db.type", "h2");
DataFixtures.executeScript(dataSource, "classpath:data/" + dbType + "cleanup-data.sql", "classpath:data/"
+ dbType + "import-data.sql");
} }
} }
\ No newline at end of file
...@@ -5,6 +5,7 @@ embeddedForLocal=true ...@@ -5,6 +5,7 @@ embeddedForLocal=true
selenium.driver=firefox selenium.driver=firefox
#(optional)override jdbc url for functional test #(optional)override jdbc url for functional test
db.type=h2
jdbc.driver=org.h2.Driver jdbc.driver=org.h2.Driver
jdbc.url=jdbc:h2:file:~/.h2/quickstart-test;AUTO_SERVER=TRUE jdbc.url=jdbc:h2:file:~/.h2/quickstart-test;AUTO_SERVER=TRUE
jdbc.username=sa jdbc.username=sa
......
...@@ -548,7 +548,7 @@ ...@@ -548,7 +548,7 @@
<sql driver="${jdbc.driver}" url="${jdbc.url}" userid="${jdbc.username}" password="${jdbc.password}" onerror="continue" encoding="${project.build.sourceEncoding}"> <sql driver="${jdbc.driver}" url="${jdbc.url}" userid="${jdbc.username}" password="${jdbc.password}" onerror="continue" encoding="${project.build.sourceEncoding}">
<classpath refid="maven.test.classpath" /> <classpath refid="maven.test.classpath" />
<transaction src="src/main/resources/sql/h2/schema.sql"/> <transaction src="src/main/resources/sql/h2/schema.sql"/>
<transaction src="src/test/resources/data/import-data.sql"/> <transaction src="src/test/resources/data/h2/import-data.sql"/>
</sql> </sql>
<sql driver="${quartz.jdbc.driver}" url="${quartz.jdbc.url}" userid="${quartz.jdbc.username}" password="${quartz.jdbc.password}" encoding="${project.build.sourceEncoding}" <sql driver="${quartz.jdbc.driver}" url="${quartz.jdbc.url}" userid="${quartz.jdbc.username}" password="${quartz.jdbc.password}" encoding="${project.build.sourceEncoding}"
src="src/main/resources/sql/h2/quartz.sql" onerror="continue"> src="src/main/resources/sql/h2/quartz.sql" onerror="continue">
......
...@@ -153,11 +153,11 @@ ...@@ -153,11 +153,11 @@
<!-- 初始化数据结构 --> <!-- 初始化数据结构 -->
<jdbc:initialize-database data-source="dataSource" ignore-failures="ALL"> <jdbc:initialize-database data-source="dataSource" ignore-failures="ALL">
<jdbc:script location="classpath:sql/h2/schema.sql" /> <jdbc:script location="classpath:sql/${db.type}/schema.sql" />
</jdbc:initialize-database> </jdbc:initialize-database>
<jdbc:initialize-database data-source="quartzDataSource" ignore-failures="ALL"> <jdbc:initialize-database data-source="quartzDataSource" ignore-failures="ALL">
<jdbc:script location="classpath:sql/h2/quartz.sql" /> <jdbc:script location="classpath:sql/${db.type}/quartz.sql" />
</jdbc:initialize-database> </jdbc:initialize-database>
</beans> </beans>
...@@ -186,7 +186,7 @@ ...@@ -186,7 +186,7 @@
<!-- 初始化数据结构与默认数据 --> <!-- 初始化数据结构与默认数据 -->
<jdbc:initialize-database data-source="dataSource" ignore-failures="ALL"> <jdbc:initialize-database data-source="dataSource" ignore-failures="ALL">
<jdbc:script location="classpath:sql/h2/schema.sql" /> <jdbc:script location="classpath:sql/h2/schema.sql" />
<jdbc:script location="classpath:data/import-data.sql" encoding="UTF-8" /> <jdbc:script location="classpath:data/h2/import-data.sql" encoding="UTF-8" />
</jdbc:initialize-database> </jdbc:initialize-database>
<jdbc:initialize-database data-source="quartzDataSource" ignore-failures="ALL"> <jdbc:initialize-database data-source="quartzDataSource" ignore-failures="ALL">
......
...@@ -81,6 +81,8 @@ public class BaseFunctionalTestCase { ...@@ -81,6 +81,8 @@ public class BaseFunctionalTestCase {
* 载入默认数据. * 载入默认数据.
*/ */
protected static void reloadSampleData() throws Exception { protected static void reloadSampleData() throws Exception {
DataFixtures.executeScript(dataSource, "classpath:data/cleanup-data.sql", "classpath:data/import-data.sql"); String dbType = propertiesLoader.getProperty("db.type", "h2");
DataFixtures.executeScript(dataSource, "classpath:data/" + dbType + "cleanup-data.sql", "classpath:data/"
+ dbType + "import-data.sql");
} }
} }
...@@ -5,6 +5,7 @@ embeddedForLocal=true ...@@ -5,6 +5,7 @@ embeddedForLocal=true
selenium.driver=firefox selenium.driver=firefox
#(optional)override jdbc url for functional test #(optional)override jdbc url for functional test
db.type=h2
jdbc.driver=org.h2.Driver jdbc.driver=org.h2.Driver
jdbc.url=jdbc:h2:file:~/.h2/showcase4-test;AUTO_SERVER=TRUE jdbc.url=jdbc:h2:file:~/.h2/showcase4-test;AUTO_SERVER=TRUE
jdbc.username=sa jdbc.username=sa
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册