From db8b5d97351e99dcaba2650f5ad2b348ba28898e Mon Sep 17 00:00:00 2001 From: Chris Schaefer Date: Fri, 21 Mar 2014 17:14:24 -0400 Subject: [PATCH] General cleanup in spring-batch-samples * Delete unused classes, files, misc ide files * Cleanup checkstyle/pmd/findbugs reports * Add @Override as needed * Remove schema versions in xml configs * Remove unused imports * General tidying * Cleanup deprecated jdbctemplate methods * Fix @Ignored OrderItemReaderTests test --- spring-batch-samples/.fbprefs | 116 ----- spring-batch-samples/.springBeans | 413 ----------------- spring-batch-samples/hsql-manager.launch | 15 - spring-batch-samples/hsql-server.launch | 16 - spring-batch-samples/jalopy_customized.xml | 436 ------------------ spring-batch-samples/jmxLauncher.launch | 10 - spring-batch-samples/jobLauncher.launch | 10 - .../maven_checks_customized.xml | 166 ------- spring-batch-samples/pom.xml | 10 +- spring-batch-samples/server.properties | 5 - .../sample/common/ColumnRangePartitioner.java | 7 +- .../common/FieldSetResultSetExtractor.java | 65 --- .../sample/common/InfiniteLoopReader.java | 8 +- .../sample/common/InfiniteLoopWriter.java | 17 +- .../batch/sample/common/LogAdvice.java | 22 - .../sample/common/OutputFileNameListener.java | 5 - .../sample/common/StagingItemListener.java | 55 --- .../sample/common/StagingItemReader.java | 5 +- .../sample/common/StagingItemWriter.java | 26 +- .../config/RetrySampleConfiguration.java | 7 +- .../batch/sample/domain/football/Game.java | 18 +- .../sample/domain/football/PlayerSummary.java | 29 +- .../internal/FootballExceptionHandler.java | 40 -- .../mail/internal/TestMailErrorHandler.java | 8 +- .../domain/multiline/AggregateItem.java | 15 +- .../domain/multiline/AggregateItemReader.java | 41 +- .../batch/sample/domain/order/Address.java | 31 +- .../sample/domain/order/BillingInfo.java | 25 +- .../batch/sample/domain/order/Customer.java | 47 +- .../batch/sample/domain/order/LineItem.java | 26 +- .../batch/sample/domain/order/Order.java | 70 ++- .../batch/sample/domain/order/OrderDao.java | 27 -- .../sample/domain/order/ShippingInfo.java | 31 +- .../order/internal/OrderItemReader.java | 4 +- .../extractor/HeaderFieldExtractor.java | 4 +- .../internal/validator/OrderValidator.java | 24 +- .../domain/order/internal/xml/Order.java | 6 +- .../batch/sample/domain/person/Child.java | 36 +- .../batch/sample/domain/person/Person.java | 61 ++- .../sample/domain/person/PersonService.java | 12 +- .../domain/person/internal/PersonWriter.java | 8 +- .../sample/domain/trade/CustomerDebit.java | 25 +- .../domain/trade/CustomerOperation.java | 12 +- .../batch/sample/domain/trade/Trade.java | 38 +- .../CommonsLoggingInvalidCustomerLogger.java | 12 +- .../CustomerCreditFieldSetMapper.java | 5 +- .../CustomerCreditIncreaseProcessor.java | 4 +- .../internal/CustomerCreditItemWriter.java | 48 -- ...erCreditUpdatePreparedStatementSetter.java | 6 +- .../internal/CustomerCreditUpdateWriter.java | 4 +- .../internal/CustomerDebitRowMapper.java | 40 -- .../internal/IbatisCustomerCreditDao.java | 66 --- .../domain/trade/internal/TradeWriter.java | 5 +- .../internal/validator/TradeValidator.java | 1 - .../JobExecutionNotificationPublisher.java | 8 +- .../StepExecutionApplicationEventAdvice.java | 6 +- .../batch/sample/launch/DefaultJobLoader.java | 4 +- .../sample/launch/ExportedJobLoader.java | 37 -- .../rabbitmq/amqp/AmqpMessageProducer.java | 8 +- .../sample/support/HeaderCopyCallback.java | 13 +- .../sample/support/RetrySampleItemWriter.java | 4 +- .../main/resources/META-INF/persistence.xml | 5 +- .../META-INF/spring/config-beans.xml | 5 +- .../jobs/amqp/amqp-example-job-beans.xml | 2 +- .../spring/jobs/amqp/amqp-example-job.xml | 4 +- .../spring/jobs/messaging/rabbitmq-beans.xml | 4 +- .../resources/adhoc-job-launcher-context.xml | 8 +- .../main/resources/data-source-context.xml | 4 +- .../src/main/resources/hibernate-context.xml | 13 +- .../src/main/resources/ibatis-config.xml | 4 +- .../main/resources/ibatis-customer-credit.xml | 4 +- .../src/main/resources/jobs/adhocLoopJob.xml | 3 +- .../main/resources/jobs/amqp-example-job.xml | 4 +- .../jobs/beanWrapperMapperSampleJob.xml | 8 +- .../jobs/compositeItemWriterSampleJob.xml | 8 +- .../main/resources/jobs/customerFilterJob.xml | 6 +- .../src/main/resources/jobs/delegatingJob.xml | 8 +- .../src/main/resources/jobs/footballJob.xml | 4 +- .../src/main/resources/jobs/groovyJob.xml | 7 +- .../resources/jobs/headerFooterSample.xml | 7 +- .../src/main/resources/jobs/hibernateJob.xml | 7 +- .../main/resources/jobs/infiniteLoopJob.xml | 13 +- .../src/main/resources/jobs/ioSampleJob.xml | 6 +- .../resources/jobs/iosample/delimited.xml | 9 +- .../resources/jobs/iosample/fixedLength.xml | 9 +- .../main/resources/jobs/iosample/ibatis.xml | 2 - .../resources/jobs/iosample/jdbcCursor.xml | 10 +- .../resources/jobs/iosample/jdbcPaging.xml | 11 +- .../resources/jobs/iosample/multiLine.xml | 10 +- .../jobs/iosample/multiRecordType.xml | 23 +- .../resources/jobs/iosample/multiResource.xml | 10 +- .../src/main/resources/jobs/iosample/xml.xml | 6 +- .../src/main/resources/jobs/jobStepSample.xml | 2 +- .../main/resources/jobs/loopFlowSample.xml | 3 +- .../src/main/resources/jobs/mailJob.xml | 13 +- .../src/main/resources/jobs/multilineJob.xml | 3 +- .../jobs/multilineOrderInputTokenizers.xml | 1 - .../main/resources/jobs/multilineOrderJob.xml | 7 +- .../jobs/multilineOrderOutputAggregators.xml | 3 +- .../src/main/resources/jobs/parallelJob.xml | 3 +- .../main/resources/jobs/partitionFileJob.xml | 6 +- .../main/resources/jobs/partitionJdbcJob.xml | 8 +- .../resources/jobs/restartFileSampleJob.xml | 3 +- .../src/main/resources/jobs/restartSample.xml | 5 +- .../src/main/resources/jobs/retrySample.xml | 3 +- .../src/main/resources/jobs/skipSampleJob.xml | 3 +- .../src/main/resources/jobs/taskletJob.xml | 3 +- .../src/main/resources/jobs/tradeJob.xml | 3 +- .../batch/sample/config/common-context.xml | 9 +- .../batch/sample/football-job-context.xml | 4 +- .../resources/quartz-job-launcher-context.xml | 42 -- .../resources/simple-job-launcher-context.xml | 6 +- .../skipSample-job-launcher-context.xml | 9 +- .../main/resources/staging-test-context.xml | 5 +- .../src/main/resources/xstream-config.xml | 75 --- ...positeItemWriterSampleFunctionalTests.java | 12 +- .../CustomerFilterJobFunctionalTests.java | 14 +- .../sample/FootballJobFunctionalTests.java | 7 +- .../HibernateFailureJobFunctionalTests.java | 49 +- .../sample/JobOperatorFunctionalTests.java | 17 +- .../batch/sample/JobStepFunctionalTests.java | 10 +- .../PartitionFileJobFunctionalTests.java | 11 +- .../PartitionJdbcJobFunctionalTests.java | 8 +- .../batch/sample/RestartFunctionalTests.java | 14 +- .../batch/sample/TestSuite.java | 33 -- .../batch/sample/TradeJobFunctionalTests.java | 18 +- .../sample/common/CustomItemReaderTests.java | 31 +- .../sample/common/CustomItemWriterTests.java | 10 +- .../batch/sample/common/ErrorLogTasklet.java | 9 +- .../common/OutputFileListenerTests.java | 2 - .../sample/common/SkipCheckingDecider.java | 2 +- .../sample/common/StagingItemReaderTests.java | 13 +- .../sample/common/StagingItemWriterTests.java | 9 +- .../internal/JdbcGameDaoIntegrationTests.java | 11 +- .../JdbcPlayerDaoIntegrationTests.java | 21 +- .../JdbcPlayerSummaryDaoIntegrationTests.java | 14 +- .../AggregateItemFieldSetMapperTests.java | 4 - .../multiline/AggregateItemReaderTests.java | 14 +- .../domain/multiline/AggregateItemTests.java | 5 +- .../order/AddressFieldSetMapperTests.java | 4 +- .../order/BillingFieldSetMapperTests.java | 5 +- .../order/CustomerFieldSetMapperTests.java | 5 +- .../order/HeaderFieldSetMapperTests.java | 5 +- .../order/OrderItemFieldSetMapperTests.java | 5 +- .../domain/order/OrderItemReaderTests.java | 47 +- .../order/ShippingFieldSetMapperTests.java | 5 +- ...ositeCustomerUpdateLineTokenizerTests.java | 27 +- .../trade/CustomerUpdateProcessorTests.java | 26 +- .../batch/sample/domain/trade/TradeTests.java | 13 +- .../CustomerCreditIncreaseProcessorTests.java | 6 +- .../CustomerCreditRowMapperTests.java | 10 +- .../CustomerCreditUpdateProcessorTests.java | 21 +- .../CustomerUpdateProcessorTests.java | 11 +- .../FlatFileCustomerCreditDaoTests.java | 21 +- .../internal/ItemTrackingTradeItemWriter.java | 16 +- .../internal/JdbcCustomerDebitDaoTests.java | 13 +- .../trade/internal/JdbcTradeWriterTests.java | 12 +- .../internal/TradeFieldSetMapperTests.java | 8 +- .../trade/internal/TradeProcessorTests.java | 9 +- .../trade/internal/TradeRowMapperTests.java | 8 +- ...oJobInstancesDelimitedFunctionalTests.java | 11 +- .../TwoJobInstancesPagingFunctionalTests.java | 8 +- .../DelegatingTradeLineAggregator.java | 3 +- .../internal/MultiLineTradeItemReader.java | 9 +- .../internal/MultiLineTradeItemWriter.java | 9 +- .../internal/TradeCustomerItemWriter.java | 45 -- ...obExecutionNotificationPublisherTests.java | 7 +- .../sample/launch/RemoteLauncherTests.java | 33 +- .../quartz/JobLauncherDetailsTests.java | 19 +- .../src/test/resources/job-runner-context.xml | 6 +- .../sample/JobStepFunctionalTests-context.xml | 4 +- .../ColumnRangePartitionerTests-context.xml | 5 +- .../common/StagingItemReaderTests-context.xml | 7 +- .../common/StagingItemWriterTests-context.xml | 5 +- .../JdbcCustomerDebitDaoTests-context.xml | 5 +- 175 files changed, 737 insertions(+), 2820 deletions(-) delete mode 100644 spring-batch-samples/.fbprefs delete mode 100644 spring-batch-samples/.springBeans delete mode 100644 spring-batch-samples/hsql-manager.launch delete mode 100644 spring-batch-samples/hsql-server.launch delete mode 100644 spring-batch-samples/jalopy_customized.xml delete mode 100644 spring-batch-samples/jmxLauncher.launch delete mode 100644 spring-batch-samples/jobLauncher.launch delete mode 100644 spring-batch-samples/maven_checks_customized.xml delete mode 100644 spring-batch-samples/server.properties delete mode 100644 spring-batch-samples/src/main/java/org/springframework/batch/sample/common/FieldSetResultSetExtractor.java delete mode 100644 spring-batch-samples/src/main/java/org/springframework/batch/sample/common/OutputFileNameListener.java delete mode 100644 spring-batch-samples/src/main/java/org/springframework/batch/sample/common/StagingItemListener.java delete mode 100644 spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/football/internal/FootballExceptionHandler.java delete mode 100644 spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/OrderDao.java delete mode 100644 spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/internal/CustomerCreditItemWriter.java delete mode 100644 spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/internal/CustomerDebitRowMapper.java delete mode 100644 spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/internal/IbatisCustomerCreditDao.java delete mode 100644 spring-batch-samples/src/main/java/org/springframework/batch/sample/launch/ExportedJobLoader.java delete mode 100644 spring-batch-samples/src/main/resources/quartz-job-launcher-context.xml delete mode 100644 spring-batch-samples/src/main/resources/xstream-config.xml delete mode 100644 spring-batch-samples/src/test/java/org/springframework/batch/sample/TestSuite.java delete mode 100644 spring-batch-samples/src/test/java/org/springframework/batch/sample/iosample/internal/TradeCustomerItemWriter.java diff --git a/spring-batch-samples/.fbprefs b/spring-batch-samples/.fbprefs deleted file mode 100644 index d498aadba..000000000 --- a/spring-batch-samples/.fbprefs +++ /dev/null @@ -1,116 +0,0 @@ -#FindBugs User Preferences -#Wed Jul 23 12:11:15 BST 2008 -detectorAppendingToAnObjectOutputStream=AppendingToAnObjectOutputStream|true -detectorBadAppletConstructor=BadAppletConstructor|false -detectorBadResultSetAccess=BadResultSetAccess|true -detectorBadSyntaxForRegularExpression=BadSyntaxForRegularExpression|true -detectorBadUseOfReturnValue=BadUseOfReturnValue|true -detectorBadlyOverriddenAdapter=BadlyOverriddenAdapter|true -detectorBooleanReturnNull=BooleanReturnNull|true -detectorCheckImmutableAnnotation=CheckImmutableAnnotation|true -detectorCheckTypeQualifiers=CheckTypeQualifiers|true -detectorCloneIdiom=CloneIdiom|true -detectorComparatorIdiom=ComparatorIdiom|true -detectorConfusedInheritance=ConfusedInheritance|true -detectorConfusionBetweenInheritedAndOuterMethod=ConfusionBetweenInheritedAndOuterMethod|true -detectorCrossSiteScripting=CrossSiteScripting|true -detectorDoInsideDoPrivileged=DoInsideDoPrivileged|true -detectorDontCatchIllegalMonitorStateException=DontCatchIllegalMonitorStateException|true -detectorDontUseEnum=DontUseEnum|true -detectorDroppedException=DroppedException|true -detectorDumbMethodInvocations=DumbMethodInvocations|true -detectorDumbMethods=DumbMethods|true -detectorDuplicateBranches=DuplicateBranches|true -detectorEmptyZipFileEntry=EmptyZipFileEntry|true -detectorFinalizerNullsFields=FinalizerNullsFields|true -detectorFindBadCast2=FindBadCast2|true -detectorFindBadForLoop=FindBadForLoop|true -detectorFindCircularDependencies=FindCircularDependencies|false -detectorFindDeadLocalStores=FindDeadLocalStores|true -detectorFindDoubleCheck=FindDoubleCheck|true -detectorFindEmptySynchronizedBlock=FindEmptySynchronizedBlock|true -detectorFindFieldSelfAssignment=FindFieldSelfAssignment|true -detectorFindFinalizeInvocations=FindFinalizeInvocations|true -detectorFindFloatEquality=FindFloatEquality|true -detectorFindHEmismatch=FindHEmismatch|true -detectorFindInconsistentSync2=FindInconsistentSync2|true -detectorFindJSR166LockMonitorenter=FindJSR166LockMonitorenter|true -detectorFindLocalSelfAssignment2=FindLocalSelfAssignment2|true -detectorFindMaskedFields=FindMaskedFields|true -detectorFindMismatchedWaitOrNotify=FindMismatchedWaitOrNotify|true -detectorFindNakedNotify=FindNakedNotify|true -detectorFindNonSerializableStoreIntoSession=FindNonSerializableStoreIntoSession|true -detectorFindNonSerializableValuePassedToWriteObject=FindNonSerializableValuePassedToWriteObject|true -detectorFindNonShortCircuit=FindNonShortCircuit|true -detectorFindNullDeref=FindNullDeref|true -detectorFindOpenStream=FindOpenStream|true -detectorFindPuzzlers=FindPuzzlers|true -detectorFindRefComparison=FindRefComparison|true -detectorFindReturnRef=FindReturnRef|true -detectorFindRunInvocations=FindRunInvocations|true -detectorFindSelfComparison=FindSelfComparison|true -detectorFindSelfComparison2=FindSelfComparison2|true -detectorFindSleepWithLockHeld=FindSleepWithLockHeld|true -detectorFindSpinLoop=FindSpinLoop|true -detectorFindSqlInjection=FindSqlInjection|true -detectorFindTwoLockWait=FindTwoLockWait|true -detectorFindUncalledPrivateMethods=FindUncalledPrivateMethods|true -detectorFindUnconditionalWait=FindUnconditionalWait|true -detectorFindUninitializedGet=FindUninitializedGet|true -detectorFindUnrelatedTypesInGenericContainer=FindUnrelatedTypesInGenericContainer|true -detectorFindUnreleasedLock=FindUnreleasedLock|true -detectorFindUnsyncGet=FindUnsyncGet|true -detectorFindUselessControlFlow=FindUselessControlFlow|true -detectorHugeSharedStringConstants=HugeSharedStringConstants|true -detectorIDivResultCastToDouble=IDivResultCastToDouble|true -detectorIncompatMask=IncompatMask|true -detectorInefficientMemberAccess=InefficientMemberAccess|false -detectorInefficientToArray=InefficientToArray|true -detectorInfiniteLoop=InfiniteLoop|true -detectorInfiniteRecursiveLoop=InfiniteRecursiveLoop|true -detectorInfiniteRecursiveLoop2=InfiniteRecursiveLoop2|false -detectorInheritanceUnsafeGetResource=InheritanceUnsafeGetResource|true -detectorInitializationChain=InitializationChain|true -detectorInstantiateStaticClass=InstantiateStaticClass|true -detectorInvalidJUnitTest=InvalidJUnitTest|true -detectorIteratorIdioms=IteratorIdioms|true -detectorLazyInit=LazyInit|true -detectorLoadOfKnownNullValue=LoadOfKnownNullValue|true -detectorMethodReturnCheck=MethodReturnCheck|true -detectorMultithreadedInstanceAccess=MultithreadedInstanceAccess|true -detectorMutableLock=MutableLock|true -detectorMutableStaticFields=MutableStaticFields|true -detectorNaming=Naming|true -detectorNumberConstructor=NumberConstructor|true -detectorOverridingEqualsNotSymmetrical=OverridingEqualsNotSymmetrical|true -detectorPreferZeroLengthArrays=PreferZeroLengthArrays|true -detectorPublicSemaphores=PublicSemaphores|false -detectorQuestionableBooleanAssignment=QuestionableBooleanAssignment|true -detectorReadReturnShouldBeChecked=ReadReturnShouldBeChecked|true -detectorRedundantInterfaces=RedundantInterfaces|true -detectorRuntimeExceptionCapture=RuntimeExceptionCapture|true -detectorSerializableIdiom=SerializableIdiom|true -detectorStartInConstructor=StartInConstructor|true -detectorStaticCalendarDetector=StaticCalendarDetector|true -detectorStringConcatenation=StringConcatenation|true -detectorSuperfluousInstanceOf=SuperfluousInstanceOf|true -detectorSuspiciousThreadInterrupted=SuspiciousThreadInterrupted|true -detectorSwitchFallthrough=SwitchFallthrough|true -detectorSynchronizeAndNullCheckField=SynchronizeAndNullCheckField|true -detectorSynchronizeOnClassLiteralNotGetClass=SynchronizeOnClassLiteralNotGetClass|true -detectorSynchronizingOnContentsOfFieldToProtectField=SynchronizingOnContentsOfFieldToProtectField|true -detectorURLProblems=URLProblems|true -detectorUncallableMethodOfAnonymousClass=UncallableMethodOfAnonymousClass|true -detectorUnnecessaryMath=UnnecessaryMath|true -detectorUnreadFields=UnreadFields|true -detectorUseObjectEquals=UseObjectEquals|false -detectorUselessSubclassMethod=UselessSubclassMethod|false -detectorVarArgsProblems=VarArgsProblems|true -detectorVolatileUsage=VolatileUsage|true -detectorWaitInLoop=WaitInLoop|true -detectorWrongMapIterator=WrongMapIterator|true -detectorXMLFactoryBypass=XMLFactoryBypass|true -detector_threshold=2 -effort=default -filter_settings=Medium|BAD_PRACTICE,CORRECTNESS,I18N,MALICIOUS_CODE,MT_CORRECTNESS,PERFORMANCE,SECURITY,STYLE|false -filter_settings_neg=| diff --git a/spring-batch-samples/.springBeans b/spring-batch-samples/.springBeans deleted file mode 100644 index 291c24367..000000000 --- a/spring-batch-samples/.springBeans +++ /dev/null @@ -1,413 +0,0 @@ - - - 1 - - - - - - - src/main/resources/jobs/multilineJob.xml - src/main/resources/jobs/multilineOrderJob.xml - src/main/resources/jobs/tradeJob.xml - src/main/resources/jobs/restartSample.xml - src/main/resources/data-source-context.xml - src/main/resources/jobs/beanWrapperMapperSampleJob.xml - src/main/resources/jobs/adhocLoopJob.xml - src/main/resources/jobs/infiniteLoopJob.xml - src/main/resources/jobs/footballJob.xml - src/main/resources/jobs/delegatingJob.xml - src/main/resources/jobs/parallelJob.xml - src/main/resources/jobs/retrySample.xml - src/main/resources/simple-job-launcher-context.xml - src/main/resources/adhoc-job-launcher-context.xml - src/main/resources/quartz-job-launcher-context.xml - src/main/resources/jobs/skipSampleJob.xml - src/main/resources/jobs/multilineOrderInputTokenizers.xml - src/main/resources/jobs/multilineOrderOutputAggregators.xml - src/main/resources/jobs/compositeItemWriterSampleJob.xml - src/main/resources/hibernate-context.xml - src/main/resources/staging-test-context.xml - src/main/resources/org/springframework/batch/sample/config/common-context.xml - src/main/resources/jobs/headerFooterSample.xml - src/main/resources/jobs/customerFilterJob.xml - src/main/resources/skipSample-job-launcher-context.xml - src/main/resources/jobs/ioSampleJob.xml - src/main/resources/jobs/iosample/delimited.xml - src/main/resources/jobs/iosample/fixedLength.xml - src/main/resources/jobs/iosample/jdbcCursor.xml - src/main/resources/jobs/iosample/multiLine.xml - src/main/resources/jobs/iosample/multiRecordType.xml - src/main/resources/jobs/iosample/multiResource.xml - src/main/resources/jobs/iosample/xml.xml - src/main/resources/jobs/iosample/hibernate.xml - src/main/resources/jobs/hibernateJob.xml - src/main/resources/jobs/iosample/jpa.xml - src/main/resources/jobs/iosample/ibatis.xml - src/test/resources/org/springframework/batch/sample/domain/trade/internal/JdbcCustomerDebitDaoTests-context.xml - src/main/resources/jobs/loopFlowSample.xml - src/test/resources/org/springframework/batch/sample/common/StagingItemReaderTests-context.xml - src/test/resources/org/springframework/batch/sample/common/StagingItemWriterTests-context.xml - src/main/resources/jobs/multilineOrderValidator.xml - src/main/resources/jobs/restartFileSampleJob.xml - src/main/resources/jobs/taskletJob.xml - src/main/resources/org/springframework/batch/sample/football-job-context.xml - src/main/resources/jobs/groovyJob.xml - src/main/resources/jobs/iosample/jdbcPaging.xml - src/main/resources/jobs/partitionJdbcJob.xml - src/main/resources/jobs/jobStepSample.xml - src/main/resources/jobs/partitionFileJob.xml - src/test/resources/org/springframework/batch/sample/common/ColumnRangePartitionerTests-context.xml - src/test/resources/job-runner-context.xml - src/test/resources/org/springframework/batch/sample/JobStepFunctionalTests-context.xml - src/main/resources/jobs/mailJob.xml - - - - - true - false - - src/main/resources/data-source-context.xml - - - - - true - false - - src/main/resources/jobs/beanWrapperMapperSampleJob.xml - src/main/resources/data-source-context.xml - src/main/resources/simple-job-launcher-context.xml - src/main/resources/org/springframework/batch/sample/config/common-context.xml - - - - - true - false - - src/main/resources/data-source-context.xml - src/main/resources/jobs/delegatingJob.xml - src/main/resources/simple-job-launcher-context.xml - src/main/resources/org/springframework/batch/sample/config/common-context.xml - - - - - true - false - - src/main/resources/data-source-context.xml - src/main/resources/jobs/footballJob.xml - src/main/resources/simple-job-launcher-context.xml - src/main/resources/org/springframework/batch/sample/config/common-context.xml - - - - - true - false - - src/main/resources/jobs/infiniteLoopJob.xml - src/main/resources/data-source-context.xml - src/main/resources/simple-job-launcher-context.xml - src/main/resources/org/springframework/batch/sample/config/common-context.xml - - - - - true - false - - src/main/resources/data-source-context.xml - src/main/resources/jobs/multilineJob.xml - src/main/resources/simple-job-launcher-context.xml - src/main/resources/org/springframework/batch/sample/config/common-context.xml - - - - - true - false - - src/main/resources/data-source-context.xml - src/main/resources/jobs/parallelJob.xml - src/main/resources/simple-job-launcher-context.xml - src/main/resources/org/springframework/batch/sample/config/common-context.xml - - - - - true - false - - src/main/resources/data-source-context.xml - src/main/resources/jobs/restartSample.xml - src/main/resources/simple-job-launcher-context.xml - src/main/resources/org/springframework/batch/sample/config/common-context.xml - - - - - true - false - - src/main/resources/jobs/retrySample.xml - src/main/resources/data-source-context.xml - src/main/resources/simple-job-launcher-context.xml - src/main/resources/org/springframework/batch/sample/config/common-context.xml - - - - - true - false - - src/main/resources/data-source-context.xml - src/main/resources/jobs/tradeJob.xml - src/main/resources/simple-job-launcher-context.xml - src/main/resources/org/springframework/batch/sample/config/common-context.xml - - - - - true - false - - src/main/resources/data-source-context.xml - src/main/resources/simple-job-launcher-context.xml - src/main/resources/org/springframework/batch/sample/config/common-context.xml - - - - - true - false - - src/main/resources/data-source-context.xml - src/main/resources/quartz-job-launcher-context.xml - src/main/resources/simple-job-launcher-context.xml - src/main/resources/org/springframework/batch/sample/config/common-context.xml - - - - - true - false - - src/main/resources/data-source-context.xml - src/main/resources/simple-job-launcher-context.xml - src/main/resources/org/springframework/batch/sample/config/common-context.xml - src/main/resources/jobs/compositeItemWriterSampleJob.xml - - - - - true - false - - src/main/resources/jobs/adhocLoopJob.xml - src/main/resources/data-source-context.xml - src/main/resources/simple-job-launcher-context.xml - src/main/resources/org/springframework/batch/sample/config/common-context.xml - - - - - true - false - - src/main/resources/data-source-context.xml - src/main/resources/staging-test-context.xml - - - - - true - false - - src/main/resources/data-source-context.xml - src/main/resources/org/springframework/batch/sample/config/common-context.xml - src/main/resources/simple-job-launcher-context.xml - - - - - true - false - - src/main/resources/adhoc-job-launcher-context.xml - src/main/resources/data-source-context.xml - src/main/resources/simple-job-launcher-context.xml - src/main/resources/org/springframework/batch/sample/config/common-context.xml - - - - - true - false - - src/main/resources/data-source-context.xml - src/main/resources/jobs/headerFooterSample.xml - src/main/resources/org/springframework/batch/sample/config/common-context.xml - src/main/resources/simple-job-launcher-context.xml - - - - - true - false - - src/main/resources/jobs/customerFilterJob.xml - src/main/resources/simple-job-launcher-context.xml - src/main/resources/data-source-context.xml - src/main/resources/org/springframework/batch/sample/config/common-context.xml - - - - - true - false - - src/main/resources/data-source-context.xml - src/main/resources/simple-job-launcher-context.xml - src/main/resources/org/springframework/batch/sample/config/common-context.xml - src/main/resources/hibernate-context.xml - src/main/resources/jobs/hibernateJob.xml - - - - - true - false - - src/main/resources/data-source-context.xml - src/main/resources/simple-job-launcher-context.xml - src/main/resources/org/springframework/batch/sample/config/common-context.xml - - - - - true - false - - src/main/resources/data-source-context.xml - src/main/resources/jobs/skipSampleJob.xml - src/main/resources/org/springframework/batch/sample/config/common-context.xml - src/main/resources/skipSample-job-launcher-context.xml - - - - - true - false - - src/main/resources/data-source-context.xml - src/main/resources/jobs/ioSampleJob.xml - src/main/resources/org/springframework/batch/sample/config/common-context.xml - src/main/resources/simple-job-launcher-context.xml - src/main/resources/hibernate-context.xml - src/main/resources/jobs/iosample/hibernate.xml - - - - - true - false - - src/main/resources/data-source-context.xml - src/main/resources/jobs/iosample/jdbcCursor.xml - src/main/resources/jobs/ioSampleJob.xml - src/main/resources/org/springframework/batch/sample/config/common-context.xml - src/main/resources/simple-job-launcher-context.xml - - - - - true - false - - src/main/resources/data-source-context.xml - src/main/resources/jobs/iosample/multiLine.xml - src/main/resources/org/springframework/batch/sample/config/common-context.xml - src/main/resources/simple-job-launcher-context.xml - - - - - true - false - - src/main/resources/data-source-context.xml - src/main/resources/jobs/iosample/multiRecordType.xml - src/main/resources/org/springframework/batch/sample/config/common-context.xml - src/main/resources/simple-job-launcher-context.xml - - - - - true - false - - src/main/resources/data-source-context.xml - src/main/resources/jobs/iosample/jpa.xml - src/main/resources/jobs/ioSampleJob.xml - src/main/resources/org/springframework/batch/sample/config/common-context.xml - src/main/resources/simple-job-launcher-context.xml - - - - - true - false - - - - - - true - false - - src/main/resources/data-source-context.xml - src/main/resources/simple-job-launcher-context.xml - src/main/resources/org/springframework/batch/sample/config/common-context.xml - src/main/resources/jobs/iosample/ibatis.xml - - - - - true - false - - src/main/resources/data-source-context.xml - src/main/resources/simple-job-launcher-context.xml - - - - - true - false - - src/main/resources/data-source-context.xml - src/main/resources/jobs/multilineOrderJob.xml - src/main/resources/simple-job-launcher-context.xml - src/main/resources/org/springframework/batch/sample/config/common-context.xml - src/main/resources/jobs/multilineOrderInputTokenizers.xml - src/main/resources/jobs/multilineOrderOutputAggregators.xml - src/main/resources/jobs/multilineOrderValidator.xml - - - - - true - false - - src/main/resources/data-source-context.xml - src/main/resources/jobs/restartFileSampleJob.xml - src/main/resources/simple-job-launcher-context.xml - src/main/resources/org/springframework/batch/sample/config/common-context.xml - - - - diff --git a/spring-batch-samples/hsql-manager.launch b/spring-batch-samples/hsql-manager.launch deleted file mode 100644 index 339e9b47b..000000000 --- a/spring-batch-samples/hsql-manager.launch +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/spring-batch-samples/hsql-server.launch b/spring-batch-samples/hsql-server.launch deleted file mode 100644 index 3b569d6d3..000000000 --- a/spring-batch-samples/hsql-server.launch +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/spring-batch-samples/jalopy_customized.xml b/spring-batch-samples/jalopy_customized.xml deleted file mode 100644 index 459f95a14..000000000 --- a/spring-batch-samples/jalopy_customized.xml +++ /dev/null @@ -1,436 +0,0 @@ - - - - - 14 - - - - - true - - - [A-Z][a-zA-Z0-9]+ - [A-Z][a-zA-Z0-9]+ - - - [a-z][\w]+ - [a-z][\w]+ - [a-zA-Z][\w]+ - [a-z][\w]+ - [a-z][\w]+ - [a-zA-Z][\w]+ - [a-z][\w]+ - [a-z][\w]+ - [a-zA-Z][\w]+ - [a-z][\w]+ - [a-z][\w]+ - [a-zA-Z][\w]+ - - [A-Z][a-zA-Z0-9]+ - \w+ - - [a-z][\w]+ - [a-z][\w]+ - [a-z][\w]+ - [a-z][\w]+ - [a-z][\w]+ - [a-z][\w]+ - [a-z][\w]+ - [a-z][\w]+ - [a-z][\w]+ - [a-z][\w]+ - [a-z][\w]+ - [a-z][\w]+ - - [a-z]+(?:\.[a-z]+)* - - [a-z][\w]+ - [a-z][\w]+ - - [a-z][\w]* - - - false - false - false - false - false - false - false - false - false - false - false - false - false - false - false - false - false - false - false - - - - 6 - - - - 30000 - 30000 - 30000 - 30000 - 30000 - 30000 - - true - - - 1 - - - - true - false - true - false - false - false - - - bak - 0 - - - - 1 - 0 - 1 - 0 -
1
-
0
- 1 - 2 - 1 - 1 -
- - 1 - 0 - 1 - - 1 - 1 - 1 - - 1 - 1 -
0
-
0
-
- 1 -
- - false - - - - false - false - - - false - false - true - false - - - true - false - false - false - false - - - false - false - - - - true - true - - - - true - - - - false - true - true - - true - - 0 - 0 - 0 - 0 - - false - true - - false - - - - @task - - - /**| * DOCUMENT ME!| *| * @author $author$| * @version $Revision: 1.9 $| */ - - */ - * @throws $exceptionType$ DOCUMENT ME! - * @param $paramType$ DOCUMENT ME! - /**| * Creates a new $objectType$ object. - - /**| * DOCUMENT ME!| *| * @author $author$| * @version $Revision: 1.9 $| */ - - */ - * @throws $exceptionType$ DOCUMENT ME! - * @param $paramType$ DOCUMENT ME! - * @return DOCUMENT ME! - /**| * DOCUMENT ME! - - /** DOCUMENT ME! */ - - - - false - false - false - - - - - false - false - - Annotations - Inner Classes - Constructors - Enumerations - Instance fields - Instance initializers - Inner Interfaces - Methods - Static fields/initializers - - - - -
- false - - 0 - false -
-
- true - Geotools2 - OpenSource mapping toolkit - 0 - /*| * GeoTools - OpenSource mapping toolkit| * http://geotools.org| * (C) 2002-2006, GeoTools Project Managment Committee (PMC)| *| * This library is free software; you can redistribute it and/or| * modify it under the terms of the GNU Lesser General Public| * License as published by the Free Software Foundation;| * version 2.1 of the License.| *| * This library is distributed in the hope that it will be useful,| * but WITHOUT ANY WARRANTY; without even the implied warranty of| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU| * Lesser General Public License for more details.| */ - false -
- - disabled - - - - 0 - *:0|java:1|javax:1|org.springframework:3|com.accenture:2 - - disabled - true - - - false - - true - false - - true - - - false - - - 1 - 1 - 0 - 1 - 4 - 55 - -1 - 4 - -1 - 0 - 8 - -1 - 1 - - - false - false - - - - false - false - false - true - false - true - false - - false - - - - - false - false - false - true - false - false - - false - - static|field|initializer|constructor|method|interface|class|annotation|enum - false - - - false - public=true|protected=true|private=true|abstract=true|static=true|final=true|synchronized=true|transient=true|volatile=true|native=true|strictfp=true - - - - - true - true - true - - - true - false - false - false - - false - - - false - false - true - - - - true - false - - true - true - true - true - true - true - - false - false - - - - - - 0 - false - false - false - - false - - false - false - - false - - - false - false - false - false - - - false - false - false - - - - - 2147483647 - - - true - - - - - 2147483647 - - - true - - - - - 2147483647 - - - true - - - - true - true - 100 - - - - false - false - false - - false - false - false - - - - false - - - false - - false - - false - - - -
-
diff --git a/spring-batch-samples/jmxLauncher.launch b/spring-batch-samples/jmxLauncher.launch deleted file mode 100644 index ef309a72e..000000000 --- a/spring-batch-samples/jmxLauncher.launch +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/spring-batch-samples/jobLauncher.launch b/spring-batch-samples/jobLauncher.launch deleted file mode 100644 index 5c39d9e9a..000000000 --- a/spring-batch-samples/jobLauncher.launch +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/spring-batch-samples/maven_checks_customized.xml b/spring-batch-samples/maven_checks_customized.xml deleted file mode 100644 index 654b243d3..000000000 --- a/spring-batch-samples/maven_checks_customized.xml +++ /dev/null @@ -1,166 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/spring-batch-samples/pom.xml b/spring-batch-samples/pom.xml index 2f5ed9b78..73f4ea543 100644 --- a/spring-batch-samples/pom.xml +++ b/spring-batch-samples/pom.xml @@ -383,15 +383,7 @@ - + gemstone Release bundles for SQLFire and GemFire http://dist.gemstone.com.s3.amazonaws.com/maven/release diff --git a/spring-batch-samples/server.properties b/spring-batch-samples/server.properties deleted file mode 100644 index f40f3db45..000000000 --- a/spring-batch-samples/server.properties +++ /dev/null @@ -1,5 +0,0 @@ -server.port=9005 -server.trace=true - -server.database.0=file:target/hsqldb-data/samples -server.dbname.0=samples diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/ColumnRangePartitioner.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/ColumnRangePartitioner.java index dd9c11e6e..595174f2f 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/ColumnRangePartitioner.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/ColumnRangePartitioner.java @@ -62,9 +62,9 @@ public class ColumnRangePartitioner implements Partitioner { * @see Partitioner#partition(int) */ public Map partition(int gridSize) { + int min = jdbcTemplate.queryForObject("SELECT MIN(" + column + ") from " + table, Integer.class); + int max = jdbcTemplate.queryForObject("SELECT MAX(" + column + ") from " + table, Integer.class); - int min = jdbcTemplate.queryForInt("SELECT MIN(" + column + ") from " + table); - int max = jdbcTemplate.queryForInt("SELECT MAX(" + column + ") from " + table); int targetSize = (max - min) / gridSize + 1; Map result = new HashMap(); @@ -73,7 +73,6 @@ public class ColumnRangePartitioner implements Partitioner { int end = start + targetSize - 1; while (start <= max) { - ExecutionContext value = new ExecutionContext(); result.put("partition" + number, value); @@ -88,7 +87,5 @@ public class ColumnRangePartitioner implements Partitioner { } return result; - } - } diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/FieldSetResultSetExtractor.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/FieldSetResultSetExtractor.java deleted file mode 100644 index cf20d19ba..000000000 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/FieldSetResultSetExtractor.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright 2006-2007 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.batch.sample.common; - -import java.sql.ResultSet; -import java.sql.ResultSetMetaData; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; - -import org.springframework.batch.item.file.transform.DefaultFieldSet; -import org.springframework.batch.item.file.transform.FieldSet; - -/** - * ResultSetExtractor implementation that returns list of FieldSets - * for given ResultSet. - * - * @author peter.zozom - * - */ -public final class FieldSetResultSetExtractor { - - // utility class not meant for instantiation - private FieldSetResultSetExtractor(){} - - /** - * Processes single row in ResultSet and returns its FieldSet representation. - * @param rs ResultSet ResultSet to extract data from. - * @return FieldSet representation of current row in ResultSet - * @throws SQLException thrown during processing - */ - public static FieldSet getFieldSet(ResultSet rs) throws SQLException { - ResultSetMetaData metaData = rs.getMetaData(); - int columnCount = metaData.getColumnCount(); - - FieldSet fs; - - List tokens = new ArrayList(); - List names = new ArrayList(); - - for (int i = 1; i <= columnCount; i++) { - tokens.add(rs.getString(i)); - names.add(metaData.getColumnName(i)); - } - - fs = new DefaultFieldSet(tokens.toArray(new String[0]), names.toArray(new String[0])); - - return fs; - } - -} diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/InfiniteLoopReader.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/InfiniteLoopReader.java index ff0a71ac1..552d57b15 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/InfiniteLoopReader.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/InfiniteLoopReader.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,8 +17,6 @@ package org.springframework.batch.sample.common; import org.springframework.batch.item.ItemReader; -import org.springframework.batch.item.ParseException; -import org.springframework.batch.item.UnexpectedInputException; /** * ItemReader implementation that will continually return a new object. It's @@ -28,9 +26,7 @@ import org.springframework.batch.item.UnexpectedInputException; * */ public class InfiniteLoopReader implements ItemReader { - - public Object read() throws Exception, UnexpectedInputException, ParseException { + public Object read() throws Exception { return new Object(); } - } diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/InfiniteLoopWriter.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/InfiniteLoopWriter.java index feae9acc0..bad7de40f 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/InfiniteLoopWriter.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/InfiniteLoopWriter.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +21,6 @@ import java.util.List; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.batch.core.StepExecution; -import org.springframework.batch.core.StepExecutionListener; import org.springframework.batch.core.listener.StepExecutionListenerSupport; import org.springframework.batch.item.ItemWriter; @@ -34,24 +33,19 @@ import org.springframework.batch.item.ItemWriter; * */ public class InfiniteLoopWriter extends StepExecutionListenerSupport implements ItemWriter { + private static final Log LOG = LogFactory.getLog(InfiniteLoopWriter.class); private StepExecution stepExecution; - private int count = 0; - private static final Log logger = LogFactory.getLog(InfiniteLoopWriter.class); - /** - * @see StepExecutionListener#beforeStep(StepExecution) + * @see org.springframework.batch.core.StepExecutionListener#beforeStep(StepExecution) */ @Override public void beforeStep(StepExecution stepExecution) { this.stepExecution = stepExecution; } - /** - * - */ public InfiniteLoopWriter() { super(); } @@ -62,9 +56,10 @@ public class InfiniteLoopWriter extends StepExecutionListenerSupport implements } catch (InterruptedException e) { Thread.currentThread().interrupt(); - throw new RuntimeException("Job interrupted."); + throw new IllegalStateException("Job interrupted.", e); } + stepExecution.setWriteCount(++count); - logger.info("Executing infinite loop, at count=" + count); + LOG.info("Executing infinite loop, at count=" + count); } } diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/LogAdvice.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/LogAdvice.java index aa29fb202..e03f28008 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/LogAdvice.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/LogAdvice.java @@ -18,8 +18,6 @@ package org.springframework.batch.sample.common; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.aspectj.lang.JoinPoint; - /** * Wraps calls for 'Processing' methods which output a single Object to write @@ -28,29 +26,9 @@ import org.aspectj.lang.JoinPoint; * @author Lucas Ward */ public class LogAdvice { - private static Log log = LogFactory.getLog(LogAdvice.class); - /* - * Wraps original method and adds logging both before and after method - */ - public void doBasicLogging(JoinPoint pjp) throws Throwable { - Object[] args = pjp.getArgs(); - StringBuffer output = new StringBuffer(); - - output.append(pjp.getTarget().getClass().getName()).append(": "); - output.append(pjp.toShortString()).append(": "); - - for (Object arg : args) { - output.append(arg).append(" "); - } - - - log.info("Basic: " + output.toString()); - } - public void doStronglyTypedLogging(Object item){ log.info("Processed: " + item); } - } diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/OutputFileNameListener.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/OutputFileNameListener.java deleted file mode 100644 index 64c0c4054..000000000 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/OutputFileNameListener.java +++ /dev/null @@ -1,5 +0,0 @@ -package org.springframework.batch.sample.common; - -public class OutputFileNameListener { - -} diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/StagingItemListener.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/StagingItemListener.java deleted file mode 100644 index e4012611b..000000000 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/StagingItemListener.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2006-2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.batch.sample.common; - -import javax.sql.DataSource; - -import org.springframework.batch.core.listener.StepListenerSupport; -import org.springframework.batch.item.ItemReader; -import org.springframework.beans.factory.InitializingBean; -import org.springframework.dao.OptimisticLockingFailureException; -import org.springframework.jdbc.core.JdbcOperations; -import org.springframework.jdbc.core.JdbcTemplate; -import org.springframework.util.Assert; - -/** - * Thread-safe database {@link ItemReader} implementing the process indicator - * pattern. - */ -public class StagingItemListener extends StepListenerSupport implements InitializingBean { - - private JdbcOperations jdbcTemplate; - - public void setDataSource(DataSource dataSource) { - jdbcTemplate = new JdbcTemplate(dataSource); - } - - public final void afterPropertiesSet() throws Exception { - Assert.notNull(jdbcTemplate, "You must provide a DataSource."); - } - - @Override - public void afterRead(Long id) { - int count = jdbcTemplate.update("UPDATE BATCH_STAGING SET PROCESSED=? WHERE ID=? AND PROCESSED=?", - StagingItemWriter.DONE, id, StagingItemWriter.NEW); - if (count != 1) { - throw new OptimisticLockingFailureException("The staging record with ID=" + id - + " was updated concurrently when trying to mark as complete (updated " + count + " records."); - } - } - -} diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/StagingItemReader.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/StagingItemReader.java index 99e05d148..fa706ec62 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/StagingItemReader.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/StagingItemReader.java @@ -32,7 +32,6 @@ import org.springframework.batch.item.ItemReader; import org.springframework.batch.item.ReaderNotOpenException; import org.springframework.beans.factory.DisposableBean; import org.springframework.beans.factory.InitializingBean; -import org.springframework.dao.DataAccessException; import org.springframework.jdbc.core.JdbcOperations; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.simple.ParameterizedRowMapper; @@ -97,8 +96,7 @@ InitializingBean, DisposableBean { } @Override - public ProcessIndicatorItemWrapper read() throws DataAccessException { - + public ProcessIndicatorItemWrapper read() { if (!initialized) { throw new ReaderNotOpenException("Reader must be open before it can be used."); } @@ -125,7 +123,6 @@ InitializingBean, DisposableBean { }, id); return new ProcessIndicatorItemWrapper(id, result); - } @Override diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/StagingItemWriter.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/StagingItemWriter.java index 865b8f3bb..80068eaf7 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/StagingItemWriter.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/StagingItemWriter.java @@ -37,11 +37,9 @@ import org.springframework.util.SerializationUtils; */ public class StagingItemWriter extends JdbcDaoSupport implements StepExecutionListener, ItemWriter { - public static final String NEW = "N"; + protected static final String NEW = "N"; - public static final String DONE = "Y"; - - public static final Object WORKING = "W"; + protected static final String DONE = "Y"; private DataFieldMaxValueIncrementer incrementer; @@ -75,11 +73,10 @@ public class StagingItemWriter extends JdbcDaoSupport implements StepExecutio */ @Override public void write(final List items) { - final ListIterator itemIterator = items.listIterator(); + getJdbcTemplate().batchUpdate("INSERT into BATCH_STAGING (ID, JOB_ID, VALUE, PROCESSED) values (?,?,?,?)", new BatchPreparedStatementSetter() { - @Override public int getBatchSize() { return items.size(); @@ -87,22 +84,14 @@ public class StagingItemWriter extends JdbcDaoSupport implements StepExecutio @Override public void setValues(PreparedStatement ps, int i) throws SQLException { + Assert.state(itemIterator.nextIndex() == i, "Item ordering must be preserved in batch sql update"); - long id = incrementer.nextLongValue(); - long jobId = stepExecution.getJobExecution().getJobId(); - - Assert.state(itemIterator.nextIndex() == i, - "Item ordering must be preserved in batch sql update"); - - byte[] blob = SerializationUtils.serialize(itemIterator.next()); - - ps.setLong(1, id); - ps.setLong(2, jobId); - ps.setBytes(3, blob); + ps.setLong(1, incrementer.nextLongValue()); + ps.setLong(2, stepExecution.getJobExecution().getJobId()); + ps.setBytes(3, SerializationUtils.serialize(itemIterator.next())); ps.setString(4, NEW); } }); - } /* @@ -127,5 +116,4 @@ public class StagingItemWriter extends JdbcDaoSupport implements StepExecutio public void beforeStep(StepExecution stepExecution) { this.stepExecution = stepExecution; } - } diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/config/RetrySampleConfiguration.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/config/RetrySampleConfiguration.java index 4b40f7f33..a25f878a4 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/config/RetrySampleConfiguration.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/config/RetrySampleConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2013 the original author or authors. + * Copyright 2012-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,12 +42,12 @@ public class RetrySampleConfiguration { private StepBuilderFactory steps; @Bean - public Job retrySample() throws Exception { + public Job retrySample() { return jobs.get("retrySample").start(step()).build(); } @Bean - protected Step step() throws Exception { + protected Step step() { return steps.get("step"). chunk(1).reader(reader()).writer(writer()).faultTolerant() .retry(Exception.class).retryLimit(3).build(); } @@ -63,5 +63,4 @@ public class RetrySampleConfiguration { protected ItemWriter writer() { return new RetrySampleItemWriter(); } - } diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/football/Game.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/football/Game.java index 531a0c537..f4cf63891 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/football/Game.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/football/Game.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -232,19 +232,25 @@ public class Game implements Serializable { } @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) + } + if (obj == null) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } Game other = (Game) obj; if (id == null) { - if (other.id != null) + if (other.id != null) { return false; + } } - else if (!id.equals(other.id)) + else if (!id.equals(other.id)) { return false; + } + return true; } diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/football/PlayerSummary.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/football/PlayerSummary.java index a8ef969a8..ffd50ca67 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/football/PlayerSummary.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/football/PlayerSummary.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,19 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.springframework.batch.sample.domain.football; - /** * Domain object representing the summary of a given Player's * year. * * @author Lucas Ward - * */ public class PlayerSummary { - private String id; private int year; private int completes; @@ -111,13 +107,14 @@ public class PlayerSummary { public void setTotalTd(int totalTd) { this.totalTd = totalTd; } - - + + @Override public String toString() { return "Player Summary: ID=" + id + " Year=" + year + "[" + completes + ";" + attempts + ";" + passingYards + ";" + passingTd + ";" + interceptions + ";" + rushes + ";" + rushYards + ";" + receptions + ";" + receptionYards + ";" + totalTd; } + @Override public int hashCode() { final int prime = 31; @@ -125,22 +122,28 @@ public class PlayerSummary { result = prime * result + ((id == null) ? 0 : id.hashCode()); return result; } + @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) + } + if (obj == null) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } PlayerSummary other = (PlayerSummary) obj; if (id == null) { - if (other.id != null) + if (other.id != null) { return false; + } } - else if (!id.equals(other.id)) + else if (!id.equals(other.id)) { return false; + } + return true; } - } diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/football/internal/FootballExceptionHandler.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/football/internal/FootballExceptionHandler.java deleted file mode 100644 index a1ff7afcb..000000000 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/football/internal/FootballExceptionHandler.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2006-2007 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.batch.sample.domain.football.internal; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.batch.repeat.RepeatContext; -import org.springframework.batch.repeat.exception.ExceptionHandler; - -public class FootballExceptionHandler implements ExceptionHandler { - - private static final Log logger = LogFactory - .getLog(FootballExceptionHandler.class); - - public void handleException(RepeatContext context, Throwable throwable) - throws Throwable { - - if (!(throwable instanceof NumberFormatException)) { - throw throwable; - } else { - logger.error("Number Format Exception!", throwable); - } - - } - -} diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/mail/internal/TestMailErrorHandler.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/mail/internal/TestMailErrorHandler.java index 4b18f54c8..c8ae95d4f 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/mail/internal/TestMailErrorHandler.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/mail/internal/TestMailErrorHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2010 the original author or authors. + * Copyright 2006-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,6 +19,8 @@ import java.util.ArrayList; import java.util.List; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.springframework.batch.item.mail.MailErrorHandler; import org.springframework.mail.MailMessage; @@ -33,13 +35,13 @@ import org.springframework.mail.MailMessage; * @since 2.1 */ public class TestMailErrorHandler implements MailErrorHandler { + private static final Log LOGGER = LogFactory.getLog(TestMailErrorHandler.class); private List failedMessages = new ArrayList(); public void handle(MailMessage failedMessage, Exception ex) { this.failedMessages.add(failedMessage); - System.out.println("Mail message failed: " + failedMessage); - System.out.println(ex); + LOGGER.error("Mail message failed: " + failedMessage, ex); } public List getFailedMessages() { diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/multiline/AggregateItem.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/multiline/AggregateItem.java index 708de125b..657b72dc8 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/multiline/AggregateItem.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/multiline/AggregateItem.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,8 +15,6 @@ */ package org.springframework.batch.sample.domain.multiline; -import org.springframework.batch.item.ItemReaderException; - /** * A wrapper type for an item that is used by {@link AggregateItemReader} to * identify the start and end of an aggregate record. @@ -27,11 +25,10 @@ import org.springframework.batch.item.ItemReaderException; * */ public class AggregateItem { - @SuppressWarnings("rawtypes") private static final AggregateItem FOOTER = new AggregateItem(false, true) { @Override - public Object getItem() throws ItemReaderException { + public Object getItem() { throw new IllegalStateException("Footer record has no item."); } }; @@ -41,14 +38,14 @@ public class AggregateItem { * @return a static {@link AggregateItem} that is a footer. */ @SuppressWarnings("unchecked") - public static final AggregateItem getFooter() { + public static AggregateItem getFooter() { return FOOTER; } @SuppressWarnings("rawtypes") private static final AggregateItem HEADER = new AggregateItem(true, false) { @Override - public Object getItem() throws ItemReaderException { + public Object getItem() { throw new IllegalStateException("Header record has no item."); } }; @@ -58,7 +55,7 @@ public class AggregateItem { * @return a static {@link AggregateItem} that is a header. */ @SuppressWarnings("unchecked") - public static final AggregateItem getHeader() { + public static AggregateItem getHeader() { return HEADER; } @@ -89,7 +86,7 @@ public class AggregateItem { * @throws IllegalStateException if called on a record for which either * {@link #isHeader()} or {@link #isFooter()} answers true. */ - public T getItem() throws IllegalStateException { + public T getItem() { return item; } diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/multiline/AggregateItemReader.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/multiline/AggregateItemReader.java index 2b12ced75..722833e7f 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/multiline/AggregateItemReader.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/multiline/AggregateItemReader.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,8 +42,7 @@ import org.springframework.batch.item.ItemReader; * */ public class AggregateItemReader implements ItemReader> { - - private static final Log log = LogFactory.getLog(AggregateItemReader.class); + private static final Log LOG = LogFactory.getLog(AggregateItemReader.class); private ItemReader> itemReader; @@ -60,8 +59,8 @@ public class AggregateItemReader implements ItemReader> { continue; } - if (!holder.exhausted) { - return holder.records; + if (!holder.isExhausted()) { + return holder.getRecords(); } else { return null; @@ -71,26 +70,26 @@ public class AggregateItemReader implements ItemReader> { private boolean process(AggregateItem value, ResultHolder holder) { // finish processing if we hit the end of file if (value == null) { - log.debug("Exhausted ItemReader"); - holder.exhausted = true; + LOG.debug("Exhausted ItemReader"); + holder.setExhausted(true); return false; } // start a new collection if (value.isHeader()) { - log.debug("Start of new record detected"); + LOG.debug("Start of new record detected"); return true; } // mark we are finished with current collection if (value.isFooter()) { - log.debug("End of record detected"); + LOG.debug("End of record detected"); return false; } // add a simple record to the current collection - log.debug("Mapping: " + value); - holder.records.add(value.getItem()); + LOG.debug("Mapping: " + value); + holder.addRecord(value.getItem()); return true; } @@ -106,9 +105,23 @@ public class AggregateItemReader implements ItemReader> { * */ private class ResultHolder { - List records = new ArrayList(); + private List records = new ArrayList(); + private boolean exhausted = false; - boolean exhausted = false; + public List getRecords() { + return records; + } + + public boolean isExhausted() { + return exhausted; + } + + public void addRecord(T record) { + records.add(record); + } + + public void setExhausted(boolean exhausted) { + this.exhausted = exhausted; + } } - } diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/Address.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/Address.java index 1d58a2c63..5d1dc7ebc 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/Address.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/Address.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -109,32 +109,41 @@ public class Address { @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) + } + if (obj == null) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } Address other = (Address) obj; if (addressee == null) { - if (other.addressee != null) + if (other.addressee != null) { return false; + } } - else if (!addressee.equals(other.addressee)) + else if (!addressee.equals(other.addressee)) { return false; + } if (country == null) { - if (other.country != null) + if (other.country != null) { return false; + } } - else if (!country.equals(other.country)) + else if (!country.equals(other.country)) { return false; + } if (zipCode == null) { - if (other.zipCode != null) + if (other.zipCode != null) { return false; + } } - else if (!zipCode.equals(other.zipCode)) + else if (!zipCode.equals(other.zipCode)) { return false; + } + return true; } - } diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/BillingInfo.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/BillingInfo.java index e54f309ee..f684a6c6a 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/BillingInfo.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/BillingInfo.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -56,26 +56,33 @@ public class BillingInfo { @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) + } + if (obj == null) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } BillingInfo other = (BillingInfo) obj; if (paymentDesc == null) { - if (other.paymentDesc != null) + if (other.paymentDesc != null) { return false; + } } - else if (!paymentDesc.equals(other.paymentDesc)) + else if (!paymentDesc.equals(other.paymentDesc)) { return false; + } if (paymentId == null) { - if (other.paymentId != null) + if (other.paymentId != null) { return false; + } } - else if (!paymentId.equals(other.paymentId)) + else if (!paymentId.equals(other.paymentId)) { return false; + } + return true; } - } diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/Customer.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/Customer.java index f5528fc7f..46e88c6b3 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/Customer.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/Customer.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -126,45 +126,60 @@ public class Customer { @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) + } + if (obj == null) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } Customer other = (Customer) obj; - if (businessCustomer != other.businessCustomer) + if (businessCustomer != other.businessCustomer) { return false; + } if (companyName == null) { - if (other.companyName != null) + if (other.companyName != null) { return false; + } } - else if (!companyName.equals(other.companyName)) + else if (!companyName.equals(other.companyName)) { return false; + } if (firstName == null) { - if (other.firstName != null) + if (other.firstName != null) { return false; + } } - else if (!firstName.equals(other.firstName)) + else if (!firstName.equals(other.firstName)) { return false; + } if (lastName == null) { - if (other.lastName != null) + if (other.lastName != null) { return false; + } } - else if (!lastName.equals(other.lastName)) + else if (!lastName.equals(other.lastName)) { return false; + } if (middleName == null) { - if (other.middleName != null) + if (other.middleName != null) { return false; + } } - else if (!middleName.equals(other.middleName)) + else if (!middleName.equals(other.middleName)) { return false; - if (registered != other.registered) + } + if (registered != other.registered) { return false; - if (registrationId != other.registrationId) + } + if (registrationId != other.registrationId) { return false; - if (vip != other.vip) + } + if (vip != other.vip) { return false; + } return true; } diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/LineItem.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/LineItem.java index 3ec0798a6..1a47bbdc0 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/LineItem.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/LineItem.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,9 +18,9 @@ package org.springframework.batch.sample.domain.order; import java.math.BigDecimal; - public class LineItem { public static final String LINE_ID_ITEM = "LIT"; + private long itemId; private BigDecimal price; private BigDecimal discountPerc; @@ -110,18 +110,28 @@ public class LineItem { @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) + } + + if (obj == null) { return false; - if (getClass() != obj.getClass()) + } + + if (getClass() != obj.getClass()) { return false; + } + LineItem other = (LineItem) obj; - if (itemId != other.itemId) + + if (itemId != other.itemId) { return false; - if (quantity != other.quantity) + } + + if (quantity != other.quantity) { return false; + } + return true; } - } diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/Order.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/Order.java index 4a1896deb..ea8f3d1b9 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/Order.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/Order.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -164,68 +164,90 @@ public class Order { @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) + } + if (obj == null) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } Order other = (Order) obj; if (billing == null) { - if (other.billing != null) + if (other.billing != null) { return false; + } } - else if (!billing.equals(other.billing)) + else if (!billing.equals(other.billing)) { return false; + } if (billingAddress == null) { - if (other.billingAddress != null) + if (other.billingAddress != null) { return false; + } } - else if (!billingAddress.equals(other.billingAddress)) + else if (!billingAddress.equals(other.billingAddress)) { return false; + } if (customer == null) { - if (other.customer != null) + if (other.customer != null) { return false; + } } - else if (!customer.equals(other.customer)) + else if (!customer.equals(other.customer)) { return false; + } if (lineItems == null) { - if (other.lineItems != null) + if (other.lineItems != null) { return false; + } } - else if (!lineItems.equals(other.lineItems)) + else if (!lineItems.equals(other.lineItems)) { return false; + } if (orderDate == null) { - if (other.orderDate != null) + if (other.orderDate != null) { return false; + } } - else if (!orderDate.equals(other.orderDate)) + else if (!orderDate.equals(other.orderDate)) { return false; - if (orderId != other.orderId) + } + if (orderId != other.orderId) { return false; + } if (shipping == null) { - if (other.shipping != null) + if (other.shipping != null) { return false; + } } - else if (!shipping.equals(other.shipping)) + else if (!shipping.equals(other.shipping)) { return false; + } if (shippingAddress == null) { - if (other.shippingAddress != null) + if (other.shippingAddress != null) { return false; + } } - else if (!shippingAddress.equals(other.shippingAddress)) + else if (!shippingAddress.equals(other.shippingAddress)) { return false; - if (totalItems != other.totalItems) + } + if (totalItems != other.totalItems) { return false; - if (totalLines != other.totalLines) + } + if (totalLines != other.totalLines) { return false; + } if (totalPrice == null) { - if (other.totalPrice != null) + if (other.totalPrice != null) { return false; + } } - else if (!totalPrice.equals(other.totalPrice)) + else if (!totalPrice.equals(other.totalPrice)) { return false; + } + return true; } - } diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/OrderDao.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/OrderDao.java deleted file mode 100644 index 2d7a279a5..000000000 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/OrderDao.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2006-2007 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.batch.sample.domain.order; - - -/** - * Interface for writing Order objects. - */ -public interface OrderDao { - - public void write(Order order); - -} diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/ShippingInfo.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/ShippingInfo.java index efdf8befb..81b60018b 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/ShippingInfo.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/ShippingInfo.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -62,32 +62,41 @@ public class ShippingInfo { @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) + } + if (obj == null) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } ShippingInfo other = (ShippingInfo) obj; if (shipperId == null) { - if (other.shipperId != null) + if (other.shipperId != null) { return false; + } } - else if (!shipperId.equals(other.shipperId)) + else if (!shipperId.equals(other.shipperId)) { return false; + } if (shippingInfo == null) { - if (other.shippingInfo != null) + if (other.shippingInfo != null) { return false; + } } - else if (!shippingInfo.equals(other.shippingInfo)) + else if (!shippingInfo.equals(other.shippingInfo)) { return false; + } if (shippingTypeId == null) { - if (other.shippingTypeId != null) + if (other.shippingTypeId != null) { return false; + } } - else if (!shippingTypeId.equals(other.shippingTypeId)) + else if (!shippingTypeId.equals(other.shippingTypeId)) { return false; + } + return true; } - } diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/internal/OrderItemReader.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/internal/OrderItemReader.java index d846fa6a4..d0345e7b2 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/internal/OrderItemReader.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/internal/OrderItemReader.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -85,7 +85,6 @@ public class OrderItemReader implements ItemReader { String lineId = fieldSet.readString(0); - // start a new Order if (Order.LINE_ID_HEADER.equals(lineId)) { log.debug("STARTING NEW RECORD"); order = headerMapper.mapFieldSet(fieldSet); @@ -145,7 +144,6 @@ public class OrderItemReader implements ItemReader { else { log.debug("Could not map LINE_ID=" + lineId); } - } /** diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/internal/extractor/HeaderFieldExtractor.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/internal/extractor/HeaderFieldExtractor.java index 61923c215..629f2d7f2 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/internal/extractor/HeaderFieldExtractor.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/internal/extractor/HeaderFieldExtractor.java @@ -10,11 +10,9 @@ import org.springframework.batch.sample.domain.order.Order; * @since 2.0.1 */ public class HeaderFieldExtractor implements FieldExtractor { - - private static final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd"); + private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd"); public Object[] extract(Order order) { return new Object[] { "BEGIN_ORDER:", order.getOrderId(), dateFormat.format(order.getOrderDate()) }; } - } diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/internal/validator/OrderValidator.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/internal/validator/OrderValidator.java index d60ec0323..8e7c8c31c 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/internal/validator/OrderValidator.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/internal/validator/OrderValidator.java @@ -21,11 +21,11 @@ public class OrderValidator implements Validator { private static final List SHIPPER_IDS = new ArrayList(); private static final List SHIPPER_TYPES = new ArrayList(); private static final long MAX_ID = 9999999999L; - private static final BigDecimal BD_MIN = new BigDecimal(0.0); - private static final BigDecimal BD_MAX = new BigDecimal(99999999.99); - private static final BigDecimal BD_PERC_MAX = new BigDecimal(100.0); + private static final BigDecimal BD_MIN = new BigDecimal("0.0"); + private static final BigDecimal BD_MAX = new BigDecimal("99999999.99"); + private static final BigDecimal BD_PERC_MAX = new BigDecimal("100.0"); private static final int MAX_QUANTITY = 9999; - private static final BigDecimal BD_100 = new BigDecimal(100.00); + private static final BigDecimal BD_100 = new BigDecimal("100.00"); static { CARD_TYPES.add("VISA"); @@ -147,32 +147,34 @@ public class OrderValidator implements Validator { } } + String lineItemsFieldName = "lineItems"; + if(!ids) { - errors.rejectValue("lineItems", "error.lineitems.id"); + errors.rejectValue(lineItemsFieldName, "error.lineitems.id"); } if(!prices) { - errors.rejectValue("lineItems", "error.lineitems.price"); + errors.rejectValue(lineItemsFieldName, "error.lineitems.price"); } if(!discounts) { - errors.rejectValue("lineItems", "error.lineitems.discount"); + errors.rejectValue(lineItemsFieldName, "error.lineitems.discount"); } if(!shippingPrices) { - errors.rejectValue("lineItems", "error.lineitems.shipping"); + errors.rejectValue(lineItemsFieldName, "error.lineitems.shipping"); } if(!handlingPrices) { - errors.rejectValue("lineItems", "error.lineitems.handling"); + errors.rejectValue(lineItemsFieldName, "error.lineitems.handling"); } if(!quantities) { - errors.rejectValue("lineItems", "error.lineitems.quantity"); + errors.rejectValue(lineItemsFieldName, "error.lineitems.quantity"); } if(!totalPrices) { - errors.rejectValue("lineItems", "error.lineitems.totalprice"); + errors.rejectValue(lineItemsFieldName, "error.lineitems.totalprice"); } } diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/internal/xml/Order.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/internal/xml/Order.java index 238d0099f..46857fbbd 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/internal/xml/Order.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/internal/xml/Order.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,11 +42,11 @@ public class Order { } public Date getDate() { - return date; + return date != null ? new Date(date.getTime()) : null; } public void setDate(Date date) { - this.date = date; + this.date = date != null ? new Date(date.getTime()) : null; } public List getLineItems() { diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/person/Child.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/person/Child.java index 0571fdaae..63efb1ec7 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/person/Child.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/person/Child.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,12 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.springframework.batch.sample.domain.person; - public class Child { - private String name; public void setName(String name){ @@ -44,20 +41,29 @@ public class Child { @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Child other = (Child) obj; - if (name == null) { - if (other.name != null) - return false; } - else if (!name.equals(other.name)) + + if (obj == null) { return false; + } + + if (getClass() != obj.getClass()) { + return false; + } + + Child other = (Child) obj; + + if (name == null) { + if (other.name != null) { + return false; + } + } + else if (!name.equals(other.name)) { + return false; + } + return true; } - } diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/person/Person.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/person/Person.java index 4ee7af83f..75bc01c03 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/person/Person.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/person/Person.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,17 +22,11 @@ import java.util.List; import org.springframework.batch.sample.domain.order.Address; public class Person { - private String title = ""; - private String firstName = ""; - private String last_name = ""; - private int age = 0; - private Address address = new Address(); - private List children = new ArrayList(); public Person() { @@ -147,46 +141,69 @@ public class Person { @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) + } + + if (obj == null) { return false; - if (getClass() != obj.getClass()) + } + + if (getClass() != obj.getClass()) { return false; + } + Person other = (Person) obj; + if (address == null) { - if (other.address != null) + if (other.address != null) { return false; + } } - else if (!address.equals(other.address)) + else if (!address.equals(other.address)) { return false; - if (age != other.age) + } + + if (age != other.age) { return false; + } + if (children == null) { - if (other.children != null) + if (other.children != null) { return false; + } } - else if (!children.equals(other.children)) + else if (!children.equals(other.children)) { return false; + } + if (firstName == null) { - if (other.firstName != null) + if (other.firstName != null) { return false; + } } - else if (!firstName.equals(other.firstName)) + else if (!firstName.equals(other.firstName)) { return false; + } + if (last_name == null) { - if (other.last_name != null) + if (other.last_name != null) { return false; + } } - else if (!last_name.equals(other.last_name)) + else if (!last_name.equals(other.last_name)) { return false; + } + if (title == null) { - if (other.title != null) + if (other.title != null) { return false; + } } - else if (!title.equals(other.title)) + else if (!title.equals(other.title)) { return false; + } + return true; } - } diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/person/PersonService.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/person/PersonService.java index 364640faa..e647ebfb0 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/person/PersonService.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/person/PersonService.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,28 +19,26 @@ package org.springframework.batch.sample.domain.person; import java.util.ArrayList; import java.util.List; -import org.springframework.batch.item.ItemReader; -import org.springframework.batch.item.ItemWriter; import org.springframework.batch.sample.domain.order.Address; /** * Custom class that contains logic that would normally be be contained in - * {@link ItemReader} and {@link ItemWriter}. + * {@link org.springframework.batch.item.ItemReader} and + * {@link javax.batch.api.chunk.ItemWriter}. * * @author tomas.slanina * @author Robert Kasanicky */ public class PersonService { - private static final int GENERATION_LIMIT = 10; private int generatedCounter = 0; - private int processedCounter = 0; public Person getData() { - if (generatedCounter >= GENERATION_LIMIT) + if (generatedCounter >= GENERATION_LIMIT) { return null; + } Person person = new Person(); Address address = new Address(); diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/person/internal/PersonWriter.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/person/internal/PersonWriter.java index c83838a87..6fe2aa67e 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/person/internal/PersonWriter.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/person/internal/PersonWriter.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,13 +23,11 @@ import org.apache.commons.logging.LogFactory; import org.springframework.batch.item.ItemWriter; import org.springframework.batch.sample.domain.person.Person; - - public class PersonWriter implements ItemWriter { private static Log log = LogFactory.getLog(PersonWriter.class); - + + @Override public void write(List data) { log.debug("Processing: " + data); } - } diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/CustomerDebit.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/CustomerDebit.java index 95566979d..0d25ba44b 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/CustomerDebit.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/CustomerDebit.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -62,26 +62,33 @@ public class CustomerDebit { @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) + } + if (obj == null) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } CustomerDebit other = (CustomerDebit) obj; if (debit == null) { - if (other.debit != null) + if (other.debit != null) { return false; + } } - else if (!debit.equals(other.debit)) + else if (!debit.equals(other.debit)) { return false; + } if (name == null) { - if (other.name != null) + if (other.name != null) { return false; + } } - else if (!name.equals(other.name)) + else if (!name.equals(other.name)) { return false; + } + return true; } - } diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/CustomerOperation.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/CustomerOperation.java index de5dcc5f9..74d58b8a8 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/CustomerOperation.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/CustomerOperation.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,22 +30,22 @@ public enum CustomerOperation { ADD('A'), UPDATE('U'), DELETE('D'); private final char code; - private static final Map codeMap; + private static final Map CODE_MAP; private CustomerOperation(char code) { this.code = code; } static{ - codeMap = new HashMap(); + CODE_MAP = new HashMap(); for(CustomerOperation operation:values()){ - codeMap.put(operation.getCode(), operation); + CODE_MAP.put(operation.getCode(), operation); } } public static CustomerOperation fromCode(char code){ - if(codeMap.containsKey(code)){ - return codeMap.get(code); + if(CODE_MAP.containsKey(code)){ + return CODE_MAP.get(code); } else{ throw new IllegalArgumentException("Invalid code: [" + code + "]"); diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/Trade.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/Trade.java index f16de1516..bd9cb06a6 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/Trade.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/Trade.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,7 +27,7 @@ import java.math.BigDecimal; public class Trade implements Serializable { private String isin = ""; private long quantity = 0; - private BigDecimal price = new BigDecimal(0); + private BigDecimal price = BigDecimal.ZERO; private String customer = ""; private Long id; private long version = 0; @@ -116,36 +116,46 @@ public class Trade implements Serializable { @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) + } + if (obj == null) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } Trade other = (Trade) obj; if (customer == null) { - if (other.customer != null) + if (other.customer != null) { return false; + } } - else if (!customer.equals(other.customer)) + else if (!customer.equals(other.customer)) { return false; + } if (isin == null) { - if (other.isin != null) + if (other.isin != null) { return false; + } } - else if (!isin.equals(other.isin)) + else if (!isin.equals(other.isin)) { return false; + } if (price == null) { - if (other.price != null) + if (other.price != null) { return false; + } } - else if (!price.equals(other.price)) + else if (!price.equals(other.price)) { return false; - if (quantity != other.quantity) + } + if (quantity != other.quantity) { return false; - if (version != other.version) + } + if (version != other.version) { return false; + } return true; } - } diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/internal/CommonsLoggingInvalidCustomerLogger.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/internal/CommonsLoggingInvalidCustomerLogger.java index 71c3b8a2c..b1f6431fb 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/internal/CommonsLoggingInvalidCustomerLogger.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/internal/CommonsLoggingInvalidCustomerLogger.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,16 +26,14 @@ import org.springframework.batch.sample.domain.trade.InvalidCustomerLogger; * @author Lucas Ward * */ -public class CommonsLoggingInvalidCustomerLogger implements - InvalidCustomerLogger { - - protected static final Log logger = LogFactory.getLog(CommandLineJobRunner.class); +public class CommonsLoggingInvalidCustomerLogger implements InvalidCustomerLogger { + protected static final Log LOG = LogFactory.getLog(CommandLineJobRunner.class); /* (non-Javadoc) * @see org.springframework.batch.sample.domain.trade.InvalidCustomerLogger#log(org.springframework.batch.sample.domain.trade.CustomerUpdate) */ + @Override public void log(CustomerUpdate customerUpdate) { - logger.error("invalid customer encountered: [ " + customerUpdate + "]"); + LOG.error("invalid customer encountered: [ " + customerUpdate + "]"); } - } diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/internal/CustomerCreditFieldSetMapper.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/internal/CustomerCreditFieldSetMapper.java index ac2667878..964111179 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/internal/CustomerCreditFieldSetMapper.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/internal/CustomerCreditFieldSetMapper.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,13 +25,12 @@ import org.springframework.batch.sample.domain.trade.CustomerCredit; * @since 2.0 */ public class CustomerCreditFieldSetMapper implements FieldSetMapper { - public static final int ID_COLUMN = 0; public static final int NAME_COLUMN = 1; public static final int CREDIT_COLUMN = 2; + @Override public CustomerCredit mapFieldSet(FieldSet fieldSet) { - CustomerCredit trade = new CustomerCredit(); trade.setId(fieldSet.readInt(ID_COLUMN)); trade.setName(fieldSet.readString(NAME_COLUMN)); diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/internal/CustomerCreditIncreaseProcessor.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/internal/CustomerCreditIncreaseProcessor.java index 0987183f3..95d4f053e 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/internal/CustomerCreditIncreaseProcessor.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/internal/CustomerCreditIncreaseProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,9 +27,9 @@ import org.springframework.batch.sample.domain.trade.CustomerCredit; * @author Robert Kasanicky */ public class CustomerCreditIncreaseProcessor implements ItemProcessor { - public static final BigDecimal FIXED_AMOUNT = new BigDecimal("5"); + @Override public CustomerCredit process(CustomerCredit item) throws Exception { return item.increaseCreditBy(FIXED_AMOUNT); } diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/internal/CustomerCreditItemWriter.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/internal/CustomerCreditItemWriter.java deleted file mode 100644 index 47a111634..000000000 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/internal/CustomerCreditItemWriter.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2006-2007 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.batch.sample.domain.trade.internal; - -import java.util.List; - -import org.springframework.batch.item.ItemWriter; -import org.springframework.batch.sample.domain.trade.CustomerCredit; -import org.springframework.batch.sample.domain.trade.CustomerCreditDao; - -/** - * Delegates actual writing to a custom DAO. - * - * @author Robert Kasanicky - */ -public class CustomerCreditItemWriter implements ItemWriter { - - private CustomerCreditDao customerCreditDao; - - /** - * Public setter for the {@link CustomerCreditDao}. - * @param customerCreditDao the {@link CustomerCreditDao} to set - */ - public void setCustomerCreditDao(CustomerCreditDao customerCreditDao) { - this.customerCreditDao = customerCreditDao; - } - - public void write(List customerCredits) throws Exception { - for (CustomerCredit customerCredit : customerCredits) { - customerCreditDao.writeCredit(customerCredit); - } - } - -} diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/internal/CustomerCreditUpdatePreparedStatementSetter.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/internal/CustomerCreditUpdatePreparedStatementSetter.java index 1f2ef6bd2..5f4507da7 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/internal/CustomerCreditUpdatePreparedStatementSetter.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/internal/CustomerCreditUpdatePreparedStatementSetter.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,17 +27,15 @@ import org.springframework.batch.sample.domain.trade.CustomerCredit; * */ public class CustomerCreditUpdatePreparedStatementSetter implements ItemPreparedStatementSetter { - public static final BigDecimal FIXED_AMOUNT = new BigDecimal(1000); - public static final String QUERY = "UPDATE CUSTOMER SET CREDIT=? WHERE ID=?"; /* (non-Javadoc) * @see org.springframework.batch.io.support.ItemPreparedStatementSetter#setValues(java.lang.Object, java.sql.PreparedStatement) */ + @Override public void setValues(CustomerCredit customerCredit, PreparedStatement ps) throws SQLException { ps.setBigDecimal(1, customerCredit.getCredit().add(FIXED_AMOUNT)); ps.setLong(2, customerCredit.getId()); } - } diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/internal/CustomerCreditUpdateWriter.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/internal/CustomerCreditUpdateWriter.java index 46586d438..c63b3b293 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/internal/CustomerCreditUpdateWriter.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/internal/CustomerCreditUpdateWriter.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,6 +27,7 @@ public class CustomerCreditUpdateWriter implements ItemWriter { private CustomerCreditDao dao; + @Override public void write(List customerCredits) throws Exception { for (CustomerCredit customerCredit : customerCredits) { if (customerCredit.getCredit().doubleValue() > creditFilter) { @@ -42,5 +43,4 @@ public class CustomerCreditUpdateWriter implements ItemWriter { public void setDao(CustomerCreditDao dao) { this.dao = dao; } - } diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/internal/CustomerDebitRowMapper.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/internal/CustomerDebitRowMapper.java deleted file mode 100644 index 09a02190d..000000000 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/internal/CustomerDebitRowMapper.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2006-2007 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.batch.sample.domain.trade.internal; - -import java.sql.ResultSet; -import java.sql.SQLException; - -import org.springframework.batch.sample.domain.trade.CustomerDebit; -import org.springframework.jdbc.core.RowMapper; - - -public class CustomerDebitRowMapper implements RowMapper { - - public static final String CUSTOMER_COLUMN = "customer"; - public static final String PRICE_COLUMN = "price"; - - public Object mapRow(ResultSet rs, int ignoredRowNumber) - throws SQLException { - CustomerDebit customerDebit = new CustomerDebit(); - - customerDebit.setName(rs.getString(CUSTOMER_COLUMN)); - customerDebit.setDebit(rs.getBigDecimal(PRICE_COLUMN)); - - return customerDebit; - } -} diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/internal/IbatisCustomerCreditDao.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/internal/IbatisCustomerCreditDao.java deleted file mode 100644 index d521761b1..000000000 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/internal/IbatisCustomerCreditDao.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright 2006-2007 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.batch.sample.domain.trade.internal; - -import java.sql.SQLException; - -import org.springframework.batch.sample.domain.trade.CustomerCredit; -import org.springframework.batch.sample.domain.trade.CustomerCreditDao; -import org.springframework.jdbc.support.SQLStateSQLExceptionTranslator; - -import com.ibatis.sqlmap.client.SqlMapClient; - -/** - * @author Lucas Ward - * - */ -public class IbatisCustomerCreditDao implements CustomerCreditDao { - - SqlMapClient sqlMapClient; - - String statementId; - - /* (non-Javadoc) - * @see org.springframework.batch.sample.domain.trade.internal.CustomerCreditWriter#write(org.springframework.batch.sample.domain.CustomerCredit) - */ - @Override - public void writeCredit(CustomerCredit customerCredit) { - - try { - sqlMapClient.update(statementId, customerCredit); - } catch (SQLException e) { - throw new SQLStateSQLExceptionTranslator().translate("SqlMapClient operation", null, e); - } - } - - /* (non-Javadoc) - * @see org.springframework.batch.item.ResourceLifecycle#close() - */ - public void close() { - } - - /* (non-Javadoc) - * @see org.springframework.batch.item.ResourceLifecycle#open() - */ - public void open() { - } - - - public void setStatementId(String statementId) { - this.statementId = statementId; - } - -} diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/internal/TradeWriter.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/internal/TradeWriter.java index d85a39bd6..4a83bf59a 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/internal/TradeWriter.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/internal/TradeWriter.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,7 +24,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.batch.core.annotation.AfterWrite; import org.springframework.batch.item.ExecutionContext; -import org.springframework.batch.item.ItemStreamException; import org.springframework.batch.item.ItemStreamSupport; import org.springframework.batch.item.ItemWriter; import org.springframework.batch.item.WriteFailedException; @@ -73,7 +72,7 @@ public class TradeWriter extends ItemStreamSupport implements ItemWriter } @Override - public void open(ExecutionContext executionContext) throws ItemStreamException { + public void open(ExecutionContext executionContext) { if (executionContext.containsKey(TOTAL_AMOUNT_KEY)) { this.totalPrice = (BigDecimal) executionContext.get(TOTAL_AMOUNT_KEY); } diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/internal/validator/TradeValidator.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/internal/validator/TradeValidator.java index b5dd4f24b..7aa65ace7 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/internal/validator/TradeValidator.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/internal/validator/TradeValidator.java @@ -15,7 +15,6 @@ */ package org.springframework.batch.sample.domain.trade.internal.validator; -import org.springframework.batch.item.validator.ValidationException; import org.springframework.validation.Errors; import org.springframework.validation.Validator; import org.springframework.batch.sample.domain.trade.Trade; diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/jmx/JobExecutionNotificationPublisher.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/jmx/JobExecutionNotificationPublisher.java index 98a55e09a..1922194b2 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/jmx/JobExecutionNotificationPublisher.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/jmx/JobExecutionNotificationPublisher.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,8 +32,7 @@ import org.springframework.jmx.export.notification.NotificationPublisherAware; * @since 1.0 */ public class JobExecutionNotificationPublisher implements ApplicationListener, NotificationPublisherAware { - - protected static final Log logger = LogFactory.getLog(JobExecutionNotificationPublisher.class); + private static final Log LOG = LogFactory.getLog(JobExecutionNotificationPublisher.class); private NotificationPublisher notificationPublisher; @@ -58,7 +57,7 @@ public class JobExecutionNotificationPublisher implements ApplicationListener, N public void onApplicationEvent(ApplicationEvent applicationEvent) { if (applicationEvent instanceof SimpleMessageApplicationEvent) { String message = applicationEvent.toString(); - logger.info(message); + LOG.info(message); publish(message); } } @@ -82,5 +81,4 @@ public class JobExecutionNotificationPublisher implements ApplicationListener, N notificationPublisher.sendNotification(notification); } } - } diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/jmx/StepExecutionApplicationEventAdvice.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/jmx/StepExecutionApplicationEventAdvice.java index 1037286aa..0dc8fb7f5 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/jmx/StepExecutionApplicationEventAdvice.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/jmx/StepExecutionApplicationEventAdvice.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,13 +18,12 @@ package org.springframework.batch.sample.jmx; import org.aspectj.lang.JoinPoint; import org.springframework.batch.core.StepExecution; -import org.springframework.context.ApplicationEvent; import org.springframework.context.ApplicationEventPublisher; import org.springframework.context.ApplicationEventPublisherAware; /** * Wraps calls for methods taking {@link StepExecution} as an argument and - * publishes notifications in the form of {@link ApplicationEvent}. + * publishes notifications in the form of {@link org.springframework.context.ApplicationEvent}. * * @author Dave Syer */ @@ -62,5 +61,4 @@ public class StepExecutionApplicationEventAdvice implements ApplicationEventPubl private void publish(Object source, String message) { applicationEventPublisher.publishEvent(new SimpleMessageApplicationEvent(source, message)); } - } diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/launch/DefaultJobLoader.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/launch/DefaultJobLoader.java index 14054ad9d..d1e6d2e44 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/launch/DefaultJobLoader.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/launch/DefaultJobLoader.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -57,7 +57,7 @@ public class DefaultJobLoader implements JobLoader, ApplicationContextAware { } } catch (NoSuchJobException e) { - throw new IllegalStateException("Registry could not locate its own job (NoSuchJobException)."); + throw new IllegalStateException("Registry could not locate its own job (NoSuchJobException).", e); } } return result; diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/launch/ExportedJobLoader.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/launch/ExportedJobLoader.java deleted file mode 100644 index 8e851a091..000000000 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/launch/ExportedJobLoader.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2006-2007 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.batch.sample.launch; - -import java.util.Map; - - -/** - * @author Dave Syer - * - */ -public interface ExportedJobLoader { - - void loadResource(String path); - - Map getConfigurations(); - - String getJob(String path); - - String getProperty(String path); - - void setProperty(String path, String value); - -} diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/rabbitmq/amqp/AmqpMessageProducer.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/rabbitmq/amqp/AmqpMessageProducer.java index 72e053f49..cc8dd7b22 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/rabbitmq/amqp/AmqpMessageProducer.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/rabbitmq/amqp/AmqpMessageProducer.java @@ -11,9 +11,11 @@ import org.springframework.context.support.ClassPathXmlApplicationContext; * Simple producer class that sends {@link String} messages to the configured queue to be processed. *

