Fixed samples so they can be launched from command line.

RESOLVED - issue BATCH-115: (some) samples launched from command line don't work 
http://opensource.atlassian.com/projects/spring/browse/BATCH-115
This commit is contained in:
dsyer
2007-08-28 12:49:08 +00:00
parent 293dfcc0e7
commit 26401ff11e
15 changed files with 223 additions and 214 deletions

View File

@@ -20,23 +20,8 @@
<config>src/main/resources/jobs/adhocLoopJob.xml</config>
<config>src/main/resources/jobs/infiniteLoopJob.xml</config>
<config>src/main/resources/data-source-context-init.xml</config>
<config>src/main/resources/jobs/compositeProcessorSample.xml</config>
</configs>
<configSets>
<configSet>
<name><![CDATA[multilineOrder]]></name>
<allowBeanDefinitionOverriding>true</allowBeanDefinitionOverriding>
<incomplete>false</incomplete>
<configs>
<config>/execution/src/test/resources/simple-container-definition.xml</config>
<config>src/main/resources/data-source-context.xml</config>
<config>src/main/resources/data-source-context-init.xml</config>
<config>src/main/resources/jobs/multilineOrderInputDescriptors.xml</config>
<config>src/main/resources/jobs/multilineOrderIo.xml</config>
<config>src/main/resources/jobs/multilineOrderJob.xml</config>
<config>src/main/resources/jobs/multilineOrderOutputDescriptors.xml</config>
</configs>
</configSet>
<configSet>
<name><![CDATA[adhocLoop]]></name>
<allowBeanDefinitionOverriding>true</allowBeanDefinitionOverriding>
@@ -131,11 +116,24 @@
<allowBeanDefinitionOverriding>true</allowBeanDefinitionOverriding>
<incomplete>false</incomplete>
<configs>
<config>src/main/resources/jobs/compositeProcessorSample.xml</config>
<config>src/main/resources/simple-container-definition.xml</config>
<config>src/main/resources/data-source-context.xml</config>
<config>src/main/resources/data-source-context-init.xml</config>
</configs>
</configSet>
<configSet>
<name><![CDATA[multilineOrder]]></name>
<allowBeanDefinitionOverriding>true</allowBeanDefinitionOverriding>
<incomplete>false</incomplete>
<configs>
<config>src/main/resources/data-source-context.xml</config>
<config>src/main/resources/data-source-context-init.xml</config>
<config>src/main/resources/jobs/multilineOrderInputDescriptors.xml</config>
<config>src/main/resources/jobs/multilineOrderIo.xml</config>
<config>src/main/resources/jobs/multilineOrderJob.xml</config>
<config>src/main/resources/jobs/multilineOrderOutputDescriptors.xml</config>
<config>src/main/resources/simple-container-definition.xml</config>
</configs>
</configSet>
</configSets>
</beansProjectDescription>

View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/execution/src/main/java/org/springframework/batch/execution/bootstrap/BatchCommandLineLauncher.java"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="1"/>
</listAttribute>
<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
<stringAttribute key="org.eclipse.debug.core.source_locator_id" value="org.eclipse.jdt.launching.sourceLocator.JavaSourceLookupDirector"/>
<stringAttribute key="org.eclipse.debug.core.source_locator_memento" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;sourceLookupDirector&gt;&#13;&#10;&lt;sourceContainers duplicates=&quot;false&quot;&gt;&#13;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#13;&amp;#10;&amp;lt;javaProject name=&amp;quot;core&amp;quot;/&amp;gt;&amp;#13;&amp;#10;&quot; typeId=&quot;org.eclipse.jdt.launching.sourceContainer.javaProject&quot;/&gt;&#13;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#13;&amp;#10;&amp;lt;classpathContainer path=&amp;quot;org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER&amp;quot;/&amp;gt;&amp;#13;&amp;#10;&quot; typeId=&quot;org.eclipse.jdt.launching.sourceContainer.classpathContainer&quot;/&gt;&#13;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#13;&amp;#10;&amp;lt;javaProject name=&amp;quot;execution&amp;quot;/&amp;gt;&amp;#13;&amp;#10;&quot; typeId=&quot;org.eclipse.jdt.launching.sourceContainer.javaProject&quot;/&gt;&#13;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#13;&amp;#10;&amp;lt;javaProject name=&amp;quot;infrastructure&amp;quot;/&amp;gt;&amp;#13;&amp;#10;&quot; typeId=&quot;org.eclipse.jdt.launching.sourceContainer.javaProject&quot;/&gt;&#13;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#13;&amp;#10;&amp;lt;default/&amp;gt;&amp;#13;&amp;#10;&quot; typeId=&quot;org.eclipse.debug.core.containerType.default&quot;/&gt;&#13;&#10;&lt;/sourceContainers&gt;&#13;&#10;&lt;/sourceLookupDirector&gt;&#13;&#10;"/>
<booleanAttribute key="org.eclipse.jdt.debug.ui.CONSIDER_INHERITED_MAIN" value="true"/>
<booleanAttribute key="org.eclipse.jdt.debug.ui.INCLUDE_EXTERNAL_JARS" value="true"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.springframework.batch.execution.bootstrap.BatchCommandLineLauncher"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="jobs/simpleTaskletJob.xml jobConfiguration"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="samples"/>
<booleanAttribute key="org.eclipse.jdt.launching.STOP_IN_MAIN" value="true"/>
</launchConfiguration>

View File

@@ -29,7 +29,7 @@ import org.springframework.beans.factory.DisposableBean;
*
* @author Dave Syer
*/
public class FlatFileOrderWriter implements OrderWriter, DisposableBean {
public class FlatFileOrderWriter implements OrderWriter {
/**
* Takes care of writing to a file
*/
@@ -56,24 +56,6 @@ public class FlatFileOrderWriter implements OrderWriter, DisposableBean {
outputSource.write(converter.convert(data));
}
public void open() {
outputSource.open();
}
public void close() {
outputSource.close();
}
/**
* Calls close to ensure that bean factories can close and always release
* resources.
*
* @see org.springframework.beans.factory.DisposableBean#destroy()
*/
public void destroy() throws Exception {
close();
}
public void setOutputSource(OutputSource outputSource) {
this.outputSource = outputSource;
}

View File

@@ -16,13 +16,12 @@
package org.springframework.batch.sample.dao;
import org.springframework.batch.item.ResourceLifecycle;
import org.springframework.batch.sample.domain.Order;
/**
* Interface for writing <code>Order</code> objects.
*/
public interface OrderWriter extends ResourceLifecycle {
public interface OrderWriter {
public void write(Order order);

View File

@@ -11,7 +11,7 @@
<property name="jobConfigurationRegistry" ref="jobConfigurationRegistry"/>
</bean>
<bean id="jobConfiguration" parent="simpleJob" p:name="beanWrapperMapperSampleJob">
<bean id="jobConfiguration" parent="simpleJob">
<property name="steps">
<list>
<bean id="step1" parent="simpleStep">
@@ -132,4 +132,9 @@
<bean id="person" class="org.springframework.batch.sample.domain.Person" scope="prototype"/>
<bean parent="customEditorConfigurer"/>
<!-- register the step scope with the application context -->
<bean class="org.springframework.batch.execution.scope.StepScope" />
</beans>

View File

@@ -12,7 +12,6 @@
</bean>
<bean id="jobConfiguration" parent="simpleJob">
<property name="name" value="parallelProcessorSample" />
<property name="steps">
<bean id="step1" parent="simpleStep">
<constructor-arg>
@@ -100,4 +99,9 @@
<bean id="fieldSetMapper" class="org.springframework.batch.sample.mapping.TradeFieldSetMapper" />
<bean parent="customEditorConfigurer"/>
<!-- register the step scope with the application context -->
<bean class="org.springframework.batch.execution.scope.StepScope" />
</beans>

View File

@@ -12,10 +12,9 @@
</bean>
<bean id="jobConfiguration" parent="simpleJob">
<property name="name" value="fixedLengthImportJob" />
<property name="steps">
<bean id="step1" parent="simpleStep">
<constructor-arg>
<property name="tasklet">
<bean
class="org.springframework.batch.execution.tasklet.RestartableItemProviderTasklet">
<property name="itemProvider">
@@ -32,7 +31,7 @@
</bean>
</property>
</bean>
</constructor-arg>
</property>
</bean>
</property>
</bean>
@@ -92,4 +91,9 @@
<bean id="fieldSetMapper" class="org.springframework.batch.sample.mapping.TradeFieldSetMapper" />
<bean parent="customEditorConfigurer"/>
<!-- register the step scope with the application context -->
<bean class="org.springframework.batch.execution.scope.StepScope" />
</beans>

View File

@@ -11,7 +11,6 @@
</bean>
<bean id="jobConfiguration" parent="simpleJob">
<property name="name" value="multilineJob" />
<property name="steps">
<bean id="step1" parent="simpleStep">
<constructor-arg>
@@ -76,5 +75,11 @@
<property name="names" value="ISIN,Quantity,Price,Customer" />
<property name="lengths" value="12,3,5,9" />
</bean>
<bean parent="customEditorConfigurer"/>
<!-- register the step scope with the application context -->
<bean class="org.springframework.batch.execution.scope.StepScope" />
</beans>

View File

@@ -1,151 +1,156 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
<import resource="multilineOrderInputDescriptors.xml" />
<import resource="multilineOrderOutputDescriptors.xml" />
<import resource="multilineOrderIo.xml" />
<bean
class="org.springframework.batch.execution.configuration.JobConfigurationRegistryBeanPostProcessor">
<property name="jobConfigurationRegistry" ref="jobConfigurationRegistry" />
</bean>
<bean id="jobConfiguration" parent="simpleJob">
<property name="name" value="multilineOrderJob" />
<property name="steps">
<bean id="step1" parent="simpleStep">
<constructor-arg>
<bean
class="org.springframework.batch.execution.tasklet.RestartableItemProviderTasklet">
<property name="itemProvider">
<bean class="org.springframework.batch.sample.module.OrderItemProvider">
<property name="inputSource" ref="fileInputTemplate" />
<property name="headerMapper" ref="headerFieldSetMapper" />
<property name="customerMapper" ref="customerFieldSetMapper" />
<property name="addressMapper" ref="addressFieldSetMapper" />
<property name="billingMapper" ref="billingFieldSetMapper" />
<property name="itemMapper" ref="orderItemFieldSetMapper" />
<property name="shippingMapper" ref="shippingFieldSetMapper" />
<property name="validator" ref="validator" />
</bean>
</property>
<property name="itemProcessor">
<bean class="org.springframework.batch.sample.module.process.OrderProcessor">
<property name="writer">
<bean class="org.springframework.batch.sample.dao.FlatFileOrderWriter">
<property name="outputSource" ref="flatFileOutputSource" />
<property name="converter">
<bean class="org.springframework.batch.sample.dao.OrderConverter">
<property name="aggregators" ref="outputDescriptors" />
</bean>
</property>
</bean>
</property>
</bean>
</property>
</bean>
</constructor-arg>
</bean>
</property>
</bean>
<bean id="headerFieldSetMapper" class="org.springframework.batch.sample.mapping.HeaderFieldSetMapper" />
<bean id="customerFieldSetMapper" class="org.springframework.batch.sample.mapping.CustomerFieldSetMapper" />
<bean id="addressFieldSetMapper" class="org.springframework.batch.sample.mapping.AddressFieldSetMapper" />
<bean id="billingFieldSetMapper" class="org.springframework.batch.sample.mapping.BillingFieldSetMapper" />
<bean id="orderItemFieldSetMapper" class="org.springframework.batch.sample.mapping.OrderItemFieldSetMapper" />
<bean id="shippingFieldSetMapper" class="org.springframework.batch.sample.mapping.ShippingFieldSetMapper" />
<bean id="validator" class="org.springframework.batch.item.validator.SpringValidator">
<property name="validator">
<bean id="orderValidator" class="org.springmodules.validation.valang.ValangValidator">
<property name="valang">
<value>
<![CDATA[
{ orderId : ? > 0 AND ? <= 9999999999 : 'Incorrect order ID' : 'error.order.id' }
{ orderDate : isFutureDate(?) = FALSE : 'Future date is not allowed' : 'error.order.date.future' }
{ totalLines : ? = size(lineItems) : 'Bad count of order lines' : 'error.order.lines.badcount'}
{ customer.registered : customer.businessCustomer = FALSE OR ? = TRUE : 'Business customer must be registered' : 'error.customer.registration'}
{ customer.companyName : customer.businessCustomer = FALSE OR ? HAS TEXT : 'Company name for business customer is mandatory' : 'error.customer.companyname'}
{ customer.firstName : customer.businessCustomer = TRUE OR ? HAS TEXT : 'Firstname for non-business customer is mandatory' : 'error.customer.firstname'}
{ customer.lastName : customer.businessCustomer = TRUE OR ? HAS TEXT : 'Lastname name for non-business customer is mandatory' : 'error.customer.lastname'}
{ customer.registrationId : customer.registered = FALSE OR (? > 0 AND ? < 99999999) : 'Incorrect registration ID' : 'error.customer.registrationid'}
{ billingAddress.addressee : ? HAS NO TEXT OR length(?) <= 60 : 'Maximum length for Addressee is 60 characters' : 'error.baddress.addresse.length'}
{ billingAddress.addrLine1 : ? HAS TEXT AND length(?) <= 50 : 'Address line1 is mandatory and maximum length for address line1 is 50 characters' : 'error.baddress.addrline1.length'}
{ billingAddress.addrLine2 : ? HAS NO TEXT OR length(?) <= 50 : 'Maximum length for address line2 is 50 characters' : 'error.baddress.addrline2.length'}
{ billingAddress.city : ? HAS TEXT AND length(?) <= 30 : 'City is mandatory and maximum length for city is 30 characters' : 'error.baddress.city.length'}
{ billingAddress.zipCode : ? HAS TEXT AND length(?) <= 50 : 'Zipcode is mandatory and maximum length for zipcode is 5 characters' : 'error.baddress.zipcode.length'}
{ billingAddress.zipCode : match('[0-9]{5}',?) = TRUE : 'ZipCode must contain exactly 5 digits' : 'error.baddress.zipcode.format'}
{ billingAddress.state : (? HAS NO TEXT AND billingAddress.country != 'United States') OR (? HAS TEXT AND length(?) <= 2) : 'Maximum length for state is 2 characters' : 'error.baddress.state.length'}
{ billingAddress.country : ? HAS TEXT AND length(?) <= 50 : 'Country is mandatory and maximum length for country is 50 characters' : 'error.baddress.country.length'}
{ shippingAddress.addressee : shippingAddress IS NULL OR (? HAS TEXT AND length(?) <= 60) : 'Addressee is mandatory and maximum length for addressee is 60 characters' : 'error.saddress.addresse.length'}
{ shippingAddress.addrLine1 : shippingAddress IS NULL OR (? HAS TEXT AND length(?) <= 50) : 'Address line1 is mandatory and maximum length for address line1 is 50 characters' : 'error.baddress.addrline1.length'}
{ shippingAddress.addrLine2 : shippingAddress IS NULL OR (? HAS NO TEXT OR length(?) <= 50) : 'Maximum length for address line2 is 50 characters' : 'error.baddress.addrline2.length'}
{ shippingAddress.city : shippingAddress IS NULL OR (? HAS TEXT AND length(?) <= 30) : 'City is mandatory and maximum length for city is 30 characters' : 'error.baddress.city.length'}
{ shippingAddress.zipCode : shippingAddress IS NULL OR (? HAS TEXT AND length(?) <= 50) : 'Zipcode is mandatory and maximum length for zipcode is 5 characters' : 'error.baddress.zipcode.length'}
{ shippingAddress.zipCode : shippingAddress IS NULL OR (match('[0-9]{5}',?) = TRUE) : 'Zipcode must contain exactly 5 digits' : 'error.baddress.zipcode.format'}
{ shippingAddress.state : shippingAddress IS NULL OR ((? HAS NO TEXT AND billingAddress.country != 'United States') OR (? HAS TEXT AND length(?) <= 2)) : 'Maximum length for state is 2 characters' : 'error.baddress.state.length'}
{ shippingAddress.country : shippingAddress IS NULL OR (? HAS TEXT AND length(?) <= 50) : 'Country is mandatory and maximum length for country is 50 characters' : 'error.baddress.country.length'}
{ billing.paymentId : ? IN 'VISA','AMEX','ECMC','DCIN','PAYP' : 'Invalid payment type' : 'error.billing.type' }
{ billing.paymentDesc : match('[A-Z]{4}-[0-9]{10,11}',?) = TRUE : 'Invalid format of payment description' : 'error.billing.desc' }
{ shipping.shipperId : ? IN 'FEDX', 'UPS', 'DHL', 'DPD' : 'Invalid shipper ID' : 'error.shipping.shipper'}
{ shipping.shippingTypeId : ? IN 'STD', 'EXP', 'AMS', 'AME' : 'Invalid shipping type' : 'error.shipping.type' }
{ shipping.shippingInfo : ? HAS NO TEXT OR length(?) <= 100 : 'Maximum length for additional shipping info is 100 characters' }
{ lineItems : validateTotalItemsCount(totalItems,?) = TRUE : 'Bad count of total line items' : 'error.lineitems.badcount' }
{ lineItems : validateIds(?) = TRUE : 'One or more invalid item IDs' : 'error.lineitems.id' }
{ lineItems : validatePrices(?) = TRUE : 'One or more invalid item prices' : 'error.lineitems.price' }
{ lineItems : validateDiscounts(?) = TRUE : 'One or more invalid item discounts' : 'error.lineitems.discount' }
{ lineItems : validateShippingPrices(?) = TRUE : 'One or more invalid item shipping prices' : 'error.lineitems.shipping' }
{ lineItems : validateHandlingPrices(?) = TRUE : 'One or more invalid item handling prices' : 'error.lineitems.handling' }
{ lineItems : validateQuantities(?) = TRUE : 'One or more invalid item quantities' : 'error.lineitems.quantity' }
{ lineItems : validateTotalPrices(?) = TRUE : 'One or more invalid item total prices' : 'error.lineitems.totalprice' }
]]>
</value>
</property>
<property name="customFunctions">
<map>
<entry key="isFutureDate"
value="org.springframework.batch.sample.validation.valang.custom.FutureDateFunction" />
<entry key="validateTotalItemsCount"
value="org.springframework.batch.sample.validation.valang.custom.TotalOrderItemsFunction" />
<entry key="validateIds"
value="org.springframework.batch.sample.validation.valang.custom.ValidateIdsFunction" />
<entry key="validatePrices"
value="org.springframework.batch.sample.validation.valang.custom.ValidatePricesFunction" />
<entry key="validateDiscounts"
value="org.springframework.batch.sample.validation.valang.custom.ValidateDiscountsFunction" />
<entry key="validateShippingPrices"
value="org.springframework.batch.sample.validation.valang.custom.ValidateShippingPricesFunction" />
<entry key="validateHandlingPrices"
value="org.springframework.batch.sample.validation.valang.custom.ValidateHandlingPricesFunction" />
<entry key="validateQuantities"
value="org.springframework.batch.sample.validation.valang.custom.ValidateQuantitiesFunction" />
<entry key="validateTotalPrices"
value="org.springframework.batch.sample.validation.valang.custom.ValidateTotalPricesFunction" />
</map>
</property>
</bean>
</property>
</bean>
<!-- "{" <key> : <rule> : <message> : [ <error_code> [ : <error_parameters> ] ] "}" -->
<bean id="fileInputLocator" class="org.springframework.core.io.ClassPathResource">
<constructor-arg type="java.lang.String"
value="data/multilineOrderJob/input/20070122.teststream.multilineOrderStep.txt" />
</bean>
<bean id="fileOutputLocator" class="org.springframework.core.io.FileSystemResource">
<constructor-arg type="java.lang.String" value="20070122.teststream.multilineOrderStep.TEMP.txt" />
</bean>
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
<import resource="multilineOrderInputDescriptors.xml" />
<import resource="multilineOrderOutputDescriptors.xml" />
<import resource="multilineOrderIo.xml" />
<bean
class="org.springframework.batch.execution.configuration.JobConfigurationRegistryBeanPostProcessor">
<property name="jobConfigurationRegistry" ref="jobConfigurationRegistry" />
</bean>
<bean id="jobConfiguration" parent="simpleJob">
<property name="steps">
<bean id="step1" parent="simpleStep">
<property name="tasklet">
<bean
class="org.springframework.batch.execution.tasklet.RestartableItemProviderTasklet">
<property name="itemProvider">
<bean class="org.springframework.batch.sample.module.OrderItemProvider">
<property name="inputSource" ref="fileInputTemplate" />
<property name="headerMapper" ref="headerFieldSetMapper" />
<property name="customerMapper" ref="customerFieldSetMapper" />
<property name="addressMapper" ref="addressFieldSetMapper" />
<property name="billingMapper" ref="billingFieldSetMapper" />
<property name="itemMapper" ref="orderItemFieldSetMapper" />
<property name="shippingMapper" ref="shippingFieldSetMapper" />
<property name="validator" ref="validator" />
</bean>
</property>
<property name="itemProcessor">
<bean class="org.springframework.batch.sample.module.process.OrderProcessor">
<property name="writer">
<bean class="org.springframework.batch.sample.dao.FlatFileOrderWriter">
<property name="outputSource" ref="flatFileOutputSource" />
<property name="converter">
<bean class="org.springframework.batch.sample.dao.OrderConverter">
<property name="aggregators" ref="outputDescriptors" />
</bean>
</property>
</bean>
</property>
</bean>
</property>
</bean>
</property>
</bean>
</property>
</bean>
<bean id="headerFieldSetMapper" class="org.springframework.batch.sample.mapping.HeaderFieldSetMapper" />
<bean id="customerFieldSetMapper" class="org.springframework.batch.sample.mapping.CustomerFieldSetMapper" />
<bean id="addressFieldSetMapper" class="org.springframework.batch.sample.mapping.AddressFieldSetMapper" />
<bean id="billingFieldSetMapper" class="org.springframework.batch.sample.mapping.BillingFieldSetMapper" />
<bean id="orderItemFieldSetMapper" class="org.springframework.batch.sample.mapping.OrderItemFieldSetMapper" />
<bean id="shippingFieldSetMapper" class="org.springframework.batch.sample.mapping.ShippingFieldSetMapper" />
<bean id="validator" class="org.springframework.batch.item.validator.SpringValidator">
<property name="validator">
<bean id="orderValidator" class="org.springmodules.validation.valang.ValangValidator">
<property name="valang">
<value>
<![CDATA[
{ orderId : ? > 0 AND ? <= 9999999999 : 'Incorrect order ID' : 'error.order.id' }
{ orderDate : isFutureDate(?) = FALSE : 'Future date is not allowed' : 'error.order.date.future' }
{ totalLines : ? = size(lineItems) : 'Bad count of order lines' : 'error.order.lines.badcount'}
{ customer.registered : customer.businessCustomer = FALSE OR ? = TRUE : 'Business customer must be registered' : 'error.customer.registration'}
{ customer.companyName : customer.businessCustomer = FALSE OR ? HAS TEXT : 'Company name for business customer is mandatory' : 'error.customer.companyname'}
{ customer.firstName : customer.businessCustomer = TRUE OR ? HAS TEXT : 'Firstname for non-business customer is mandatory' : 'error.customer.firstname'}
{ customer.lastName : customer.businessCustomer = TRUE OR ? HAS TEXT : 'Lastname name for non-business customer is mandatory' : 'error.customer.lastname'}
{ customer.registrationId : customer.registered = FALSE OR (? > 0 AND ? < 99999999) : 'Incorrect registration ID' : 'error.customer.registrationid'}
{ billingAddress.addressee : ? HAS NO TEXT OR length(?) <= 60 : 'Maximum length for Addressee is 60 characters' : 'error.baddress.addresse.length'}
{ billingAddress.addrLine1 : ? HAS TEXT AND length(?) <= 50 : 'Address line1 is mandatory and maximum length for address line1 is 50 characters' : 'error.baddress.addrline1.length'}
{ billingAddress.addrLine2 : ? HAS NO TEXT OR length(?) <= 50 : 'Maximum length for address line2 is 50 characters' : 'error.baddress.addrline2.length'}
{ billingAddress.city : ? HAS TEXT AND length(?) <= 30 : 'City is mandatory and maximum length for city is 30 characters' : 'error.baddress.city.length'}
{ billingAddress.zipCode : ? HAS TEXT AND length(?) <= 50 : 'Zipcode is mandatory and maximum length for zipcode is 5 characters' : 'error.baddress.zipcode.length'}
{ billingAddress.zipCode : match('[0-9]{5}',?) = TRUE : 'ZipCode must contain exactly 5 digits' : 'error.baddress.zipcode.format'}
{ billingAddress.state : (? HAS NO TEXT AND billingAddress.country != 'United States') OR (? HAS TEXT AND length(?) <= 2) : 'Maximum length for state is 2 characters' : 'error.baddress.state.length'}
{ billingAddress.country : ? HAS TEXT AND length(?) <= 50 : 'Country is mandatory and maximum length for country is 50 characters' : 'error.baddress.country.length'}
{ shippingAddress.addressee : shippingAddress IS NULL OR (? HAS TEXT AND length(?) <= 60) : 'Addressee is mandatory and maximum length for addressee is 60 characters' : 'error.saddress.addresse.length'}
{ shippingAddress.addrLine1 : shippingAddress IS NULL OR (? HAS TEXT AND length(?) <= 50) : 'Address line1 is mandatory and maximum length for address line1 is 50 characters' : 'error.baddress.addrline1.length'}
{ shippingAddress.addrLine2 : shippingAddress IS NULL OR (? HAS NO TEXT OR length(?) <= 50) : 'Maximum length for address line2 is 50 characters' : 'error.baddress.addrline2.length'}
{ shippingAddress.city : shippingAddress IS NULL OR (? HAS TEXT AND length(?) <= 30) : 'City is mandatory and maximum length for city is 30 characters' : 'error.baddress.city.length'}
{ shippingAddress.zipCode : shippingAddress IS NULL OR (? HAS TEXT AND length(?) <= 50) : 'Zipcode is mandatory and maximum length for zipcode is 5 characters' : 'error.baddress.zipcode.length'}
{ shippingAddress.zipCode : shippingAddress IS NULL OR (match('[0-9]{5}',?) = TRUE) : 'Zipcode must contain exactly 5 digits' : 'error.baddress.zipcode.format'}
{ shippingAddress.state : shippingAddress IS NULL OR ((? HAS NO TEXT AND billingAddress.country != 'United States') OR (? HAS TEXT AND length(?) <= 2)) : 'Maximum length for state is 2 characters' : 'error.baddress.state.length'}
{ shippingAddress.country : shippingAddress IS NULL OR (? HAS TEXT AND length(?) <= 50) : 'Country is mandatory and maximum length for country is 50 characters' : 'error.baddress.country.length'}
{ billing.paymentId : ? IN 'VISA','AMEX','ECMC','DCIN','PAYP' : 'Invalid payment type' : 'error.billing.type' }
{ billing.paymentDesc : match('[A-Z]{4}-[0-9]{10,11}',?) = TRUE : 'Invalid format of payment description' : 'error.billing.desc' }
{ shipping.shipperId : ? IN 'FEDX', 'UPS', 'DHL', 'DPD' : 'Invalid shipper ID' : 'error.shipping.shipper'}
{ shipping.shippingTypeId : ? IN 'STD', 'EXP', 'AMS', 'AME' : 'Invalid shipping type' : 'error.shipping.type' }
{ shipping.shippingInfo : ? HAS NO TEXT OR length(?) <= 100 : 'Maximum length for additional shipping info is 100 characters' }
{ lineItems : validateTotalItemsCount(totalItems,?) = TRUE : 'Bad count of total line items' : 'error.lineitems.badcount' }
{ lineItems : validateIds(?) = TRUE : 'One or more invalid item IDs' : 'error.lineitems.id' }
{ lineItems : validatePrices(?) = TRUE : 'One or more invalid item prices' : 'error.lineitems.price' }
{ lineItems : validateDiscounts(?) = TRUE : 'One or more invalid item discounts' : 'error.lineitems.discount' }
{ lineItems : validateShippingPrices(?) = TRUE : 'One or more invalid item shipping prices' : 'error.lineitems.shipping' }
{ lineItems : validateHandlingPrices(?) = TRUE : 'One or more invalid item handling prices' : 'error.lineitems.handling' }
{ lineItems : validateQuantities(?) = TRUE : 'One or more invalid item quantities' : 'error.lineitems.quantity' }
{ lineItems : validateTotalPrices(?) = TRUE : 'One or more invalid item total prices' : 'error.lineitems.totalprice' }
]]>
</value>
</property>
<property name="customFunctions">
<map>
<entry key="isFutureDate"
value="org.springframework.batch.sample.validation.valang.custom.FutureDateFunction" />
<entry key="validateTotalItemsCount"
value="org.springframework.batch.sample.validation.valang.custom.TotalOrderItemsFunction" />
<entry key="validateIds"
value="org.springframework.batch.sample.validation.valang.custom.ValidateIdsFunction" />
<entry key="validatePrices"
value="org.springframework.batch.sample.validation.valang.custom.ValidatePricesFunction" />
<entry key="validateDiscounts"
value="org.springframework.batch.sample.validation.valang.custom.ValidateDiscountsFunction" />
<entry key="validateShippingPrices"
value="org.springframework.batch.sample.validation.valang.custom.ValidateShippingPricesFunction" />
<entry key="validateHandlingPrices"
value="org.springframework.batch.sample.validation.valang.custom.ValidateHandlingPricesFunction" />
<entry key="validateQuantities"
value="org.springframework.batch.sample.validation.valang.custom.ValidateQuantitiesFunction" />
<entry key="validateTotalPrices"
value="org.springframework.batch.sample.validation.valang.custom.ValidateTotalPricesFunction" />
</map>
</property>
</bean>
</property>
</bean>
<!-- "{" <key> : <rule> : <message> : [ <error_code> [ : <error_parameters> ] ] "}" -->
<bean id="fileInputLocator" class="org.springframework.core.io.ClassPathResource">
<constructor-arg type="java.lang.String"
value="data/multilineOrderJob/input/20070122.teststream.multilineOrderStep.txt" />
</bean>
<bean id="fileOutputLocator" class="org.springframework.core.io.FileSystemResource">
<constructor-arg type="java.lang.String" value="20070122.teststream.multilineOrderStep.TEMP.txt" />
</bean>
<bean parent="customEditorConfigurer"/>
<!-- register the step scope with the application context -->
<bean class="org.springframework.batch.execution.scope.StepScope" />
</beans>

View File

@@ -11,7 +11,6 @@
</bean>
<bean id="jobConfiguration" parent="simpleJob">
<property name="name" value="simpleTaskletJob" />
<property name="steps">
<list>
<bean id="step1" parent="simpleStep">

View File

@@ -125,4 +125,8 @@
value="20070122.testStream.CustomerReportStep.TEMP.txt" />
</bean>
<!-- register the step scope with the application context -->
<bean class="org.springframework.batch.execution.scope.StepScope" />
</beans>

View File

@@ -116,4 +116,9 @@
</property>
</bean>
<!-- register the step scope with the application context -->
<bean class="org.springframework.batch.execution.scope.StepScope" />
</beans>

View File

@@ -80,7 +80,6 @@
<bean id="simpleJob" class="org.springframework.batch.core.configuration.JobConfiguration"
abstract="true">
<property name="name" value="simpleJob" />
<property name="restartable" value="true" />
</bean>

View File

@@ -35,7 +35,7 @@ public class CompositeProcessorSampleFunctionalTests extends AbstractLifecycleSp
// @Override
protected String[] getConfigLocations() {
return new String[]{"jobs/compositeProcessorSample.xml"};
return new String[]{"jobs/compositeProcessorSampleJob.xml"};
}
/* (non-Javadoc)

View File

@@ -46,24 +46,6 @@ public class FlatFileOrderWriterTests extends TestCase {
writer.setOutputSource(output);
}
public void testOpen() {
//call tested method
writer.open();
//verify method calls
assertEquals(1, list.size());
}
public void testClose() {
//call tested method
writer.close();
//verify method calls
assertEquals(1, list.size());
}
public void testWrite() {
//Create and set-up Order