Java Reference
In-Depth Information
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<import resource="classpath*:/launch-context.xml"/>
<import resource="classpath*:/jobs/statementJob.xml"/>
<bean id="placeholderProperties"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="classpath:batch.properties" />
<property name="systemPropertiesModeName"
value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />
<property name="ignoreUnresolvablePlaceholders" value="true" />
<property name="order" value="1" />
</bean>
<bean id="dataSourceInitializer"
class="org.springframework.jdbc.datasource.init.DataSourceInitializer">
<property name="dataSource" ref="dataSource"/>
<property name="enabled" value="true"/>
<property name="databasePopulator">
<bean class="org.springframework.jdbc.datasource.init.ResourceDatabasePopulator">
<property name="continueOnError" value="false"/>
<property name="ignoreFailedDrops" value="false"/>
<property name="sqlScriptEncoding" value="UTF-8"/>
<property name="scripts">
<list>
<value type="org.springframework.core.io.Resource">classpath:schema.sql</value>
</list>
</property>
</bean>
</property>
</bean>
</beans>
The advantage of this configuration structure is that you can override it in test. The job-context.xml
file is located in your <PROJECT>/src/main/resources directory . In <PROJECT>/src/test/resources , you
create an identical file called test-context.xml . However, instead of referring to batch.properties for
the location, you refer to test-batch.properties . The other addition to the test-context.xml file is the
configuration of a utility that comes with Spring 3 that is a huge help in integration testing:
DataSourceIntializer .
The test-batch.properties file mentioned earlier contains the required information for your
HSQLDB instance and is located in the same directory as test-context.xml . Listing 12-10 shows the
contents of test-batch.properties .
Listing 12-10. test-batch.properties
batch.jdbc.driver=org.hsqldb.jdbcDriver
batch.jdbc.url=jdbc:hsqldb:mem:testdb;sql.enforce_strict_size=true
batch.jdbc.user=sa
batch.jdbc.password=
batch.schema=
batch.schema.script=org/springframework/batch/core/schema-hsqldb.sql
 
Search WWH ::




Custom Search