*/ -public class AmqpMessageProducer { - public static final int SEND_MESSAGE_COUNT = 10; - public static final String[] BEAN_CONFIG = { "classpath:/META-INF/spring/jobs/messaging/rabbitmq-beans.xml", +public final class AmqpMessageProducer { + private AmqpMessageProducer() {} + + private static final int SEND_MESSAGE_COUNT = 10; + private static final String[] BEAN_CONFIG = { "classpath:/META-INF/spring/jobs/messaging/rabbitmq-beans.xml", "classpath:/META-INF/spring/config-beans.xml" }; public static void main(String[] args) { diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/support/HeaderCopyCallback.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/support/HeaderCopyCallback.java index f3025235e..2826ee06c 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/support/HeaderCopyCallback.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/support/HeaderCopyCallback.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,18 +20,15 @@ import java.io.IOException; import java.io.Writer; import org.springframework.batch.item.file.FlatFileHeaderCallback; -import org.springframework.batch.item.file.FlatFileItemReader; -import org.springframework.batch.item.file.FlatFileItemWriter; import org.springframework.batch.item.file.LineCallbackHandler; import org.springframework.util.Assert; /** - * Designed to be registered with both {@link FlatFileItemReader} and - * {@link FlatFileItemWriter} and copy header line from input file to output - * file. + * Designed to be registered with both {@link org.springframework.batch.item.file.FlatFileItemReader} + * and {@link org.springframework.batch.item.file.FlatFileItemWriter} and copy header line from input + * file to output file. */ public class HeaderCopyCallback implements LineCallbackHandler, FlatFileHeaderCallback { - private String header = ""; public void handleLine(String line) { @@ -41,7 +38,5 @@ public class HeaderCopyCallback implements LineCallbackHandler, FlatFileHeaderCa public void writeHeader(Writer writer) throws IOException { writer.write("header from input: " + header); - } - } diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/support/RetrySampleItemWriter.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/support/RetrySampleItemWriter.java index 4920caf00..9be637b70 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/support/RetrySampleItemWriter.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/support/RetrySampleItemWriter.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,7 +34,7 @@ public class RetrySampleItemWriter implements ItemWriter { int current = counter; counter += items.size(); if (current < 3 && (counter >= 2 || counter >= 3)) { - throw new RuntimeException("Temporary error"); + throw new IllegalStateException("Temporary error"); } } diff --git a/spring-batch-samples/src/main/resources/META-INF/persistence.xml b/spring-batch-samples/src/main/resources/META-INF/persistence.xml index bc3353f67..50cfb848f 100644 --- a/spring-batch-samples/src/main/resources/META-INF/persistence.xml +++ b/spring-batch-samples/src/main/resources/META-INF/persistence.xml @@ -4,10 +4,7 @@ version="1.0"> - org.springframework.batch.sample.domain.trade.CustomerCredit true - - - \ No newline at end of file + diff --git a/spring-batch-samples/src/main/resources/META-INF/spring/config-beans.xml b/spring-batch-samples/src/main/resources/META-INF/spring/config-beans.xml index f5dc575de..3ddbc29ce 100644 --- a/spring-batch-samples/src/main/resources/META-INF/spring/config-beans.xml +++ b/spring-batch-samples/src/main/resources/META-INF/spring/config-beans.xml @@ -5,9 +5,8 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation=" - http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd - http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd"> + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd + http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> - diff --git a/spring-batch-samples/src/main/resources/META-INF/spring/jobs/amqp/amqp-example-job-beans.xml b/spring-batch-samples/src/main/resources/META-INF/spring/jobs/amqp/amqp-example-job-beans.xml index 8d77e3866..c673593b4 100644 --- a/spring-batch-samples/src/main/resources/META-INF/spring/jobs/amqp/amqp-example-job-beans.xml +++ b/spring-batch-samples/src/main/resources/META-INF/spring/jobs/amqp/amqp-example-job-beans.xml @@ -4,7 +4,7 @@ xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" - http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd"> + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> diff --git a/spring-batch-samples/src/main/resources/META-INF/spring/jobs/amqp/amqp-example-job.xml b/spring-batch-samples/src/main/resources/META-INF/spring/jobs/amqp/amqp-example-job.xml index 0f92248cb..9d52bdf8b 100644 --- a/spring-batch-samples/src/main/resources/META-INF/spring/jobs/amqp/amqp-example-job.xml +++ b/spring-batch-samples/src/main/resources/META-INF/spring/jobs/amqp/amqp-example-job.xml @@ -5,8 +5,8 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:batch="http://www.springframework.org/schema/batch" xsi:schemaLocation=" - http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-2.2.xsd - http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd"> + http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch.xsd + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> diff --git a/spring-batch-samples/src/main/resources/META-INF/spring/jobs/messaging/rabbitmq-beans.xml b/spring-batch-samples/src/main/resources/META-INF/spring/jobs/messaging/rabbitmq-beans.xml index 4bca5f143..946a0ffd8 100644 --- a/spring-batch-samples/src/main/resources/META-INF/spring/jobs/messaging/rabbitmq-beans.xml +++ b/spring-batch-samples/src/main/resources/META-INF/spring/jobs/messaging/rabbitmq-beans.xml @@ -6,8 +6,8 @@ xmlns:rabbit="http://www.springframework.org/schema/rabbit" xmlns:p="http://www.springframework.org/schema/p" xsi:schemaLocation=" - http://www.springframework.org/schema/rabbit http://www.springframework.org/schema/rabbit/spring-rabbit-1.0.xsd - http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd"> + http://www.springframework.org/schema/rabbit http://www.springframework.org/schema/rabbit/spring-rabbit.xsd + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> diff --git a/spring-batch-samples/src/main/resources/adhoc-job-launcher-context.xml b/spring-batch-samples/src/main/resources/adhoc-job-launcher-context.xml index f7a680309..b187f79e4 100644 --- a/spring-batch-samples/src/main/resources/adhoc-job-launcher-context.xml +++ b/spring-batch-samples/src/main/resources/adhoc-job-launcher-context.xml @@ -1,10 +1,7 @@ + xsi:schemaLocation="http://www.springframework.org/schema/beans + http://www.springframework.org/schema/beans/spring-beans.xsd"> @@ -57,5 +54,4 @@ - \ No newline at end of file diff --git a/spring-batch-samples/src/main/resources/data-source-context.xml b/spring-batch-samples/src/main/resources/data-source-context.xml index 9c34cc82c..6cbfc6061 100644 --- a/spring-batch-samples/src/main/resources/data-source-context.xml +++ b/spring-batch-samples/src/main/resources/data-source-context.xml @@ -1,8 +1,8 @@ + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd + http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd"> diff --git a/spring-batch-samples/src/main/resources/hibernate-context.xml b/spring-batch-samples/src/main/resources/hibernate-context.xml index 845c8be5c..873bd3fb4 100644 --- a/spring-batch-samples/src/main/resources/hibernate-context.xml +++ b/spring-batch-samples/src/main/resources/hibernate-context.xml @@ -1,8 +1,8 @@ - - - + + + @@ -19,5 +19,4 @@ - - + diff --git a/spring-batch-samples/src/main/resources/ibatis-config.xml b/spring-batch-samples/src/main/resources/ibatis-config.xml index 9d2f4e8c3..d038e54c5 100644 --- a/spring-batch-samples/src/main/resources/ibatis-config.xml +++ b/spring-batch-samples/src/main/resources/ibatis-config.xml @@ -3,7 +3,5 @@ "http://ibatis.apache.org/dtd/sql-map-config-2.dtd"> - - - \ No newline at end of file + diff --git a/spring-batch-samples/src/main/resources/ibatis-customer-credit.xml b/spring-batch-samples/src/main/resources/ibatis-customer-credit.xml index cd23cf0a7..eabd330a9 100644 --- a/spring-batch-samples/src/main/resources/ibatis-customer-credit.xml +++ b/spring-batch-samples/src/main/resources/ibatis-customer-credit.xml @@ -3,7 +3,6 @@ "http://ibatis.apache.org/dtd/sql-map-2.dtd"> - @@ -24,5 +23,4 @@ update CUSTOMER set CREDIT = #credit# where NAME = #name# - - \ No newline at end of file + diff --git a/spring-batch-samples/src/main/resources/jobs/adhocLoopJob.xml b/spring-batch-samples/src/main/resources/jobs/adhocLoopJob.xml index 8c341129a..4df1fbfdf 100644 --- a/spring-batch-samples/src/main/resources/jobs/adhocLoopJob.xml +++ b/spring-batch-samples/src/main/resources/jobs/adhocLoopJob.xml @@ -6,7 +6,7 @@ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/batch - http://www.springframework.org/schema/batch/spring-batch-2.2.xsd + http://www.springframework.org/schema/batch/spring-batch.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd"> @@ -40,5 +40,4 @@ method="onError" /> - diff --git a/spring-batch-samples/src/main/resources/jobs/amqp-example-job.xml b/spring-batch-samples/src/main/resources/jobs/amqp-example-job.xml index 0f92248cb..9d52bdf8b 100644 --- a/spring-batch-samples/src/main/resources/jobs/amqp-example-job.xml +++ b/spring-batch-samples/src/main/resources/jobs/amqp-example-job.xml @@ -5,8 +5,8 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:batch="http://www.springframework.org/schema/batch" xsi:schemaLocation=" - http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-2.2.xsd - http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd"> + http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch.xsd + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> diff --git a/spring-batch-samples/src/main/resources/jobs/beanWrapperMapperSampleJob.xml b/spring-batch-samples/src/main/resources/jobs/beanWrapperMapperSampleJob.xml index 4e437f426..ba12a5bcb 100644 --- a/spring-batch-samples/src/main/resources/jobs/beanWrapperMapperSampleJob.xml +++ b/spring-batch-samples/src/main/resources/jobs/beanWrapperMapperSampleJob.xml @@ -1,12 +1,9 @@ - + http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch.xsd"> @@ -94,5 +91,4 @@ - diff --git a/spring-batch-samples/src/main/resources/jobs/compositeItemWriterSampleJob.xml b/spring-batch-samples/src/main/resources/jobs/compositeItemWriterSampleJob.xml index 71e934f02..021296173 100644 --- a/spring-batch-samples/src/main/resources/jobs/compositeItemWriterSampleJob.xml +++ b/spring-batch-samples/src/main/resources/jobs/compositeItemWriterSampleJob.xml @@ -1,12 +1,9 @@ + http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch.xsd"> - diff --git a/spring-batch-samples/src/main/resources/jobs/customerFilterJob.xml b/spring-batch-samples/src/main/resources/jobs/customerFilterJob.xml index ac57161f4..e5d71d40c 100644 --- a/spring-batch-samples/src/main/resources/jobs/customerFilterJob.xml +++ b/spring-batch-samples/src/main/resources/jobs/customerFilterJob.xml @@ -1,9 +1,8 @@ + http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch.xsd"> @@ -72,5 +71,4 @@ - diff --git a/spring-batch-samples/src/main/resources/jobs/delegatingJob.xml b/spring-batch-samples/src/main/resources/jobs/delegatingJob.xml index 3236ebf9f..7ee3bb150 100644 --- a/spring-batch-samples/src/main/resources/jobs/delegatingJob.xml +++ b/spring-batch-samples/src/main/resources/jobs/delegatingJob.xml @@ -1,14 +1,9 @@ + http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch.xsd"> The intent is to to give an example of how existing bean @@ -41,5 +36,4 @@ - \ No newline at end of file diff --git a/spring-batch-samples/src/main/resources/jobs/footballJob.xml b/spring-batch-samples/src/main/resources/jobs/footballJob.xml index 0e85cdb20..5e3395014 100644 --- a/spring-batch-samples/src/main/resources/jobs/footballJob.xml +++ b/spring-batch-samples/src/main/resources/jobs/footballJob.xml @@ -1,10 +1,9 @@ @@ -127,5 +126,4 @@ - \ No newline at end of file diff --git a/spring-batch-samples/src/main/resources/jobs/groovyJob.xml b/spring-batch-samples/src/main/resources/jobs/groovyJob.xml index 922e25fdf..0118572ce 100644 --- a/spring-batch-samples/src/main/resources/jobs/groovyJob.xml +++ b/spring-batch-samples/src/main/resources/jobs/groovyJob.xml @@ -1,9 +1,9 @@ @@ -53,5 +53,4 @@ } - \ No newline at end of file diff --git a/spring-batch-samples/src/main/resources/jobs/headerFooterSample.xml b/spring-batch-samples/src/main/resources/jobs/headerFooterSample.xml index 917f5ed3d..936f036b3 100644 --- a/spring-batch-samples/src/main/resources/jobs/headerFooterSample.xml +++ b/spring-batch-samples/src/main/resources/jobs/headerFooterSample.xml @@ -1,12 +1,9 @@ + http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch.xsd"> Showcases reading and writing of headers and footers. Copies header from input to output and adds a footer. diff --git a/spring-batch-samples/src/main/resources/jobs/hibernateJob.xml b/spring-batch-samples/src/main/resources/jobs/hibernateJob.xml index 47292f82a..072af78f9 100644 --- a/spring-batch-samples/src/main/resources/jobs/hibernateJob.xml +++ b/spring-batch-samples/src/main/resources/jobs/hibernateJob.xml @@ -1,9 +1,9 @@ + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd + http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch.xsd"> Example for Hibernate integration. @@ -42,5 +42,4 @@ - \ No newline at end of file diff --git a/spring-batch-samples/src/main/resources/jobs/infiniteLoopJob.xml b/spring-batch-samples/src/main/resources/jobs/infiniteLoopJob.xml index 560935156..79459c6c2 100644 --- a/spring-batch-samples/src/main/resources/jobs/infiniteLoopJob.xml +++ b/spring-batch-samples/src/main/resources/jobs/infiniteLoopJob.xml @@ -1,10 +1,7 @@ + xsi:schemaLocation="http://www.springframework.org/schema/beans + http://www.springframework.org/schema/beans/spring-beans.xsd"> @@ -37,11 +34,6 @@ - @@ -54,5 +46,4 @@ - \ No newline at end of file diff --git a/spring-batch-samples/src/main/resources/jobs/ioSampleJob.xml b/spring-batch-samples/src/main/resources/jobs/ioSampleJob.xml index 31050e0e2..de51a2541 100644 --- a/spring-batch-samples/src/main/resources/jobs/ioSampleJob.xml +++ b/spring-batch-samples/src/main/resources/jobs/ioSampleJob.xml @@ -1,7 +1,7 @@ @@ -13,7 +13,5 @@ - - + diff --git a/spring-batch-samples/src/main/resources/jobs/iosample/delimited.xml b/spring-batch-samples/src/main/resources/jobs/iosample/delimited.xml index 3027fec6b..30e823f40 100644 --- a/spring-batch-samples/src/main/resources/jobs/iosample/delimited.xml +++ b/spring-batch-samples/src/main/resources/jobs/iosample/delimited.xml @@ -1,15 +1,8 @@ + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> diff --git a/spring-batch-samples/src/main/resources/jobs/iosample/fixedLength.xml b/spring-batch-samples/src/main/resources/jobs/iosample/fixedLength.xml index 9253f7e70..2085bb625 100644 --- a/spring-batch-samples/src/main/resources/jobs/iosample/fixedLength.xml +++ b/spring-batch-samples/src/main/resources/jobs/iosample/fixedLength.xml @@ -1,13 +1,8 @@ + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> diff --git a/spring-batch-samples/src/main/resources/jobs/iosample/ibatis.xml b/spring-batch-samples/src/main/resources/jobs/iosample/ibatis.xml index 469b94769..5f1f51f39 100644 --- a/spring-batch-samples/src/main/resources/jobs/iosample/ibatis.xml +++ b/spring-batch-samples/src/main/resources/jobs/iosample/ibatis.xml @@ -3,7 +3,6 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> - @@ -21,5 +20,4 @@ - diff --git a/spring-batch-samples/src/main/resources/jobs/iosample/jdbcCursor.xml b/spring-batch-samples/src/main/resources/jobs/iosample/jdbcCursor.xml index d0e0b69a5..d9b3e36a4 100644 --- a/spring-batch-samples/src/main/resources/jobs/iosample/jdbcCursor.xml +++ b/spring-batch-samples/src/main/resources/jobs/iosample/jdbcCursor.xml @@ -1,15 +1,8 @@ + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> @@ -28,5 +21,4 @@ - diff --git a/spring-batch-samples/src/main/resources/jobs/iosample/jdbcPaging.xml b/spring-batch-samples/src/main/resources/jobs/iosample/jdbcPaging.xml index 74f080fb9..63e32dbb2 100644 --- a/spring-batch-samples/src/main/resources/jobs/iosample/jdbcPaging.xml +++ b/spring-batch-samples/src/main/resources/jobs/iosample/jdbcPaging.xml @@ -1,12 +1,8 @@ - + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> @@ -45,5 +41,4 @@ - diff --git a/spring-batch-samples/src/main/resources/jobs/iosample/multiLine.xml b/spring-batch-samples/src/main/resources/jobs/iosample/multiLine.xml index 3e22bed2f..ed253903f 100644 --- a/spring-batch-samples/src/main/resources/jobs/iosample/multiLine.xml +++ b/spring-batch-samples/src/main/resources/jobs/iosample/multiLine.xml @@ -1,17 +1,10 @@ + http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch.xsd"> @@ -49,5 +42,4 @@ - diff --git a/spring-batch-samples/src/main/resources/jobs/iosample/multiRecordType.xml b/spring-batch-samples/src/main/resources/jobs/iosample/multiRecordType.xml index 25906509f..aeeac0f30 100644 --- a/spring-batch-samples/src/main/resources/jobs/iosample/multiRecordType.xml +++ b/spring-batch-samples/src/main/resources/jobs/iosample/multiRecordType.xml @@ -1,17 +1,10 @@ + http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch.xsd"> @@ -34,12 +27,12 @@ - - - - - - + + + + + + + class="org.springframework.batch.sample.domain.trade.internal.TradeFieldSetMapper" /> diff --git a/spring-batch-samples/src/main/resources/jobs/iosample/multiResource.xml b/spring-batch-samples/src/main/resources/jobs/iosample/multiResource.xml index 050c3265f..558220494 100644 --- a/spring-batch-samples/src/main/resources/jobs/iosample/multiResource.xml +++ b/spring-batch-samples/src/main/resources/jobs/iosample/multiResource.xml @@ -1,13 +1,8 @@ + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> @@ -59,5 +54,4 @@ - diff --git a/spring-batch-samples/src/main/resources/jobs/iosample/xml.xml b/spring-batch-samples/src/main/resources/jobs/iosample/xml.xml index caac90308..57046f47a 100644 --- a/spring-batch-samples/src/main/resources/jobs/iosample/xml.xml +++ b/spring-batch-samples/src/main/resources/jobs/iosample/xml.xml @@ -1,12 +1,9 @@ @@ -36,5 +33,4 @@ - diff --git a/spring-batch-samples/src/main/resources/jobs/jobStepSample.xml b/spring-batch-samples/src/main/resources/jobs/jobStepSample.xml index 5bc712995..e5ce2c32b 100644 --- a/spring-batch-samples/src/main/resources/jobs/jobStepSample.xml +++ b/spring-batch-samples/src/main/resources/jobs/jobStepSample.xml @@ -1,6 +1,6 @@ diff --git a/spring-batch-samples/src/main/resources/jobs/loopFlowSample.xml b/spring-batch-samples/src/main/resources/jobs/loopFlowSample.xml index e77079f51..6d5bb4d83 100644 --- a/spring-batch-samples/src/main/resources/jobs/loopFlowSample.xml +++ b/spring-batch-samples/src/main/resources/jobs/loopFlowSample.xml @@ -1,7 +1,7 @@ @@ -40,5 +40,4 @@ - \ No newline at end of file diff --git a/spring-batch-samples/src/main/resources/jobs/mailJob.xml b/spring-batch-samples/src/main/resources/jobs/mailJob.xml index bf813e328..e4fc07fec 100644 --- a/spring-batch-samples/src/main/resources/jobs/mailJob.xml +++ b/spring-batch-samples/src/main/resources/jobs/mailJob.xml @@ -1,9 +1,8 @@ - + @@ -12,9 +11,6 @@ - @@ -48,5 +44,4 @@ - diff --git a/spring-batch-samples/src/main/resources/jobs/multilineJob.xml b/spring-batch-samples/src/main/resources/jobs/multilineJob.xml index fb80f375f..60bb1a0f1 100644 --- a/spring-batch-samples/src/main/resources/jobs/multilineJob.xml +++ b/spring-batch-samples/src/main/resources/jobs/multilineJob.xml @@ -1,7 +1,7 @@ @@ -75,5 +75,4 @@ - \ No newline at end of file diff --git a/spring-batch-samples/src/main/resources/jobs/multilineOrderInputTokenizers.xml b/spring-batch-samples/src/main/resources/jobs/multilineOrderInputTokenizers.xml index 02b773655..5c03b5444 100644 --- a/spring-batch-samples/src/main/resources/jobs/multilineOrderInputTokenizers.xml +++ b/spring-batch-samples/src/main/resources/jobs/multilineOrderInputTokenizers.xml @@ -61,5 +61,4 @@ - \ No newline at end of file diff --git a/spring-batch-samples/src/main/resources/jobs/multilineOrderJob.xml b/spring-batch-samples/src/main/resources/jobs/multilineOrderJob.xml index 08cdbd7eb..3b8f7871c 100644 --- a/spring-batch-samples/src/main/resources/jobs/multilineOrderJob.xml +++ b/spring-batch-samples/src/main/resources/jobs/multilineOrderJob.xml @@ -1,12 +1,10 @@ + http://www.springframework.org/schema/batch/spring-batch.xsd"> @@ -67,5 +65,4 @@ - diff --git a/spring-batch-samples/src/main/resources/jobs/multilineOrderOutputAggregators.xml b/spring-batch-samples/src/main/resources/jobs/multilineOrderOutputAggregators.xml index 93c5ebe71..83c21757c 100644 --- a/spring-batch-samples/src/main/resources/jobs/multilineOrderOutputAggregators.xml +++ b/spring-batch-samples/src/main/resources/jobs/multilineOrderOutputAggregators.xml @@ -1,6 +1,6 @@ @@ -57,5 +57,4 @@ - \ No newline at end of file diff --git a/spring-batch-samples/src/main/resources/jobs/parallelJob.xml b/spring-batch-samples/src/main/resources/jobs/parallelJob.xml index 05449790f..901875ba1 100644 --- a/spring-batch-samples/src/main/resources/jobs/parallelJob.xml +++ b/spring-batch-samples/src/main/resources/jobs/parallelJob.xml @@ -3,7 +3,7 @@ xmlns:aop="http://www.springframework.org/schema/aop" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd - http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-2.2.xsd + http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> @@ -107,5 +107,4 @@ method="doStronglyTypedLogging" /> - \ No newline at end of file diff --git a/spring-batch-samples/src/main/resources/jobs/partitionFileJob.xml b/spring-batch-samples/src/main/resources/jobs/partitionFileJob.xml index 3dba31804..5c6206258 100644 --- a/spring-batch-samples/src/main/resources/jobs/partitionFileJob.xml +++ b/spring-batch-samples/src/main/resources/jobs/partitionFileJob.xml @@ -1,8 +1,7 @@ - @@ -82,5 +81,4 @@ - diff --git a/spring-batch-samples/src/main/resources/jobs/partitionJdbcJob.xml b/spring-batch-samples/src/main/resources/jobs/partitionJdbcJob.xml index 09949e95b..a4e2b2839 100644 --- a/spring-batch-samples/src/main/resources/jobs/partitionJdbcJob.xml +++ b/spring-batch-samples/src/main/resources/jobs/partitionJdbcJob.xml @@ -1,9 +1,8 @@ - + xsi:schemaLocation="http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch.xsd + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> @@ -113,5 +112,4 @@ - diff --git a/spring-batch-samples/src/main/resources/jobs/restartFileSampleJob.xml b/spring-batch-samples/src/main/resources/jobs/restartFileSampleJob.xml index 9a50f37db..7173ef653 100644 --- a/spring-batch-samples/src/main/resources/jobs/restartFileSampleJob.xml +++ b/spring-batch-samples/src/main/resources/jobs/restartFileSampleJob.xml @@ -1,7 +1,7 @@ @@ -63,5 +63,4 @@ - diff --git a/spring-batch-samples/src/main/resources/jobs/restartSample.xml b/spring-batch-samples/src/main/resources/jobs/restartSample.xml index 8233a20c2..82ef5d921 100644 --- a/spring-batch-samples/src/main/resources/jobs/restartSample.xml +++ b/spring-batch-samples/src/main/resources/jobs/restartSample.xml @@ -1,7 +1,7 @@ @@ -16,8 +16,6 @@ - - @@ -63,5 +61,4 @@ - \ No newline at end of file diff --git a/spring-batch-samples/src/main/resources/jobs/retrySample.xml b/spring-batch-samples/src/main/resources/jobs/retrySample.xml index 6d4fa47c7..538af8e7d 100644 --- a/spring-batch-samples/src/main/resources/jobs/retrySample.xml +++ b/spring-batch-samples/src/main/resources/jobs/retrySample.xml @@ -1,7 +1,7 @@ @@ -24,5 +24,4 @@ - \ No newline at end of file diff --git a/spring-batch-samples/src/main/resources/jobs/skipSampleJob.xml b/spring-batch-samples/src/main/resources/jobs/skipSampleJob.xml index 14e4dee71..3b1e4b70d 100644 --- a/spring-batch-samples/src/main/resources/jobs/skipSampleJob.xml +++ b/spring-batch-samples/src/main/resources/jobs/skipSampleJob.xml @@ -1,7 +1,7 @@ @@ -133,5 +133,4 @@ - diff --git a/spring-batch-samples/src/main/resources/jobs/taskletJob.xml b/spring-batch-samples/src/main/resources/jobs/taskletJob.xml index 68cb7aa5b..9cb21f6be 100644 --- a/spring-batch-samples/src/main/resources/jobs/taskletJob.xml +++ b/spring-batch-samples/src/main/resources/jobs/taskletJob.xml @@ -1,7 +1,7 @@ @@ -34,5 +34,4 @@ scope="step"> - diff --git a/spring-batch-samples/src/main/resources/jobs/tradeJob.xml b/spring-batch-samples/src/main/resources/jobs/tradeJob.xml index 0ce3d7635..841c7e2db 100644 --- a/spring-batch-samples/src/main/resources/jobs/tradeJob.xml +++ b/spring-batch-samples/src/main/resources/jobs/tradeJob.xml @@ -3,7 +3,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:batch="http://www.springframework.org/schema/batch" - xsi:schemaLocation="http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-2.2.xsd + xsi:schemaLocation="http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> @@ -109,5 +109,4 @@ - \ No newline at end of file diff --git a/spring-batch-samples/src/main/resources/org/springframework/batch/sample/config/common-context.xml b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/config/common-context.xml index b6d093d45..b72a5bb50 100644 --- a/spring-batch-samples/src/main/resources/org/springframework/batch/sample/config/common-context.xml +++ b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/config/common-context.xml @@ -1,11 +1,7 @@ - + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> @@ -14,5 +10,4 @@ - diff --git a/spring-batch-samples/src/main/resources/org/springframework/batch/sample/football-job-context.xml b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/football-job-context.xml index bb710eac3..e1295fc3f 100644 --- a/spring-batch-samples/src/main/resources/org/springframework/batch/sample/football-job-context.xml +++ b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/football-job-context.xml @@ -1,11 +1,9 @@ + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> - diff --git a/spring-batch-samples/src/main/resources/quartz-job-launcher-context.xml b/spring-batch-samples/src/main/resources/quartz-job-launcher-context.xml deleted file mode 100644 index be921bc83..000000000 --- a/spring-batch-samples/src/main/resources/quartz-job-launcher-context.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/spring-batch-samples/src/main/resources/simple-job-launcher-context.xml b/spring-batch-samples/src/main/resources/simple-job-launcher-context.xml index f65a418cd..be43000e4 100644 --- a/spring-batch-samples/src/main/resources/simple-job-launcher-context.xml +++ b/spring-batch-samples/src/main/resources/simple-job-launcher-context.xml @@ -1,11 +1,8 @@ + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> @@ -47,5 +44,4 @@ - diff --git a/spring-batch-samples/src/main/resources/skipSample-job-launcher-context.xml b/spring-batch-samples/src/main/resources/skipSample-job-launcher-context.xml index bcf62cae5..d059b794e 100644 --- a/spring-batch-samples/src/main/resources/skipSample-job-launcher-context.xml +++ b/spring-batch-samples/src/main/resources/skipSample-job-launcher-context.xml @@ -1,9 +1,8 @@ - + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> @@ -45,6 +44,4 @@ - - diff --git a/spring-batch-samples/src/main/resources/staging-test-context.xml b/spring-batch-samples/src/main/resources/staging-test-context.xml index 0c0dc8714..6526914a3 100644 --- a/spring-batch-samples/src/main/resources/staging-test-context.xml +++ b/spring-batch-samples/src/main/resources/staging-test-context.xml @@ -1,8 +1,6 @@ + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> @@ -18,5 +16,4 @@ - \ No newline at end of file diff --git a/spring-batch-samples/src/main/resources/xstream-config.xml b/spring-batch-samples/src/main/resources/xstream-config.xml deleted file mode 100644 index a61f8a2a8..000000000 --- a/spring-batch-samples/src/main/resources/xstream-config.xml +++ /dev/null @@ -1,75 +0,0 @@ - - - 1003 - purchaseOrders - - - xmlns - http://adsj.accenture.com/purchaseorders - - - xmlns:xsi - http://www.w3.org/2001/XMLSchema-instance - - - xsi:schemaLocation - http://adsj.accenture.com/purchaseorders purchaseorders.xsd - - - - - - - - - org.springframework.batch.sample.domain.order.internal.xml.Customer - org.springframework.batch.sample.domain.order.internal.xml.Order - customer - - - org.springframework.batch.sample.domain.order.internal.xml.Shipper - org.springframework.batch.sample.domain.order.internal.xml.Order - shipper - - - - - - - - - - - - - - - - - - - http://adsj.accenture.com/purchaseorders - order - - org.springframework.batch.sample.domain.order.internal.xml.Order - - - http://adsj.accenture.com/purchaseorders - customer - - org.springframework.batch.sample.domain.order.internal.xml.Customer - - - http://adsj.accenture.com/purchaseorders - shipper - - org.springframework.batch.sample.domain.order.internal.xml.Shipper - - - http://adsj.accenture.com/purchaseorders - lineItem - - org.springframework.batch.sample.domain.order.internal.xml.LineItem - - - diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/CompositeItemWriterSampleFunctionalTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/CompositeItemWriterSampleFunctionalTests.java index 37f42a5c7..62de3bb52 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/CompositeItemWriterSampleFunctionalTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/CompositeItemWriterSampleFunctionalTests.java @@ -27,9 +27,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "/simple-job-launcher-context.xml", "/jobs/compositeItemWriterSampleJob.xml", "/job-runner-context.xml" }) public class CompositeItemWriterSampleFunctionalTests { - private static final String GET_TRADES = "SELECT isin, quantity, price, customer FROM TRADE order by isin"; - private static final String EXPECTED_OUTPUT_FILE = "Trade: [isin=UK21341EAH41,quantity=211,price=31.11,customer=customer1]" + "Trade: [isin=UK21341EAH42,quantity=212,price=32.11,customer=customer2]" + "Trade: [isin=UK21341EAH43,quantity=213,price=33.11,customer=customer3]" @@ -48,16 +46,14 @@ public class CompositeItemWriterSampleFunctionalTests { @Test public void testJobLaunch() throws Exception { - jdbcTemplate.update("DELETE from TRADE"); - int before = jdbcTemplate.queryForInt("SELECT COUNT(*) from TRADE"); + int before = jdbcTemplate.queryForObject("SELECT COUNT(*) from TRADE", Integer.class); jobLauncherTestUtils.launchJob(); checkOutputFile("target/test-outputs/CustomerReport1.txt"); checkOutputFile("target/test-outputs/CustomerReport2.txt"); checkOutputTable(before); - } private void checkOutputTable(int before) { @@ -71,13 +67,14 @@ public class CompositeItemWriterSampleFunctionalTests { } }; - int after = jdbcTemplate.queryForInt("SELECT COUNT(*) from TRADE"); + int after = jdbcTemplate.queryForObject("SELECT COUNT(*) from TRADE", Integer.class); assertEquals(before + 5, after); - jdbcTemplate.query(GET_TRADES, new RowCallbackHandler() { private int activeRow = 0; + + @Override public void processRow(ResultSet rs) throws SQLException { Trade trade = trades.get(activeRow++); @@ -101,5 +98,4 @@ public class CompositeItemWriterSampleFunctionalTests { assertEquals(EXPECTED_OUTPUT_FILE, output); } - } diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/CustomerFilterJobFunctionalTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/CustomerFilterJobFunctionalTests.java index afea2890f..98f7ab0ea 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/CustomerFilterJobFunctionalTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/CustomerFilterJobFunctionalTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2012 the original author or authors. + * Copyright 2006-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,12 +43,9 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "/simple-job-launcher-context.xml", "/jobs/customerFilterJob.xml", "/job-runner-context.xml" }) public class CustomerFilterJobFunctionalTests { - private static final String GET_CUSTOMERS = "select NAME, CREDIT from CUSTOMER order by NAME"; - private List customers; private int activeRow = 0; - private JdbcOperations jdbcTemplate; private Map credits = new HashMap(); @@ -65,7 +62,9 @@ public class CustomerFilterJobFunctionalTests { jdbcTemplate.update("delete from TRADE"); jdbcTemplate.update("delete from CUSTOMER where ID > 4"); jdbcTemplate.update("update CUSTOMER set credit=100000"); + List> list = jdbcTemplate.queryForList("select name, CREDIT from CUSTOMER"); + for (Map map : list) { credits.put((String) map.get("NAME"), ((Number) map.get("CREDIT")).doubleValue()); } @@ -79,17 +78,15 @@ public class CustomerFilterJobFunctionalTests { @Test public void testFilterJob() throws Exception { - JobExecution jobExecution = jobLauncherTestUtils.launchJob(); customers = Arrays.asList(new Customer("customer1", (credits.get("customer1"))), new Customer("customer2", (credits.get("customer2"))), new Customer("customer3", 100500), new Customer("customer4", credits .get("customer4")), new Customer("customer5", 32345), new Customer("customer6", 123456)); - // check content of the customer table activeRow = 0; jdbcTemplate.query(GET_CUSTOMERS, new RowCallbackHandler() { - + @Override public void processRow(ResultSet rs) throws SQLException { Customer customer = customers.get(activeRow++); assertEquals(customer.getName(), rs.getString(1)); @@ -101,7 +98,6 @@ public class CustomerFilterJobFunctionalTests { assertEquals("4", step1Execution.get("READ_COUNT").toString()); assertEquals("1", step1Execution.get("FILTER_COUNT").toString()); assertEquals("3", step1Execution.get("WRITE_COUNT").toString()); - } private Map getStepExecution(JobExecution jobExecution, String stepName) { @@ -174,7 +170,5 @@ public class CustomerFilterJobFunctionalTests { return false; return true; } - } - } diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/FootballJobFunctionalTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/FootballJobFunctionalTests.java index 1bdd75935..37d7761bc 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/FootballJobFunctionalTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/FootballJobFunctionalTests.java @@ -16,10 +16,8 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "/simple-job-launcher-context.xml", "/jobs/footballJob.xml", "/job-runner-context.xml" }) public class FootballJobFunctionalTests { - @Autowired private JobLauncherTestUtils jobLauncherTestUtils; - private JdbcOperations jdbcTemplate; @Autowired @@ -29,16 +27,13 @@ public class FootballJobFunctionalTests { @Test public void testLaunchJob() throws Exception { - jdbcTemplate.update("DELETE FROM PLAYERS"); jdbcTemplate.update("DELETE FROM GAMES"); jdbcTemplate.update("DELETE FROM PLAYER_SUMMARY"); jobLauncherTestUtils.launchJob(); - int count = jdbcTemplate.queryForInt("SELECT COUNT(*) from PLAYER_SUMMARY"); + int count = jdbcTemplate.queryForObject("SELECT COUNT(*) from PLAYER_SUMMARY", Integer.class); assertTrue(count > 0); - } - } diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/HibernateFailureJobFunctionalTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/HibernateFailureJobFunctionalTests.java index 2f1222935..a7a13515b 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/HibernateFailureJobFunctionalTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/HibernateFailureJobFunctionalTests.java @@ -42,29 +42,21 @@ import org.springframework.transaction.support.TransactionTemplate; @ContextConfiguration(locations = { "/simple-job-launcher-context.xml", "/hibernate-context.xml", "/jobs/hibernateJob.xml", "/job-runner-context.xml" }) public class HibernateFailureJobFunctionalTests { - - @Autowired - private HibernateCreditDao writer; - - private JdbcOperations jdbcTemplate; - - private PlatformTransactionManager transactionManager; - private static final BigDecimal CREDIT_INCREASE = CustomerCreditIncreaseProcessor.FIXED_AMOUNT; - - private static String[] customers = { "INSERT INTO CUSTOMER (id, version, name, credit) VALUES (1, 0, 'customer1', 100000)", - "INSERT INTO CUSTOMER (id, version, name, credit) VALUES (2, 0, 'customer2', 100000)", - "INSERT INTO CUSTOMER (id, version, name, credit) VALUES (3, 0, 'customer3', 100000)", - "INSERT INTO CUSTOMER (id, version, name, credit) VALUES (4, 0, 'customer4', 100000)"}; - - private static String DELETE_CUSTOMERS = "DELETE FROM CUSTOMER"; - + private static final String DELETE_CUSTOMERS = "DELETE FROM CUSTOMER"; private static final String ALL_CUSTOMERS = "select * from CUSTOMER order by ID"; - private static final String CREDIT_COLUMN = "CREDIT"; + private static String[] customers = { "INSERT INTO CUSTOMER (id, version, name, credit) VALUES (1, 0, 'customer1', 100000)", + "INSERT INTO CUSTOMER (id, version, name, credit) VALUES (2, 0, 'customer2', 100000)", + "INSERT INTO CUSTOMER (id, version, name, credit) VALUES (3, 0, 'customer3', 100000)", + "INSERT INTO CUSTOMER (id, version, name, credit) VALUES (4, 0, 'customer4', 100000)"}; protected static final String ID_COLUMN = "ID"; + @Autowired + private HibernateCreditDao writer; + private JdbcOperations jdbcTemplate; + private PlatformTransactionManager transactionManager; private List creditsBeforeUpdate; @Autowired @@ -82,7 +74,6 @@ public class HibernateFailureJobFunctionalTests { @Test public void testLaunchJob() throws Exception { - validatePreConditions(); JobParameters params = new JobParametersBuilder().addString("key", "failureJob").toJobParameters(); @@ -100,11 +91,11 @@ public class HibernateFailureJobFunctionalTests { // assertEquals(1, writer.getErrors().size()); throw e; } - int after = jdbcTemplate.queryForInt("SELECT COUNT(*) from CUSTOMER"); + + int after = jdbcTemplate.queryForObject("SELECT COUNT(*) from CUSTOMER", Integer.class); assertEquals(4, after); validatePostConditions(); - } /** @@ -114,8 +105,10 @@ public class HibernateFailureJobFunctionalTests { protected void validatePreConditions() throws Exception { ensureState(); creditsBeforeUpdate = (List) new TransactionTemplate(transactionManager).execute(new TransactionCallback() { + @Override public Object doInTransaction(TransactionStatus status) { return jdbcTemplate.query(ALL_CUSTOMERS, new ParameterizedRowMapper() { + @Override public BigDecimal mapRow(ResultSet rs, int rowNum) throws SQLException { return rs.getBigDecimal(CREDIT_COLUMN); } @@ -129,32 +122,31 @@ public class HibernateFailureJobFunctionalTests { * customer table and reading the expected defaults. */ private void ensureState(){ - new TransactionTemplate(transactionManager).execute(new TransactionCallback(){ - + new TransactionTemplate(transactionManager).execute(new TransactionCallback() { + @Override public Object doInTransaction(TransactionStatus status) { - jdbcTemplate.update(DELETE_CUSTOMERS); + jdbcTemplate.update(DELETE_CUSTOMERS); for (String customer : customers) { - jdbcTemplate.update(customer); + jdbcTemplate.update(customer); } return null; } - }); - + }); } /** * Credit was increased by CREDIT_INCREASE */ protected void validatePostConditions() throws Exception { - final List matches = new ArrayList(); new TransactionTemplate(transactionManager).execute(new TransactionCallback() { + @Override public Object doInTransaction(TransactionStatus status) { jdbcTemplate.query(ALL_CUSTOMERS, new RowCallbackHandler() { - private int i = 0; + @Override public void processRow(ResultSet rs) throws SQLException { final BigDecimal creditBeforeUpdate = creditsBeforeUpdate.get(i++); final BigDecimal expectedCredit = creditBeforeUpdate.add(CREDIT_INCREASE); @@ -164,6 +156,7 @@ public class HibernateFailureJobFunctionalTests { } }); + return null; } }); diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/JobOperatorFunctionalTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/JobOperatorFunctionalTests.java index 9ab073b2f..6ce05f26e 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/JobOperatorFunctionalTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/JobOperatorFunctionalTests.java @@ -26,8 +26,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "/simple-job-launcher-context.xml", "/jobs/infiniteLoopJob.xml" }) public class JobOperatorFunctionalTests { - - private static final Log logger = LogFactory.getLog(JobOperatorFunctionalTests.class); + private static final Log LOG = LogFactory.getLog(JobOperatorFunctionalTests.class); @Autowired private JobOperator operator; @@ -47,7 +46,6 @@ public class JobOperatorFunctionalTests { @Test public void testStartStopResumeJob() throws Exception { - String params = new JobParametersBuilder().addLong("jobOperatorTestParam", 7L).toJobParameters().toString(); long executionId = operator.start(job.getName(), params); @@ -67,14 +65,12 @@ public class JobOperatorFunctionalTests { // latest execution is the first in the returned list assertEquals(resumedExecutionId, executions.get(0).longValue()); assertEquals(executionId, executions.get(1).longValue()); - } /** * @param executionId id of running job execution */ private void stopAndCheckStatus(long executionId) throws Exception { - // wait to the job to get up and running Thread.sleep(1000); @@ -88,7 +84,7 @@ public class JobOperatorFunctionalTests { int count = 0; while (operator.getRunningExecutions(job.getName()).contains(executionId) && count <= 10) { - logger.info("Checking for running JobExecution: count=" + count); + LOG.info("Checking for running JobExecution: count=" + count); Thread.sleep(100); count++; } @@ -101,7 +97,7 @@ public class JobOperatorFunctionalTests { // there is just a single step in the test job Map summaries = operator.getStepExecutionSummaries(executionId); - System.err.println(summaries); + LOG.info(summaries); assertTrue(summaries.values().toString().contains(BatchStatus.STOPPED.toString())); } @@ -117,24 +113,25 @@ public class JobOperatorFunctionalTests { long exec2 = operator.startNextInstance(jobName); assertTrue(exec1 != exec2); - assertTrue(operator.getParameters(exec1) != operator.getParameters(exec2)); + assertTrue(!operator.getParameters(exec1).equals(operator.getParameters(exec2))); Set executions = operator.getRunningExecutions(jobName); assertTrue(executions.contains(exec1)); assertTrue(executions.contains(exec2)); + int count = 0; boolean running = operator.getSummary(exec1).contains("STARTED") && operator.getSummary(exec2).contains("STARTED"); + while (count++ < 10 && !running) { Thread.sleep(100L); running = operator.getSummary(exec1).contains("STARTED") && operator.getSummary(exec2).contains("STARTED"); } + assertTrue(String.format("Jobs not started: [%s] and [%s]", operator.getSummary(exec1), operator .getSummary(exec1)), running); operator.stop(exec1); operator.stop(exec2); - } - } diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/JobStepFunctionalTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/JobStepFunctionalTests.java index d787b9491..ce1038c1e 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/JobStepFunctionalTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/JobStepFunctionalTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2012 the original author or authors. + * Copyright 2006-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,11 +39,8 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration public class JobStepFunctionalTests { - @Autowired private JobLauncherTestUtils jobLauncherTestUtils; - - // auto-injected attributes private JdbcOperations jdbcTemplate; @Autowired @@ -53,16 +50,13 @@ public class JobStepFunctionalTests { @Test public void testJobLaunch() throws Exception { - jdbcTemplate.update("DELETE FROM TRADE"); jobLauncherTestUtils.launchJob(new DefaultJobParametersConverter() .getJobParameters(PropertiesConverter .stringToProperties("run.id(long)=1,parameter=true,run.date=20070122,input.file=classpath:data/fixedLengthImportJob/input/20070122.teststream.ImportTradeDataStep.txt"))); - int after = jdbcTemplate.queryForInt("SELECT COUNT(*) FROM TRADE"); + int after = jdbcTemplate.queryForObject("SELECT COUNT(*) FROM TRADE", Integer.class); assertEquals(5, after); - } - } diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/PartitionFileJobFunctionalTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/PartitionFileJobFunctionalTests.java index de7fe3241..8eb4cadb5 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/PartitionFileJobFunctionalTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/PartitionFileJobFunctionalTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -46,16 +46,15 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @ContextConfiguration(locations = { "/simple-job-launcher-context.xml", "/jobs/partitionFileJob.xml", "/job-runner-context.xml" }) public class PartitionFileJobFunctionalTests implements ApplicationContextAware { - @Autowired @Qualifier("inputTestReader") private ItemReader inputReader; @Autowired private JobLauncherTestUtils jobLauncherTestUtils; - private ApplicationContext applicationContext; + @Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { this.applicationContext = applicationContext; } @@ -66,7 +65,6 @@ public class PartitionFileJobFunctionalTests implements ApplicationContextAware */ @Test public void testUpdateCredit() throws Exception { - assertTrue("Define a prototype bean called 'outputTestReader' to check the output", applicationContext .containsBeanDefinition("outputTestReader")); @@ -93,7 +91,6 @@ public class PartitionFileJobFunctionalTests implements ApplicationContextAware assertEquals(inputs.get(i).getCredit().add(CustomerCreditIncreaseProcessor.FIXED_AMOUNT).intValue(), outputs.get(i).getCredit().intValue()); } - } /** @@ -102,11 +99,12 @@ public class PartitionFileJobFunctionalTests implements ApplicationContextAware private Set getCredits(ItemReader reader) throws Exception { CustomerCredit credit; Set result = new LinkedHashSet(); + while ((credit = reader.read()) != null) { result.add(credit); } - return result; + return result; } /** @@ -126,5 +124,4 @@ public class PartitionFileJobFunctionalTests implements ApplicationContextAware ((ItemStream) reader).close(); } } - } diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/PartitionJdbcJobFunctionalTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/PartitionJdbcJobFunctionalTests.java index 0bfb8a7e8..492b26396 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/PartitionJdbcJobFunctionalTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/PartitionJdbcJobFunctionalTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -46,16 +46,15 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @ContextConfiguration(locations = { "/simple-job-launcher-context.xml", "/jobs/partitionJdbcJob.xml", "/job-runner-context.xml" }) public class PartitionJdbcJobFunctionalTests implements ApplicationContextAware { - @Autowired @Qualifier("inputTestReader") private ItemReader inputReader; @Autowired private JobLauncherTestUtils jobLauncherTestUtils; - private ApplicationContext applicationContext; + @Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { this.applicationContext = applicationContext; } @@ -66,7 +65,6 @@ public class PartitionJdbcJobFunctionalTests implements ApplicationContextAware */ @Test public void testUpdateCredit() throws Exception { - assertTrue("Define a prototype bean called 'outputTestReader' to check the output", applicationContext .containsBeanDefinition("outputTestReader")); @@ -93,7 +91,6 @@ public class PartitionJdbcJobFunctionalTests implements ApplicationContextAware assertEquals(inputs.get(i).getCredit().add(CustomerCreditIncreaseProcessor.FIXED_AMOUNT).intValue(), outputs.get(i).getCredit().intValue()); } - } /** @@ -126,5 +123,4 @@ public class PartitionJdbcJobFunctionalTests implements ApplicationContextAware ((ItemStream) reader).close(); } } - } diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/RestartFunctionalTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/RestartFunctionalTests.java index 47b4557b2..bb1c9e7df 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/RestartFunctionalTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/RestartFunctionalTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2012 the original author or authors. + * Copyright 2006-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,13 +44,11 @@ import org.springframework.test.context.transaction.BeforeTransaction; @ContextConfiguration(locations = { "/simple-job-launcher-context.xml", "/jobs/restartSample.xml", "/job-runner-context.xml" }) public class RestartFunctionalTests { + private JdbcOperations jdbcTemplate; @Autowired private JobLauncherTestUtils jobLauncherTestUtils; - // auto-injected attributes - private JdbcOperations jdbcTemplate; - @Autowired public void setDataSource(DataSource dataSource) { this.jdbcTemplate = new JdbcTemplate(dataSource); @@ -72,8 +70,7 @@ public class RestartFunctionalTests { */ @Test public void testLaunchJob() throws Exception { - - int before = jdbcTemplate.queryForInt("SELECT COUNT(*) FROM TRADE"); + int before = jdbcTemplate.queryForObject("SELECT COUNT(*) FROM TRADE", Integer.class); JobExecution jobExecution = runJobForRestartTest(); assertEquals(BatchStatus.FAILED, jobExecution.getStatus()); @@ -86,14 +83,14 @@ public class RestartFunctionalTests { throw new RuntimeException(ex); } - int medium = jdbcTemplate.queryForInt("SELECT COUNT(*) FROM TRADE"); + int medium = jdbcTemplate.queryForObject("SELECT COUNT(*) FROM TRADE", Integer.class); // assert based on commit interval = 2 assertEquals(before + 2, medium); jobExecution = runJobForRestartTest(); assertEquals(BatchStatus.COMPLETED, jobExecution.getStatus()); - int after = jdbcTemplate.queryForInt("SELECT COUNT(*) FROM TRADE"); + int after = jdbcTemplate.queryForObject("SELECT COUNT(*) FROM TRADE", Integer.class); assertEquals(before + 5, after); } @@ -105,5 +102,4 @@ public class RestartFunctionalTests { .getJobParameters(PropertiesConverter .stringToProperties("run.id(long)=1,parameter=true,run.date=20070122,input.file=classpath:data/fixedLengthImportJob/input/20070122.teststream.ImportTradeDataStep.txt"))); } - } diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/TestSuite.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/TestSuite.java deleted file mode 100644 index 660da4083..000000000 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/TestSuite.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2006-2009 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.batch.sample; - -import org.junit.Ignore; -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import org.junit.runners.Suite.SuiteClasses; - -/** - * Temporary test suite to find bug in build.... - * - */ -@Ignore -@RunWith(Suite.class) -@SuiteClasses({SkipSampleFunctionalTests.class, CustomerFilterJobFunctionalTests.class}) -public class TestSuite { - -} diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/TradeJobFunctionalTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/TradeJobFunctionalTests.java index 354d924c8..9d05cb736 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/TradeJobFunctionalTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/TradeJobFunctionalTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2012 the original author or authors. + * Copyright 2006-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -46,14 +46,12 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @ContextConfiguration(locations = { "/simple-job-launcher-context.xml", "/jobs/tradeJob.xml", "/job-runner-context.xml" }) public class TradeJobFunctionalTests { - private static final String GET_TRADES = "select ISIN, QUANTITY, PRICE, CUSTOMER, ID, VERSION from TRADE order by ISIN"; private static final String GET_CUSTOMERS = "select NAME, CREDIT from CUSTOMER order by NAME"; private List customers; private List trades; private int activeRow = 0; - private JdbcOperations jdbcTemplate; private Map credits = new HashMap(); @@ -69,6 +67,7 @@ public class TradeJobFunctionalTests { public void onSetUp() throws Exception { jdbcTemplate.update("delete from TRADE"); List> list = jdbcTemplate.queryForList("select NAME, CREDIT from CUSTOMER"); + for (Map map : list) { credits.put((String) map.get("NAME"), ((Number) map.get("CREDIT")).doubleValue()); } @@ -81,7 +80,6 @@ public class TradeJobFunctionalTests { @Test public void testLaunchJob() throws Exception { - jobLauncherTestUtils.launchJob(); customers = Arrays.asList(new Customer("customer1", (credits.get("customer1") - 98.34)), @@ -95,9 +93,8 @@ public class TradeJobFunctionalTests { new Trade("UK21341EAH48", 108, new BigDecimal("109.25"), "customer3"), new Trade("UK21341EAH49", 854, new BigDecimal("123.39"), "customer4")); - // check content of the trade table jdbcTemplate.query(GET_TRADES, new RowCallbackHandler() { - + @Override public void processRow(ResultSet rs) throws SQLException { Trade trade = trades.get(activeRow++); @@ -110,10 +107,9 @@ public class TradeJobFunctionalTests { assertEquals(activeRow, trades.size()); - // check content of the customer table activeRow = 0; jdbcTemplate.query(GET_CUSTOMERS, new RowCallbackHandler() { - + @Override public void processRow(ResultSet rs) throws SQLException { Customer customer = customers.get(activeRow++); @@ -123,8 +119,6 @@ public class TradeJobFunctionalTests { }); assertEquals(customers.size(), activeRow); - - // check content of the output file } private static class Customer { @@ -179,9 +173,5 @@ public class TradeJobFunctionalTests { return false; return true; } - - } - - } diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/CustomItemReaderTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/CustomItemReaderTests.java index 612c55bcb..1867121c9 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/CustomItemReaderTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/CustomItemReaderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2008 the original author or authors. + * Copyright 2006-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,8 +27,6 @@ import org.springframework.batch.item.ExecutionContext; import org.springframework.batch.item.ItemReader; import org.springframework.batch.item.ItemStream; import org.springframework.batch.item.ItemStreamException; -import org.springframework.batch.item.ParseException; -import org.springframework.batch.item.UnexpectedInputException; /** * Unit test class that was used as part of the Reference Documentation. I'm only including it in the @@ -38,15 +36,13 @@ import org.springframework.batch.item.UnexpectedInputException; * */ public class CustomItemReaderTests { - - ItemReader itemReader; + private ItemReader itemReader; /* (non-Javadoc) * @see junit.framework.TestCase#setUp() */ @Before public void setUp() throws Exception { - List items = new ArrayList(); items.add("1"); items.add("2"); @@ -57,7 +53,6 @@ public class CustomItemReaderTests { @Test public void testRead() throws Exception{ - assertEquals("1", itemReader.read()); assertEquals("2", itemReader.read()); assertEquals("3", itemReader.read()); @@ -66,7 +61,6 @@ public class CustomItemReaderTests { @Test public void testRestart() throws Exception{ - ExecutionContext executionContext = new ExecutionContext(); ((ItemStream)itemReader).open(executionContext); assertEquals("1", itemReader.read()); @@ -82,24 +76,24 @@ public class CustomItemReaderTests { } public static class CustomItemReader implements ItemReader, ItemStream { - - List items; - int currentIndex = 0; private static final String CURRENT_INDEX = "current.index"; - + + private List items; + private int currentIndex = 0; + public CustomItemReader(List items) { this.items = items; } - public T read() throws Exception, UnexpectedInputException, - ParseException { - + @Override + public T read() throws Exception { if (currentIndex < items.size()) { return items.get(currentIndex++); } return null; } - + + @Override public void open(ExecutionContext executionContext) throws ItemStreamException { if(executionContext.containsKey(CURRENT_INDEX)){ currentIndex = executionContext.getInt(CURRENT_INDEX); @@ -109,11 +103,12 @@ public class CustomItemReaderTests { } } + @Override public void close() throws ItemStreamException {} + @Override public void update(ExecutionContext executionContext) throws ItemStreamException { executionContext.putInt(CURRENT_INDEX, currentIndex); - }; - + } } } diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/CustomItemWriterTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/CustomItemWriterTests.java index 66dff1a53..58824750f 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/CustomItemWriterTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/CustomItemWriterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2008 the original author or authors. + * Copyright 2006-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,21 +34,19 @@ import org.springframework.batch.support.transaction.TransactionAwareProxyFactor * */ public class CustomItemWriterTests { - @Test public void testFlush() throws Exception { - CustomItemWriter itemWriter = new CustomItemWriter(); itemWriter.write(Collections.singletonList("1")); assertEquals(1, itemWriter.getOutput().size()); - itemWriter.write(Arrays.asList(new String[] {"2","3"})); + itemWriter.write(Arrays.asList("2","3")); assertEquals(3, itemWriter.getOutput().size()); } public static class CustomItemWriter implements ItemWriter { + private List output = TransactionAwareProxyFactory.createTransactionalList(); - List output = TransactionAwareProxyFactory.createTransactionalList(); - + @Override public void write(List items) throws Exception { output.addAll(items); } diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/ErrorLogTasklet.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/ErrorLogTasklet.java index 762014af1..0f2e65908 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/ErrorLogTasklet.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/ErrorLogTasklet.java @@ -20,15 +20,9 @@ import org.springframework.util.Assert; * @since 2.0 */ public class ErrorLogTasklet implements Tasklet, StepExecutionListener { - - protected final Log logger = LogFactory.getLog(getClass()); - private JdbcOperations jdbcTemplate; - private String jobName; - private StepExecution stepExecution; - private String stepName; public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { @@ -58,6 +52,7 @@ public class ErrorLogTasklet implements Tasklet, StepExecutionListener { this.jdbcTemplate = new JdbcTemplate(dataSource); } + @Override public void beforeStep(StepExecution stepExecution) { this.jobName = stepExecution.getJobExecution().getJobInstance().getJobName().trim(); this.stepName = (String) stepExecution.getJobExecution().getExecutionContext().get("stepName"); @@ -65,8 +60,8 @@ public class ErrorLogTasklet implements Tasklet, StepExecutionListener { stepExecution.getJobExecution().getExecutionContext().remove("stepName"); } + @Override public ExitStatus afterStep(StepExecution stepExecution) { return null; } - } diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/OutputFileListenerTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/OutputFileListenerTests.java index ef1df4846..57122f661 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/OutputFileListenerTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/OutputFileListenerTests.java @@ -7,7 +7,6 @@ import org.springframework.batch.core.JobExecution; import org.springframework.batch.core.StepExecution; public class OutputFileListenerTests { - private OutputFileListener listener = new OutputFileListener(); private StepExecution stepExecution = new StepExecution("foo", new JobExecution(0L), 1L); @@ -40,5 +39,4 @@ public class OutputFileListenerTests { listener.createOutputNameFromInput(stepExecution); assertEquals("bar.csv", stepExecution.getExecutionContext().getString("outputFile")); } - } diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/SkipCheckingDecider.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/SkipCheckingDecider.java index be69db195..5be4bfa0e 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/SkipCheckingDecider.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/SkipCheckingDecider.java @@ -7,7 +7,7 @@ import org.springframework.batch.core.job.flow.FlowExecutionStatus; import org.springframework.batch.core.job.flow.JobExecutionDecider; public class SkipCheckingDecider implements JobExecutionDecider { - + @Override public FlowExecutionStatus decide(JobExecution jobExecution, StepExecution stepExecution) { if (!stepExecution.getExitStatus().getExitCode().equals( ExitStatus.FAILED.getExitCode()) diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/StagingItemReaderTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/StagingItemReaderTests.java index c24fa8f4b..9ecb446ea 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/StagingItemReaderTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/StagingItemReaderTests.java @@ -30,7 +30,6 @@ import org.springframework.transaction.support.TransactionTemplate; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration() public class StagingItemReaderTests { - private JdbcOperations jdbcTemplate; @Autowired @@ -54,7 +53,7 @@ public class StagingItemReaderTests { StepExecution stepExecution = new StepExecution("stepName", new JobExecution(new JobInstance(jobId, "testJob"), new JobParameters())); writer.beforeStep(stepExecution); - writer.write(Arrays.asList(new String[] { "FOO", "BAR", "SPAM", "BUCKET" })); + writer.write(Arrays.asList("FOO", "BAR", "SPAM", "BUCKET")); reader.beforeStep(stepExecution); } @@ -67,8 +66,7 @@ public class StagingItemReaderTests { @Transactional @Test public void testReaderWithProcessorUpdatesProcessIndicator() throws Exception { - - long id = jdbcTemplate.queryForLong("SELECT MIN(ID) from BATCH_STAGING where JOB_ID=?", jobId); + long id = jdbcTemplate.queryForObject("SELECT MIN(ID) from BATCH_STAGING where JOB_ID=?", Long.class, jobId); String before = jdbcTemplate.queryForObject("SELECT PROCESSED from BATCH_STAGING where ID=?", String.class, id); assertEquals(StagingItemWriter.NEW, before); @@ -84,7 +82,6 @@ public class StagingItemReaderTests { String after = jdbcTemplate.queryForObject("SELECT PROCESSED from BATCH_STAGING where ID=?", String.class, id); assertEquals(StagingItemWriter.DONE, after); - } @Transactional @@ -103,7 +100,7 @@ public class StagingItemReaderTests { return null; } }); - long id = jdbcTemplate.queryForLong("SELECT MIN(ID) from BATCH_STAGING where JOB_ID=?", jobId); + long id = jdbcTemplate.queryForObject("SELECT MIN(ID) from BATCH_STAGING where JOB_ID=?", Long.class, jobId); String before = jdbcTemplate.queryForObject("SELECT PROCESSED from BATCH_STAGING where ID=?", String.class, id); assertEquals(StagingItemWriter.DONE, before); @@ -112,14 +109,13 @@ public class StagingItemReaderTests { @Transactional @Test public void testReaderRollsBackProcessIndicator() throws Exception { - TransactionTemplate txTemplate = new TransactionTemplate(transactionManager); txTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW); final Long idToUse = (Long) txTemplate.execute(new TransactionCallback() { public Object doInTransaction(TransactionStatus transactionStatus) { - long id = jdbcTemplate.queryForLong("SELECT MIN(ID) from BATCH_STAGING where JOB_ID=?", jobId); + long id = jdbcTemplate.queryForObject("SELECT MIN(ID) from BATCH_STAGING where JOB_ID=?", Long.class, jobId); String before = jdbcTemplate.queryForObject("SELECT PROCESSED from BATCH_STAGING where ID=?", String.class, id); assertEquals(StagingItemWriter.NEW, before); @@ -136,6 +132,5 @@ public class StagingItemReaderTests { String after = jdbcTemplate.queryForObject("SELECT PROCESSED from BATCH_STAGING where ID=?", String.class, idToUse); assertEquals(StagingItemWriter.NEW, after); - } } diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/StagingItemWriterTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/StagingItemWriterTests.java index 1fccfce0b..c0317a59b 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/StagingItemWriterTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/StagingItemWriterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2012 the original author or authors. + * Copyright 2006-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,7 +38,6 @@ import org.springframework.transaction.annotation.Transactional; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration public class StagingItemWriterTests { - private JdbcOperations jdbcTemplate; @Autowired @@ -59,10 +58,10 @@ public class StagingItemWriterTests { @Transactional @Test public void testProcessInsertsNewItem() throws Exception { - int before = jdbcTemplate.queryForInt("SELECT COUNT(*) from BATCH_STAGING"); + int before = jdbcTemplate.queryForObject("SELECT COUNT(*) from BATCH_STAGING", Integer.class); writer.write(Collections.singletonList("FOO")); - int after = jdbcTemplate.queryForInt("SELECT COUNT(*) from BATCH_STAGING"); + + int after = jdbcTemplate.queryForObject("SELECT COUNT(*) from BATCH_STAGING", Integer.class); assertEquals(before + 1, after); } - } diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/football/internal/JdbcGameDaoIntegrationTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/football/internal/JdbcGameDaoIntegrationTests.java index de6a8020d..80dbc34e9 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/football/internal/JdbcGameDaoIntegrationTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/football/internal/JdbcGameDaoIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2012 the original author or authors. + * Copyright 2006-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,11 +42,8 @@ import org.springframework.transaction.annotation.Transactional; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = {"/data-source-context.xml"}) public class JdbcGameDaoIntegrationTests { - private JdbcGameDao gameDao; - private Game game = new Game(); - private JdbcOperations jdbcTemplate; @Autowired @@ -59,7 +56,6 @@ public class JdbcGameDaoIntegrationTests { @Before public void onSetUpBeforeTransaction() throws Exception { - game.setId("XXXXX00"); game.setYear(1996); game.setTeam("mia"); @@ -75,12 +71,10 @@ public class JdbcGameDaoIntegrationTests { game.setReceptions(1); game.setReceptionYards(16); game.setTotalTd(2); - } @Transactional @Test public void testWrite() { - gameDao.write(Collections.singletonList(game)); Game tempGame = jdbcTemplate.queryForObject("SELECT * FROM GAMES where PLAYER_ID=? AND YEAR_NO=?", @@ -89,9 +83,8 @@ public class JdbcGameDaoIntegrationTests { } private static class GameRowMapper implements ParameterizedRowMapper { - + @Override public Game mapRow(ResultSet rs, int arg1) throws SQLException { - if (rs == null) { return null; } diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/football/internal/JdbcPlayerDaoIntegrationTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/football/internal/JdbcPlayerDaoIntegrationTests.java index 2730acdee..075735b99 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/football/internal/JdbcPlayerDaoIntegrationTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/football/internal/JdbcPlayerDaoIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2012 the original author or authors. + * Copyright 2006-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,18 +41,13 @@ import org.springframework.transaction.annotation.Transactional; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = {"/data-source-context.xml"}) public class JdbcPlayerDaoIntegrationTests { - private JdbcPlayerDao playerDao; - private Player player; - private static final String GET_PLAYER = "SELECT * from PLAYERS"; - private JdbcOperations jdbcTemplate; @Autowired public void init(DataSource dataSource) { - this.jdbcTemplate = new JdbcTemplate(dataSource); playerDao = new JdbcPlayerDao(); playerDao.setDataSource(dataSource); @@ -64,24 +59,19 @@ public class JdbcPlayerDaoIntegrationTests { player.setPosition("QB"); player.setBirthYear(1975); player.setDebutYear(1998); - } - @Before public void onSetUpInTransaction() throws Exception { - jdbcTemplate.execute("delete from PLAYERS"); - } - @Transactional @Test + @Test + @Transactional public void testSavePlayer(){ - playerDao.savePlayer(player); - - jdbcTemplate.query(GET_PLAYER, new RowCallbackHandler(){ - + jdbcTemplate.query(GET_PLAYER, new RowCallbackHandler() { + @Override public void processRow(ResultSet rs) throws SQLException { assertEquals(rs.getString("PLAYER_ID"), "AKFJDL00"); assertEquals(rs.getString("LAST_NAME"), "Doe"); @@ -92,5 +82,4 @@ public class JdbcPlayerDaoIntegrationTests { } }); } - } diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/football/internal/JdbcPlayerSummaryDaoIntegrationTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/football/internal/JdbcPlayerSummaryDaoIntegrationTests.java index 04ca13dff..0b159b8f2 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/football/internal/JdbcPlayerSummaryDaoIntegrationTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/football/internal/JdbcPlayerSummaryDaoIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2012 the original author or authors. + * Copyright 2006-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,16 +39,12 @@ import org.springframework.transaction.annotation.Transactional; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "/data-source-context.xml" }) public class JdbcPlayerSummaryDaoIntegrationTests { - private JdbcPlayerSummaryDao playerSummaryDao; - private PlayerSummary summary; - private JdbcOperations jdbcTemplate; @Autowired public void init(DataSource dataSource) { - this.jdbcTemplate = new JdbcTemplate(dataSource); playerSummaryDao = new JdbcPlayerSummaryDao(); playerSummaryDao.setDataSource(dataSource); @@ -66,27 +62,21 @@ public class JdbcPlayerSummaryDaoIntegrationTests { summary.setReceptions(0); summary.setReceptionYards(0); summary.setTotalTd(0); - } @Before public void onSetUpInTransaction() throws Exception { - jdbcTemplate.execute("delete from PLAYER_SUMMARY"); - } - @Transactional @Test + @Transactional public void testWrite() { - playerSummaryDao.write(Collections.singletonList(summary)); PlayerSummary testSummary = jdbcTemplate.queryForObject("SELECT * FROM PLAYER_SUMMARY", new PlayerSummaryMapper()); assertEquals(summary, testSummary); - } - } diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/multiline/AggregateItemFieldSetMapperTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/multiline/AggregateItemFieldSetMapperTests.java index 48fdc5311..a393b7413 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/multiline/AggregateItemFieldSetMapperTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/multiline/AggregateItemFieldSetMapperTests.java @@ -9,10 +9,8 @@ import org.junit.Test; import org.springframework.batch.item.file.mapping.FieldSetMapper; import org.springframework.batch.item.file.transform.DefaultFieldSet; import org.springframework.batch.item.file.transform.FieldSet; -import org.springframework.batch.sample.domain.multiline.AggregateItemFieldSetMapper; public class AggregateItemFieldSetMapperTests { - private AggregateItemFieldSetMapper mapper = new AggregateItemFieldSetMapper(); @Test @@ -59,6 +57,4 @@ public class AggregateItemFieldSetMapperTests { }); assertEquals("foo", mapper.mapFieldSet(new DefaultFieldSet(new String[] { "FOO" })).getItem()); } - - } diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/multiline/AggregateItemReaderTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/multiline/AggregateItemReaderTests.java index b3f61bb75..75f686484 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/multiline/AggregateItemReaderTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/multiline/AggregateItemReaderTests.java @@ -6,22 +6,17 @@ import java.util.Collection; import org.junit.Before; import org.junit.Test; import org.springframework.batch.item.ItemReader; -import org.springframework.batch.sample.domain.multiline.AggregateItem; -import org.springframework.batch.sample.domain.multiline.AggregateItemReader; public class AggregateItemReaderTests { - private ItemReader> input; - private AggregateItemReader provider; @Before public void setUp() { - // create mock for input input = new ItemReader>() { - private int count = 0; + @Override public AggregateItem read() { switch (count++) { case 0: @@ -38,17 +33,15 @@ public class AggregateItemReaderTests { } }; - // create provider + provider = new AggregateItemReader(); provider.setItemReader(input); } @Test public void testNext() throws Exception { - // read object Object result = provider.read(); - // it should be collection of 3 strings "line" Collection lines = (Collection) result; assertEquals(3, lines.size()); @@ -56,9 +49,6 @@ public class AggregateItemReaderTests { assertEquals("line", line); } - // read object again - it should return null assertNull(provider.read()); - } - } diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/multiline/AggregateItemTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/multiline/AggregateItemTests.java index 58669e847..931195a5a 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/multiline/AggregateItemTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/multiline/AggregateItemTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,14 +20,12 @@ import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import org.junit.Test; -import org.springframework.batch.sample.domain.multiline.AggregateItem; /** * @author Dave Syer * */ public class AggregateItemTests { - /** * Test method for {@link org.springframework.batch.sample.domain.multiline.AggregateItem#getFooter()}. */ @@ -65,5 +63,4 @@ public class AggregateItemTests { // expected } } - } diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/order/AddressFieldSetMapperTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/order/AddressFieldSetMapperTests.java index 251689b05..ebcd406ad 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/order/AddressFieldSetMapperTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/order/AddressFieldSetMapperTests.java @@ -7,7 +7,6 @@ import org.springframework.batch.sample.domain.order.internal.mapper.AddressFiel import org.springframework.batch.sample.support.AbstractFieldSetMapperTests; public class AddressFieldSetMapperTests extends AbstractFieldSetMapperTests { - private static final String ADDRESSEE = "Jan Hrach"; private static final String ADDRESS_LINE_1 = "Plynarenska 7c"; private static final String ADDRESS_LINE_2 = ""; @@ -16,6 +15,7 @@ public class AddressFieldSetMapperTests extends AbstractFieldSetMapperTests { private static final String COUNTRY = "Slovakia"; private static final String ZIP_CODE = "80000"; + @Override protected Object expectedDomainObject() { Address address = new Address(); address.setAddressee(ADDRESSEE); @@ -28,6 +28,7 @@ public class AddressFieldSetMapperTests extends AbstractFieldSetMapperTests { return address; } + @Override protected FieldSet fieldSet() { String[] tokens = new String[] { ADDRESSEE, ADDRESS_LINE_1, ADDRESS_LINE_2, CITY, STATE, COUNTRY, ZIP_CODE }; String[] columnNames = new String[] { AddressFieldSetMapper.ADDRESSEE_COLUMN, @@ -38,6 +39,7 @@ public class AddressFieldSetMapperTests extends AbstractFieldSetMapperTests { return new DefaultFieldSet(tokens, columnNames); } + @Override protected FieldSetMapper
fieldSetMapper() { return new AddressFieldSetMapper(); } diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/order/BillingFieldSetMapperTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/order/BillingFieldSetMapperTests.java index 3370d1975..ffcd63e8a 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/order/BillingFieldSetMapperTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/order/BillingFieldSetMapperTests.java @@ -7,10 +7,10 @@ import org.springframework.batch.sample.domain.order.internal.mapper.BillingFiel import org.springframework.batch.sample.support.AbstractFieldSetMapperTests; public class BillingFieldSetMapperTests extends AbstractFieldSetMapperTests { - private static final String PAYMENT_ID = "777"; private static final String PAYMENT_DESC = "My last penny"; + @Override protected Object expectedDomainObject() { BillingInfo bInfo = new BillingInfo(); bInfo.setPaymentDesc(PAYMENT_DESC); @@ -18,6 +18,7 @@ public class BillingFieldSetMapperTests extends AbstractFieldSetMapperTests { return bInfo; } + @Override protected FieldSet fieldSet() { String[] tokens = new String[] { PAYMENT_ID, PAYMENT_DESC }; String[] columnNames = new String[] { BillingFieldSetMapper.PAYMENT_TYPE_ID_COLUMN, @@ -25,8 +26,8 @@ public class BillingFieldSetMapperTests extends AbstractFieldSetMapperTests { return new DefaultFieldSet(tokens, columnNames); } + @Override protected FieldSetMapper fieldSetMapper() { return new BillingFieldSetMapper(); } - } diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/order/CustomerFieldSetMapperTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/order/CustomerFieldSetMapperTests.java index 2a5d06037..657e6533d 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/order/CustomerFieldSetMapperTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/order/CustomerFieldSetMapperTests.java @@ -7,7 +7,6 @@ import org.springframework.batch.sample.domain.order.internal.mapper.CustomerFie import org.springframework.batch.sample.support.AbstractFieldSetMapperTests; public class CustomerFieldSetMapperTests extends AbstractFieldSetMapperTests { - private static final boolean BUSINESS_CUSTOMER = false; private static final String FIRST_NAME = "Jan"; private static final String LAST_NAME = "Hrach"; @@ -16,6 +15,7 @@ public class CustomerFieldSetMapperTests extends AbstractFieldSetMapperTests { private static final long REG_ID = 1; private static final boolean VIP = true; + @Override protected Object expectedDomainObject() { Customer cs = new Customer(); cs.setBusinessCustomer(BUSINESS_CUSTOMER); @@ -28,6 +28,7 @@ public class CustomerFieldSetMapperTests extends AbstractFieldSetMapperTests { return cs; } + @Override protected FieldSet fieldSet() { String[] tokens = new String[] { Customer.LINE_ID_NON_BUSINESS_CUST, FIRST_NAME, LAST_NAME, MIDDLE_NAME, CustomerFieldSetMapper.TRUE_SYMBOL, String.valueOf(REG_ID), CustomerFieldSetMapper.TRUE_SYMBOL }; @@ -39,8 +40,8 @@ public class CustomerFieldSetMapperTests extends AbstractFieldSetMapperTests { return new DefaultFieldSet(tokens, columnNames); } + @Override protected FieldSetMapper fieldSetMapper() { return new CustomerFieldSetMapper(); } - } diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/order/HeaderFieldSetMapperTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/order/HeaderFieldSetMapperTests.java index 0adf78be9..ee5e7d0fa 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/order/HeaderFieldSetMapperTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/order/HeaderFieldSetMapperTests.java @@ -9,10 +9,10 @@ import org.springframework.batch.sample.domain.order.internal.mapper.HeaderField import org.springframework.batch.sample.support.AbstractFieldSetMapperTests; public class HeaderFieldSetMapperTests extends AbstractFieldSetMapperTests { - private static final long ORDER_ID = 1; private static final String DATE = "2007-01-01"; + @Override protected Object expectedDomainObject() { Order order = new Order(); Calendar calendar = Calendar.getInstance(); @@ -23,6 +23,7 @@ public class HeaderFieldSetMapperTests extends AbstractFieldSetMapperTests { return order; } + @Override protected FieldSet fieldSet() { String[] tokens = new String[] { String.valueOf(ORDER_ID), DATE }; String[] columnNames = new String[] { HeaderFieldSetMapper.ORDER_ID_COLUMN, @@ -30,8 +31,8 @@ public class HeaderFieldSetMapperTests extends AbstractFieldSetMapperTests { return new DefaultFieldSet(tokens, columnNames); } + @Override protected FieldSetMapper fieldSetMapper() { return new HeaderFieldSetMapper(); } - } diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/order/OrderItemFieldSetMapperTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/order/OrderItemFieldSetMapperTests.java index b023f692d..323c1a505 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/order/OrderItemFieldSetMapperTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/order/OrderItemFieldSetMapperTests.java @@ -9,7 +9,6 @@ import org.springframework.batch.sample.domain.order.internal.mapper.OrderItemFi import org.springframework.batch.sample.support.AbstractFieldSetMapperTests; public class OrderItemFieldSetMapperTests extends AbstractFieldSetMapperTests { - private static final BigDecimal DISCOUNT_AMOUNT = new BigDecimal("1"); private static final BigDecimal DISCOUNT_PERC = new BigDecimal("2"); private static final BigDecimal HANDLING_PRICE = new BigDecimal("3"); @@ -19,6 +18,7 @@ public class OrderItemFieldSetMapperTests extends AbstractFieldSetMapperTests { private static final BigDecimal SHIPPING_PRICE = new BigDecimal("7"); private static final BigDecimal TOTAL_PRICE = new BigDecimal("8"); + @Override protected Object expectedDomainObject() { LineItem item = new LineItem(); item.setDiscountAmount(DISCOUNT_AMOUNT); @@ -32,6 +32,7 @@ public class OrderItemFieldSetMapperTests extends AbstractFieldSetMapperTests { return item; } + @Override protected FieldSet fieldSet() { String[] tokens = new String[] { String.valueOf(DISCOUNT_AMOUNT), String.valueOf(DISCOUNT_PERC), String.valueOf(HANDLING_PRICE), String.valueOf(ITEM_ID), String.valueOf(PRICE), @@ -44,8 +45,8 @@ public class OrderItemFieldSetMapperTests extends AbstractFieldSetMapperTests { return new DefaultFieldSet(tokens, columnNames); } + @Override protected FieldSetMapper fieldSetMapper() { return new OrderItemFieldSetMapper(); } - } diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/order/OrderItemReaderTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/order/OrderItemReaderTests.java index 59c534231..175c83942 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/order/OrderItemReaderTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/order/OrderItemReaderTests.java @@ -7,10 +7,7 @@ import static org.junit.Assert.assertNull; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -import java.util.Iterator; - import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; import org.springframework.batch.item.ItemReader; import org.springframework.batch.item.file.mapping.FieldSetMapper; @@ -19,15 +16,12 @@ import org.springframework.batch.item.file.transform.FieldSet; import org.springframework.batch.sample.domain.order.internal.OrderItemReader; public class OrderItemReaderTests { - private OrderItemReader provider; - private ItemReader
input; - @SuppressWarnings("unchecked") @Before + @SuppressWarnings("unchecked") public void setUp() { - input = (ItemReader
) mock(ItemReader.class); provider = new OrderItemReader(); @@ -35,7 +29,7 @@ public class OrderItemReaderTests { } /* - * OrderItemProvider is resposible for retrieving validated value object + * OrderItemProvider is responsible for retrieving validated value object * from input source. OrderItemProvider.next(): - reads lines from the input * source - returned as fieldsets - pass fieldsets to the mapper - mapper * will create value object - pass value object to validator - returns @@ -44,12 +38,9 @@ public class OrderItemReaderTests { * In testNext method we are going to test these responsibilities. So we * need create mock objects for input source, mapper and validator. */ - @Ignore //TODO mockito fix - @SuppressWarnings("unchecked") @Test + @SuppressWarnings("unchecked") public void testNext() throws Exception { - - // create fieldsets and set return values for input source FieldSet headerFS = new DefaultFieldSet(new String[] { Order.LINE_ID_HEADER }); FieldSet customerFS = new DefaultFieldSet(new String[] { Customer.LINE_ID_NON_BUSINESS_CUST }); FieldSet billingFS = new DefaultFieldSet(new String[] { Address.LINE_ID_BILLING_ADDR }); @@ -60,19 +51,9 @@ public class OrderItemReaderTests { FieldSet footerFS = new DefaultFieldSet(new String[] { Order.LINE_ID_FOOTER, "100", "3", "3" }, new String[] { "ID", "TOTAL_PRICE", "TOTAL_LINE_ITEMS", "TOTAL_ITEMS" }); - when(input.read()).thenReturn(headerFS); - when(input.read()).thenReturn(customerFS); - when(input.read()).thenReturn(billingFS); - when(input.read()).thenReturn(shippingFS); - when(input.read()).thenReturn(billingInfoFS); - when(input.read()).thenReturn(shippingInfoFS); - when(input.read()).thenReturn(itemFS); - when(input.read()).thenReturn(footerFS); - when(input.read()).thenReturn(null); -// replay(input); -// input.read(); + when(input.read()).thenReturn(headerFS, customerFS, billingFS, shippingFS, billingInfoFS, + shippingInfoFS, itemFS, itemFS, itemFS, footerFS, null); - // create value objects Order order = new Order(); Customer customer = new Customer(); Address billing = new Address(); @@ -81,10 +62,7 @@ public class OrderItemReaderTests { ShippingInfo shippingInfo = new ShippingInfo(); LineItem item = new LineItem(); - // create mock mapper - @SuppressWarnings("rawtypes") FieldSetMapper mapper = mock(FieldSetMapper.class); - // set how mapper should respond - set return values for mapper when(mapper.mapFieldSet(headerFS)).thenReturn(order); when(mapper.mapFieldSet(customerFS)).thenReturn(customer); when(mapper.mapFieldSet(billingFS)).thenReturn(billing); @@ -93,7 +71,6 @@ public class OrderItemReaderTests { when(mapper.mapFieldSet(shippingInfoFS)).thenReturn(shippingInfo); when(mapper.mapFieldSet(itemFS)).thenReturn(item); - // set-up provider: set mappers provider.setAddressMapper(mapper); provider.setBillingMapper(mapper); provider.setCustomerMapper(mapper); @@ -101,31 +78,25 @@ public class OrderItemReaderTests { provider.setItemMapper(mapper); provider.setShippingMapper(mapper); - // call tested method Object result = provider.read(); - // verify result assertNotNull(result); - // verify whether order is constructed correctly - // Order object should contain same instances as returned by mapper Order o = (Order) result; assertEquals(o, order); assertEquals(o.getCustomer(), customer); - // is it non-bussines customer assertFalse(o.getCustomer().isBusinessCustomer()); assertEquals(o.getBillingAddress(), billing); assertEquals(o.getShippingAddress(), shipping); assertEquals(o.getBilling(), billingInfo); assertEquals(o.getShipping(), shippingInfo); - // there should be 3 line items + assertEquals(3, o.getLineItems().size()); - for (Iterator i = o.getLineItems().iterator(); i.hasNext();) { - assertEquals(i.next(), item); + + for (LineItem lineItem : o.getLineItems()) { + assertEquals(lineItem, item); } - // try to retrieve next object - nothing should be returned assertNull(provider.read()); } - } diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/order/ShippingFieldSetMapperTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/order/ShippingFieldSetMapperTests.java index 7310f43c3..51319b78b 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/order/ShippingFieldSetMapperTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/order/ShippingFieldSetMapperTests.java @@ -7,11 +7,11 @@ import org.springframework.batch.sample.domain.order.internal.mapper.ShippingFie import org.springframework.batch.sample.support.AbstractFieldSetMapperTests; public class ShippingFieldSetMapperTests extends AbstractFieldSetMapperTests { - private static final String SHIPPER_ID = "1"; private static final String SHIPPING_INFO = "most interesting and informative shipping info ever"; private static final String SHIPPING_TYPE_ID = "X"; + @Override protected Object expectedDomainObject() { ShippingInfo info = new ShippingInfo(); info.setShipperId(SHIPPER_ID); @@ -20,6 +20,7 @@ public class ShippingFieldSetMapperTests extends AbstractFieldSetMapperTests { return info; } + @Override protected FieldSet fieldSet() { String[] tokens = new String[] { SHIPPER_ID, SHIPPING_INFO, SHIPPING_TYPE_ID }; String[] columnNames = new String[] { ShippingFieldSetMapper.SHIPPER_ID_COLUMN, @@ -27,8 +28,8 @@ public class ShippingFieldSetMapperTests extends AbstractFieldSetMapperTests { return new DefaultFieldSet(tokens, columnNames); } + @Override protected FieldSetMapper fieldSetMapper() { return new ShippingFieldSetMapper(); } - } diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/CompositeCustomerUpdateLineTokenizerTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/CompositeCustomerUpdateLineTokenizerTests.java index b44cf6f53..772ac18b3 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/CompositeCustomerUpdateLineTokenizerTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/CompositeCustomerUpdateLineTokenizerTests.java @@ -1,6 +1,3 @@ -/** - * - */ package org.springframework.batch.sample.domain.trade; import static org.junit.Assert.assertEquals; @@ -16,25 +13,21 @@ import org.springframework.batch.item.file.transform.LineTokenizer; * */ public class CompositeCustomerUpdateLineTokenizerTests { - - StubLineTokenizer customerTokenizer; - FieldSet customerFieldSet = new DefaultFieldSet(null); - StubLineTokenizer footerTokenizer; - FieldSet footerFieldSet = new DefaultFieldSet(null); - CompositeCustomerUpdateLineTokenizer compositeTokenizer; + private StubLineTokenizer customerTokenizer; + private FieldSet customerFieldSet = new DefaultFieldSet(null); + private FieldSet footerFieldSet = new DefaultFieldSet(null); + private CompositeCustomerUpdateLineTokenizer compositeTokenizer; @Before public void init(){ customerTokenizer = new StubLineTokenizer(customerFieldSet); - footerTokenizer = new StubLineTokenizer(footerFieldSet); compositeTokenizer = new CompositeCustomerUpdateLineTokenizer(); compositeTokenizer.setCustomerTokenizer(customerTokenizer); - compositeTokenizer.setFooterTokenizer(footerTokenizer); + compositeTokenizer.setFooterTokenizer(new StubLineTokenizer(footerFieldSet)); } @Test public void testCustomerAdd() throws Exception{ - String customerAddLine = "AFDASFDASFDFSA"; FieldSet fs = compositeTokenizer.tokenize(customerAddLine); assertEquals(customerFieldSet, fs); @@ -43,7 +36,6 @@ public class CompositeCustomerUpdateLineTokenizerTests { @Test public void testCustomerDelete() throws Exception{ - String customerAddLine = "DFDASFDASFDFSA"; FieldSet fs = compositeTokenizer.tokenize(customerAddLine); assertEquals(customerFieldSet, fs); @@ -52,7 +44,6 @@ public class CompositeCustomerUpdateLineTokenizerTests { @Test public void testCustomerUpdate() throws Exception{ - String customerAddLine = "UFDASFDASFDFSA"; FieldSet fs = compositeTokenizer.tokenize(customerAddLine); assertEquals(customerFieldSet, fs); @@ -61,21 +52,19 @@ public class CompositeCustomerUpdateLineTokenizerTests { @Test(expected=IllegalArgumentException.class) public void testInvalidLine() throws Exception{ - String invalidLine = "INVALID"; compositeTokenizer.tokenize(invalidLine); } - - - private static class StubLineTokenizer implements LineTokenizer{ + private static class StubLineTokenizer implements LineTokenizer{ private final FieldSet fieldSetToReturn; private String tokenizedLine; public StubLineTokenizer(FieldSet fieldSetToReturn) { this.fieldSetToReturn = fieldSetToReturn; } - + + @Override public FieldSet tokenize(String line) { this.tokenizedLine = line; return fieldSetToReturn; diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/CustomerUpdateProcessorTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/CustomerUpdateProcessorTests.java index 0a699bfe6..bb90cd70a 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/CustomerUpdateProcessorTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/CustomerUpdateProcessorTests.java @@ -1,6 +1,3 @@ -/** - * - */ package org.springframework.batch.sample.domain.trade; import static org.junit.Assert.assertEquals; @@ -21,10 +18,9 @@ import org.junit.Test; * */ public class CustomerUpdateProcessorTests { - - CustomerDao customerDao; - InvalidCustomerLogger logger; - CustomerUpdateProcessor processor; + private CustomerDao customerDao; + private InvalidCustomerLogger logger; + private CustomerUpdateProcessor processor; @Before public void init(){ @@ -37,16 +33,14 @@ public class CustomerUpdateProcessorTests { @Test public void testSuccessfulAdd() throws Exception{ - - CustomerUpdate customerUpdate = new CustomerUpdate(ADD, "test customer", new BigDecimal(232.2)); + CustomerUpdate customerUpdate = new CustomerUpdate(ADD, "test customer", new BigDecimal("232.2")); when(customerDao.getCustomerByName("test customer")).thenReturn(null); assertEquals(customerUpdate, processor.process(customerUpdate)); } @Test public void testInvalidAdd() throws Exception{ - - CustomerUpdate customerUpdate = new CustomerUpdate(ADD, "test customer", new BigDecimal(232.2)); + CustomerUpdate customerUpdate = new CustomerUpdate(ADD, "test customer", new BigDecimal("232.2")); when(customerDao.getCustomerByName("test customer")).thenReturn(new CustomerCredit()); logger.log(customerUpdate); assertNull("Processor should return null", processor.process(customerUpdate)); @@ -54,27 +48,23 @@ public class CustomerUpdateProcessorTests { @Test public void testDelete() throws Exception{ - //delete should never work, therefore, ensure it fails fast. - CustomerUpdate customerUpdate = new CustomerUpdate(DELETE, "test customer", new BigDecimal(232.2)); + CustomerUpdate customerUpdate = new CustomerUpdate(DELETE, "test customer", new BigDecimal("232.2")); logger.log(customerUpdate); assertNull("Processor should return null", processor.process(customerUpdate)); } @Test public void testSuccessfulUpdate() throws Exception{ - - CustomerUpdate customerUpdate = new CustomerUpdate(UPDATE, "test customer", new BigDecimal(232.2)); + CustomerUpdate customerUpdate = new CustomerUpdate(UPDATE, "test customer", new BigDecimal("232.2")); when(customerDao.getCustomerByName("test customer")).thenReturn(new CustomerCredit()); assertEquals(customerUpdate, processor.process(customerUpdate)); } @Test public void testInvalidUpdate() throws Exception{ - - CustomerUpdate customerUpdate = new CustomerUpdate(UPDATE, "test customer", new BigDecimal(232.2)); + CustomerUpdate customerUpdate = new CustomerUpdate(UPDATE, "test customer", new BigDecimal("232.2")); when(customerDao.getCustomerByName("test customer")).thenReturn(null); logger.log(customerUpdate); assertNull("Processor should return null", processor.process(customerUpdate)); } - } diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/TradeTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/TradeTests.java index 91b4a2bd0..d677efbdc 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/TradeTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/TradeTests.java @@ -1,19 +1,18 @@ package org.springframework.batch.sample.domain.trade; -import static org.junit.Assert.*; - import java.math.BigDecimal; import org.junit.Test; -public class TradeTests { +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +public class TradeTests { @Test public void testEquality(){ - - Trade trade1 = new Trade("isin", 1, new BigDecimal(1.1), "customer1"); - Trade trade1Clone = new Trade("isin", 1, new BigDecimal(1.1), "customer1"); - Trade trade2 = new Trade("isin", 1, new BigDecimal(2.3), "customer2"); + Trade trade1 = new Trade("isin", 1, new BigDecimal("1.1"), "customer1"); + Trade trade1Clone = new Trade("isin", 1, new BigDecimal("1.1"), "customer1"); + Trade trade2 = new Trade("isin", 1, new BigDecimal("2.3"), "customer2"); assertEquals(trade1, trade1Clone); assertFalse(trade1.equals(trade2)); diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/internal/CustomerCreditIncreaseProcessorTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/internal/CustomerCreditIncreaseProcessorTests.java index af9832f80..44cf465c0 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/internal/CustomerCreditIncreaseProcessorTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/internal/CustomerCreditIncreaseProcessorTests.java @@ -8,12 +8,11 @@ import org.junit.Test; import org.springframework.batch.sample.domain.trade.CustomerCredit; /** - * Tests for {@link CustomerCreditItemWriter}. + * Tests for {@link CustomerCreditIncreaseProcessor}. * * @author Robert Kasanicky */ public class CustomerCreditIncreaseProcessorTests { - private CustomerCreditIncreaseProcessor tested = new CustomerCreditIncreaseProcessor(); /* @@ -21,8 +20,7 @@ public class CustomerCreditIncreaseProcessorTests { */ @Test public void testProcess() throws Exception { - - final BigDecimal oldCredit = new BigDecimal(10.54); + final BigDecimal oldCredit = new BigDecimal("10.54"); CustomerCredit customerCredit = new CustomerCredit(); customerCredit.setCredit(oldCredit); diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/internal/CustomerCreditRowMapperTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/internal/CustomerCreditRowMapperTests.java index cb1e0a1a8..84720f25a 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/internal/CustomerCreditRowMapperTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/internal/CustomerCreditRowMapperTests.java @@ -11,14 +11,11 @@ import org.springframework.batch.sample.support.AbstractRowMapperTests; import org.springframework.jdbc.core.RowMapper; public class CustomerCreditRowMapperTests extends AbstractRowMapperTests { - - /** - * - */ private static final int ID = 12; private static final String CUSTOMER = "Jozef Mak"; - private static final BigDecimal CREDIT = new BigDecimal(0.1); + private static final BigDecimal CREDIT = new BigDecimal("0.1"); + @Override protected Object expectedDomainObject() { CustomerCredit credit = new CustomerCredit(); credit.setId(ID); @@ -27,14 +24,15 @@ public class CustomerCreditRowMapperTests extends AbstractRowMapperTests { return credit; } + @Override protected RowMapper rowMapper() { return new CustomerCreditRowMapper(); } + @Override protected void setUpResultSetMock(ResultSet rs) throws SQLException { when(rs.getInt(CustomerCreditRowMapper.ID_COLUMN)).thenReturn(ID); when(rs.getString(CustomerCreditRowMapper.NAME_COLUMN)).thenReturn(CUSTOMER); when(rs.getBigDecimal(CustomerCreditRowMapper.CREDIT_COLUMN)).thenReturn(CREDIT); } - } diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/internal/CustomerCreditUpdateProcessorTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/internal/CustomerCreditUpdateProcessorTests.java index c533c47b9..e2b365b40 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/internal/CustomerCreditUpdateProcessorTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/internal/CustomerCreditUpdateProcessorTests.java @@ -1,7 +1,6 @@ package org.springframework.batch.sample.domain.trade.internal; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; import java.math.BigDecimal; import java.util.Collections; @@ -12,16 +11,14 @@ import org.springframework.batch.sample.domain.trade.CustomerCredit; import org.springframework.batch.sample.domain.trade.CustomerCreditDao; public class CustomerCreditUpdateProcessorTests { - private CustomerCreditDao dao; private CustomerCreditUpdateWriter writer; private static final double CREDIT_FILTER = 355.0; @Before public void setUp() { - //create mock writer dao = mock(CustomerCreditDao.class); - //create processor, set writer and credit filter + writer = new CustomerCreditUpdateWriter(); writer.setDao(dao); writer.setCreditFilter(CREDIT_FILTER); @@ -29,25 +26,15 @@ public class CustomerCreditUpdateProcessorTests { @Test public void testProcess() throws Exception { - - //set-up mock writer - no writer's method should be called - - //create credit and set it to same value as credit filter CustomerCredit credit = new CustomerCredit(); credit.setCredit(new BigDecimal(CREDIT_FILTER)); - //call tested method + writer.write(Collections.singletonList(credit)); - //verify method calls - no method should be called - //because credit is not greater then credit filter - - //change credit to be greater than credit filter + credit.setCredit(new BigDecimal(CREDIT_FILTER + 1)); - //reset and set-up writer - write method is expected to be called + dao.writeCredit(credit); - //call tested method writer.write(Collections.singletonList(credit)); - } - } diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/internal/CustomerUpdateProcessorTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/internal/CustomerUpdateProcessorTests.java index 5660dbe68..1d975aa83 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/internal/CustomerUpdateProcessorTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/internal/CustomerUpdateProcessorTests.java @@ -11,28 +11,23 @@ import org.springframework.batch.sample.domain.trade.CustomerDebitDao; import org.springframework.batch.sample.domain.trade.Trade; public class CustomerUpdateProcessorTests { - @Test public void testProcess() { - - //create trade object Trade trade = new Trade(); trade.setCustomer("testCustomerName"); - trade.setPrice(new BigDecimal(123.0)); + trade.setPrice(new BigDecimal("123.0")); - //create dao CustomerDebitDao dao = new CustomerDebitDao() { + @Override public void write(CustomerDebit customerDebit) { assertEquals("testCustomerName", customerDebit.getName()); - assertEquals(new BigDecimal(123.0), customerDebit.getDebit()); + assertEquals(new BigDecimal("123.0"), customerDebit.getDebit()); } }; - //create processor and set dao CustomerUpdateWriter processor = new CustomerUpdateWriter(); processor.setDao(dao); - //call tested method - see asserts in dao.write() method processor.write(Collections.singletonList(trade)); } } diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/internal/FlatFileCustomerCreditDaoTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/internal/FlatFileCustomerCreditDaoTests.java index 265ea6c60..b4d7d028d 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/internal/FlatFileCustomerCreditDaoTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/internal/FlatFileCustomerCreditDaoTests.java @@ -28,17 +28,13 @@ import org.springframework.batch.item.ItemWriter; import org.springframework.batch.sample.domain.trade.CustomerCredit; public class FlatFileCustomerCreditDaoTests { - private ResourceLifecycleItemWriter output; private FlatFileCustomerCreditDao writer; @Before public void setUp() throws Exception { - - //create mock for OutputSource output = mock(ResourceLifecycleItemWriter.class); - //create new writer writer = new FlatFileCustomerCreditDao(); writer.setItemWriter(output); } @@ -46,45 +42,34 @@ public class FlatFileCustomerCreditDaoTests { @Test public void testOpen() throws Exception { ExecutionContext executionContext = new ExecutionContext(); - //set-up outputSource mock + output.open(executionContext); - //call tested method writer.open(executionContext); - } @Test public void testClose() throws Exception{ - - //set-up outputSource mock output.close(); - //call tested method writer.close(); - } @Test public void testWrite() throws Exception { - - //Create and set-up CustomerCredit CustomerCredit credit = new CustomerCredit(); credit.setCredit(new BigDecimal(1)); credit.setName("testName"); - //set separator writer.setSeparator(";"); - //set-up OutputSource mock output.write(Collections.singletonList("testName;1")); output.open(new ExecutionContext()); - //call tested method writer.writeCredit(credit); } - private interface ResourceLifecycleItemWriter extends ItemWriter, ItemStream{ - + private interface ResourceLifecycleItemWriter extends ItemWriter, ItemStream { + } } diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/internal/ItemTrackingTradeItemWriter.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/internal/ItemTrackingTradeItemWriter.java index 992e2fc36..c3218d09a 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/internal/ItemTrackingTradeItemWriter.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/internal/ItemTrackingTradeItemWriter.java @@ -12,11 +12,8 @@ import org.springframework.jdbc.core.JdbcOperations; import org.springframework.jdbc.core.JdbcTemplate; public class ItemTrackingTradeItemWriter implements ItemWriter { - private List items = new ArrayList(); - private String writeFailureISIN; - private JdbcOperations jdbcTemplate; public void setDataSource(DataSource dataSource) { @@ -27,30 +24,27 @@ public class ItemTrackingTradeItemWriter implements ItemWriter { this.writeFailureISIN = writeFailureISIN; } - public void setItems(List items) { - this.items = items; - } - public List getItems() { return items; } - public void clearItems() { - this.items.clear(); - } - + @Override public void write(List items) throws Exception { List newItems = new ArrayList(); + for (Trade t : items) { if (t.getIsin().equals(this.writeFailureISIN)) { throw new IOException("write failed"); } + newItems.add(t); + if (jdbcTemplate != null) { jdbcTemplate.update("UPDATE TRADE set VERSION=? where ID=? and version=?", t.getVersion() + 1, t .getId(), t.getVersion()); } } + this.items.addAll(newItems); } } diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/internal/JdbcCustomerDebitDaoTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/internal/JdbcCustomerDebitDaoTests.java index 794e496b4..2704d4753 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/internal/JdbcCustomerDebitDaoTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/internal/JdbcCustomerDebitDaoTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2012 the original author or authors. + * Copyright 2006-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,7 +37,6 @@ import org.springframework.transaction.annotation.Transactional; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration() public class JdbcCustomerDebitDaoTests { - private JdbcOperations jdbcTemplate; @Autowired @@ -48,27 +47,23 @@ public class JdbcCustomerDebitDaoTests { this.jdbcTemplate = new JdbcTemplate(dataSource); } - @Transactional @Test + @Test + @Transactional public void testWrite() { - - //insert customer credit jdbcTemplate.execute("INSERT INTO CUSTOMER VALUES (99, 0, 'testName', 100)"); - //create customer debit CustomerDebit customerDebit = new CustomerDebit(); customerDebit.setName("testName"); customerDebit.setDebit(BigDecimal.valueOf(5)); - //call writer writer.write(customerDebit); - //verify customer credit jdbcTemplate.query("SELECT name, credit FROM CUSTOMER WHERE name = 'testName'", new RowCallbackHandler() { + @Override public void processRow(ResultSet rs) throws SQLException { assertEquals(95, rs.getLong("credit")); } }); - } } diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/internal/JdbcTradeWriterTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/internal/JdbcTradeWriterTests.java index 79dc49731..bff2ba183 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/internal/JdbcTradeWriterTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/internal/JdbcTradeWriterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2012 the original author or authors. + * Copyright 2006-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,11 +40,8 @@ import org.springframework.transaction.annotation.Transactional; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = {"/data-source-context.xml"}) public class JdbcTradeWriterTests implements InitializingBean { - private JdbcOperations jdbcTemplate; - private JdbcTradeDao writer; - private AbstractDataFieldMaxValueIncrementer incrementer; @Autowired @@ -52,7 +49,6 @@ public class JdbcTradeWriterTests implements InitializingBean { this.jdbcTemplate = new JdbcTemplate(dataSource); this.writer = new JdbcTradeDao(); this.writer.setDataSource(dataSource); - } @Autowired @@ -61,13 +57,13 @@ public class JdbcTradeWriterTests implements InitializingBean { this.incrementer = incrementer; } - @Transactional @Test + @Test + @Transactional public void testWrite() { - Trade trade = new Trade(); trade.setCustomer("testCustomer"); trade.setIsin("5647238492"); - trade.setPrice(new BigDecimal(Double.toString(99.69))); + trade.setPrice(new BigDecimal("99.69")); trade.setQuantity(5); writer.writeTrade(trade); diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/internal/TradeFieldSetMapperTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/internal/TradeFieldSetMapperTests.java index 780762acd..e57c2a9d4 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/internal/TradeFieldSetMapperTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/internal/TradeFieldSetMapperTests.java @@ -9,15 +9,12 @@ import org.springframework.batch.sample.domain.trade.Trade; import org.springframework.batch.sample.support.AbstractFieldSetMapperTests; public class TradeFieldSetMapperTests extends AbstractFieldSetMapperTests { - private static final String CUSTOMER = "Mike Tomcat"; - private static final BigDecimal PRICE = new BigDecimal(1.3); - private static final long QUANTITY = 7; - private static final String ISIN = "fj893gnsalX"; + @Override protected Object expectedDomainObject() { Trade trade = new Trade(); trade.setIsin(ISIN); @@ -27,6 +24,7 @@ public class TradeFieldSetMapperTests extends AbstractFieldSetMapperTests { return trade; } + @Override protected FieldSet fieldSet() { String[] tokens = new String[4]; tokens[TradeFieldSetMapper.ISIN_COLUMN] = ISIN; @@ -37,8 +35,8 @@ public class TradeFieldSetMapperTests extends AbstractFieldSetMapperTests { return new DefaultFieldSet(tokens); } + @Override protected FieldSetMapper fieldSetMapper() { return new TradeFieldSetMapper(); } - } diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/internal/TradeProcessorTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/internal/TradeProcessorTests.java index a42ae2cef..cf96179e3 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/internal/TradeProcessorTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/internal/TradeProcessorTests.java @@ -10,30 +10,23 @@ import org.springframework.batch.sample.domain.trade.Trade; import org.springframework.batch.sample.domain.trade.TradeDao; public class TradeProcessorTests { - private TradeDao writer; private TradeWriter processor; @Before public void setUp() { - - //create mock writer writer = mock(TradeDao.class); - //create processor processor = new TradeWriter(); processor.setDao(writer); } @Test public void testProcess() { - Trade trade = new Trade(); - //set-up mock writer + writer.writeTrade(trade); - //call tested method processor.write(Collections.singletonList(trade)); } - } diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/internal/TradeRowMapperTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/internal/TradeRowMapperTests.java index 5d896af4a..99c540277 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/internal/TradeRowMapperTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/internal/TradeRowMapperTests.java @@ -11,25 +11,28 @@ import org.springframework.batch.sample.support.AbstractRowMapperTests; import org.springframework.jdbc.core.RowMapper; public class TradeRowMapperTests extends AbstractRowMapperTests { - private static final String ISIN = "jsgk342"; private static final long QUANTITY = 0; - private static final BigDecimal PRICE = new BigDecimal(1.1); + private static final BigDecimal PRICE = new BigDecimal("1.1"); private static final String CUSTOMER = "Martin Hrancok"; + @Override protected Object expectedDomainObject() { Trade trade = new Trade(); trade.setIsin(ISIN); trade.setQuantity(QUANTITY); trade.setPrice(PRICE); trade.setCustomer(CUSTOMER); + return trade; } + @Override protected RowMapper rowMapper() { return new TradeRowMapper(); } + @Override protected void setUpResultSetMock(ResultSet rs) throws SQLException { when(rs.getLong(TradeRowMapper.ID_COLUMN)).thenReturn(12L); when(rs.getString(TradeRowMapper.ISIN_COLUMN)).thenReturn(ISIN); @@ -38,5 +41,4 @@ public class TradeRowMapperTests extends AbstractRowMapperTests { when(rs.getString(TradeRowMapper.CUSTOMER_COLUMN)).thenReturn(CUSTOMER); when(rs.getInt(TradeRowMapper.VERSION_COLUMN)).thenReturn(0); } - } diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/iosample/TwoJobInstancesDelimitedFunctionalTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/iosample/TwoJobInstancesDelimitedFunctionalTests.java index 9e871ba6b..b32483a1f 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/iosample/TwoJobInstancesDelimitedFunctionalTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/iosample/TwoJobInstancesDelimitedFunctionalTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -49,7 +49,6 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @ContextConfiguration(locations = { "/simple-job-launcher-context.xml", "/jobs/ioSampleJob.xml", "/jobs/iosample/delimited.xml" }) public class TwoJobInstancesDelimitedFunctionalTests { - @Autowired private JobLauncher launcher; @@ -74,15 +73,13 @@ public class TwoJobInstancesDelimitedFunctionalTests { } private void verifyOutput(int expected) throws Exception { - JobParameters jobParameters = new JobParametersBuilder().addString("inputFile", "file:./target/test-outputs/delimitedOutput.csv").toJobParameters(); StepExecution stepExecution = MetaDataInstanceFactory.createStepExecution(jobParameters); int count = StepScopeTestUtils.doInStepScope(stepExecution, new Callable() { - + @Override public Integer call() throws Exception { - int count = 0; readerStream.open(new ExecutionContext()); @@ -96,18 +93,14 @@ public class TwoJobInstancesDelimitedFunctionalTests { readerStream.close(); } return count; - } - }); assertEquals(expected, count); - } protected JobParameters getJobParameters(String fileName) { return new JobParametersBuilder().addLong("timestamp", new Date().getTime()).addString("inputFile", fileName) .addString("outputFile", "file:./target/test-outputs/delimitedOutput.csv").toJobParameters(); } - } \ No newline at end of file diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/iosample/TwoJobInstancesPagingFunctionalTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/iosample/TwoJobInstancesPagingFunctionalTests.java index 8b0d7cef3..c62d86a57 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/iosample/TwoJobInstancesPagingFunctionalTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/iosample/TwoJobInstancesPagingFunctionalTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2012 the original author or authors. + * Copyright 2006-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -45,7 +45,6 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @ContextConfiguration(locations = { "/simple-job-launcher-context.xml", "/jobs/ioSampleJob.xml", "/jobs/iosample/jdbcPaging.xml" }) public class TwoJobInstancesPagingFunctionalTests { - @Autowired private JobLauncher launcher; @@ -61,11 +60,11 @@ public class TwoJobInstancesPagingFunctionalTests { @Test public void testLaunchJobTwice() throws Exception { - int first = jdbcTemplate.queryForInt("select count(0) from CUSTOMER where credit>1000"); + int first = jdbcTemplate.queryForObject("select count(0) from CUSTOMER where credit>1000", Integer.class); JobExecution jobExecution = launcher.run(this.job, getJobParameters(1000.)); assertEquals(BatchStatus.COMPLETED, jobExecution.getStatus()); assertEquals(first, jobExecution.getStepExecutions().iterator().next().getWriteCount()); - int second = jdbcTemplate.queryForInt("select count(0) from CUSTOMER where credit>1000000"); + int second = jdbcTemplate.queryForObject("select count(0) from CUSTOMER where credit>1000000", Integer.class); assertNotSame("The number of records above the threshold did not change", first, second); jobExecution = launcher.run(this.job, getJobParameters(1000000.)); assertEquals(BatchStatus.COMPLETED, jobExecution.getStatus()); @@ -76,5 +75,4 @@ public class TwoJobInstancesPagingFunctionalTests { return new JobParametersBuilder().addLong("timestamp", new Date().getTime()).addDouble("credit", amount) .toJobParameters(); } - } \ No newline at end of file diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/iosample/internal/DelegatingTradeLineAggregator.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/iosample/internal/DelegatingTradeLineAggregator.java index 2ee5cd3df..66ba6a4db 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/iosample/internal/DelegatingTradeLineAggregator.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/iosample/internal/DelegatingTradeLineAggregator.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,6 +28,7 @@ public class DelegatingTradeLineAggregator implements LineAggregator { private LineAggregator tradeLineAggregator; private LineAggregator customerLineAggregator; + @Override public String aggregate(Object item) { if (item instanceof Trade) { return this.tradeLineAggregator.aggregate((Trade) item); diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/iosample/internal/MultiLineTradeItemReader.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/iosample/internal/MultiLineTradeItemReader.java index 9d4ad95a9..ce9faa9b2 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/iosample/internal/MultiLineTradeItemReader.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/iosample/internal/MultiLineTradeItemReader.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,16 +30,16 @@ import org.springframework.util.Assert; * @since 2.0 */ public class MultiLineTradeItemReader implements ItemReader, ItemStream { - private FlatFileItemReader
delegate; /** * @see org.springframework.batch.item.ItemReader#read() */ + @Override public Trade read() throws Exception { Trade t = null; - for (FieldSet line = null; (line = this.delegate.read()) != null;) { + for (FieldSet line; (line = this.delegate.read()) != null;) { String prefix = line.readString(0); if (prefix.equals("BEGIN")) { t = new Trade(); // Record must start with 'BEGIN' @@ -66,14 +66,17 @@ public class MultiLineTradeItemReader implements ItemReader, ItemStream { this.delegate = delegate; } + @Override public void close() throws ItemStreamException { this.delegate.close(); } + @Override public void open(ExecutionContext executionContext) throws ItemStreamException { this.delegate.open(executionContext); } + @Override public void update(ExecutionContext executionContext) throws ItemStreamException { this.delegate.update(executionContext); } diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/iosample/internal/MultiLineTradeItemWriter.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/iosample/internal/MultiLineTradeItemWriter.java index b82df72f8..c1ddabd55 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/iosample/internal/MultiLineTradeItemWriter.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/iosample/internal/MultiLineTradeItemWriter.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,17 +31,19 @@ import org.springframework.batch.sample.domain.trade.Trade; * @since 2.0 */ public class MultiLineTradeItemWriter implements ItemWriter, ItemStream { - private FlatFileItemWriter delegate; + @Override public void write(List items) throws Exception { List lines = new ArrayList(); + for (Trade t : items) { lines.add("BEGIN"); lines.add("INFO," + t.getIsin() + "," + t.getCustomer()); lines.add("AMNT," + t.getQuantity() + "," + t.getPrice()); lines.add("END"); } + this.delegate.write(lines); } @@ -49,14 +51,17 @@ public class MultiLineTradeItemWriter implements ItemWriter, ItemStream { this.delegate = delegate; } + @Override public void close() throws ItemStreamException { this.delegate.close(); } + @Override public void open(ExecutionContext executionContext) throws ItemStreamException { this.delegate.open(executionContext); } + @Override public void update(ExecutionContext executionContext) throws ItemStreamException { this.delegate.update(executionContext); } diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/iosample/internal/TradeCustomerItemWriter.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/iosample/internal/TradeCustomerItemWriter.java deleted file mode 100644 index 019156e46..000000000 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/iosample/internal/TradeCustomerItemWriter.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2006-2007 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.batch.sample.iosample.internal; - -import java.math.BigDecimal; -import java.util.List; - -import org.springframework.batch.item.ItemWriter; -import org.springframework.batch.sample.domain.trade.CustomerCredit; -import org.springframework.batch.sample.domain.trade.Trade; -import org.springframework.batch.sample.domain.trade.TradeDao; - -/** - * @author Dan Garrette - * @since 2.0 - */ -public class TradeCustomerItemWriter implements ItemWriter { - private TradeDao dao; - private int count; - - public void write(List items) throws Exception { - for (CustomerCredit c : items) { - Trade t = new Trade("ISIN" + count++, 100, new BigDecimal("1.50"), c.getName()); - this.dao.writeTrade(t); - } - } - - public void setDao(TradeDao dao) { - this.dao = dao; - } -} diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/jmx/JobExecutionNotificationPublisherTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/jmx/JobExecutionNotificationPublisherTests.java index f4255a466..39617b982 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/jmx/JobExecutionNotificationPublisherTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/jmx/JobExecutionNotificationPublisherTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2008 the original author or authors. + * Copyright 2006-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,21 +33,22 @@ import org.springframework.jmx.export.notification.UnableToSendNotificationExcep * */ public class JobExecutionNotificationPublisherTests { - JobExecutionNotificationPublisher publisher = new JobExecutionNotificationPublisher(); @Test public void testRepeatOperationsOpenUsed() throws Exception { final List list = new ArrayList(); + publisher.setNotificationPublisher(new NotificationPublisher() { + @Override public void sendNotification(Notification notification) throws UnableToSendNotificationException { list.add(notification); } }); + publisher.onApplicationEvent(new SimpleMessageApplicationEvent(this, "foo")); assertEquals(1, list.size()); String message = list.get(0).getMessage(); assertTrue("Message does not contain 'foo': ", message.indexOf("foo") > 0); } - } diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/launch/RemoteLauncherTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/launch/RemoteLauncherTests.java index 45ea7a5b2..7bf50d911 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/launch/RemoteLauncherTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/launch/RemoteLauncherTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,7 +24,6 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; -import javax.management.MBeanServerConnection; import javax.management.MalformedObjectNameException; import org.apache.commons.logging.Log; @@ -44,23 +43,20 @@ import org.springframework.jmx.support.MBeanServerConnectionFactoryBean; * */ public class RemoteLauncherTests { - private static Log logger = LogFactory.getLog(RemoteLauncherTests.class); - private static List errors = new ArrayList(); - private static JobOperator launcher; - private static JobLoader loader; - static private Thread thread; @Test public void testConnect() throws Exception { String message = errors.isEmpty() ? "" : errors.get(0).getMessage(); + if (!errors.isEmpty()) { fail(message); } + assertTrue(isConnected()); } @@ -68,12 +64,12 @@ public class RemoteLauncherTests { public void testLaunchBadJob() throws Exception { assertEquals(0, errors.size()); assertTrue(isConnected()); + try { launcher.start("foo", "time=" + (new Date().getTime())); fail("Expected RuntimeException"); } catch (RuntimeException e) { - // expected; String message = e.getMessage(); assertTrue("Wrong message: " + message, message.contains("NoSuchJobException")); } @@ -89,18 +85,20 @@ public class RemoteLauncherTests { @Test public void testPauseJob() throws Exception { final int SLEEP_INTERVAL = 600; + assertTrue(isConnected()); assertTrue(launcher.getJobNames().contains("loopJob")); + long executionId = launcher.start("loopJob", ""); // sleep long enough to avoid race conditions (serializable tx isolation // doesn't work with HSQL) Thread.sleep(SLEEP_INTERVAL); - // assertEquals(1, launcher.getRunningExecutions("loopJob").size()); + launcher.stop(executionId); Thread.sleep(SLEEP_INTERVAL); - // assertEquals(0, launcher.getRunningExecutions("loopJob").size()); + logger.debug(launcher.getSummary(executionId)); long resumedId = launcher.restart(executionId); assertNotSame("Picked up the same execution after pause and resume", executionId, resumedId); @@ -109,14 +107,12 @@ public class RemoteLauncherTests { launcher.stop(resumedId); Thread.sleep(SLEEP_INTERVAL); - // assertEquals(0, launcher.getRunningExecutions("loopJob").size()); logger.debug(launcher.getSummary(resumedId)); long resumeId2 = launcher.restart(resumedId); assertNotSame("Picked up the same execution after pause and resume", executionId, resumeId2); Thread.sleep(SLEEP_INTERVAL); launcher.stop(resumeId2); - } /* @@ -127,20 +123,23 @@ public class RemoteLauncherTests { @BeforeClass public static void setUp() throws Exception { System.setProperty("com.sun.management.jmxremote", ""); + thread = new Thread(new Runnable() { + @Override public void run() { try { JobRegistryBackgroundJobRunner.main("adhoc-job-launcher-context.xml", "jobs/adhocLoopJob.xml"); } catch (Exception e) { - // e.printStackTrace(); logger.error(e); errors.add(e); } } }); + thread.start(); int count = 0; + while (!isConnected() && count++ < 10) { Thread.sleep(1000); } @@ -153,21 +152,24 @@ public class RemoteLauncherTests { private static boolean isConnected() throws Exception { boolean connected = false; + if (!JobRegistryBackgroundJobRunner.getErrors().isEmpty()) { throw JobRegistryBackgroundJobRunner.getErrors().get(0); } + if (launcher == null) { MBeanServerConnectionFactoryBean connectionFactory = new MBeanServerConnectionFactoryBean(); + try { launcher = (JobOperator) getMBean(connectionFactory, "spring:service=batch,bean=jobOperator", JobOperator.class); loader = (JobLoader) getMBean(connectionFactory, "spring:service=batch,bean=jobLoader", JobLoader.class); } catch (MBeanServerNotFoundException e) { - // ignore return false; } } + try { launcher.getJobNames(); connected = loader.getConfigurations().size() > 0; @@ -184,9 +186,8 @@ public class RemoteLauncherTests { MBeanProxyFactoryBean factory = new MBeanProxyFactoryBean(); factory.setObjectName(objectName); factory.setProxyInterface(interfaceType); - factory.setServer((MBeanServerConnection) connectionFactory.getObject()); + factory.setServer(connectionFactory.getObject()); factory.afterPropertiesSet(); return factory.getObject(); } - } diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/quartz/JobLauncherDetailsTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/quartz/JobLauncherDetailsTests.java index 162192313..bd58bc32c 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/quartz/JobLauncherDetailsTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/quartz/JobLauncherDetailsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -46,23 +46,23 @@ import org.springframework.batch.core.repository.JobRestartException; * */ public class JobLauncherDetailsTests { - private JobLauncherDetails details = new JobLauncherDetails(); - private TriggerFiredBundle firedBundle; - private List list = new ArrayList(); @Before public void setUp() throws Exception { details.setJobLauncher(new JobLauncher() { + @Override public JobExecution run(org.springframework.batch.core.Job job, JobParameters jobParameters) throws JobExecutionAlreadyRunningException, JobRestartException { list.add(jobParameters); return null; } }); + details.setJobLocator(new JobLocator() { + @Override public org.springframework.batch.core.Job getJob(String name) throws NoSuchJobException { list.add(name); return new StubJob("foo"); @@ -154,39 +154,40 @@ public class JobLauncherDetailsTests { } private final class StubJobExecutionContext extends JobExecutionContext { - private StubJobExecutionContext() { super(mock(Scheduler.class), firedBundle, mock(Job.class)); } - } private static class StubJob implements org.springframework.batch.core.Job { - private final String name; public StubJob(String name) { this.name = name; } + @Override public void execute(JobExecution execution) { } + @Override public JobParametersIncrementer getJobParametersIncrementer() { return null; } + + @Override public JobParametersValidator getJobParametersValidator() { return null; } + @Override public String getName() { return name; } + @Override public boolean isRestartable() { return false; } - } - } diff --git a/spring-batch-samples/src/test/resources/job-runner-context.xml b/spring-batch-samples/src/test/resources/job-runner-context.xml index 5e56c1b71..596b80a1e 100644 --- a/spring-batch-samples/src/test/resources/job-runner-context.xml +++ b/spring-batch-samples/src/test/resources/job-runner-context.xml @@ -1,10 +1,10 @@ + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd + http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> - + diff --git a/spring-batch-samples/src/test/resources/org/springframework/batch/sample/JobStepFunctionalTests-context.xml b/spring-batch-samples/src/test/resources/org/springframework/batch/sample/JobStepFunctionalTests-context.xml index 9add530d8..1d66468bf 100644 --- a/spring-batch-samples/src/test/resources/org/springframework/batch/sample/JobStepFunctionalTests-context.xml +++ b/spring-batch-samples/src/test/resources/org/springframework/batch/sample/JobStepFunctionalTests-context.xml @@ -1,7 +1,6 @@ - + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> @@ -9,5 +8,4 @@ - diff --git a/spring-batch-samples/src/test/resources/org/springframework/batch/sample/common/ColumnRangePartitionerTests-context.xml b/spring-batch-samples/src/test/resources/org/springframework/batch/sample/common/ColumnRangePartitionerTests-context.xml index ed39a3495..2072e0b5b 100644 --- a/spring-batch-samples/src/test/resources/org/springframework/batch/sample/common/ColumnRangePartitionerTests-context.xml +++ b/spring-batch-samples/src/test/resources/org/springframework/batch/sample/common/ColumnRangePartitionerTests-context.xml @@ -1,10 +1,7 @@ + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> - \ No newline at end of file diff --git a/spring-batch-samples/src/test/resources/org/springframework/batch/sample/common/StagingItemReaderTests-context.xml b/spring-batch-samples/src/test/resources/org/springframework/batch/sample/common/StagingItemReaderTests-context.xml index 1962da944..83c970cfc 100644 --- a/spring-batch-samples/src/test/resources/org/springframework/batch/sample/common/StagingItemReaderTests-context.xml +++ b/spring-batch-samples/src/test/resources/org/springframework/batch/sample/common/StagingItemReaderTests-context.xml @@ -1,10 +1,7 @@ + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> - - \ No newline at end of file + diff --git a/spring-batch-samples/src/test/resources/org/springframework/batch/sample/common/StagingItemWriterTests-context.xml b/spring-batch-samples/src/test/resources/org/springframework/batch/sample/common/StagingItemWriterTests-context.xml index 1962da944..640333c64 100644 --- a/spring-batch-samples/src/test/resources/org/springframework/batch/sample/common/StagingItemWriterTests-context.xml +++ b/spring-batch-samples/src/test/resources/org/springframework/batch/sample/common/StagingItemWriterTests-context.xml @@ -1,10 +1,7 @@ + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> - \ No newline at end of file diff --git a/spring-batch-samples/src/test/resources/org/springframework/batch/sample/domain/trade/internal/JdbcCustomerDebitDaoTests-context.xml b/spring-batch-samples/src/test/resources/org/springframework/batch/sample/domain/trade/internal/JdbcCustomerDebitDaoTests-context.xml index 9e6004179..bd56090a4 100644 --- a/spring-batch-samples/src/test/resources/org/springframework/batch/sample/domain/trade/internal/JdbcCustomerDebitDaoTests-context.xml +++ b/spring-batch-samples/src/test/resources/org/springframework/batch/sample/domain/trade/internal/JdbcCustomerDebitDaoTests-context.xml @@ -1,11 +1,8 @@ + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> - \ No newline at end of file