Created
July 2, 2011 20:56
-
-
Save trevershick/1061641 to your computer and use it in GitHub Desktop.
A simple gist that shows how to switch test resource folders based on a profile which allows switching between h2 and oracle for unit and functional tests.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<beans xmlns="http://www.springframework.org/schema/beans" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xmlns:util="http://www.springframework.org/schema/util" | |
xmlns:p="http://www.springframework.org/schema/p" | |
xsi:schemaLocation="http://www.springframework.org/schema/beans | |
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd | |
http://www.springframework.org/schema/util | |
http://www.springframework.org/schema/util/spring-util-3.0.xsd"> | |
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close" | |
p:driverClassName="org.h2.Driver" | |
p:url="jdbc:h2:mem:loa_func" | |
p:username="sa" | |
p:password=""/> | |
<bean id="oracleSchema" class="java.lang.String"> | |
<constructor-arg> | |
<value>PUBLIC</value> | |
</constructor-arg> | |
</bean> | |
<bean id="hibernateDialect" class="java.lang.String"> | |
<constructor-arg> | |
<value>org.hibernate.dialect.H2Dialect</value> | |
</constructor-arg> | |
</bean> | |
<!-- org.hibernate.dialect.OracleDialect --> | |
<bean id="hibernateHbm2ddlAuto" class="java.lang.String"> | |
<constructor-arg> | |
<value>create-drop</value> | |
</constructor-arg> | |
</bean> | |
</beans> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<beans xmlns="http://www.springframework.org/schema/beans" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xmlns:util="http://www.springframework.org/schema/util" | |
xmlns:p="http://www.springframework.org/schema/p" | |
xsi:schemaLocation="http://www.springframework.org/schema/beans | |
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd | |
http://www.springframework.org/schema/util | |
http://www.springframework.org/schema/util/spring-util-3.0.xsd"> | |
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close" | |
p:driverClassName="oracle.jdbc.OracleDriver" | |
p:url="jdbc:oracle:thin:@oracledev:1521:dev" | |
p:username="my_func_schema" | |
p:password="my_func_schema"/> | |
<bean id="oracleSchema" class="java.lang.String"> | |
<constructor-arg> | |
<value>my_func_schema</value> | |
</constructor-arg> | |
</bean> | |
<bean id="hibernateDialect" class="java.lang.String"> | |
<constructor-arg> | |
<value>org.hibernate.dialect.Oracle10gDialect</value> | |
</constructor-arg> | |
</bean> | |
<bean id="hibernateHbm2ddlAuto" class="java.lang.String"> | |
<constructor-arg> | |
<value>validate</value> | |
</constructor-arg> | |
</bean> | |
</beans> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<profiles> | |
<profile> | |
<id>run_with_h2</id> | |
<activation> | |
<activeByDefault>true</activeByDefault> | |
</activation> | |
<dependencies> | |
<dependency> | |
<groupId>com.h2database</groupId> | |
<artifactId>h2</artifactId> | |
<version>1.3.151</version> | |
<scope>test</scope> | |
</dependency> | |
</dependencies> | |
<build> | |
<testResources> | |
<testResource> | |
<directory>src/test/h2</directory> | |
</testResource> | |
</testResources> | |
</build> | |
</profile> | |
<profile> | |
<id>run_with_oracle</id> | |
<activation> | |
<property> | |
<name>run_with</name> | |
<value>oracle</value> | |
</property> | |
</activation> | |
<dependencies> | |
<dependency> | |
<groupId>com.oracle</groupId> | |
<artifactId>ojdbc</artifactId> | |
<version>10.2.0.4.0</version> | |
<scope>test</scope> | |
</dependency> | |
</dependencies> | |
<build> | |
<testResources> | |
<testResource> | |
<directory>src/test/oracle</directory> | |
</testResource> | |
</testResources> | |
</build> | |
</profile> | |
</profiles> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment