diff --git a/spring-batch-samples/README.md b/spring-batch-samples/README.md index 23e6d8c77..0e535316a 100644 --- a/spring-batch-samples/README.md +++ b/spring-batch-samples/README.md @@ -21,87 +21,66 @@ offered by the spring batch framework. Consider the following: Here is a list of samples with checks to indicate which features each one demonstrates: -Job/Feature | skip | retry | restart | automatic mapping | asynch launch | validation | delegation | write behind | non-squenetial | asynch process | filtering -:------------------------------------------------ | :--: | :---: | :-----: | :---------------: | :-----------: | :--------: | :--------: | :----------: | :------------: | :------------: | :-------: -[Adhoc Loop and JMX Demo](#adhoc-loop-and-jmx-demo) | | | | | X | | | | | | -[Amqp Job Sample](#amqp-job-sample) | | | | | | | | | | X | -[BeanWrapperMapper Sample](#beanwrappermapper-sample) | | | | X | | | | | | | -[Composite ItemWriter Sample](#composite-itemwriter-sample) | | | | | | | X | | | | -[Customer Filter Sample](#customer-filter-sample) | | | | | | | | | | | X -[Delegating Sample](#delegating-sample) | | | | | | | X | | | | -[Football Job](#football-job) | | | | | | | | | | | -[Header Footer Sample](#header-footer-sample) | | | | | | | | | | | -[Hibernate Sample](#hibernate-sample) | | X | | | | | | X | | | -IO Sample Job | | | | | | X | | X | | | -[Infinite Loop Sample](#infinite-loop-sample) | | | | | | X | | | X | | -[Loop Flow Sample](#loop-flow-sample) | | | | | | | | | | | -[Multiline](#multiline) | | | | | | | X | | | | -[Multiline Order Job](#multiline-order-job) | | | | | | | X | | | | -[Parallel Sample](#parallel-sample) | | | | | | | | | | X | -[Partitioning Sample](#partitioning-sample) | | | | | | | | | | X | -[Remote Chunking Sample](#remote-chunking-sample) | | | | | | | | | | X | -[Quartz Sample](#quartz-sample) | | | | | X | | | | | | -[Restart Sample](#restart-sample) | | | X | | | | | | | | -[Retry Sample](#retry-sample) | | X | | | | | | | | | -[Skip Sample](#skip-sample) | X | | | | | | | | | | -[Chunk Scanning Sample](#chunk-scanning-sample) | X | | | | | | | | | | -[Trade Job](#trade-job) | | | | | | X | | | | | +| Job/Feature | skip | retry | restart | automatic mapping | asynch launch | validation | delegation | write behind | non-sequential | asynch process | filtering | +|:--------------------------------------------------------------|:----:|:-----:|:-------:|:-----------------:|:-------------:|:----------:|:----------:|:------------:|:--------------:|:--------------:|:---------:| +| [Amqp Job Sample](#amqp-job-sample) | | | | | | | | | | X | | +| [BeanWrapperMapper Sample](#beanwrappermapper-sample) | | | | X | | | | | | | | +| [Composite ItemWriter Sample](#composite-itemwriter-sample) | | | | | | | X | | | | | +| [Customer Filter Sample](#customer-filter-sample) | | | | | | | | | | | X | +| [Reader Writer Adapter Sample](#reader-writer-adapter-sample) | | | | | | | X | | | | | +| [Football Job](#football-job) | | | | | | | | | | | | +| [Trade Job](#trade-job) | | | | | | X | | | | | | +| [Header Footer Sample](#header-footer-sample) | | | | | | | | | | | | +| [Hibernate Sample](#hibernate-sample) | | X | | | | | | X | | | | +| [Loop Flow Sample](#loop-flow-sample) | | | | | | | | | | | | +| [Multiline Sample](#multiline-input-job) | | | | | | | X | | | | | +| [Pattern matching Sample](#pattern-matching-sample) | | | | | | | X | | | | | +| [Process indicator Sample](#process-indicator-pattern-sample) | | | | | | | | | | X | | +| [Local Partitioning Sample](#local-partitioning-sample) | | | | | | | | | | X | | +| [Remote Partitioning Sample](#remote-partitioning-sample) | | | | | | | | | | X | | +| [Remote Chunking Sample](#remote-chunking-sample) | | | | | | | | | | X | | +| [Quartz Sample](#quartz-sample) | | | | | X | | | | | | | +| [Stop Restart Sample](#stop-restart-sample) | | | X | | | | | | | | | +| [Fail Restart Sample](#fail-restart-sample) | | | X | | | | | | | | | +| [Retry Sample](#retry-sample) | | X | | | | | | | | | | +| [Skip Sample](#skip-sample) | X | | | | | | | | | | | +| [Chunk Scanning Sample](#chunk-scanning-sample) | X | X | | | | | | | | | | +| [Adhoc Loop and JMX Demo](#adhoc-loop-and-jmx-sample) | | | X | | X | | | | | | | The IO Sample Job has a number of special instances that show different IO features using the same job configuration but with different readers and writers: -Job/Feature | delimited input | fixed-length input | xml input | db paging input | db cursor input | delimited output | fixed-length output | xml output | db output | multiple files | multi-line | mulit-record -:-------------------------- | :-------------: | :----------------: | :-------: | :-------------: | :-------------: | :--------------: | :-----------------: | :--------: | :-------: | :------------: | :--------: | :----------: -delimited | x | | | | | | | x | | | | -[Fixed Length Import Job](#fixed-length-import-job) | | x | | | | | | | x | | | -[Hibernate Sample](#hibernate-sample) | | | | | x | | | | | | x | -[Jdbc Cursor and Batch Update](#jdbc-cursor-and-batch-update) | | | | | x | | | | | | x | -jpa | | | | x | | | | | | | x | -[Multiline](#multiline) | x | | | | | | | x | | | x | -multiRecordtype | | x | | | | | | | x | | | x -multiResource | x | | | | | | | x | | | | x -[XML Input Output](#xml-input-output) | | | x | | | | | | | x | | -[MongoDB sample](#mongodb-sample) | | | | | x | | | | x | | | - +| Job/Feature | delimited input | fixed-length input | xml input | db paging input | db cursor input | delimited output | fixed-length output | xml output | db output | multiple files | multi-line | multi-record | +|:--------------------------------------------------------------------|:---------------:|:------------------:|:---------:|:---------------:|:---------------:|:----------------:|:-------------------:|:----------:|:---------:|:--------------:|:----------:|:------------:| +| [Delimited File Import Job](#delimited-file-import-job) | x | | | | | | | x | | | | | +| [Fixed Length Import Job](#fixed-length-import-job) | | x | | | | | | | x | | | | +| [Hibernate Sample](#hibernate-sample) | | | | | x | | | | | | x | | +| [Jdbc Readers and Writers Sample](#jdbc-readers-and-writers-sample) | | | | | x | | | | | | x | | +| [JPA Readers and Writers sample](#jpa-readers-and-writers-sample) | | | | x | | | | | | | x | | +| [Multiline Input Sample](#multiline-input-job) | x | | | | | | | x | | | x | | +| [multiRecord Type Sample](#multirecord-type-input-job) | | x | | | | | | | x | | | x | +| [multiResource Sample](#multiresource-input-output-job) | x | | | | | | | x | | x | | x | +| [XML Input Output Sample](#xml-input-output) | | | x | | | | | | | | | | +| [MongoDB sample](#mongodb-sample) | | | | | x | | | | x | | | | ### Common Sample Source Structures -The easiest way to launch a sample job in Spring Batch is to open up -a unit test in your IDE and run it directly. Each sample has a -separate test case in the `org.springframework.batch.samples` -package. The name of the test case is `[JobName]FunctionalTests`. +Samples are organised by feature in separate packages. Each sample +has a specific README file in its corresponding package. -**Note:** The test cases do not ship in the samples jar file, but they -are in the .zip distribution and in the source code, which -you can download using subversion (or browse in a web browser if -you need to). See here for a link to the source code repository. +The easiest way to launch a sample is to open up a unit test in +your IDE and run it directly. Each sample has a test case in the +`org.springframework.batch.samples` package. The name of the test +case is `[JobName]FunctionalTests`. You can also run each sample +from the command line as follows: -You can also use the same Spring configuration as the unit test to -launch the job via a main method in `CommmandLineJobRunner`. -The samples source code has an Eclipse launch configuration to do -this, taking the hassle out of setting up a classpath to run the -job. +``` +$>cd spring-batch-samples +$>../mvnw -Dtest=[JobName]FunctionalTests#test[JobName] test +``` -### Adhoc Loop and JMX Demo +Please refer to the README of each sample for launching instructions. -This job is simply an infinite loop. It runs forever so it is -useful for testing features to do with stopping and starting jobs. -It is used, for instance, as one of the jobs that can be run from -JMX using the Eclipse launch configuration "jmxLauncher". - -The JMX launcher uses an additional XML configuration file -(adhoc-job-launcher-context.xml) to set up a `JobOperator` for -running jobs asynchronously (i.e. in a background thread). This -follows the same pattern as the [Quartz sample](#quartz-sample), so see that section - for more details of the `JobLauncher` configuration. - -The rest of the configuration for this demo consists of exposing -some components from the application context as JMX managed beans. -The `JobOperator` is exposed so that it can be controlled from a -remote client (such as JConsole from the JDK) which does not have -Spring Batch on the classpath. See the Spring Core Reference Guide -for more details on how to customise the JMX configuration. - -### Jdbc Readers and Batch Update sample +### Jdbc Readers and Writers sample The purpose of this sample is to show to usage of the `JdbcCursorItemReader`/`JdbcPagingItemReader` and the `JdbcBatchItemWriter` to make @@ -123,7 +102,7 @@ The `AmqpItemReader` and Writer were contributed by Chris Schaefer. It is modeled after the `JmsItemReader` / Writer implementations, which are popular models for remote chunking. It leverages the `AmqpTemplate`. -[Amqp Job Sample](./src/main/java/org/springframework/batch/sample/rabbitmq/README.md) +[Amqp Job Sample](src/main/java/org/springframework/batch/sample/amqp/README.md) ### BeanWrapperMapper Sample @@ -134,14 +113,7 @@ beans, and then their properties are set using the `BeanWrapperFieldSetMapper`, which sets properties of the prototype according to the field names in the file. -Nested property paths are resolved in the same way as normal Spring -binding occurs, but with a little extra leeway in terms of spelling -and capitalisation. Thus for instance, the `Trade` object has a -property called `customer` (lower case), but the file has been -configured to have a column name `CUSTOMER` (upper case), and -the mapper will accept the values happily. Underscores instead of -camel-casing (e.g. `CREDIT_CARD` instead of `creditCard`) -also work. +[BeanWrapperMapper Sample](./src/main/java/org/springframework/batch/sample/beanwrapper/README.md) ### Composite ItemWriter Sample @@ -157,18 +129,31 @@ streams in the `Step` where they are used, in order for the step to be restartable. This is a common feature of all delegate patterns. +[Composite writer Sample](./src/main/java/org/springframework/batch/sample/compositewriter/README.md) + ### Customer Filter Sample This shows the use of the `ItemProcessor` to filter out items by returning null. When an item is filtered it leads to an increment in the `filterCount` in the step execution. -### Delegating Sample +[Customer Filter Sample](./src/main/java/org/springframework/batch/sample/filter/README.md) -This sample shows the delegate pattern again, and also the +### Reader Writer Adapter Sample + +This sample shows the delegate pattern, and also the `ItemReaderAdapter` which is used to adapt a POJO to the `ItemReader` interface. +[Reader Writer Adapter Sample](src/main/java/org/springframework/batch/sample/adapter/readerwriter/README.md) + +### Tasklet Adapter Sample + +This sample shows the delegate pattern again, to adapt an +existing service to a `Tasklet`. + +[Tasklet Adapter Sample](src/main/java/org/springframework/batch/sample/adapter/tasklet/README.md) + ### Delimited File Import Job The goal is to demonstrate a typical scenario of reading data @@ -253,6 +238,64 @@ TRADUK21341EAH50234 32.45customer6 [MultiRecord type Input Job Sample](./src/main/java/org/springframework/batch/sample/file/multirecordtype/README.md) +### Multiline Aggregate Sample + +The goal of this sample is to show some common tricks with multiline +records in file input jobs. + +The input file in this case consists of two groups of trades +delimited by special lines in a file (BEGIN and END): + +``` +BEGIN +UK21341EAH4597898.34customer1 +UK21341EAH4611218.12customer2 +END +BEGIN +UK21341EAH4724512.78customer2 +UK21341EAH4810809.25customer3 +UK21341EAH4985423.39customer4 +END +``` + +The goal of the job is to operate on the two groups, so the item +type is naturally `List. + +[Multiline Aggregate Sample](./src/main/java/org/springframework/batch/sample/file/multilineaggregate/README.md) + +### Pattern Matching Sample + +The goal is to demonstrate how to handle a more complex file input +format, where a record meant for processing includes nested records +and spans multiple lines. + +The input source is a file with multiline records: + +``` +HEA;0013100345;2007-02-15 +NCU;Smith;Peter;;T;20014539;F +BAD;;Oak Street 31/A;;Small Town;00235;IL;US +SAD;Smith, Elizabeth;Elm Street 17;;Some City;30011;FL;United States +BIN;VISA;VISA-12345678903 +LIT;1044391041;37.49;0;0;4.99;2.99;1;45.47 +LIT;2134776319;221.99;5;0;7.99;2.99;1;221.87 +SIN;UPS;EXP;DELIVER ONLY ON WEEKDAYS +FOT;2;2;267.34 +HEA;0013100346;2007-02-15 +BCU;Acme Factory of England;72155919;T +BAD;;St. Andrews Road 31;;London;55342;;UK +BIN;AMEX;AMEX-72345678903 +LIT;1044319101;1070.50;5;0;7.99;2.99;12;12335.46 +LIT;2134727219;21.79;5;0;7.99;2.99;12;380.17 +LIT;1044339301;79.95;0;5.5;4.99;2.99;4;329.72 +LIT;2134747319;55.29;10;0;7.99;2.99;6;364.45 +LIT;1044359501;339.99;10;0;7.99;2.99;2;633.94 +SIN;FEDX;AMS; +FOT;5;36;14043.74 +``` + +[Pattern Matching Sample](./src/main/java/org/springframework/batch/sample/file/patternmatching/README.md) + ### Football Job This is a (American) Football statistics loading job. It loads two files containing players and games @@ -260,6 +303,18 @@ data into a database, and then combines them to summarise how each player perfor [Football Job](./src/main/java/org/springframework/batch/sample/football/README.md) +### Trade Job + +The goal is to show a reasonably complex scenario, that would +resemble the real-life usage of the framework. + +This job has 3 steps. First, data about trades are imported from a +file to database. Second, the trades are read from the database and +credit on customer accounts is decreased appropriately. Last, a +report about customers is exported to a file. + +[Trade Job](./src/main/java/org/springframework/batch/sample/trade/README.md) + ### Header Footer Sample This sample shows the use of callbacks and listeners to deal with @@ -270,6 +325,8 @@ input to the output. * `SummaryFooterCallback`: creates a summary footer at the end of the output file. +[Header Footer Sample](./src/main/java/org/springframework/batch/sample/headerfooter/README.md) + ### Hibernate Sample The purpose of this sample is to show a typical usage of Hibernate @@ -286,119 +343,47 @@ The output reliability and robustness are improved by the use of need to take control of it so that the skip and retry features provided by Spring Batch can work effectively. -### Infinite Loop Sample +### Stop Restart Sample This sample has a single step that is an infinite loop, reading and writing fake data. It is used to demonstrate stop signals and restart capabilities. +[Stop / Restart Sample](src/main/java/org/springframework/batch/sample/restart/stop/README.md) + +### Fail Restart Sample + +The goal of this sample is to show how a job can be restarted after +a failure and continue processing where it left off. + +To simulate a failure we "fake" a failure on the fourth record +though the use of a sample component +`ExceptionThrowingItemReaderProxy`. This is a stateful reader +that counts how many records it has processed and throws a planned +exception in a specified place. Since we re-use the same instance +when we restart the job it will not fail the second time. + +[Fail / Restart Sample](src/main/java/org/springframework/batch/sample/restart/fail/README.md) + ### Loop Flow Sample Shows how to implement a job that repeats one of its steps up to a limit set by a `JobExecutionDecider`. -### Multiline +[Loop Flow Sample](src/main/java/org/springframework/batch/sample/loop/README.md) -The goal of this sample is to show some common tricks with multiline -records in file input jobs. - -The input file in this case consists of two groups of trades -delimited by special lines in a file (BEGIN and END): - - BEGIN - UK21341EAH4597898.34customer1 - UK21341EAH4611218.12customer2 - END - BEGIN - UK21341EAH4724512.78customer2 - UK21341EAH4810809.25customer3 - UK21341EAH4985423.39customer4 - END - -The goal of the job is to operate on the two groups, so the item -type is naturally `List. To get these items delivered -from an item reader we employ two components from Spring Batch: the -`AggregateItemReader` and the -`PrefixMatchingCompositeLineTokenizer`. The latter is -responsible for recognising the difference between the trade data -and the delimiter records. The former is responsible for -aggregating the trades from each group into a `List` and handing -out the list from its `read()` method. To help these components -perform their responsibilities we also provide some business -knowledge about the data in the form of a `FieldSetMapper` -(`TradeFieldSetMapper`). The `TradeFieldSetMapper` checks -its input for the delimiter fields (BEGIN, END) and if it detects -them, returns the special tokens that `AggregateItemReader` -needs. Otherwise it maps the input into a `Trade` object. - -### Multiline Order Job - -The goal is to demonstrate how to handle a more complex file input -format, where a record meant for processing includes nested records -and spans multiple lines - -The input source is file with multiline records. -`OrderItemReader` is an example of a non-default programmatic -item reader. It reads input until it detects that the multiline -record has finished and encapsulates the record in a single domain -object. - -The output target is a file with multiline records. The concrete -`ItemWriter` passes the object to a an injected 'delegate -writer' which in this case writes the output to a file. The writer -in this case demonstrates how to write multiline output using a -custom aggregator transformer. - -### Parallel Sample +### Process Indicator pattern Sample The purpose of this sample is to show multi-threaded step execution using the Process Indicator pattern. The job reads data from the same file as the [Fixed Length Import sample](#fixed-length-import-job), but instead of writing it out directly it goes through a staging table, and the -staging table is read in a multi-threaded step. Note that for such -a simple example where the item processing was not expensive, there -is unlikely to be much if any benefit in using a multi-threaded -step. +staging table is read in a multi-threaded step. -Multi-threaded step execution is easy to configure using Spring -Batch, but there are some limitations. Most of the out-of-the-box -`ItemReader` and `ItemWriter` implementations are not -designed to work in this scenario because they need to be -restartable and they are also stateful. There should be no surprise -about this, and reading a file (for instance) is usually fast enough -that multi-threading that part of the process is not likely to -provide much benefit, compared to the cost of managing the state. +[Process Indicator pattern Sample](src/main/java/org/springframework/batch/sample/processindicator/README.md) -The best strategy to cope with restart state from multiple -concurrent threads depends on the kind of input source involved: - -* For file-based input (and output) restart sate is practically -impossible to manage. Spring Batch does not provide any features -or samples to help with this use case. -* With message middleware input it is trivial to manage restarts, -since there is no state to store (if a transaction rolls back the -messages are returned to the destination they came from). -* With database input state management is still necessary, but it -isn't particularly difficult. The easiest thing to do is rely on -a Process Indicator in the input data, which is a column in the -data indicating for each row if it has been processed or not. The -flag is updated inside the batch transaction, and then in the case -of a failure the updates are lost, and the records will show as -un-processed on a restart. - -This last strategy is implemented in the `StagingItemReader`. -Its companion, the `StagingItemWriter` is responsible for -setting up the data in a staging table which contains the process -indicator. The reader is then driven by a simple SQL query that -includes a where clause for the processed flag, i.e. - - SELECT ID FROM BATCH_STAGING WHERE JOB_ID=? AND PROCESSED=? ORDER BY ID - -It is then responsible for updating the processed flag (which -happens inside the main step transaction). - -### Partitioning Sample +### Local Partitioning Sample The purpose of this sample is to show multi-threaded step execution using the `PartitionHandler` SPI. The example uses a @@ -443,76 +428,9 @@ and Spring Integration channels and messages are sent over the wire through a TC ### Quartz Sample The goal is to demonstrate how to schedule job execution using -Quartz scheduler. In this case there is no unit test to launch the -sample because it just re-uses the football job. There is a main -method in `JobRegistryBackgroundJobRunner` and an Eclipse launch -configuration which runs it with arguments to pick up the football -job. +Quartz scheduler. -The additional XML configuration for this job is in -`quartz-job-launcher.xml`, and it also re-uses -`footballJob.xml` - -The configuration declares a `JobLauncher` bean. The launcher -bean is different from the other samples only in that it uses an -asynchronous task executor, so that the jobs are launched in a -separate thread to the main method: - - - - - - - - -Also, a Quartz `JobDetail` is defined using a Spring -`JobDetailBean` as a convenience. - - - - - - - - - - - - - -Finally, a trigger with a scheduler is defined that will launch the -job detail every 10 seconds: - - - - - - - - - - -The job is thus scheduled to run every 10 seconds. In fact it -should be successful on the first attempt, so the second and -subsequent attempts should through a -`JobInstanceAlreadyCompleteException`. In a production system, -the job detail would probably be modified to account for this -exception (e.g. catch it and re-submit with a new set of job -parameters). The point here is that Spring Batch guarantees that -the job execution is idempotent - you can never inadvertently -process the same data twice. - -### Restart Sample - -The goal of this sample is to show how a job can be restarted after -a failure and continue processing where it left off. - -To simulate a failure we "fake" a failure on the fourth record -though the use of a sample component -`ExceptionThrowingItemReaderProxy`. This is a stateful reader -that counts how many records it has processed and throws a planned -exception in a specified place. Since we re-use the same instance -when we restart the job it will not fail the second time. +[Quartz Sample](src/main/java/org/springframework/batch/sample/misc/quartz/README.md) ### Retry Sample @@ -701,16 +619,6 @@ For simplicity we are only displaying the job configuration itself and leaving out the details of the supporting batch execution environment configuration. -### Trade Job - -The goal is to show a reasonably complex scenario, that would -resemble the real-life usage of the framework. - -This job has 3 steps. First, data about trades are imported from a -file to database. Second, the trades are read from the database and -credit on customer accounts is decreased appropriately. Last, a -report about customers is exported to a file. - ### Batch metrics with Micrometer This sample shows how to use [Micrometer](https://micrometer.io) to collect batch metrics in Spring Batch. @@ -726,7 +634,7 @@ This sample requires [docker compose](https://docs.docker.com/compose/) to start To run the sample, please follow these steps: ``` -$>cd spring-batch-samples/src/grafana +$>cd spring-batch-samples/src/main/resources/org/springframework/batch/sample/metrics $>docker-compose up -d ``` @@ -737,7 +645,7 @@ This should start the required monitoring stack: * Grafana on port `3000` Once started, you need to [configure Prometheus as data source in Grafana](https://grafana.com/docs/features/datasources/prometheus/) -and import the ready-to-use dashboard in `spring-batch-samples/src/grafana/spring-batch-dashboard.json`. +and import the ready-to-use dashboard in `spring-batch-samples/src/main/resources/org/springframework/batch/sample/metrics/spring-batch-dashboard.json`. Finally, run the `org.springframework.batch.sample.metrics.BatchMetricsApplication` class without any argument to start the sample. @@ -757,3 +665,11 @@ $>docker run --name mongodb --rm -d -p 27017:27017 mongo Once MongoDB is up and running, run the `org.springframework.batch.sample.mongodb.MongoDBSampleApp` class without any argument to start the sample. + +### Adhoc Loop and JMX Sample + +This job is simply an infinite loop. It runs forever so it is +useful for testing features to do with stopping and starting jobs. +It is used, for instance, as one of the jobs that can be run from JMX. + +[Adhoc Loop and JMX Sample](src/main/java/org/springframework/batch/sample/misc/jmx/README.md) diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/adapter/readerwriter/README.md b/spring-batch-samples/src/main/java/org/springframework/batch/sample/adapter/readerwriter/README.md new file mode 100644 index 000000000..62f2859c9 --- /dev/null +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/adapter/readerwriter/README.md @@ -0,0 +1,16 @@ +## Reader Writer adapter Sample + +### About + +This sample shows the delegate pattern again, and also the +`ItemReaderAdapter` which is used to adapt a POJO to the +`ItemReader` interface. + +## Run the sample + +You can run the sample from the command line as following: + +``` +$>cd spring-batch-samples +$>../mvnw -Dtest=DelegatingJobFunctionalTests#testLaunchJob test +``` \ No newline at end of file diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/adapter/tasklet/README.md b/spring-batch-samples/src/main/java/org/springframework/batch/sample/adapter/tasklet/README.md new file mode 100644 index 000000000..b1f7041b0 --- /dev/null +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/adapter/tasklet/README.md @@ -0,0 +1,15 @@ +## Tasklet Adapter Sample + +### About + +This sample shows the delegate pattern again, to adapt an +existing service to a `Tasklet`. + +## Run the sample + +You can run the sample from the command line as following: + +``` +$>cd spring-batch-samples +$>../mvnw -Dtest=TaskletAdapterJobFunctionalTests#testLaunchJob test +``` \ No newline at end of file diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/adapter/tasklet/Task.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/adapter/tasklet/Task.java new file mode 100644 index 000000000..9a78d5514 --- /dev/null +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/adapter/tasklet/Task.java @@ -0,0 +1,27 @@ +/* + * Copyright 2006-2023 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 + * + * https://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.adapter.tasklet; + +import org.springframework.batch.core.scope.context.ChunkContext; + +public class Task { + + public boolean doWork(ChunkContext chunkContext) { + chunkContext.getStepContext().getStepExecution().getJobExecution().getExecutionContext().put("done", "yes"); + return true; + } + +} \ No newline at end of file diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/rabbitmq/AmqpJobConfiguration.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/amqp/AmqpJobConfiguration.java similarity index 96% rename from spring-batch-samples/src/main/java/org/springframework/batch/sample/rabbitmq/AmqpJobConfiguration.java rename to spring-batch-samples/src/main/java/org/springframework/batch/sample/amqp/AmqpJobConfiguration.java index a8088d189..f82898a52 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/rabbitmq/AmqpJobConfiguration.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/amqp/AmqpJobConfiguration.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.batch.sample.rabbitmq; +package org.springframework.batch.sample.amqp; import javax.sql.DataSource; @@ -29,7 +29,6 @@ import org.springframework.batch.item.ItemReader; import org.springframework.batch.item.ItemWriter; import org.springframework.batch.item.amqp.builder.AmqpItemReaderBuilder; import org.springframework.batch.item.amqp.builder.AmqpItemWriterBuilder; -import org.springframework.batch.sample.rabbitmq.processor.MessageProcessor; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder; 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/amqp/AmqpMessageProducer.java similarity index 87% rename from spring-batch-samples/src/main/java/org/springframework/batch/sample/rabbitmq/amqp/AmqpMessageProducer.java rename to spring-batch-samples/src/main/java/org/springframework/batch/sample/amqp/AmqpMessageProducer.java index edf052bd9..6546710a0 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/amqp/AmqpMessageProducer.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.batch.sample.rabbitmq.amqp; +package org.springframework.batch.sample.amqp; import org.springframework.amqp.core.AmqpTemplate; import org.springframework.amqp.rabbit.core.RabbitTemplate; @@ -34,8 +34,8 @@ public final class 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" }; + private static final String[] BEAN_CONFIG = { + "classpath:org/springframework/batch/sample/amqp/job/rabbitmq-beans.xml" }; public static void main(String[] args) { ApplicationContext applicationContext = new ClassPathXmlApplicationContext(BEAN_CONFIG); diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/rabbitmq/processor/MessageProcessor.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/amqp/MessageProcessor.java similarity index 94% rename from spring-batch-samples/src/main/java/org/springframework/batch/sample/rabbitmq/processor/MessageProcessor.java rename to spring-batch-samples/src/main/java/org/springframework/batch/sample/amqp/MessageProcessor.java index e7aa7c2bf..c982944ea 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/rabbitmq/processor/MessageProcessor.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/amqp/MessageProcessor.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.batch.sample.rabbitmq.processor; +package org.springframework.batch.sample.amqp; import org.springframework.batch.item.ItemProcessor; import org.springframework.lang.Nullable; diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/rabbitmq/README.md b/spring-batch-samples/src/main/java/org/springframework/batch/sample/amqp/README.md similarity index 86% rename from spring-batch-samples/src/main/java/org/springframework/batch/sample/rabbitmq/README.md rename to spring-batch-samples/src/main/java/org/springframework/batch/sample/amqp/README.md index bc3b37d95..0a684f307 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/rabbitmq/README.md +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/amqp/README.md @@ -19,6 +19,6 @@ You can run the sample from the command line as following: ``` cd spring-batch-samples # Launch the test using the XML configuration -../mvnw -Dtest=AMQPJobFunctionalTests#testLaunchJobWithXmlConfig test +../mvnw -Dtest=AmqpJobFunctionalTests#testLaunchJobWithXmlConfig test # Launch the test using the Java configuration -../mvnw -Dtest=AMQPJobFunctionalTests#testLaunchJobWithJavaConfig test \ No newline at end of file +../mvnw -Dtest=AmqpJobFunctionalTests#testLaunchJobWithJavaConfig test \ No newline at end of file diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/beanwrapper/README.md b/spring-batch-samples/src/main/java/org/springframework/batch/sample/beanwrapper/README.md new file mode 100644 index 000000000..aba6ce4e4 --- /dev/null +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/beanwrapper/README.md @@ -0,0 +1,28 @@ +## BeanWrapperMapper Sample + +### About + +This sample shows the use of automatic mapping from fields in a file +to a domain object. The `Trade` and `Person` objects needed +by the job are created from the Spring configuration using prototype +beans, and then their properties are set using the +`BeanWrapperFieldSetMapper`, which sets properties of the +prototype according to the field names in the file. + +Nested property paths are resolved in the same way as normal Spring +binding occurs, but with a little extra leeway in terms of spelling +and capitalisation. Thus for instance, the `Trade` object has a +property called `customer` (lower case), but the file has been +configured to have a column name `CUSTOMER` (upper case), and +the mapper will accept the values happily. Underscores instead of +camel-casing (e.g. `CREDIT_CARD` instead of `creditCard`) +also work. + +### Run the sample + +You can run the sample from the command line as following: + +``` +$>cd spring-batch-samples +$>../mvnw -Dtest=BeanWrapperMapperSampleJobFunctionalTests#testJobLaunch test +``` \ No newline at end of file diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/remotechunking/DataSourceConfiguration.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/chunking/DataSourceConfiguration.java similarity index 96% rename from spring-batch-samples/src/main/java/org/springframework/batch/sample/remotechunking/DataSourceConfiguration.java rename to spring-batch-samples/src/main/java/org/springframework/batch/sample/chunking/DataSourceConfiguration.java index 9147d301d..e76ee046e 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/remotechunking/DataSourceConfiguration.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/chunking/DataSourceConfiguration.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.batch.sample.remotechunking; +package org.springframework.batch.sample.chunking; import javax.sql.DataSource; diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/remotechunking/ManagerConfiguration.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/chunking/ManagerConfiguration.java similarity index 96% rename from spring-batch-samples/src/main/java/org/springframework/batch/sample/remotechunking/ManagerConfiguration.java rename to spring-batch-samples/src/main/java/org/springframework/batch/sample/chunking/ManagerConfiguration.java index c9c8317a2..94dbeb5a2 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/remotechunking/ManagerConfiguration.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/chunking/ManagerConfiguration.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.batch.sample.remotechunking; +package org.springframework.batch.sample.chunking; import java.util.Arrays; @@ -51,7 +51,7 @@ import org.springframework.integration.jms.dsl.Jms; @EnableBatchProcessing @EnableBatchIntegration @EnableIntegration -@PropertySource("classpath:remote-chunking.properties") +@PropertySource("classpath:org/springframework/batch/sample/chunking/remote-chunking.properties") @Import(DataSourceConfiguration.class) public class ManagerConfiguration { diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/remotechunking/WorkerConfiguration.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/chunking/WorkerConfiguration.java similarity index 96% rename from spring-batch-samples/src/main/java/org/springframework/batch/sample/remotechunking/WorkerConfiguration.java rename to spring-batch-samples/src/main/java/org/springframework/batch/sample/chunking/WorkerConfiguration.java index 84c185b3d..e490a73d3 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/remotechunking/WorkerConfiguration.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/chunking/WorkerConfiguration.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.batch.sample.remotechunking; +package org.springframework.batch.sample.chunking; import jakarta.jms.JMSException; import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory; @@ -50,7 +50,7 @@ import org.springframework.integration.jms.dsl.Jms; @EnableBatchProcessing @EnableBatchIntegration @EnableIntegration -@PropertySource("classpath:remote-chunking.properties") +@PropertySource("classpath:org/springframework/batch/sample/chunking/remote-chunking.properties") @Import(DataSourceConfiguration.class) public class WorkerConfiguration { diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/ErrorLogTasklet.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/ErrorLogTasklet.java similarity index 100% rename from spring-batch-samples/src/test/java/org/springframework/batch/sample/common/ErrorLogTasklet.java rename to spring-batch-samples/src/main/java/org/springframework/batch/sample/common/ErrorLogTasklet.java diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/SkipCheckingDecider.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/SkipCheckingDecider.java similarity index 100% rename from spring-batch-samples/src/test/java/org/springframework/batch/sample/common/SkipCheckingDecider.java rename to spring-batch-samples/src/main/java/org/springframework/batch/sample/common/SkipCheckingDecider.java diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/SkipCheckingListener.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/SkipCheckingListener.java similarity index 100% rename from spring-batch-samples/src/test/java/org/springframework/batch/sample/common/SkipCheckingListener.java rename to spring-batch-samples/src/main/java/org/springframework/batch/sample/common/SkipCheckingListener.java 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/common/StepExecutionApplicationEventAdvice.java similarity index 94% rename from spring-batch-samples/src/main/java/org/springframework/batch/sample/jmx/StepExecutionApplicationEventAdvice.java rename to spring-batch-samples/src/main/java/org/springframework/batch/sample/common/StepExecutionApplicationEventAdvice.java index f183bf0dc..b83857644 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/common/StepExecutionApplicationEventAdvice.java @@ -14,10 +14,11 @@ * limitations under the License. */ -package org.springframework.batch.sample.jmx; +package org.springframework.batch.sample.common; import org.aspectj.lang.JoinPoint; import org.springframework.batch.core.StepExecution; +import org.springframework.batch.sample.misc.jmx.SimpleMessageApplicationEvent; import org.springframework.context.ApplicationEventPublisher; import org.springframework.context.ApplicationEventPublisherAware; diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/compositewriter/README.md b/spring-batch-samples/src/main/java/org/springframework/batch/sample/compositewriter/README.md new file mode 100644 index 000000000..cd5211d74 --- /dev/null +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/compositewriter/README.md @@ -0,0 +1,24 @@ +## Composite ItemWriter Sample + +### About + +This shows a common use case using a composite pattern, composing +instances of other framework readers or writers. It is also quite +common for business-specific readers or writers to wrap +off-the-shelf components in a similar way. + +In this job the composite pattern is used just to make duplicate +copies of the output data. The delegates for the +`CompositeItemWriter` have to be separately registered as +streams in the `Step` where they are used, in order for the step +to be restartable. This is a common feature of all delegate +patterns. + +### Run the sample + +You can run the sample from the command line as following: + +``` +$>cd spring-batch-samples +$>../mvnw -Dtest=CompositeItemWriterSampleFunctionalTests#testJobLaunch test +``` \ No newline at end of file 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 f9babfab4..e42c44b9b 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 @@ -19,7 +19,7 @@ package org.springframework.batch.sample.domain.person; import java.util.ArrayList; import java.util.List; -import org.springframework.batch.sample.domain.order.Address; +import org.springframework.batch.sample.file.patternmatching.Address; public class Person { 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 590f2b57d..534219148 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 @@ -19,7 +19,7 @@ package org.springframework.batch.sample.domain.person; import java.util.ArrayList; import java.util.List; -import org.springframework.batch.sample.domain.order.Address; +import org.springframework.batch.sample.file.patternmatching.Address; /** * Custom class that contains logic that would normally be be contained in diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/internal/ItemTrackingTradeItemWriter.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/internal/ItemTrackingTradeItemWriter.java similarity index 100% rename from spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/internal/ItemTrackingTradeItemWriter.java rename to spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/internal/ItemTrackingTradeItemWriter.java 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/file/multilineaggregate/AggregateItem.java similarity index 97% rename from spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/multiline/AggregateItem.java rename to spring-batch-samples/src/main/java/org/springframework/batch/sample/file/multilineaggregate/AggregateItem.java index 85bc3bf7d..a1ca70bd9 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/file/multilineaggregate/AggregateItem.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.batch.sample.domain.multiline; +package org.springframework.batch.sample.file.multilineaggregate; /** * A wrapper type for an item that is used by {@link AggregateItemReader} to identify the diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/multiline/AggregateItemFieldSetMapper.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/file/multilineaggregate/AggregateItemFieldSetMapper.java similarity index 96% rename from spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/multiline/AggregateItemFieldSetMapper.java rename to spring-batch-samples/src/main/java/org/springframework/batch/sample/file/multilineaggregate/AggregateItemFieldSetMapper.java index b49d2fe25..c7fc11ec0 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/multiline/AggregateItemFieldSetMapper.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/file/multilineaggregate/AggregateItemFieldSetMapper.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2022 the original author or authors. + * Copyright 2006-2023 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,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.batch.sample.domain.multiline; +package org.springframework.batch.sample.file.multilineaggregate; import org.springframework.batch.item.file.mapping.FieldSetMapper; import org.springframework.batch.item.file.transform.FieldSet; 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/file/multilineaggregate/AggregateItemReader.java similarity index 98% rename from spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/multiline/AggregateItemReader.java rename to spring-batch-samples/src/main/java/org/springframework/batch/sample/file/multilineaggregate/AggregateItemReader.java index cf96e3da8..a86c1dc05 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/file/multilineaggregate/AggregateItemReader.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.batch.sample.domain.multiline; +package org.springframework.batch.sample.file.multilineaggregate; import java.util.ArrayList; import java.util.List; diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/file/multilineaggregate/README.md b/spring-batch-samples/src/main/java/org/springframework/batch/sample/file/multilineaggregate/README.md new file mode 100644 index 000000000..58db121ed --- /dev/null +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/file/multilineaggregate/README.md @@ -0,0 +1,46 @@ +## Multiline Aggregate Sample + +### About + +The goal of this sample is to show some common tricks with multiline +records in file input jobs. + +The input file in this case consists of two groups of trades +delimited by special lines in a file (BEGIN and END): + +``` +BEGIN +UK21341EAH4597898.34customer1 +UK21341EAH4611218.12customer2 +END +BEGIN +UK21341EAH4724512.78customer2 +UK21341EAH4810809.25customer3 +UK21341EAH4985423.39customer4 +END +``` + +The goal of the job is to operate on the two groups, so the item +type is naturally `List. To get these items delivered +from an item reader we employ two components from Spring Batch: the +`AggregateItemReader` and the +`PrefixMatchingCompositeLineTokenizer`. The latter is +responsible for recognising the difference between the trade data +and the delimiter records. The former is responsible for +aggregating the trades from each group into a `List` and handing +out the list from its `read()` method. To help these components +perform their responsibilities we also provide some business +knowledge about the data in the form of a `FieldSetMapper` +(`TradeFieldSetMapper`). The `TradeFieldSetMapper` checks +its input for the delimiter fields (BEGIN, END) and if it detects +them, returns the special tokens that `AggregateItemReader` +needs. Otherwise it maps the input into a `Trade` object. + +### Run the sample + +You can run the sample from the command line as following: + +``` +$>cd spring-batch-samples +$>../mvnw -Dtest=MultilineAggregateJobFunctionalTests#testJobLaunch test +``` \ No newline at end of file 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/file/patternmatching/Address.java similarity index 97% rename from spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/Address.java rename to spring-batch-samples/src/main/java/org/springframework/batch/sample/file/patternmatching/Address.java index f50b023fb..e02b70ef9 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/file/patternmatching/Address.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.batch.sample.domain.order; +package org.springframework.batch.sample.file.patternmatching; public class Address { 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/file/patternmatching/BillingInfo.java similarity index 96% rename from spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/BillingInfo.java rename to spring-batch-samples/src/main/java/org/springframework/batch/sample/file/patternmatching/BillingInfo.java index 796ba0e20..a81b86b54 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/file/patternmatching/BillingInfo.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.batch.sample.domain.order; +package org.springframework.batch.sample.file.patternmatching; public class BillingInfo { 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/file/patternmatching/Customer.java similarity index 98% rename from spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/Customer.java rename to spring-batch-samples/src/main/java/org/springframework/batch/sample/file/patternmatching/Customer.java index 4f0400344..1481b29e6 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/file/patternmatching/Customer.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.batch.sample.domain.order; +package org.springframework.batch.sample.file.patternmatching; public class Customer { 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/file/patternmatching/LineItem.java similarity index 97% rename from spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/LineItem.java rename to spring-batch-samples/src/main/java/org/springframework/batch/sample/file/patternmatching/LineItem.java index f587ab505..bfc14d12b 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/file/patternmatching/LineItem.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.batch.sample.domain.order; +package org.springframework.batch.sample.file.patternmatching; import java.math.BigDecimal; 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/file/patternmatching/Order.java similarity index 98% rename from spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/Order.java rename to spring-batch-samples/src/main/java/org/springframework/batch/sample/file/patternmatching/Order.java index f2bb615a9..2d7a6b25e 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/file/patternmatching/Order.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.batch.sample.domain.order; +package org.springframework.batch.sample.file.patternmatching; import java.math.BigDecimal; import java.util.Date; diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/file/patternmatching/README.md b/spring-batch-samples/src/main/java/org/springframework/batch/sample/file/patternmatching/README.md new file mode 100644 index 000000000..c8ab3252e --- /dev/null +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/file/patternmatching/README.md @@ -0,0 +1,53 @@ +### Pattern Matching Sample + +## About + +The goal is to demonstrate how to handle a more complex file input +format, where a record meant for processing includes nested records +and spans multiple lines. + +The input source is a file with multiline records: + +``` +HEA;0013100345;2007-02-15 +NCU;Smith;Peter;;T;20014539;F +BAD;;Oak Street 31/A;;Small Town;00235;IL;US +SAD;Smith, Elizabeth;Elm Street 17;;Some City;30011;FL;United States +BIN;VISA;VISA-12345678903 +LIT;1044391041;37.49;0;0;4.99;2.99;1;45.47 +LIT;2134776319;221.99;5;0;7.99;2.99;1;221.87 +SIN;UPS;EXP;DELIVER ONLY ON WEEKDAYS +FOT;2;2;267.34 +HEA;0013100346;2007-02-15 +BCU;Acme Factory of England;72155919;T +BAD;;St. Andrews Road 31;;London;55342;;UK +BIN;AMEX;AMEX-72345678903 +LIT;1044319101;1070.50;5;0;7.99;2.99;12;12335.46 +LIT;2134727219;21.79;5;0;7.99;2.99;12;380.17 +LIT;1044339301;79.95;0;5.5;4.99;2.99;4;329.72 +LIT;2134747319;55.29;10;0;7.99;2.99;6;364.45 +LIT;1044359501;339.99;10;0;7.99;2.99;2;633.94 +SIN;FEDX;AMS; +FOT;5;36;14043.74 +``` + +`OrderItemReader` is an example of a non-default programmatic +item reader. It reads input until it detects that the multiline +record has finished and encapsulates the record in a single domain +object. + +The output target is a file with multiline records. The concrete +`ItemWriter` passes the object to a an injected 'delegate +writer' which in this case writes the output to a file. The writer +in this case demonstrates how to write multiline output using a +custom aggregator transformer. + +## Run the sample + +You can run the sample from the command line as following: + +``` +$>cd spring-batch-samples +$>../mvnw -Dtest=PatternMatchingJobFunctionalTests#testJobLaunch test +``` + 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/file/patternmatching/ShippingInfo.java similarity index 97% rename from spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/ShippingInfo.java rename to spring-batch-samples/src/main/java/org/springframework/batch/sample/file/patternmatching/ShippingInfo.java index 623401800..fd2029b7d 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/file/patternmatching/ShippingInfo.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.batch.sample.domain.order; +package org.springframework.batch.sample.file.patternmatching; public class ShippingInfo { 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/file/patternmatching/internal/OrderItemReader.java similarity index 91% rename from spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/internal/OrderItemReader.java rename to spring-batch-samples/src/main/java/org/springframework/batch/sample/file/patternmatching/internal/OrderItemReader.java index 17ecfa772..96302187a 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/file/patternmatching/internal/OrderItemReader.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.batch.sample.domain.order.internal; +package org.springframework.batch.sample.file.patternmatching.internal; import java.util.ArrayList; @@ -23,12 +23,12 @@ import org.apache.commons.logging.LogFactory; import org.springframework.batch.item.ItemReader; import org.springframework.batch.item.file.mapping.FieldSetMapper; import org.springframework.batch.item.file.transform.FieldSet; -import org.springframework.batch.sample.domain.order.Address; -import org.springframework.batch.sample.domain.order.BillingInfo; -import org.springframework.batch.sample.domain.order.Customer; -import org.springframework.batch.sample.domain.order.LineItem; -import org.springframework.batch.sample.domain.order.Order; -import org.springframework.batch.sample.domain.order.ShippingInfo; +import org.springframework.batch.sample.file.patternmatching.Address; +import org.springframework.batch.sample.file.patternmatching.BillingInfo; +import org.springframework.batch.sample.file.patternmatching.Customer; +import org.springframework.batch.sample.file.patternmatching.LineItem; +import org.springframework.batch.sample.file.patternmatching.Order; +import org.springframework.batch.sample.file.patternmatching.ShippingInfo; import org.springframework.lang.Nullable; /** diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/internal/OrderLineAggregator.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/file/patternmatching/internal/OrderLineAggregator.java similarity index 90% rename from spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/internal/OrderLineAggregator.java rename to spring-batch-samples/src/main/java/org/springframework/batch/sample/file/patternmatching/internal/OrderLineAggregator.java index ef89c3450..7fa67736a 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/internal/OrderLineAggregator.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/file/patternmatching/internal/OrderLineAggregator.java @@ -14,13 +14,13 @@ * limitations under the License. */ -package org.springframework.batch.sample.domain.order.internal; +package org.springframework.batch.sample.file.patternmatching.internal; import java.util.Map; import org.springframework.batch.item.file.transform.LineAggregator; -import org.springframework.batch.sample.domain.order.LineItem; -import org.springframework.batch.sample.domain.order.Order; +import org.springframework.batch.sample.file.patternmatching.LineItem; +import org.springframework.batch.sample.file.patternmatching.Order; /** * Converts Order object to a list of strings. diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/internal/extractor/AddressFieldExtractor.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/file/patternmatching/internal/extractor/AddressFieldExtractor.java similarity index 82% rename from spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/internal/extractor/AddressFieldExtractor.java rename to spring-batch-samples/src/main/java/org/springframework/batch/sample/file/patternmatching/internal/extractor/AddressFieldExtractor.java index 66faab80a..da9371738 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/internal/extractor/AddressFieldExtractor.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/file/patternmatching/internal/extractor/AddressFieldExtractor.java @@ -13,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.batch.sample.domain.order.internal.extractor; +package org.springframework.batch.sample.file.patternmatching.internal.extractor; import org.springframework.batch.item.file.transform.FieldExtractor; -import org.springframework.batch.sample.domain.order.Address; -import org.springframework.batch.sample.domain.order.Order; +import org.springframework.batch.sample.file.patternmatching.Address; +import org.springframework.batch.sample.file.patternmatching.Order; /** * @author Dan Garrette diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/internal/extractor/BillingInfoFieldExtractor.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/file/patternmatching/internal/extractor/BillingInfoFieldExtractor.java similarity index 81% rename from spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/internal/extractor/BillingInfoFieldExtractor.java rename to spring-batch-samples/src/main/java/org/springframework/batch/sample/file/patternmatching/internal/extractor/BillingInfoFieldExtractor.java index 320f8cc86..36eddae02 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/internal/extractor/BillingInfoFieldExtractor.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/file/patternmatching/internal/extractor/BillingInfoFieldExtractor.java @@ -13,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.batch.sample.domain.order.internal.extractor; +package org.springframework.batch.sample.file.patternmatching.internal.extractor; import org.springframework.batch.item.file.transform.FieldExtractor; -import org.springframework.batch.sample.domain.order.BillingInfo; -import org.springframework.batch.sample.domain.order.Order; +import org.springframework.batch.sample.file.patternmatching.BillingInfo; +import org.springframework.batch.sample.file.patternmatching.Order; /** * @author Dan Garrette diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/internal/extractor/CustomerFieldExtractor.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/file/patternmatching/internal/extractor/CustomerFieldExtractor.java similarity index 84% rename from spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/internal/extractor/CustomerFieldExtractor.java rename to spring-batch-samples/src/main/java/org/springframework/batch/sample/file/patternmatching/internal/extractor/CustomerFieldExtractor.java index 28a3df132..8b35dafe8 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/internal/extractor/CustomerFieldExtractor.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/file/patternmatching/internal/extractor/CustomerFieldExtractor.java @@ -13,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.batch.sample.domain.order.internal.extractor; +package org.springframework.batch.sample.file.patternmatching.internal.extractor; import org.springframework.batch.item.file.transform.FieldExtractor; -import org.springframework.batch.sample.domain.order.Customer; -import org.springframework.batch.sample.domain.order.Order; +import org.springframework.batch.sample.file.patternmatching.Customer; +import org.springframework.batch.sample.file.patternmatching.Order; /** * @author Dan Garrette diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/internal/extractor/FooterFieldExtractor.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/file/patternmatching/internal/extractor/FooterFieldExtractor.java similarity index 86% rename from spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/internal/extractor/FooterFieldExtractor.java rename to spring-batch-samples/src/main/java/org/springframework/batch/sample/file/patternmatching/internal/extractor/FooterFieldExtractor.java index a67ed0501..2eae5764e 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/internal/extractor/FooterFieldExtractor.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/file/patternmatching/internal/extractor/FooterFieldExtractor.java @@ -13,10 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.batch.sample.domain.order.internal.extractor; +package org.springframework.batch.sample.file.patternmatching.internal.extractor; import org.springframework.batch.item.file.transform.FieldExtractor; -import org.springframework.batch.sample.domain.order.Order; +import org.springframework.batch.sample.file.patternmatching.Order; /** * @author Dan Garrette 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/file/patternmatching/internal/extractor/HeaderFieldExtractor.java similarity index 88% rename from spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/internal/extractor/HeaderFieldExtractor.java rename to spring-batch-samples/src/main/java/org/springframework/batch/sample/file/patternmatching/internal/extractor/HeaderFieldExtractor.java index 27445ce9a..ca590e260 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/file/patternmatching/internal/extractor/HeaderFieldExtractor.java @@ -13,12 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.batch.sample.domain.order.internal.extractor; +package org.springframework.batch.sample.file.patternmatching.internal.extractor; import java.text.SimpleDateFormat; import org.springframework.batch.item.file.transform.FieldExtractor; -import org.springframework.batch.sample.domain.order.Order; +import org.springframework.batch.sample.file.patternmatching.Order; /** * @author Dan Garrette diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/internal/extractor/LineItemFieldExtractor.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/file/patternmatching/internal/extractor/LineItemFieldExtractor.java similarity index 86% rename from spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/internal/extractor/LineItemFieldExtractor.java rename to spring-batch-samples/src/main/java/org/springframework/batch/sample/file/patternmatching/internal/extractor/LineItemFieldExtractor.java index 951ccc280..4c608d81a 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/internal/extractor/LineItemFieldExtractor.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/file/patternmatching/internal/extractor/LineItemFieldExtractor.java @@ -13,10 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.batch.sample.domain.order.internal.extractor; +package org.springframework.batch.sample.file.patternmatching.internal.extractor; import org.springframework.batch.item.file.transform.FieldExtractor; -import org.springframework.batch.sample.domain.order.LineItem; +import org.springframework.batch.sample.file.patternmatching.LineItem; /** * @author Dan Garrette diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/internal/mapper/AddressFieldSetMapper.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/file/patternmatching/internal/mapper/AddressFieldSetMapper.java similarity index 92% rename from spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/internal/mapper/AddressFieldSetMapper.java rename to spring-batch-samples/src/main/java/org/springframework/batch/sample/file/patternmatching/internal/mapper/AddressFieldSetMapper.java index 475e359c8..9e9f91538 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/internal/mapper/AddressFieldSetMapper.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/file/patternmatching/internal/mapper/AddressFieldSetMapper.java @@ -14,11 +14,11 @@ * limitations under the License. */ -package org.springframework.batch.sample.domain.order.internal.mapper; +package org.springframework.batch.sample.file.patternmatching.internal.mapper; import org.springframework.batch.item.file.mapping.FieldSetMapper; import org.springframework.batch.item.file.transform.FieldSet; -import org.springframework.batch.sample.domain.order.Address; +import org.springframework.batch.sample.file.patternmatching.Address; public class AddressFieldSetMapper implements FieldSetMapper
{ diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/internal/mapper/BillingFieldSetMapper.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/file/patternmatching/internal/mapper/BillingFieldSetMapper.java similarity index 88% rename from spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/internal/mapper/BillingFieldSetMapper.java rename to spring-batch-samples/src/main/java/org/springframework/batch/sample/file/patternmatching/internal/mapper/BillingFieldSetMapper.java index 60e2145fb..f8ba05c7e 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/internal/mapper/BillingFieldSetMapper.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/file/patternmatching/internal/mapper/BillingFieldSetMapper.java @@ -14,11 +14,11 @@ * limitations under the License. */ -package org.springframework.batch.sample.domain.order.internal.mapper; +package org.springframework.batch.sample.file.patternmatching.internal.mapper; import org.springframework.batch.item.file.mapping.FieldSetMapper; import org.springframework.batch.item.file.transform.FieldSet; -import org.springframework.batch.sample.domain.order.BillingInfo; +import org.springframework.batch.sample.file.patternmatching.BillingInfo; public class BillingFieldSetMapper implements FieldSetMapper { diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/internal/mapper/CustomerFieldSetMapper.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/file/patternmatching/internal/mapper/CustomerFieldSetMapper.java similarity index 93% rename from spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/internal/mapper/CustomerFieldSetMapper.java rename to spring-batch-samples/src/main/java/org/springframework/batch/sample/file/patternmatching/internal/mapper/CustomerFieldSetMapper.java index b691a81e8..e48160a52 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/internal/mapper/CustomerFieldSetMapper.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/file/patternmatching/internal/mapper/CustomerFieldSetMapper.java @@ -14,11 +14,11 @@ * limitations under the License. */ -package org.springframework.batch.sample.domain.order.internal.mapper; +package org.springframework.batch.sample.file.patternmatching.internal.mapper; import org.springframework.batch.item.file.mapping.FieldSetMapper; import org.springframework.batch.item.file.transform.FieldSet; -import org.springframework.batch.sample.domain.order.Customer; +import org.springframework.batch.sample.file.patternmatching.Customer; public class CustomerFieldSetMapper implements FieldSetMapper { diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/internal/mapper/HeaderFieldSetMapper.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/file/patternmatching/internal/mapper/HeaderFieldSetMapper.java similarity index 88% rename from spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/internal/mapper/HeaderFieldSetMapper.java rename to spring-batch-samples/src/main/java/org/springframework/batch/sample/file/patternmatching/internal/mapper/HeaderFieldSetMapper.java index a978d1145..74fe29558 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/internal/mapper/HeaderFieldSetMapper.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/file/patternmatching/internal/mapper/HeaderFieldSetMapper.java @@ -14,11 +14,11 @@ * limitations under the License. */ -package org.springframework.batch.sample.domain.order.internal.mapper; +package org.springframework.batch.sample.file.patternmatching.internal.mapper; import org.springframework.batch.item.file.mapping.FieldSetMapper; import org.springframework.batch.item.file.transform.FieldSet; -import org.springframework.batch.sample.domain.order.Order; +import org.springframework.batch.sample.file.patternmatching.Order; public class HeaderFieldSetMapper implements FieldSetMapper { diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/internal/mapper/OrderItemFieldSetMapper.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/file/patternmatching/internal/mapper/OrderItemFieldSetMapper.java similarity index 92% rename from spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/internal/mapper/OrderItemFieldSetMapper.java rename to spring-batch-samples/src/main/java/org/springframework/batch/sample/file/patternmatching/internal/mapper/OrderItemFieldSetMapper.java index 3029ee964..d69012147 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/internal/mapper/OrderItemFieldSetMapper.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/file/patternmatching/internal/mapper/OrderItemFieldSetMapper.java @@ -14,11 +14,11 @@ * limitations under the License. */ -package org.springframework.batch.sample.domain.order.internal.mapper; +package org.springframework.batch.sample.file.patternmatching.internal.mapper; import org.springframework.batch.item.file.mapping.FieldSetMapper; import org.springframework.batch.item.file.transform.FieldSet; -import org.springframework.batch.sample.domain.order.LineItem; +import org.springframework.batch.sample.file.patternmatching.LineItem; public class OrderItemFieldSetMapper implements FieldSetMapper { diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/internal/mapper/ShippingFieldSetMapper.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/file/patternmatching/internal/mapper/ShippingFieldSetMapper.java similarity index 90% rename from spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/internal/mapper/ShippingFieldSetMapper.java rename to spring-batch-samples/src/main/java/org/springframework/batch/sample/file/patternmatching/internal/mapper/ShippingFieldSetMapper.java index 7a6daeea1..27ec0f5d4 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/internal/mapper/ShippingFieldSetMapper.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/file/patternmatching/internal/mapper/ShippingFieldSetMapper.java @@ -14,11 +14,11 @@ * limitations under the License. */ -package org.springframework.batch.sample.domain.order.internal.mapper; +package org.springframework.batch.sample.file.patternmatching.internal.mapper; import org.springframework.batch.item.file.mapping.FieldSetMapper; import org.springframework.batch.item.file.transform.FieldSet; -import org.springframework.batch.sample.domain.order.ShippingInfo; +import org.springframework.batch.sample.file.patternmatching.ShippingInfo; public class ShippingFieldSetMapper implements FieldSetMapper { 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/file/patternmatching/internal/validator/OrderValidator.java similarity index 95% rename from spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/internal/validator/OrderValidator.java rename to spring-batch-samples/src/main/java/org/springframework/batch/sample/file/patternmatching/internal/validator/OrderValidator.java index e2c3bbab1..e1a8feb93 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/file/patternmatching/internal/validator/OrderValidator.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.batch.sample.domain.order.internal.validator; +package org.springframework.batch.sample.file.patternmatching.internal.validator; import java.math.BigDecimal; import java.math.RoundingMode; @@ -21,12 +21,12 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; -import org.springframework.batch.sample.domain.order.Address; -import org.springframework.batch.sample.domain.order.BillingInfo; -import org.springframework.batch.sample.domain.order.Customer; -import org.springframework.batch.sample.domain.order.LineItem; -import org.springframework.batch.sample.domain.order.Order; -import org.springframework.batch.sample.domain.order.ShippingInfo; +import org.springframework.batch.sample.file.patternmatching.Address; +import org.springframework.batch.sample.file.patternmatching.BillingInfo; +import org.springframework.batch.sample.file.patternmatching.Customer; +import org.springframework.batch.sample.file.patternmatching.LineItem; +import org.springframework.batch.sample.file.patternmatching.Order; +import org.springframework.batch.sample.file.patternmatching.ShippingInfo; import org.springframework.util.StringUtils; import org.springframework.validation.Errors; import org.springframework.validation.Validator; diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/internal/xml/Customer.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/file/patternmatching/internal/xml/Customer.java similarity index 95% rename from spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/internal/xml/Customer.java rename to spring-batch-samples/src/main/java/org/springframework/batch/sample/file/patternmatching/internal/xml/Customer.java index 709dd1083..c9561ab0c 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/internal/xml/Customer.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/file/patternmatching/internal/xml/Customer.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.batch.sample.domain.order.internal.xml; +package org.springframework.batch.sample.file.patternmatching.internal.xml; /** * An XML customer. diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/internal/xml/LineItem.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/file/patternmatching/internal/xml/LineItem.java similarity index 94% rename from spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/internal/xml/LineItem.java rename to spring-batch-samples/src/main/java/org/springframework/batch/sample/file/patternmatching/internal/xml/LineItem.java index bdc71dc2e..c293e51ba 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/internal/xml/LineItem.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/file/patternmatching/internal/xml/LineItem.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.batch.sample.domain.order.internal.xml; +package org.springframework.batch.sample.file.patternmatching.internal.xml; /** * An XML line-item. 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/file/patternmatching/internal/xml/Order.java similarity index 95% rename from spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/internal/xml/Order.java rename to spring-batch-samples/src/main/java/org/springframework/batch/sample/file/patternmatching/internal/xml/Order.java index 081849dad..244763a23 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/file/patternmatching/internal/xml/Order.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.batch.sample.domain.order.internal.xml; +package org.springframework.batch.sample.file.patternmatching.internal.xml; import java.util.Date; import java.util.List; diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/internal/xml/Shipper.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/file/patternmatching/internal/xml/Shipper.java similarity index 93% rename from spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/internal/xml/Shipper.java rename to spring-batch-samples/src/main/java/org/springframework/batch/sample/file/patternmatching/internal/xml/Shipper.java index 40a844dbe..a45f7703a 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/internal/xml/Shipper.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/file/patternmatching/internal/xml/Shipper.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.batch.sample.domain.order.internal.xml; +package org.springframework.batch.sample.file.patternmatching.internal.xml; /** * An XML shipper. diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/filter/README.md b/spring-batch-samples/src/main/java/org/springframework/batch/sample/filter/README.md new file mode 100644 index 000000000..aa2c6da50 --- /dev/null +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/filter/README.md @@ -0,0 +1,16 @@ +## Customer Filter Sample + +### About + +This shows the use of the `ItemProcessor` to filter out items by +returning null. When an item is filtered it leads to an increment +in the `filterCount` in the step execution. + +### Run the sample + +You can run the sample from the command line as following: + +``` +$>cd spring-batch-samples +$>../mvnw -Dtest=CustomerFilterJobFunctionalTests#testFilterJob test +``` \ No newline at end of file diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/headerfooter/README.md b/spring-batch-samples/src/main/java/org/springframework/batch/sample/headerfooter/README.md new file mode 100644 index 000000000..2190725cc --- /dev/null +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/headerfooter/README.md @@ -0,0 +1,20 @@ +## Header Footer Sample + +### About + +This sample shows the use of callbacks and listeners to deal with +headers and footers in flat files. It uses two custom callbacks: + +* `HeaderCopyCallback`: copies the header of a file from the + input to the output. +* `SummaryFooterCallback`: creates a summary footer at the end + of the output file. + +### Run the sample + +You can run the sample from the command line as following: + +``` +$>cd spring-batch-samples +$>../mvnw -Dtest=HeaderFooterSampleFunctionalTests#testJob test +``` \ No newline at end of file diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/jobstep/README.md b/spring-batch-samples/src/main/java/org/springframework/batch/sample/jobstep/README.md new file mode 100644 index 000000000..12328a52f --- /dev/null +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/jobstep/README.md @@ -0,0 +1,14 @@ +## Job Step sample + +### About + +This sample shows how to use a step to launch a (sub) job. + +### Run the sample + +You can run the sample from the command line as following: + +``` +$>cd spring-batch-samples +$>../mvnw -Dtest=JobStepFunctionalTests#testJobLaunch test +``` diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/loop/README.md b/spring-batch-samples/src/main/java/org/springframework/batch/sample/loop/README.md new file mode 100644 index 000000000..40ec5d72f --- /dev/null +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/loop/README.md @@ -0,0 +1,15 @@ +### Loop Flow Sample + +## About + +Shows how to implement a job that repeats one of its steps up to a +limit set by a `JobExecutionDecider`. + +## Run the samples + +You can run the sample from the command line as following: + +``` +$>cd spring-batch-samples +$>../mvnw -Dtest=LoopFlowSampleFunctionalTests#testJobLaunch test +``` diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/mail/README.md b/spring-batch-samples/src/main/java/org/springframework/batch/sample/mail/README.md new file mode 100644 index 000000000..e8c035a02 --- /dev/null +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/mail/README.md @@ -0,0 +1,15 @@ +## Mail writer sample + +### About + +This sample shows how to use the `SimpleMailMessageItemWriter` to send +emails in a step. + +### Run the sample + +You can run the sample from the command line as following: + +``` +$>cd spring-batch-samples +$>../mvnw -Dtest=MailJobFunctionalTests#testLaunchJob test +``` \ No newline at end of file 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/mail/TestMailErrorHandler.java similarity index 96% rename from spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/mail/internal/TestMailErrorHandler.java rename to spring-batch-samples/src/main/java/org/springframework/batch/sample/mail/TestMailErrorHandler.java index 4d1c4eaae..a06111e61 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/mail/TestMailErrorHandler.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.batch.sample.domain.mail.internal; +package org.springframework.batch.sample.mail; import java.util.ArrayList; import java.util.List; diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/mail/internal/TestMailSender.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/mail/TestMailSender.java similarity index 97% rename from spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/mail/internal/TestMailSender.java rename to spring-batch-samples/src/main/java/org/springframework/batch/sample/mail/TestMailSender.java index 1772dc586..bcc7f25da 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/mail/internal/TestMailSender.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/mail/TestMailSender.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.batch.sample.domain.mail.internal; +package org.springframework.batch.sample.mail; import java.util.ArrayList; import java.util.LinkedHashMap; diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/mail/User.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/mail/User.java similarity index 95% rename from spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/mail/User.java rename to spring-batch-samples/src/main/java/org/springframework/batch/sample/mail/User.java index 9066ebc15..de6831e99 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/mail/User.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/mail/User.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.batch.sample.domain.mail; +package org.springframework.batch.sample.mail; /** * @author Dan Garrette diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/mail/internal/UserMailItemProcessor.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/mail/UserMailItemProcessor.java similarity index 92% rename from spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/mail/internal/UserMailItemProcessor.java rename to spring-batch-samples/src/main/java/org/springframework/batch/sample/mail/UserMailItemProcessor.java index 8aefc9058..d8ba89000 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/mail/internal/UserMailItemProcessor.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/mail/UserMailItemProcessor.java @@ -13,12 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.batch.sample.domain.mail.internal; +package org.springframework.batch.sample.mail; import java.util.Date; import org.springframework.batch.item.ItemProcessor; -import org.springframework.batch.sample.domain.mail.User; +import org.springframework.batch.sample.mail.User; import org.springframework.lang.Nullable; import org.springframework.mail.SimpleMailMessage; diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/misc/groovy/README.md b/spring-batch-samples/src/main/java/org/springframework/batch/sample/misc/groovy/README.md new file mode 100644 index 000000000..6a33ad4d5 --- /dev/null +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/misc/groovy/README.md @@ -0,0 +1,14 @@ +## Groovy sample + +### About + +This sample shows how to adapt and use a Groovy script as a `Tasklet`. + +### Run the sample + +You can run the sample from the command line as following: + +``` +$>cd spring-batch-samples +$>../mvnw -Dtest=GroovyJobFunctionalTests#testLaunchJob test +``` \ No newline at end of file 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/misc/jmx/InfiniteLoopReader.java similarity index 95% rename from spring-batch-samples/src/main/java/org/springframework/batch/sample/common/InfiniteLoopReader.java rename to spring-batch-samples/src/main/java/org/springframework/batch/sample/misc/jmx/InfiniteLoopReader.java index 76fe9a952..a830d9a20 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/misc/jmx/InfiniteLoopReader.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.batch.sample.common; +package org.springframework.batch.sample.misc.jmx; import org.springframework.batch.item.ItemReader; import org.springframework.lang.Nullable; 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/misc/jmx/InfiniteLoopWriter.java similarity index 97% rename from spring-batch-samples/src/main/java/org/springframework/batch/sample/common/InfiniteLoopWriter.java rename to spring-batch-samples/src/main/java/org/springframework/batch/sample/misc/jmx/InfiniteLoopWriter.java index 87f5b4a0d..f56a4199f 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/misc/jmx/InfiniteLoopWriter.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.batch.sample.common; +package org.springframework.batch.sample.misc.jmx; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; 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/misc/jmx/JobExecutionNotificationPublisher.java similarity index 98% rename from spring-batch-samples/src/main/java/org/springframework/batch/sample/jmx/JobExecutionNotificationPublisher.java rename to spring-batch-samples/src/main/java/org/springframework/batch/sample/misc/jmx/JobExecutionNotificationPublisher.java index 4aa260ad1..cd0998022 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/misc/jmx/JobExecutionNotificationPublisher.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.batch.sample.jmx; +package org.springframework.batch.sample.misc.jmx; import javax.management.Notification; diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/misc/jmx/README.md b/spring-batch-samples/src/main/java/org/springframework/batch/sample/misc/jmx/README.md new file mode 100644 index 000000000..8866e5655 --- /dev/null +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/misc/jmx/README.md @@ -0,0 +1,27 @@ +## Adhoc Loop and JMX Sample + +### About + +This job is simply an infinite loop. It runs forever so it is +useful for testing features to do with stopping and starting jobs. +It is used, for instance, as one of the jobs that can be run from JMX. + +The JMX launcher uses an additional XML configuration file +(`adhoc-job-launcher-context.xml`) to set up a `JobOperator` for +running jobs asynchronously (i.e. in a background thread). + +The rest of the configuration for this demo consists of exposing +some components from the application context as JMX managed beans. +The `JobOperator` is exposed so that it can be controlled from a +remote client (such as JConsole from the JDK) which does not have +Spring Batch on the classpath. See the Spring Core Reference Guide +for more details on how to customise the JMX configuration. + +### Run the sample + +You can run the sample from the command line as following: + +``` +$>cd spring-batch-samples +$>../mvnw -Dtest=RemoteLauncherTests#testPauseJob test +``` \ No newline at end of file diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/jmx/SimpleMessageApplicationEvent.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/misc/jmx/SimpleMessageApplicationEvent.java similarity index 95% rename from spring-batch-samples/src/main/java/org/springframework/batch/sample/jmx/SimpleMessageApplicationEvent.java rename to spring-batch-samples/src/main/java/org/springframework/batch/sample/misc/jmx/SimpleMessageApplicationEvent.java index 5e628d346..23c7f2132 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/jmx/SimpleMessageApplicationEvent.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/misc/jmx/SimpleMessageApplicationEvent.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.batch.sample.jmx; +package org.springframework.batch.sample.misc.jmx; import org.springframework.context.ApplicationEvent; diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/quartz/JobLauncherDetails.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/misc/quartz/JobLauncherDetails.java similarity index 98% rename from spring-batch-samples/src/main/java/org/springframework/batch/sample/quartz/JobLauncherDetails.java rename to spring-batch-samples/src/main/java/org/springframework/batch/sample/misc/quartz/JobLauncherDetails.java index b90d98368..a4321a85d 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/quartz/JobLauncherDetails.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/misc/quartz/JobLauncherDetails.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.batch.sample.quartz; +package org.springframework.batch.sample.misc.quartz; import java.util.Date; import java.util.Map; diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/misc/quartz/README.md b/spring-batch-samples/src/main/java/org/springframework/batch/sample/misc/quartz/README.md new file mode 100644 index 000000000..56da85d88 --- /dev/null +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/misc/quartz/README.md @@ -0,0 +1,75 @@ +## Quartz Sample + +FIXME: Update job configuration and classes imported from Spring Framework + +### About + +The goal is to demonstrate how to schedule job execution using +Quartz scheduler. In this case there is no unit test to launch the +sample because it just re-uses the football job. There is a main +method in `JobRegistryBackgroundJobRunner` and an Eclipse launch +configuration which runs it with arguments to pick up the football +job. + +The additional XML configuration for this job is in +`quartz-job-launcher.xml`, and it also re-uses +`footballJob.xml` + +The configuration declares a `JobLauncher` bean. The launcher +bean is different from the other samples only in that it uses an +asynchronous task executor, so that the jobs are launched in a +separate thread to the main method: + +```xml + + + + + + +``` + +Also, a Quartz `JobDetail` is defined using a Spring +`JobDetailBean` as a convenience. + +```xml + + + + + + + + + + + +``` + +Finally, a trigger with a scheduler is defined that will launch the +job detail every 10 seconds: + +```xml + + + + + + + + +``` + +The job is thus scheduled to run every 10 seconds. In fact it +should be successful on the first attempt, so the second and +subsequent attempts should through a +`JobInstanceAlreadyCompleteException`. In a production system, +the job detail would probably be modified to account for this +exception (e.g. catch it and re-submit with a new set of job +parameters). The point here is that Spring Batch guarantees that +the job execution is idempotent - you can never inadvertently +process the same data twice. + +## Run the sample + +TODO \ No newline at end of file diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/mongodb/MongoDBConfiguration.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/mongodb/MongoDBConfiguration.java index f68b60c33..05b0a12da 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/mongodb/MongoDBConfiguration.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/mongodb/MongoDBConfiguration.java @@ -28,7 +28,7 @@ import org.springframework.data.mongodb.core.MongoTemplate; import org.springframework.data.mongodb.core.SimpleMongoClientDatabaseFactory; @Configuration -@PropertySource("classpath:/mongodb-sample.properties") +@PropertySource("classpath:/org/springframework/batch/sample/mongodb/mongodb-sample.properties") public class MongoDBConfiguration { @Value("${mongodb.host}") diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/partitioning/local/README.md b/spring-batch-samples/src/main/java/org/springframework/batch/sample/partitioning/local/README.md new file mode 100644 index 000000000..5c1c94c40 --- /dev/null +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/partitioning/local/README.md @@ -0,0 +1,22 @@ +## Local Partitioning Sample + +### About + +The purpose of this sample is to show multi-threaded step execution +using the `PartitionHandler` SPI. The example uses a +`TaskExecutorPartitionHandler` to spread the work of reading +some files across multiple threads, with one `Step` execution +per thread. The key components are the `PartitionStep` and the +`MultiResourcePartitioner` which is responsible for dividing up +the work. Notice that the readers and writers in the `Step` +that is being partitioned are step-scoped, so that their state does +not get shared across threads of execution. + +### Run the sample + +You can run the sample from the command line as following: + +``` +$>cd spring-batch-samples +$>../mvnw -Dtest=MailJobFunctionalTests#testLaunchJob test +``` \ No newline at end of file diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/remotepartitioning/BasicPartitioner.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/partitioning/remote/BasicPartitioner.java similarity index 95% rename from spring-batch-samples/src/main/java/org/springframework/batch/sample/remotepartitioning/BasicPartitioner.java rename to spring-batch-samples/src/main/java/org/springframework/batch/sample/partitioning/remote/BasicPartitioner.java index e9a396a2f..953f252d0 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/remotepartitioning/BasicPartitioner.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/partitioning/remote/BasicPartitioner.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.batch.sample.remotepartitioning; +package org.springframework.batch.sample.partitioning.remote; import java.util.Map; diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/remotepartitioning/BrokerConfiguration.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/partitioning/remote/BrokerConfiguration.java similarity index 88% rename from spring-batch-samples/src/main/java/org/springframework/batch/sample/remotepartitioning/BrokerConfiguration.java rename to spring-batch-samples/src/main/java/org/springframework/batch/sample/partitioning/remote/BrokerConfiguration.java index b47377390..6de7fc175 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/remotepartitioning/BrokerConfiguration.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/partitioning/remote/BrokerConfiguration.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.batch.sample.remotepartitioning; +package org.springframework.batch.sample.partitioning.remote; import jakarta.jms.JMSException; import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory; @@ -28,7 +28,7 @@ import org.springframework.context.annotation.PropertySource; * @author Mahmoud Ben Hassine */ @Configuration -@PropertySource("classpath:remote-partitioning.properties") +@PropertySource("classpath:org/springframework/batch/sample/partitioning/remote/remote-partitioning.properties") public class BrokerConfiguration { @Value("${broker.url}") diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/remotepartitioning/DataSourceConfiguration.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/partitioning/remote/DataSourceConfiguration.java similarity index 90% rename from spring-batch-samples/src/main/java/org/springframework/batch/sample/remotepartitioning/DataSourceConfiguration.java rename to spring-batch-samples/src/main/java/org/springframework/batch/sample/partitioning/remote/DataSourceConfiguration.java index 2ba2da312..d2b7bdc8d 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/remotepartitioning/DataSourceConfiguration.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/partitioning/remote/DataSourceConfiguration.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.batch.sample.remotepartitioning; +package org.springframework.batch.sample.partitioning.remote; import javax.sql.DataSource; @@ -30,7 +30,7 @@ import org.springframework.jdbc.support.JdbcTransactionManager; * @author Mahmoud Ben Hassine */ @Configuration -@PropertySource("classpath:remote-partitioning.properties") +@PropertySource("classpath:org/springframework/batch/sample/partitioning/remote/remote-partitioning.properties") public class DataSourceConfiguration { @Value("${datasource.url}") diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/remotepartitioning/aggregating/ManagerConfiguration.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/partitioning/remote/aggregating/ManagerConfiguration.java similarity index 91% rename from spring-batch-samples/src/main/java/org/springframework/batch/sample/remotepartitioning/aggregating/ManagerConfiguration.java rename to spring-batch-samples/src/main/java/org/springframework/batch/sample/partitioning/remote/aggregating/ManagerConfiguration.java index eb0dde1e4..e1f4485aa 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/remotepartitioning/aggregating/ManagerConfiguration.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/partitioning/remote/aggregating/ManagerConfiguration.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.batch.sample.remotepartitioning.aggregating; +package org.springframework.batch.sample.partitioning.remote.aggregating; import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory; @@ -24,9 +24,9 @@ import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.integration.config.annotation.EnableBatchIntegration; import org.springframework.batch.integration.partition.RemotePartitioningManagerStepBuilderFactory; -import org.springframework.batch.sample.remotepartitioning.BasicPartitioner; -import org.springframework.batch.sample.remotepartitioning.BrokerConfiguration; -import org.springframework.batch.sample.remotepartitioning.DataSourceConfiguration; +import org.springframework.batch.sample.partitioning.remote.BasicPartitioner; +import org.springframework.batch.sample.partitioning.remote.BrokerConfiguration; +import org.springframework.batch.sample.partitioning.remote.DataSourceConfiguration; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/remotepartitioning/aggregating/WorkerConfiguration.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/partitioning/remote/aggregating/WorkerConfiguration.java similarity index 93% rename from spring-batch-samples/src/main/java/org/springframework/batch/sample/remotepartitioning/aggregating/WorkerConfiguration.java rename to spring-batch-samples/src/main/java/org/springframework/batch/sample/partitioning/remote/aggregating/WorkerConfiguration.java index 6e83c4dfe..07cd0a86b 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/remotepartitioning/aggregating/WorkerConfiguration.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/partitioning/remote/aggregating/WorkerConfiguration.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.batch.sample.remotepartitioning.aggregating; +package org.springframework.batch.sample.partitioning.remote.aggregating; import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory; @@ -24,8 +24,8 @@ import org.springframework.batch.core.step.tasklet.Tasklet; import org.springframework.batch.integration.config.annotation.EnableBatchIntegration; import org.springframework.batch.integration.partition.RemotePartitioningWorkerStepBuilderFactory; import org.springframework.batch.repeat.RepeatStatus; -import org.springframework.batch.sample.remotepartitioning.BrokerConfiguration; -import org.springframework.batch.sample.remotepartitioning.DataSourceConfiguration; +import org.springframework.batch.sample.partitioning.remote.BrokerConfiguration; +import org.springframework.batch.sample.partitioning.remote.DataSourceConfiguration; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/remotepartitioning/polling/ManagerConfiguration.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/partitioning/remote/polling/ManagerConfiguration.java similarity index 90% rename from spring-batch-samples/src/main/java/org/springframework/batch/sample/remotepartitioning/polling/ManagerConfiguration.java rename to spring-batch-samples/src/main/java/org/springframework/batch/sample/partitioning/remote/polling/ManagerConfiguration.java index e179f057f..0b00cf070 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/remotepartitioning/polling/ManagerConfiguration.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/partitioning/remote/polling/ManagerConfiguration.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.batch.sample.remotepartitioning.polling; +package org.springframework.batch.sample.partitioning.remote.polling; import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory; @@ -24,9 +24,9 @@ import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.integration.config.annotation.EnableBatchIntegration; import org.springframework.batch.integration.partition.RemotePartitioningManagerStepBuilderFactory; -import org.springframework.batch.sample.remotepartitioning.BasicPartitioner; -import org.springframework.batch.sample.remotepartitioning.BrokerConfiguration; -import org.springframework.batch.sample.remotepartitioning.DataSourceConfiguration; +import org.springframework.batch.sample.partitioning.remote.BasicPartitioner; +import org.springframework.batch.sample.partitioning.remote.BrokerConfiguration; +import org.springframework.batch.sample.partitioning.remote.DataSourceConfiguration; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/remotepartitioning/polling/WorkerConfiguration.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/partitioning/remote/polling/WorkerConfiguration.java similarity index 93% rename from spring-batch-samples/src/main/java/org/springframework/batch/sample/remotepartitioning/polling/WorkerConfiguration.java rename to spring-batch-samples/src/main/java/org/springframework/batch/sample/partitioning/remote/polling/WorkerConfiguration.java index 747304aa8..00a138b28 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/remotepartitioning/polling/WorkerConfiguration.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/partitioning/remote/polling/WorkerConfiguration.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.batch.sample.remotepartitioning.polling; +package org.springframework.batch.sample.partitioning.remote.polling; import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory; @@ -24,8 +24,8 @@ import org.springframework.batch.core.step.tasklet.Tasklet; import org.springframework.batch.integration.config.annotation.EnableBatchIntegration; import org.springframework.batch.integration.partition.RemotePartitioningWorkerStepBuilderFactory; import org.springframework.batch.repeat.RepeatStatus; -import org.springframework.batch.sample.remotepartitioning.BrokerConfiguration; -import org.springframework.batch.sample.remotepartitioning.DataSourceConfiguration; +import org.springframework.batch.sample.partitioning.remote.BrokerConfiguration; +import org.springframework.batch.sample.partitioning.remote.DataSourceConfiguration; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/processindicator/README.md b/spring-batch-samples/src/main/java/org/springframework/batch/sample/processindicator/README.md new file mode 100644 index 000000000..64b752c56 --- /dev/null +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/processindicator/README.md @@ -0,0 +1,61 @@ +## Process Indicator pattern Sample + +## About + +The purpose of this sample is to show multi-threaded step execution +using the Process Indicator pattern. + +The job reads data from the a fixed length file , but instead of +writing it out directly it goes through a staging table, and the +staging table is read in a multi-threaded step. Note that for such +a simple example where the item processing was not expensive, there +is unlikely to be much if any benefit in using a multi-threaded +step. + +Multi-threaded step execution is easy to configure using Spring +Batch, but there are some limitations. Most of the out-of-the-box +`ItemReader` and `ItemWriter` implementations are not +designed to work in this scenario because they need to be +restartable and they are also stateful. There should be no surprise +about this, and reading a file (for instance) is usually fast enough +that multi-threading that part of the process is not likely to +provide much benefit, compared to the cost of managing the state. + +The best strategy to cope with restart state from multiple +concurrent threads depends on the kind of input source involved: + +* For file-based input (and output) restart sate is practically + impossible to manage. Spring Batch does not provide any features + or samples to help with this use case. +* With message middleware input it is trivial to manage restarts, + since there is no state to store (if a transaction rolls back the + messages are returned to the destination they came from). +* With database input state management is still necessary, but it + isn't particularly difficult. The easiest thing to do is rely on + a Process Indicator in the input data, which is a column in the + data indicating for each row if it has been processed or not. The + flag is updated inside the batch transaction, and then in the case + of a failure the updates are lost, and the records will show as + un-processed on a restart. + +This last strategy is implemented in the `StagingItemReader`. +Its companion, the `StagingItemWriter` is responsible for +setting up the data in a staging table which contains the process +indicator. The reader is then driven by a simple SQL query that +includes a where clause for the processed flag, i.e. + +```sql +SELECT ID FROM BATCH_STAGING WHERE JOB_ID=? AND PROCESSED=? ORDER BY ID +``` + +It is then responsible for updating the processed flag (which +happens inside the main step transaction). + +## Run the sample + +You can run the sample from the command line as following: + +``` +$>cd spring-batch-samples +$>../mvnw -Dtest=ProcessIndicatorJobFunctionalTests#testLaunchJob test +``` \ No newline at end of file diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/restart/fail/README.md b/spring-batch-samples/src/main/java/org/springframework/batch/sample/restart/fail/README.md new file mode 100644 index 000000000..3e8b06e02 --- /dev/null +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/restart/fail/README.md @@ -0,0 +1,22 @@ +## Fail / Restart Sample + +### About + +The goal of this sample is to show how a job can be restarted after +a failure and continue processing where it left off. + +To simulate a failure we "fake" a failure on the fourth record +though the use of a sample component +`ExceptionThrowingItemReaderProxy`. This is a stateful reader +that counts how many records it has processed and throws a planned +exception in a specified place. Since we re-use the same instance +when we restart the job it will not fail the second time. + +### Run the sample + +You can run the sample from the command line as following: + +``` +$>cd spring-batch-samples +$>../mvnw -Dtest=RestartFunctionalTests#testLaunchJob test +``` \ No newline at end of file diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/restart/stop/README.md b/spring-batch-samples/src/main/java/org/springframework/batch/sample/restart/stop/README.md new file mode 100644 index 000000000..8a43e25f6 --- /dev/null +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/restart/stop/README.md @@ -0,0 +1,16 @@ +## Stop / Restart Sample + +### About + +This sample has a single step that is an infinite loop, reading and +writing fake data. It is used to demonstrate stop signals and +restart capabilities. + +### Run the sample + +You can run the sample from the command line as following: + +``` +$>cd spring-batch-samples +$>../mvnw -Dtest=JobOperatorFunctionalTests#testStartStopResumeJob test +``` \ No newline at end of file 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/retry/RetrySampleConfiguration.java similarity index 98% rename from spring-batch-samples/src/main/java/org/springframework/batch/sample/config/RetrySampleConfiguration.java rename to spring-batch-samples/src/main/java/org/springframework/batch/sample/retry/RetrySampleConfiguration.java index 2724b9389..a5f645695 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/retry/RetrySampleConfiguration.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.batch.sample.config; +package org.springframework.batch.sample.retry; import org.springframework.batch.core.Job; import org.springframework.batch.core.Step; diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/trade/README.md b/spring-batch-samples/src/main/java/org/springframework/batch/sample/trade/README.md new file mode 100644 index 000000000..903a3fd9a --- /dev/null +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/trade/README.md @@ -0,0 +1,28 @@ +## Trade Job + +### About + +The goal is to show a reasonably complex scenario, that would +resemble the real-life usage of the framework. + +This job has 3 steps: + +```mermaid +graph LR + A(tradeLoad) --> B(decreaseCredit) + B --> C(generateReport) +``` + +First, data about trades are imported from a +file to database. Second, the trades are read from the database and +credit on customer accounts is decreased appropriately. Last, a +report about customers is exported to a file. + +## Run the sample + +You can run the sample from the command line as following: + +``` +$>cd spring-batch-samples +$>../mvnw -Dtest=TradeJobFunctionalTests#testLaunchJob test +``` \ No newline at end of file diff --git a/spring-batch-samples/src/main/resources/jobs/delegatingJob.xml b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/adapter/readerwriter/delegatingJob.xml similarity index 100% rename from spring-batch-samples/src/main/resources/jobs/delegatingJob.xml rename to spring-batch-samples/src/main/resources/org/springframework/batch/sample/adapter/readerwriter/delegatingJob.xml diff --git a/spring-batch-samples/src/main/resources/jobs/taskletJob.xml b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/adapter/tasklet/taskletJob.xml similarity index 90% rename from spring-batch-samples/src/main/resources/jobs/taskletJob.xml rename to spring-batch-samples/src/main/resources/org/springframework/batch/sample/adapter/tasklet/taskletJob.xml index 5824f8aa7..f3a042e03 100644 --- a/spring-batch-samples/src/main/resources/jobs/taskletJob.xml +++ b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/adapter/tasklet/taskletJob.xml @@ -44,11 +44,11 @@ - + diff --git a/spring-batch-samples/src/main/resources/org/springframework/batch/sample/rabbitmq/default.amqp.properties b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/amqp/default.amqp.properties similarity index 100% rename from spring-batch-samples/src/main/resources/org/springframework/batch/sample/rabbitmq/default.amqp.properties rename to spring-batch-samples/src/main/resources/org/springframework/batch/sample/amqp/default.amqp.properties diff --git a/spring-batch-samples/src/main/resources/org/springframework/batch/sample/rabbitmq/job/amqp-example-job.xml b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/amqp/job/amqp-example-job.xml similarity index 87% rename from spring-batch-samples/src/main/resources/org/springframework/batch/sample/rabbitmq/job/amqp-example-job.xml rename to spring-batch-samples/src/main/resources/org/springframework/batch/sample/amqp/job/amqp-example-job.xml index 40e3fc316..467a93c21 100644 --- a/spring-batch-samples/src/main/resources/org/springframework/batch/sample/rabbitmq/job/amqp-example-job.xml +++ b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/amqp/job/amqp-example-job.xml @@ -8,8 +8,7 @@ xsi:schemaLocation="http://www.springframework.org/schema/batch https://www.springframework.org/schema/batch/spring-batch.xsd http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> - - + @@ -23,7 +22,7 @@ - + diff --git a/spring-batch-samples/src/main/resources/org/springframework/batch/sample/rabbitmq/job/rabbitmq-beans.xml b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/amqp/job/rabbitmq-beans.xml similarity index 75% rename from spring-batch-samples/src/main/resources/org/springframework/batch/sample/rabbitmq/job/rabbitmq-beans.xml rename to spring-batch-samples/src/main/resources/org/springframework/batch/sample/amqp/job/rabbitmq-beans.xml index f5fff1a0a..fa4528151 100644 --- a/spring-batch-samples/src/main/resources/org/springframework/batch/sample/rabbitmq/job/rabbitmq-beans.xml +++ b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/amqp/job/rabbitmq-beans.xml @@ -4,10 +4,13 @@ xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rabbit="http://www.springframework.org/schema/rabbit" - xmlns:p="http://www.springframework.org/schema/p" + xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation=" http://www.springframework.org/schema/rabbit https://www.springframework.org/schema/rabbit/spring-rabbit.xsd - http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd"> + http://www.springframework.org/schema/beans https://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/data/beanWrapperMapperSampleJob/input/20070122.teststream.ImportPersonDataStep.txt b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/beanwrapper/data/ImportPersonDataStep.txt similarity index 100% rename from spring-batch-samples/src/main/resources/data/beanWrapperMapperSampleJob/input/20070122.teststream.ImportPersonDataStep.txt rename to spring-batch-samples/src/main/resources/org/springframework/batch/sample/beanwrapper/data/ImportPersonDataStep.txt diff --git a/spring-batch-samples/src/main/resources/data/beanWrapperMapperSampleJob/input/20070122.teststream.ImportTradeDataStep.txt b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/beanwrapper/data/ImportTradeDataStep.txt similarity index 100% rename from spring-batch-samples/src/main/resources/data/beanWrapperMapperSampleJob/input/20070122.teststream.ImportTradeDataStep.txt rename to spring-batch-samples/src/main/resources/org/springframework/batch/sample/beanwrapper/data/ImportTradeDataStep.txt diff --git a/spring-batch-samples/src/main/resources/jobs/beanWrapperMapperSampleJob.xml b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/beanwrapper/job/beanWrapperMapperSampleJob.xml similarity index 94% rename from spring-batch-samples/src/main/resources/jobs/beanWrapperMapperSampleJob.xml rename to spring-batch-samples/src/main/resources/org/springframework/batch/sample/beanwrapper/job/beanWrapperMapperSampleJob.xml index 2b00aa692..e3c037451 100644 --- a/spring-batch-samples/src/main/resources/jobs/beanWrapperMapperSampleJob.xml +++ b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/beanwrapper/job/beanWrapperMapperSampleJob.xml @@ -24,7 +24,7 @@ + value="classpath:org/springframework/batch/sample/beanwrapper/data/ImportTradeDataStep.txt" /> @@ -35,7 +35,7 @@ + value="classpath:org/springframework/batch/sample/beanwrapper/data/ImportPersonDataStep.txt" /> diff --git a/spring-batch-samples/src/main/resources/remote-chunking.properties b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/chunking/remote-chunking.properties similarity index 100% rename from spring-batch-samples/src/main/resources/remote-chunking.properties rename to spring-batch-samples/src/main/resources/org/springframework/batch/sample/chunking/remote-chunking.properties diff --git a/spring-batch-samples/src/main/resources/data/fixedLengthImportJob/input/20070122.teststream.ImportTradeDataStep.txt b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/compositewriter/data/ImportTradeDataStep.txt similarity index 100% rename from spring-batch-samples/src/main/resources/data/fixedLengthImportJob/input/20070122.teststream.ImportTradeDataStep.txt rename to spring-batch-samples/src/main/resources/org/springframework/batch/sample/compositewriter/data/ImportTradeDataStep.txt diff --git a/spring-batch-samples/src/main/resources/jobs/compositeItemWriterSampleJob.xml b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/compositewriter/job/compositeItemWriterSampleJob.xml similarity index 97% rename from spring-batch-samples/src/main/resources/jobs/compositeItemWriterSampleJob.xml rename to spring-batch-samples/src/main/resources/org/springframework/batch/sample/compositewriter/job/compositeItemWriterSampleJob.xml index 34874fc98..eb3ab2aac 100644 --- a/spring-batch-samples/src/main/resources/jobs/compositeItemWriterSampleJob.xml +++ b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/compositewriter/job/compositeItemWriterSampleJob.xml @@ -42,7 +42,7 @@ + value="classpath:org/springframework/batch/sample/compositewriter/data/ImportTradeDataStep.txt" /> diff --git a/spring-batch-samples/src/main/resources/data/multilineJob/input/20070122.teststream.multilineStep.txt b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/file/multilineaggregate/data/multilineStep.txt similarity index 100% rename from spring-batch-samples/src/main/resources/data/multilineJob/input/20070122.teststream.multilineStep.txt rename to spring-batch-samples/src/main/resources/org/springframework/batch/sample/file/multilineaggregate/data/multilineStep.txt diff --git a/spring-batch-samples/src/main/resources/jobs/multilineJob.xml b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/file/multilineaggregate/job/multilineJob.xml similarity index 87% rename from spring-batch-samples/src/main/resources/jobs/multilineJob.xml rename to spring-batch-samples/src/main/resources/org/springframework/batch/sample/file/multilineaggregate/job/multilineJob.xml index fd987bc74..b5a03ccce 100644 --- a/spring-batch-samples/src/main/resources/jobs/multilineJob.xml +++ b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/file/multilineaggregate/job/multilineJob.xml @@ -17,13 +17,13 @@ + class="org.springframework.batch.sample.file.multilineaggregate.AggregateItemReader"> + value="file:target/test-outputs/multilineStep-output.txt" /> @@ -32,13 +32,13 @@ + value="classpath:org/springframework/batch/sample/file/multilineaggregate/data/multilineStep.txt" /> + class="org.springframework.batch.sample.file.multilineaggregate.AggregateItemFieldSetMapper"> diff --git a/spring-batch-samples/src/main/resources/data/multilineOrderJob/input/multilineOrderInput.txt b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/file/patternmatching/data/multilineOrderInput.txt similarity index 100% rename from spring-batch-samples/src/main/resources/data/multilineOrderJob/input/multilineOrderInput.txt rename to spring-batch-samples/src/main/resources/org/springframework/batch/sample/file/patternmatching/data/multilineOrderInput.txt diff --git a/spring-batch-samples/src/main/resources/data/multilineOrderJob/result/multilineOrderOutput.txt b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/file/patternmatching/data/multilineOrderOutput.txt similarity index 100% rename from spring-batch-samples/src/main/resources/data/multilineOrderJob/result/multilineOrderOutput.txt rename to spring-batch-samples/src/main/resources/org/springframework/batch/sample/file/patternmatching/data/multilineOrderOutput.txt diff --git a/spring-batch-samples/src/main/resources/data/multilineOrderJob/order_sample.txt b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/file/patternmatching/data/order_sample.txt similarity index 100% rename from spring-batch-samples/src/main/resources/data/multilineOrderJob/order_sample.txt rename to spring-batch-samples/src/main/resources/org/springframework/batch/sample/file/patternmatching/data/order_sample.txt diff --git a/spring-batch-samples/src/main/resources/jobs/multilineOrderInputTokenizers.xml b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/file/patternmatching/job/multilineOrderInputTokenizers.xml similarity index 100% rename from spring-batch-samples/src/main/resources/jobs/multilineOrderInputTokenizers.xml rename to spring-batch-samples/src/main/resources/org/springframework/batch/sample/file/patternmatching/job/multilineOrderInputTokenizers.xml diff --git a/spring-batch-samples/src/main/resources/jobs/multilineOrderJob.xml b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/file/patternmatching/job/multilineOrderJob.xml similarity index 77% rename from spring-batch-samples/src/main/resources/jobs/multilineOrderJob.xml rename to spring-batch-samples/src/main/resources/org/springframework/batch/sample/file/patternmatching/job/multilineOrderJob.xml index c6e8bc501..3138f7da5 100644 --- a/spring-batch-samples/src/main/resources/jobs/multilineOrderJob.xml +++ b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/file/patternmatching/job/multilineOrderJob.xml @@ -23,7 +23,7 @@ - + @@ -34,7 +34,7 @@ - + @@ -45,12 +45,12 @@ - - - - - - + + + + + + @@ -60,7 +60,7 @@ - + diff --git a/spring-batch-samples/src/main/resources/jobs/multilineOrderOutputAggregators.xml b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/file/patternmatching/job/multilineOrderOutputAggregators.xml similarity index 73% rename from spring-batch-samples/src/main/resources/jobs/multilineOrderOutputAggregators.xml rename to spring-batch-samples/src/main/resources/org/springframework/batch/sample/file/patternmatching/job/multilineOrderOutputAggregators.xml index 007b8d2df..a15643f3c 100644 --- a/spring-batch-samples/src/main/resources/jobs/multilineOrderOutputAggregators.xml +++ b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/file/patternmatching/job/multilineOrderOutputAggregators.xml @@ -19,42 +19,42 @@ - + - + - + - + - + - + \ No newline at end of file diff --git a/spring-batch-samples/src/main/resources/jobs/multilineOrderValidator.xml b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/file/patternmatching/job/multilineOrderValidator.xml similarity index 88% rename from spring-batch-samples/src/main/resources/jobs/multilineOrderValidator.xml rename to spring-batch-samples/src/main/resources/org/springframework/batch/sample/file/patternmatching/job/multilineOrderValidator.xml index 68cc76515..45466ef37 100644 --- a/spring-batch-samples/src/main/resources/jobs/multilineOrderValidator.xml +++ b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/file/patternmatching/job/multilineOrderValidator.xml @@ -1,12 +1,12 @@ - - - - - - - - - + + + + + + + + + diff --git a/spring-batch-samples/src/main/resources/data/customerFilterJob/input/customers.txt b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/filter/data/customers.txt similarity index 100% rename from spring-batch-samples/src/main/resources/data/customerFilterJob/input/customers.txt rename to spring-batch-samples/src/main/resources/org/springframework/batch/sample/filter/data/customers.txt diff --git a/spring-batch-samples/src/main/resources/jobs/customerFilterJob.xml b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/filter/job/customerFilterJob.xml similarity index 96% rename from spring-batch-samples/src/main/resources/jobs/customerFilterJob.xml rename to spring-batch-samples/src/main/resources/org/springframework/batch/sample/filter/job/customerFilterJob.xml index ad727d9e1..5b702cd83 100644 --- a/spring-batch-samples/src/main/resources/jobs/customerFilterJob.xml +++ b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/filter/job/customerFilterJob.xml @@ -23,7 +23,7 @@ - + diff --git a/spring-batch-samples/src/main/resources/data/headerFooterSample/input.txt b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/headerfooter/data/input.txt similarity index 95% rename from spring-batch-samples/src/main/resources/data/headerFooterSample/input.txt rename to spring-batch-samples/src/main/resources/org/springframework/batch/sample/headerfooter/data/input.txt index da7709d50..84116ea47 100644 --- a/spring-batch-samples/src/main/resources/data/headerFooterSample/input.txt +++ b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/headerfooter/data/input.txt @@ -1,5 +1,5 @@ -# next line is a header and should be copied to to output file -names -john -joe +# next line is a header and should be copied to to output file +names +john +joe jane \ 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/org/springframework/batch/sample/headerfooter/job/headerFooterSample.xml similarity index 97% rename from spring-batch-samples/src/main/resources/jobs/headerFooterSample.xml rename to spring-batch-samples/src/main/resources/org/springframework/batch/sample/headerfooter/job/headerFooterSample.xml index b799c1c00..462fb9682 100644 --- a/spring-batch-samples/src/main/resources/jobs/headerFooterSample.xml +++ b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/headerfooter/job/headerFooterSample.xml @@ -57,7 +57,7 @@ class="org.springframework.batch.sample.support.HeaderCopyCallback" /> + value="org/springframework/batch/sample/headerfooter/data/input.txt" /> - + @@ -32,11 +32,11 @@ - + - + - + John Adams's Account Info diff --git a/spring-batch-samples/src/grafana/docker-compose.yml b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/metrics/docker-compose.yml similarity index 84% rename from spring-batch-samples/src/grafana/docker-compose.yml rename to spring-batch-samples/src/main/resources/org/springframework/batch/sample/metrics/docker-compose.yml index f82d08a70..a04917f91 100644 --- a/spring-batch-samples/src/grafana/docker-compose.yml +++ b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/metrics/docker-compose.yml @@ -7,7 +7,7 @@ services: ports: - '9090:9090' volumes: - - ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml + - ./prometheus.yml:/etc/prometheus/prometheus.yml pushgateway: image: prom/pushgateway:v0.6.0 diff --git a/spring-batch-samples/src/main/resources/metrics-sample.properties b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/metrics/metrics-sample.properties similarity index 100% rename from spring-batch-samples/src/main/resources/metrics-sample.properties rename to spring-batch-samples/src/main/resources/org/springframework/batch/sample/metrics/metrics-sample.properties diff --git a/spring-batch-samples/src/grafana/prometheus/prometheus.yml b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/metrics/prometheus.yml similarity index 100% rename from spring-batch-samples/src/grafana/prometheus/prometheus.yml rename to spring-batch-samples/src/main/resources/org/springframework/batch/sample/metrics/prometheus.yml diff --git a/spring-batch-samples/src/grafana/spring-batch-dashboard.json b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/metrics/spring-batch-dashboard.json similarity index 100% rename from spring-batch-samples/src/grafana/spring-batch-dashboard.json rename to spring-batch-samples/src/main/resources/org/springframework/batch/sample/metrics/spring-batch-dashboard.json diff --git a/spring-batch-samples/src/main/resources/data/groovyJob/input/files.zip b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/misc/groovy/data/files.zip similarity index 100% rename from spring-batch-samples/src/main/resources/data/groovyJob/input/files.zip rename to spring-batch-samples/src/main/resources/org/springframework/batch/sample/misc/groovy/data/files.zip diff --git a/spring-batch-samples/src/main/resources/jobs/groovyJob.xml b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/misc/groovy/job/groovyJob.xml similarity index 93% rename from spring-batch-samples/src/main/resources/jobs/groovyJob.xml rename to spring-batch-samples/src/main/resources/org/springframework/batch/sample/misc/groovy/job/groovyJob.xml index 84ef9aeac..08d4072a0 100644 --- a/spring-batch-samples/src/main/resources/jobs/groovyJob.xml +++ b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/misc/groovy/job/groovyJob.xml @@ -1,56 +1,56 @@ - - - - - - - - - - - - - - - - - - - - - - - - - class UnzipTasklet { - void execute() { - def ant = new AntBuilder() - ant.unzip(src:"src/main/resources/data/groovyJob/input/files.zip", - dest:"target/groovyJob/staging") - } - } - - - - - - class ZipTasklet { - void execute() { - def ant = new AntBuilder() - ant.mkdir(dir:"target/groovyJob/output") - ant.zip(destfile:"target/groovyJob/output/files.zip", - basedir:"target/groovyJob/staging", includes:"**") - } - } - - + + + + + + + + + + + + + + + + + + + + + + + + + class UnzipTasklet { + void execute() { + def ant = new AntBuilder() + ant.unzip(src:"src/main/resources/org/springframework/batch/sample/misc/groovy/data/files.zip", + dest:"target/groovyJob/staging") + } + } + + + + + + class ZipTasklet { + void execute() { + def ant = new AntBuilder() + ant.mkdir(dir:"target/groovyJob/output") + ant.zip(destfile:"target/groovyJob/output/files.zip", + basedir:"target/groovyJob/staging", includes:"**") + } + } + + \ No newline at end of file diff --git a/spring-batch-samples/src/main/resources/adhoc-job-launcher-context.xml b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/misc/jmx/adhoc-job-launcher-context.xml similarity index 94% rename from spring-batch-samples/src/main/resources/adhoc-job-launcher-context.xml rename to spring-batch-samples/src/main/resources/org/springframework/batch/sample/misc/jmx/adhoc-job-launcher-context.xml index 6f4b148ff..1a04aba55 100644 --- a/spring-batch-samples/src/main/resources/adhoc-job-launcher-context.xml +++ b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/misc/jmx/adhoc-job-launcher-context.xml @@ -3,7 +3,7 @@ xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd"> - + @@ -30,7 +30,7 @@ - + diff --git a/spring-batch-samples/src/main/resources/jobs/adhocLoopJob.xml b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/misc/jmx/adhocLoopJob.xml similarity index 89% rename from spring-batch-samples/src/main/resources/jobs/adhocLoopJob.xml rename to spring-batch-samples/src/main/resources/org/springframework/batch/sample/misc/jmx/adhocLoopJob.xml index 0865fe928..6dfd5b8bc 100644 --- a/spring-batch-samples/src/main/resources/jobs/adhocLoopJob.xml +++ b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/misc/jmx/adhocLoopJob.xml @@ -21,8 +21,8 @@ - - + + diff --git a/spring-batch-samples/src/main/resources/org/springframework/batch/sample/misc/quartz/quartz-job-launcher-context.xml b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/misc/quartz/quartz-job-launcher-context.xml new file mode 100644 index 000000000..7f334d2ba --- /dev/null +++ b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/misc/quartz/quartz-job-launcher-context.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spring-batch-samples/src/main/resources/mongodb-sample.properties b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/mongodb/mongodb-sample.properties similarity index 100% rename from spring-batch-samples/src/main/resources/mongodb-sample.properties rename to spring-batch-samples/src/main/resources/org/springframework/batch/sample/mongodb/mongodb-sample.properties diff --git a/spring-batch-samples/src/main/resources/org/springframework/batch/sample/partition/file/data/delimited1.csv b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/partition/file/data/delimited1.csv new file mode 100644 index 000000000..95a077e6b --- /dev/null +++ b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/partition/file/data/delimited1.csv @@ -0,0 +1,6 @@ +customer1,10 +customer2,20 +customer3,30 +customer4,40 +customer5,50 +customer6,60 \ No newline at end of file diff --git a/spring-batch-samples/src/main/resources/org/springframework/batch/sample/partition/file/data/delimited2.csv b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/partition/file/data/delimited2.csv new file mode 100644 index 000000000..46f251216 --- /dev/null +++ b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/partition/file/data/delimited2.csv @@ -0,0 +1,2 @@ +customer7,70 +customer8,80 \ 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/org/springframework/batch/sample/partition/file/job/partitionFileJob.xml similarity index 93% rename from spring-batch-samples/src/main/resources/jobs/partitionFileJob.xml rename to spring-batch-samples/src/main/resources/org/springframework/batch/sample/partition/file/job/partitionFileJob.xml index c20420372..861c3d013 100644 --- a/spring-batch-samples/src/main/resources/jobs/partitionFileJob.xml +++ b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/partition/file/job/partitionFileJob.xml @@ -13,7 +13,7 @@ - + @@ -37,7 +37,7 @@ - + diff --git a/spring-batch-samples/src/main/resources/jobs/partitionJdbcJob.xml b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/partition/jdbc/partitionJdbcJob.xml similarity index 100% rename from spring-batch-samples/src/main/resources/jobs/partitionJdbcJob.xml rename to spring-batch-samples/src/main/resources/org/springframework/batch/sample/partition/jdbc/partitionJdbcJob.xml diff --git a/spring-batch-samples/src/main/resources/remote-partitioning.properties b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/partitioning/remote/remote-partitioning.properties similarity index 100% rename from spring-batch-samples/src/main/resources/remote-partitioning.properties rename to spring-batch-samples/src/main/resources/org/springframework/batch/sample/partitioning/remote/remote-partitioning.properties diff --git a/spring-batch-samples/src/main/resources/org/springframework/batch/sample/processindicator/data/ImportTradeDataStep.txt b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/processindicator/data/ImportTradeDataStep.txt new file mode 100644 index 000000000..c48f5c51c --- /dev/null +++ b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/processindicator/data/ImportTradeDataStep.txt @@ -0,0 +1,5 @@ +UK21341EAH4121131.11customer1 +UK21341EAH4221232.11customer2 +UK21341EAH4321333.11customer3 +UK21341EAH4421434.11customer4 +UK21341EAH4521535.11customer5 \ 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/org/springframework/batch/sample/processindicator/job/parallelJob.xml similarity index 97% rename from spring-batch-samples/src/main/resources/jobs/parallelJob.xml rename to spring-batch-samples/src/main/resources/org/springframework/batch/sample/processindicator/job/parallelJob.xml index 21c5822f2..f83fe0886 100644 --- a/spring-batch-samples/src/main/resources/jobs/parallelJob.xml +++ b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/processindicator/job/parallelJob.xml @@ -60,7 +60,7 @@ --> + value="classpath:org/springframework/batch/sample/processindicator/data/ImportTradeDataStep.txt" /> diff --git a/spring-batch-samples/src/main/resources/staging-test-context.xml b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/processindicator/job/staging-test-context.xml similarity index 100% rename from spring-batch-samples/src/main/resources/staging-test-context.xml rename to spring-batch-samples/src/main/resources/org/springframework/batch/sample/processindicator/job/staging-test-context.xml diff --git a/spring-batch-samples/src/main/resources/org/springframework/batch/sample/restart/fail/data/ImportTradeDataStep.txt b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/restart/fail/data/ImportTradeDataStep.txt new file mode 100644 index 000000000..a65f1d3c8 --- /dev/null +++ b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/restart/fail/data/ImportTradeDataStep.txt @@ -0,0 +1,5 @@ +UK21341EAH4597898.34customer1 +UK21341EAH4611218.12customer2 +UK21341EAH4724512.78customer2 +UK21341EAH4810819.25customer3 +UK21341EAH4985423.39customer4 diff --git a/spring-batch-samples/src/main/resources/data/restartFileSample/input/restartFile.csv b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/restart/fail/data/restartFile.csv similarity index 93% rename from spring-batch-samples/src/main/resources/data/restartFileSample/input/restartFile.csv rename to spring-batch-samples/src/main/resources/org/springframework/batch/sample/restart/fail/data/restartFile.csv index 8be0f6b83..91ee47203 100644 --- a/spring-batch-samples/src/main/resources/data/restartFileSample/input/restartFile.csv +++ b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/restart/fail/data/restartFile.csv @@ -1,20 +1,20 @@ -customer1,10 -customer2,20 -customer3,30 -customer4,40 -customer5,50 -customer6,60 -customer7,70 -customer8,80 -customer9,90 -customer10,100 -customer11,110 -customer12,120 -customer13,130 -customer14,140 -customer15,150 -customer16,160 -customer17,170 -customer18,180 -customer19,190 -customer20,200 +customer1,10 +customer2,20 +customer3,30 +customer4,40 +customer5,50 +customer6,60 +customer7,70 +customer8,80 +customer9,90 +customer10,100 +customer11,110 +customer12,120 +customer13,130 +customer14,140 +customer15,150 +customer16,160 +customer17,170 +customer18,180 +customer19,190 +customer20,200 diff --git a/spring-batch-samples/src/main/resources/jobs/restartSample.xml b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/restart/fail/job/failRestartSample.xml similarity index 100% rename from spring-batch-samples/src/main/resources/jobs/restartSample.xml rename to spring-batch-samples/src/main/resources/org/springframework/batch/sample/restart/fail/job/failRestartSample.xml diff --git a/spring-batch-samples/src/main/resources/jobs/restartFileSampleJob.xml b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/restart/fail/job/restartFileSampleJob.xml similarity index 91% rename from spring-batch-samples/src/main/resources/jobs/restartFileSampleJob.xml rename to spring-batch-samples/src/main/resources/org/springframework/batch/sample/restart/fail/job/restartFileSampleJob.xml index cfc8fd6ff..65f13a7b5 100644 --- a/spring-batch-samples/src/main/resources/jobs/restartFileSampleJob.xml +++ b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/restart/fail/job/restartFileSampleJob.xml @@ -37,14 +37,14 @@ - + + class="org.springframework.batch.sample.restart.fail.RestartFileSampleFunctionalTests$CustomerCreditFlatFileItemWriter"> - - + + @@ -23,7 +23,7 @@ - + diff --git a/spring-batch-samples/src/main/resources/jobs/skipSampleJob.xml b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/skip/job/skipSampleJob.xml similarity index 97% rename from spring-batch-samples/src/main/resources/jobs/skipSampleJob.xml rename to spring-batch-samples/src/main/resources/org/springframework/batch/sample/skip/job/skipSampleJob.xml index 8116ae2e8..9c4517ce3 100644 --- a/spring-batch-samples/src/main/resources/jobs/skipSampleJob.xml +++ b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/skip/job/skipSampleJob.xml @@ -73,7 +73,7 @@ - + diff --git a/spring-batch-samples/src/main/resources/data/tradeJob/input/20070122.teststream.ImportTradeDataStep.txt b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/trade/data/ImportTradeDataStep.txt similarity index 100% rename from spring-batch-samples/src/main/resources/data/tradeJob/input/20070122.teststream.ImportTradeDataStep.txt rename to spring-batch-samples/src/main/resources/org/springframework/batch/sample/trade/data/ImportTradeDataStep.txt diff --git a/spring-batch-samples/src/main/resources/data/tradeJob/input/TradeJob.csv b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/trade/data/TradeJob.csv similarity index 100% rename from spring-batch-samples/src/main/resources/data/tradeJob/input/TradeJob.csv rename to spring-batch-samples/src/main/resources/org/springframework/batch/sample/trade/data/TradeJob.csv diff --git a/spring-batch-samples/src/main/resources/jobs/tradeJob.xml b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/trade/job/tradeJob.xml similarity index 93% rename from spring-batch-samples/src/main/resources/jobs/tradeJob.xml rename to spring-batch-samples/src/main/resources/org/springframework/batch/sample/trade/job/tradeJob.xml index ebba9b7e5..a9bd73e05 100644 --- a/spring-batch-samples/src/main/resources/jobs/tradeJob.xml +++ b/spring-batch-samples/src/main/resources/org/springframework/batch/sample/trade/job/tradeJob.xml @@ -1,112 +1,112 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file 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 b29452800..b036987c1 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 @@ -38,5 +38,5 @@ + class="org.springframework.batch.sample.common.StepExecutionApplicationEventAdvice" /> diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/DelegatingJobFunctionalTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/adapter/readerwriter/DelegatingJobFunctionalTests.java similarity index 82% rename from spring-batch-samples/src/test/java/org/springframework/batch/sample/DelegatingJobFunctionalTests.java rename to spring-batch-samples/src/test/java/org/springframework/batch/sample/adapter/readerwriter/DelegatingJobFunctionalTests.java index 738edd813..aec56c503 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/DelegatingJobFunctionalTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/adapter/readerwriter/DelegatingJobFunctionalTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2007-2022 the original author or authors. + * Copyright 2007-2023 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,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.batch.sample; +package org.springframework.batch.sample.adapter.readerwriter; import org.junit.jupiter.api.Test; @@ -25,8 +25,8 @@ import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; -@SpringJUnitConfig( - locations = { "/simple-job-launcher-context.xml", "/jobs/delegatingJob.xml", "/job-runner-context.xml" }) +@SpringJUnitConfig(locations = { "/org/springframework/batch/sample/adapter/readerwriter/delegatingJob.xml", + "/simple-job-launcher-context.xml", "/job-runner-context.xml" }) class DelegatingJobFunctionalTests { @Autowired diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/TaskletJobFunctionalTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/adapter/tasklet/TaskletAdapterJobFunctionalTests.java similarity index 77% rename from spring-batch-samples/src/test/java/org/springframework/batch/sample/TaskletJobFunctionalTests.java rename to spring-batch-samples/src/test/java/org/springframework/batch/sample/adapter/tasklet/TaskletAdapterJobFunctionalTests.java index 9ee37466b..f7cc4d2b1 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/TaskletJobFunctionalTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/adapter/tasklet/TaskletAdapterJobFunctionalTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2022 the original author or authors. + * Copyright 2006-2023 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. @@ -14,23 +14,22 @@ * limitations under the License. */ -package org.springframework.batch.sample; +package org.springframework.batch.sample.adapter.tasklet; import org.junit.jupiter.api.Test; import org.springframework.batch.core.BatchStatus; import org.springframework.batch.core.JobExecution; import org.springframework.batch.core.JobParametersBuilder; -import org.springframework.batch.core.scope.context.ChunkContext; import org.springframework.batch.test.JobLauncherTestUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import static org.junit.jupiter.api.Assertions.assertEquals; -@SpringJUnitConfig( - locations = { "/simple-job-launcher-context.xml", "/jobs/taskletJob.xml", "/job-runner-context.xml" }) -class TaskletJobFunctionalTests { +@SpringJUnitConfig(locations = { "/org/springframework/batch/sample/adapter/tasklet/taskletJob.xml", + "/simple-job-launcher-context.xml", "/job-runner-context.xml" }) +class TaskletAdapterJobFunctionalTests { @Autowired private JobLauncherTestUtils jobLauncherTestUtils; @@ -60,13 +59,4 @@ class TaskletJobFunctionalTests { } - static class Task { - - public boolean doWork(ChunkContext chunkContext) { - chunkContext.getStepContext().getStepExecution().getJobExecution().getExecutionContext().put("done", "yes"); - return true; - } - - } - } diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/AMQPJobFunctionalTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/amqp/AmqpJobFunctionalTests.java similarity index 93% rename from spring-batch-samples/src/test/java/org/springframework/batch/sample/AMQPJobFunctionalTests.java rename to spring-batch-samples/src/test/java/org/springframework/batch/sample/amqp/AmqpJobFunctionalTests.java index 1bc9eeca5..00132a7b1 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/AMQPJobFunctionalTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/amqp/AmqpJobFunctionalTests.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.batch.sample; +package org.springframework.batch.sample.amqp; import org.junit.jupiter.api.Test; import org.testcontainers.containers.RabbitMQContainer; @@ -36,7 +36,8 @@ import org.springframework.batch.core.explore.JobExplorer; import org.springframework.batch.core.launch.JobLauncher; import org.springframework.batch.item.ItemReader; import org.springframework.batch.item.ItemWriter; -import org.springframework.batch.sample.rabbitmq.AmqpJobConfiguration; +import org.springframework.batch.sample.amqp.AmqpJobConfiguration; +import org.springframework.batch.sample.amqp.AmqpMessageProducer; import org.springframework.batch.test.JobLauncherTestUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; @@ -50,9 +51,8 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext /** *

* Ensure a RabbitMQ instance is running, modifying default.amqp.properties if needed. - * Execute the - * {@link org.springframework.batch.sample.rabbitmq.amqp.AmqpMessageProducer#main(String[])} - * method in order for messages will be written to the "test.inbound" queue. + * Execute the {@link AmqpMessageProducer#main(String[])} method in order for messages + * will be written to the "test.inbound" queue. *

* *

@@ -61,10 +61,10 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext *

*/ -@SpringJUnitConfig(locations = { "/org/springframework/batch/sample/rabbitmq/job/amqp-example-job.xml", +@SpringJUnitConfig(locations = { "/org/springframework/batch/sample/amqp/job/amqp-example-job.xml", "/simple-job-launcher-context.xml", "/job-runner-context.xml" }) @Testcontainers(disabledWithoutDocker = true) -class AMQPJobFunctionalTests { +class AmqpJobFunctionalTests { private static final DockerImageName RABBITMQ_IMAGE = DockerImageName.parse("rabbitmq:3"); diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/BeanWrapperMapperSampleJobFunctionalTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/beanwrapper/BeanWrapperMapperSampleJobFunctionalTests.java similarity index 62% rename from spring-batch-samples/src/test/java/org/springframework/batch/sample/BeanWrapperMapperSampleJobFunctionalTests.java rename to spring-batch-samples/src/test/java/org/springframework/batch/sample/beanwrapper/BeanWrapperMapperSampleJobFunctionalTests.java index ab338a589..3443e7223 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/BeanWrapperMapperSampleJobFunctionalTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/beanwrapper/BeanWrapperMapperSampleJobFunctionalTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2022 the original author or authors. + * Copyright 2006-2023 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. @@ -14,16 +14,20 @@ * limitations under the License. */ -package org.springframework.batch.sample; +package org.springframework.batch.sample.beanwrapper; import org.junit.jupiter.api.Test; +import org.springframework.batch.core.BatchStatus; +import org.springframework.batch.core.JobExecution; import org.springframework.batch.test.JobLauncherTestUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; -@SpringJUnitConfig(locations = { "/simple-job-launcher-context.xml", "/jobs/beanWrapperMapperSampleJob.xml", - "/job-runner-context.xml" }) +import static org.junit.jupiter.api.Assertions.assertEquals; + +@SpringJUnitConfig(locations = { "/org/springframework/batch/sample/beanwrapper/job/beanWrapperMapperSampleJob.xml", + "/simple-job-launcher-context.xml", "/job-runner-context.xml" }) class BeanWrapperMapperSampleJobFunctionalTests { @Autowired @@ -32,10 +36,10 @@ class BeanWrapperMapperSampleJobFunctionalTests { @Test void testJobLaunch() throws Exception { // when - this.jobLauncherTestUtils.launchJob(); + JobExecution jobExecution = this.jobLauncherTestUtils.launchJob(); // then - // FIXME no assertions? + assertEquals(BatchStatus.COMPLETED, jobExecution.getStatus()); } } diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/RemoteChunkingJobFunctionalTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/chunking/RemoteChunkingJobFunctionalTests.java similarity index 92% rename from spring-batch-samples/src/test/java/org/springframework/batch/sample/RemoteChunkingJobFunctionalTests.java rename to spring-batch-samples/src/test/java/org/springframework/batch/sample/chunking/RemoteChunkingJobFunctionalTests.java index c3f408972..3bed4c70d 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/RemoteChunkingJobFunctionalTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/chunking/RemoteChunkingJobFunctionalTests.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.batch.sample; +package org.springframework.batch.sample.chunking; import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.config.impl.ConfigurationImpl; @@ -26,8 +26,6 @@ import org.springframework.batch.core.ExitStatus; import org.springframework.batch.core.Job; import org.springframework.batch.core.JobExecution; import org.springframework.batch.sample.config.JobRunnerConfiguration; -import org.springframework.batch.sample.remotechunking.ManagerConfiguration; -import org.springframework.batch.sample.remotechunking.WorkerConfiguration; import org.springframework.batch.test.JobLauncherTestUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.AnnotationConfigApplicationContext; @@ -46,7 +44,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; */ @SpringJUnitConfig(classes = { JobRunnerConfiguration.class, ManagerConfiguration.class }) -@PropertySource("classpath:remote-chunking.properties") +@PropertySource("classpath:org/springframework/batch/sample/chunking/remote-chunking.properties") class RemoteChunkingJobFunctionalTests { @Autowired 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 903ff6378..9b7157e1c 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 @@ -39,7 +39,8 @@ import org.springframework.transaction.support.TransactionTemplate; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.fail; -@SpringJUnitConfig(locations = "classpath:staging-test-context.xml") +@SpringJUnitConfig( + locations = "classpath:org/springframework/batch/sample/processindicator/job/staging-test-context.xml") class StagingItemReaderTests { private JdbcTemplate jdbcTemplate; 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 c6041db12..5f62637a2 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 @@ -33,7 +33,8 @@ import org.springframework.transaction.annotation.Transactional; import static org.junit.jupiter.api.Assertions.assertEquals; -@SpringJUnitConfig(locations = "classpath:staging-test-context.xml") +@SpringJUnitConfig( + locations = "classpath:org/springframework/batch/sample/processindicator/job/staging-test-context.xml") class StagingItemWriterTests { private JdbcTemplate jdbcTemplate; 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/compositewriter/CompositeItemWriterSampleFunctionalTests.java similarity index 94% rename from spring-batch-samples/src/test/java/org/springframework/batch/sample/CompositeItemWriterSampleFunctionalTests.java rename to spring-batch-samples/src/test/java/org/springframework/batch/sample/compositewriter/CompositeItemWriterSampleFunctionalTests.java index b9704f14b..46b9bec18 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/compositewriter/CompositeItemWriterSampleFunctionalTests.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.batch.sample; +package org.springframework.batch.sample.compositewriter; import java.io.FileInputStream; import java.io.IOException; @@ -38,8 +38,9 @@ import org.springframework.test.jdbc.JdbcTestUtils; import static org.junit.jupiter.api.Assertions.assertEquals; -@SpringJUnitConfig(locations = { "/simple-job-launcher-context.xml", "/jobs/compositeItemWriterSampleJob.xml", - "/job-runner-context.xml" }) +@SpringJUnitConfig( + locations = { "/org/springframework/batch/sample/compositewriter/job/compositeItemWriterSampleJob.xml", + "/simple-job-launcher-context.xml", "/job-runner-context.xml" }) class CompositeItemWriterSampleFunctionalTests { private static final String GET_TRADES = "SELECT isin, quantity, price, customer FROM TRADE order by isin"; 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 1d1ff93dd..3e72b284e 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 @@ -17,6 +17,7 @@ package org.springframework.batch.sample.domain.multiline; import org.junit.jupiter.api.Test; import org.springframework.batch.item.file.transform.DefaultFieldSet; +import org.springframework.batch.sample.file.multilineaggregate.AggregateItemFieldSetMapper; import static org.junit.jupiter.api.Assertions.*; 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 8bbdef2a6..27483d27b 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 @@ -18,6 +18,8 @@ package org.springframework.batch.sample.domain.multiline; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.springframework.batch.item.ItemReader; +import org.springframework.batch.sample.file.multilineaggregate.AggregateItem; +import org.springframework.batch.sample.file.multilineaggregate.AggregateItemReader; import org.springframework.lang.Nullable; import java.util.Collection; 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 1f1e9983a..19e2340c0 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 @@ -17,6 +17,8 @@ package org.springframework.batch.sample.domain.multiline; import org.junit.jupiter.api.Test; +import org.springframework.batch.sample.file.multilineaggregate.AggregateItem; + import static org.junit.jupiter.api.Assertions.*; /** 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 d369e8da9..bb6daa423 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 @@ -18,7 +18,8 @@ package org.springframework.batch.sample.domain.order; 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.order.internal.mapper.AddressFieldSetMapper; +import org.springframework.batch.sample.file.patternmatching.Address; +import org.springframework.batch.sample.file.patternmatching.internal.mapper.AddressFieldSetMapper; import org.springframework.batch.sample.support.AbstractFieldSetMapperTests; class AddressFieldSetMapperTests extends AbstractFieldSetMapperTests { 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 ab3f741d3..c97beb0f8 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 @@ -18,7 +18,8 @@ package org.springframework.batch.sample.domain.order; 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.order.internal.mapper.BillingFieldSetMapper; +import org.springframework.batch.sample.file.patternmatching.BillingInfo; +import org.springframework.batch.sample.file.patternmatching.internal.mapper.BillingFieldSetMapper; import org.springframework.batch.sample.support.AbstractFieldSetMapperTests; class BillingFieldSetMapperTests extends AbstractFieldSetMapperTests { 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 dd1b0980d..05d995c8f 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 @@ -18,7 +18,8 @@ package org.springframework.batch.sample.domain.order; 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.order.internal.mapper.CustomerFieldSetMapper; +import org.springframework.batch.sample.file.patternmatching.Customer; +import org.springframework.batch.sample.file.patternmatching.internal.mapper.CustomerFieldSetMapper; import org.springframework.batch.sample.support.AbstractFieldSetMapperTests; class CustomerFieldSetMapperTests extends AbstractFieldSetMapperTests { 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 4d385eb10..92d1ead43 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 @@ -20,7 +20,8 @@ import java.util.Calendar; 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.order.internal.mapper.HeaderFieldSetMapper; +import org.springframework.batch.sample.file.patternmatching.Order; +import org.springframework.batch.sample.file.patternmatching.internal.mapper.HeaderFieldSetMapper; import org.springframework.batch.sample.support.AbstractFieldSetMapperTests; class HeaderFieldSetMapperTests extends AbstractFieldSetMapperTests { 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 3a4922711..de4bc7654 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 @@ -20,7 +20,8 @@ import java.math.BigDecimal; 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.order.internal.mapper.OrderItemFieldSetMapper; +import org.springframework.batch.sample.file.patternmatching.LineItem; +import org.springframework.batch.sample.file.patternmatching.internal.mapper.OrderItemFieldSetMapper; import org.springframework.batch.sample.support.AbstractFieldSetMapperTests; class OrderItemFieldSetMapperTests extends AbstractFieldSetMapperTests { 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 97ecc7dbf..a80d97c7e 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 @@ -21,7 +21,13 @@ import org.springframework.batch.item.ItemReader; 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.order.internal.OrderItemReader; +import org.springframework.batch.sample.file.patternmatching.Address; +import org.springframework.batch.sample.file.patternmatching.BillingInfo; +import org.springframework.batch.sample.file.patternmatching.Customer; +import org.springframework.batch.sample.file.patternmatching.LineItem; +import org.springframework.batch.sample.file.patternmatching.Order; +import org.springframework.batch.sample.file.patternmatching.ShippingInfo; +import org.springframework.batch.sample.file.patternmatching.internal.OrderItemReader; import static org.junit.jupiter.api.Assertions.*; import static org.mockito.Mockito.mock; 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 3eec81b36..dfd8cafaf 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 @@ -18,7 +18,8 @@ package org.springframework.batch.sample.domain.order; 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.order.internal.mapper.ShippingFieldSetMapper; +import org.springframework.batch.sample.file.patternmatching.ShippingInfo; +import org.springframework.batch.sample.file.patternmatching.internal.mapper.ShippingFieldSetMapper; import org.springframework.batch.sample.support.AbstractFieldSetMapperTests; class ShippingFieldSetMapperTests extends AbstractFieldSetMapperTests { diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/MultilineJobFunctionalTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/file/multilineaggregate/MultilineAggregateJobFunctionalTests.java similarity index 86% rename from spring-batch-samples/src/test/java/org/springframework/batch/sample/MultilineJobFunctionalTests.java rename to spring-batch-samples/src/test/java/org/springframework/batch/sample/file/multilineaggregate/MultilineAggregateJobFunctionalTests.java index 294813ab7..9133edc69 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/MultilineJobFunctionalTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/file/multilineaggregate/MultilineAggregateJobFunctionalTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.batch.sample; +package org.springframework.batch.sample.file.multilineaggregate; import java.nio.charset.StandardCharsets; @@ -30,9 +30,9 @@ import org.springframework.util.StringUtils; import static org.junit.jupiter.api.Assertions.assertEquals; -@SpringJUnitConfig( - locations = { "/simple-job-launcher-context.xml", "/jobs/multilineJob.xml", "/job-runner-context.xml" }) -class MultilineJobFunctionalTests { +@SpringJUnitConfig(locations = { "/org/springframework/batch/sample/file/multilineaggregate/job/multilineJob.xml", + "/simple-job-launcher-context.xml", "/job-runner-context.xml" }) +class MultilineAggregateJobFunctionalTests { @Autowired private JobLauncherTestUtils jobLauncherTestUtils; @@ -42,7 +42,7 @@ class MultilineJobFunctionalTests { private static final String EXPECTED_RESULT = "[Trade: [isin=UK21341EAH45,quantity=978,price=98.34,customer=customer1], Trade: [isin=UK21341EAH46,quantity=112,price=18.12,customer=customer2]]" + "[Trade: [isin=UK21341EAH47,quantity=245,price=12.78,customer=customer2], Trade: [isin=UK21341EAH48,quantity=108,price=9.25,customer=customer3], Trade: [isin=UK21341EAH49,quantity=854,price=23.39,customer=customer4]]"; - private final Resource output = new FileSystemResource("target/test-outputs/20070122.testStream.multilineStep.txt"); + private final Resource output = new FileSystemResource("target/test-outputs/multilineStep-output.txt"); @Test void testJobLaunch() throws Exception { diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/MultilineOrderJobFunctionalTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/file/patternmatching/PatternMatchingJobFunctionalTests.java similarity index 75% rename from spring-batch-samples/src/test/java/org/springframework/batch/sample/MultilineOrderJobFunctionalTests.java rename to spring-batch-samples/src/test/java/org/springframework/batch/sample/file/patternmatching/PatternMatchingJobFunctionalTests.java index 9fdf297e6..bab835e24 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/MultilineOrderJobFunctionalTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/file/patternmatching/PatternMatchingJobFunctionalTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2022 the original author or authors. + * Copyright 2006-2023 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. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.batch.sample; +package org.springframework.batch.sample.file.patternmatching; import java.nio.file.Files; import java.nio.file.Path; @@ -28,13 +28,13 @@ import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.FileSystemResource; import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; -@SpringJUnitConfig( - locations = { "/simple-job-launcher-context.xml", "/jobs/multilineOrderJob.xml", "/job-runner-context.xml" }) -class MultilineOrderJobFunctionalTests { +@SpringJUnitConfig(locations = { "/org/springframework/batch/sample/file/patternmatching/job/multilineOrderJob.xml", + "/simple-job-launcher-context.xml", "/job-runner-context.xml" }) +class PatternMatchingJobFunctionalTests { private static final String ACTUAL = "target/test-outputs/multilineOrderOutput.txt"; - private static final String EXPECTED = "data/multilineOrderJob/result/multilineOrderOutput.txt"; + private static final String EXPECTED = "org/springframework/batch/sample/file/patternmatching/data/multilineOrderOutput.txt"; @Autowired private JobLauncherTestUtils jobLauncherTestUtils; diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/order/internal/validator/OrderValidatorTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/file/patternmatching/internal/validator/OrderValidatorTests.java similarity index 96% rename from spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/order/internal/validator/OrderValidatorTests.java rename to spring-batch-samples/src/test/java/org/springframework/batch/sample/file/patternmatching/internal/validator/OrderValidatorTests.java index f3994455b..feaa9cf54 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/order/internal/validator/OrderValidatorTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/file/patternmatching/internal/validator/OrderValidatorTests.java @@ -13,11 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.batch.sample.domain.order.internal.validator; +package org.springframework.batch.sample.file.patternmatching.internal.validator; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.springframework.batch.sample.domain.order.*; + +import org.springframework.batch.sample.file.patternmatching.Address; +import org.springframework.batch.sample.file.patternmatching.BillingInfo; +import org.springframework.batch.sample.file.patternmatching.Customer; +import org.springframework.batch.sample.file.patternmatching.LineItem; +import org.springframework.batch.sample.file.patternmatching.Order; +import org.springframework.batch.sample.file.patternmatching.ShippingInfo; import org.springframework.validation.BeanPropertyBindingResult; import org.springframework.validation.Errors; 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/filter/CustomerFilterJobFunctionalTests.java similarity index 95% rename from spring-batch-samples/src/test/java/org/springframework/batch/sample/CustomerFilterJobFunctionalTests.java rename to spring-batch-samples/src/test/java/org/springframework/batch/sample/filter/CustomerFilterJobFunctionalTests.java index 83d036ccc..121a7da74 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/filter/CustomerFilterJobFunctionalTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.batch.sample; +package org.springframework.batch.sample.filter; import java.util.Arrays; import java.util.HashMap; @@ -36,8 +36,8 @@ import org.springframework.test.jdbc.JdbcTestUtils; import static org.junit.jupiter.api.Assertions.assertEquals; -@SpringJUnitConfig( - locations = { "/simple-job-launcher-context.xml", "/jobs/customerFilterJob.xml", "/job-runner-context.xml" }) +@SpringJUnitConfig(locations = { "/org/springframework/batch/sample/filter/job/customerFilterJob.xml", + "/simple-job-launcher-context.xml", "/job-runner-context.xml" }) class CustomerFilterJobFunctionalTests { private static final String GET_CUSTOMERS = "select NAME, CREDIT from CUSTOMER order by NAME"; diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/HeaderFooterSampleFunctionalTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/headerfooter/HeaderFooterSampleFunctionalTests.java similarity index 88% rename from spring-batch-samples/src/test/java/org/springframework/batch/sample/HeaderFooterSampleFunctionalTests.java rename to spring-batch-samples/src/test/java/org/springframework/batch/sample/headerfooter/HeaderFooterSampleFunctionalTests.java index 812cdc164..c2292258f 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/HeaderFooterSampleFunctionalTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/headerfooter/HeaderFooterSampleFunctionalTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2008-2022 the original author or authors. + * Copyright 2008-2023 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,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.batch.sample; +package org.springframework.batch.sample.headerfooter; import java.io.BufferedReader; import java.io.FileReader; @@ -28,8 +28,8 @@ import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import static org.springframework.test.util.AssertionErrors.assertTrue; -@SpringJUnitConfig( - locations = { "/simple-job-launcher-context.xml", "/jobs/headerFooterSample.xml", "/job-runner-context.xml" }) +@SpringJUnitConfig(locations = { "/org/springframework/batch/sample/headerfooter/job/headerFooterSample.xml", + "/simple-job-launcher-context.xml", "/job-runner-context.xml" }) class HeaderFooterSampleFunctionalTests { @Autowired 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/jobstep/JobStepFunctionalTests.java similarity index 75% rename from spring-batch-samples/src/test/java/org/springframework/batch/sample/JobStepFunctionalTests.java rename to spring-batch-samples/src/test/java/org/springframework/batch/sample/jobstep/JobStepFunctionalTests.java index 3e0148b27..5120c7de0 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/jobstep/JobStepFunctionalTests.java @@ -14,15 +14,15 @@ * limitations under the License. */ -package org.springframework.batch.sample; +package org.springframework.batch.sample.jobstep; import javax.sql.DataSource; import org.junit.jupiter.api.Test; import org.springframework.batch.core.Job; -import org.springframework.batch.core.converter.DefaultJobParametersConverter; -import org.springframework.batch.support.PropertiesConverter; +import org.springframework.batch.core.JobParameters; +import org.springframework.batch.core.JobParametersBuilder; import org.springframework.batch.test.JobLauncherTestUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jdbc.core.JdbcTemplate; @@ -39,8 +39,8 @@ import static org.junit.jupiter.api.Assertions.assertEquals; * @author Glenn Renfro */ -@SpringJUnitConfig(locations = { "classpath:/simple-job-launcher-context.xml", "classpath:/jobs/jobStepSample.xml", - "/job-runner-context.xml" }) +@SpringJUnitConfig(locations = { "classpath:/org/springframework/batch/sample/jobstep/job/jobStepSample.xml", + "classpath:/simple-job-launcher-context.xml", "/job-runner-context.xml" }) class JobStepFunctionalTests { @Autowired @@ -61,9 +61,10 @@ class JobStepFunctionalTests { jobLauncherTestUtils.setJob(jobStepJob); JdbcTestUtils.deleteFromTables(jdbcTemplate, "TRADE"); - jobLauncherTestUtils - .launchJob(new DefaultJobParametersConverter().getJobParameters(PropertiesConverter.stringToProperties( - "input.file=classpath:data/fixedLengthImportJob/input/20070122.teststream.ImportTradeDataStep.txt"))); + JobParameters jobParameters = new JobParametersBuilder() + .addString("input.file", "org/springframework/batch/sample/jobstep/data/ImportTradeDataStep.txt") + .toJobParameters(); + jobLauncherTestUtils.launchJob(jobParameters); int after = JdbcTestUtils.countRowsInTable(jdbcTemplate, "TRADE"); assertEquals(5, after); diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/VirtualThreadsSupportTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/loom/VirtualThreadsSupportTests.java similarity index 99% rename from spring-batch-samples/src/test/java/org/springframework/batch/sample/VirtualThreadsSupportTests.java rename to spring-batch-samples/src/test/java/org/springframework/batch/sample/loom/VirtualThreadsSupportTests.java index 58588f526..8ca41b9cd 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/VirtualThreadsSupportTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/loom/VirtualThreadsSupportTests.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.batch.sample; +package org.springframework.batch.sample.loom; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/LoopFlowSampleFunctionalTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/loop/LoopFlowSampleFunctionalTests.java similarity index 84% rename from spring-batch-samples/src/test/java/org/springframework/batch/sample/LoopFlowSampleFunctionalTests.java rename to spring-batch-samples/src/test/java/org/springframework/batch/sample/loop/LoopFlowSampleFunctionalTests.java index a7b54e51d..edb738542 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/LoopFlowSampleFunctionalTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/loop/LoopFlowSampleFunctionalTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2022 the original author or authors. + * Copyright 2006-2023 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,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.batch.sample; +package org.springframework.batch.sample.loop; import org.junit.jupiter.api.Test; @@ -33,8 +33,8 @@ import static org.junit.jupiter.api.Assertions.assertEquals; * @since 2.0 */ -@SpringJUnitConfig( - locations = { "/simple-job-launcher-context.xml", "/jobs/loopFlowSample.xml", "/job-runner-context.xml" }) +@SpringJUnitConfig(locations = { "/simple-job-launcher-context.xml", + "/org/springframework/batch/sample/loop/loopFlowSample.xml", "/job-runner-context.xml" }) class LoopFlowSampleFunctionalTests { @Autowired diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/MailJobFunctionalTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/mail/MailJobFunctionalTests.java similarity index 90% rename from spring-batch-samples/src/test/java/org/springframework/batch/sample/MailJobFunctionalTests.java rename to spring-batch-samples/src/test/java/org/springframework/batch/sample/mail/MailJobFunctionalTests.java index d6d289685..33a406298 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/MailJobFunctionalTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/mail/MailJobFunctionalTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2022 the original author or authors. + * Copyright 2006-2023 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,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.batch.sample; +package org.springframework.batch.sample.mail; import java.util.Iterator; import java.util.List; @@ -26,8 +26,6 @@ import org.junit.jupiter.api.Test; import org.springframework.batch.core.ExitStatus; import org.springframework.batch.core.JobExecution; -import org.springframework.batch.sample.domain.mail.internal.TestMailErrorHandler; -import org.springframework.batch.sample.domain.mail.internal.TestMailSender; import org.springframework.batch.test.JobLauncherTestUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jdbc.core.JdbcTemplate; @@ -45,7 +43,8 @@ import static org.junit.jupiter.api.Assertions.assertEquals; * @author Glenn Renfro * @since 2.1 */ -@SpringJUnitConfig(locations = { "/simple-job-launcher-context.xml", "/jobs/mailJob.xml", "/job-runner-context.xml" }) +@SpringJUnitConfig(locations = { "/org/springframework/batch/sample/mail/mailJob.xml", + "/simple-job-launcher-context.xml", "/job-runner-context.xml" }) class MailJobFunctionalTests { private static final String email = "to@company.com"; @@ -95,7 +94,7 @@ class MailJobFunctionalTests { } @Test - void testSkip() throws Exception { + void testLaunchJob() throws Exception { this.createUsers(new Object[][] { USER1, USER2_SKIP, USER3, USER4_SKIP, USER5, USER6, USER7, USER8 }); JobExecution jobExecution = jobLauncherTestUtils.launchJob(); diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/GroovyJobFunctionalTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/misc/groovy/GroovyJobFunctionalTests.java similarity index 84% rename from spring-batch-samples/src/test/java/org/springframework/batch/sample/GroovyJobFunctionalTests.java rename to spring-batch-samples/src/test/java/org/springframework/batch/sample/misc/groovy/GroovyJobFunctionalTests.java index bd58f285d..c4b538285 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/GroovyJobFunctionalTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/misc/groovy/GroovyJobFunctionalTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2022 the original author or authors. + * Copyright 2006-2023 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. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.batch.sample; +package org.springframework.batch.sample.misc.groovy; import java.io.File; import java.io.IOException; @@ -30,7 +30,8 @@ import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; -@SpringJUnitConfig(locations = { "/simple-job-launcher-context.xml", "/jobs/groovyJob.xml", "/job-runner-context.xml" }) +@SpringJUnitConfig(locations = { "/org/springframework/batch/sample/misc/groovy/job/groovyJob.xml", + "/simple-job-launcher-context.xml", "/job-runner-context.xml" }) public class GroovyJobFunctionalTests { @Autowired 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/misc/jmx/JobExecutionNotificationPublisherTests.java similarity index 96% rename from spring-batch-samples/src/test/java/org/springframework/batch/sample/jmx/JobExecutionNotificationPublisherTests.java rename to spring-batch-samples/src/test/java/org/springframework/batch/sample/misc/jmx/JobExecutionNotificationPublisherTests.java index bafc3d871..d13f82c90 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/misc/jmx/JobExecutionNotificationPublisherTests.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.batch.sample.jmx; +package org.springframework.batch.sample.misc.jmx; import org.junit.jupiter.api.Test; 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/misc/jmx/RemoteLauncherTests.java similarity index 94% rename from spring-batch-samples/src/test/java/org/springframework/batch/sample/launch/RemoteLauncherTests.java rename to spring-batch-samples/src/test/java/org/springframework/batch/sample/misc/jmx/RemoteLauncherTests.java index fcabdb607..b0f6adaca 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/misc/jmx/RemoteLauncherTests.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.batch.sample.launch; +package org.springframework.batch.sample.misc.jmx; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -22,6 +22,7 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.springframework.batch.core.launch.JobOperator; import org.springframework.batch.core.launch.support.JobRegistryBackgroundJobRunner; +import org.springframework.batch.sample.launch.JobLoader; import org.springframework.jmx.MBeanServerNotFoundException; import org.springframework.jmx.access.InvalidInvocationException; import org.springframework.jmx.access.MBeanProxyFactoryBean; @@ -120,7 +121,9 @@ class RemoteLauncherTests { Thread thread = new Thread(() -> { try { - JobRegistryBackgroundJobRunner.main("adhoc-job-launcher-context.xml", "jobs/adhocLoopJob.xml"); + JobRegistryBackgroundJobRunner.main( + "org/springframework/batch/sample/misc/jmx/adhoc-job-launcher-context.xml", + "org/springframework/batch/sample/misc/jmx/adhocLoopJob.xml"); } catch (Exception e) { logger.error(e); 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/misc/quartz/JobLauncherDetailsTests.java similarity index 98% rename from spring-batch-samples/src/test/java/org/springframework/batch/sample/quartz/JobLauncherDetailsTests.java rename to spring-batch-samples/src/test/java/org/springframework/batch/sample/misc/quartz/JobLauncherDetailsTests.java index 0e6bd32b8..449c3eaab 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/misc/quartz/JobLauncherDetailsTests.java @@ -13,14 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.batch.sample.quartz; +package org.springframework.batch.sample.misc.quartz; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.quartz.Job; import org.quartz.JobDetail; import org.quartz.JobExecutionContext; -import org.quartz.Scheduler; import org.quartz.impl.JobDetailImpl; import org.quartz.impl.JobExecutionContextImpl; import org.quartz.impl.triggers.SimpleTriggerImpl; 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/partition/file/PartitionFileJobFunctionalTests.java similarity index 94% rename from spring-batch-samples/src/test/java/org/springframework/batch/sample/PartitionFileJobFunctionalTests.java rename to spring-batch-samples/src/test/java/org/springframework/batch/sample/partition/file/PartitionFileJobFunctionalTests.java index c5518ac89..a2282b07b 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/partition/file/PartitionFileJobFunctionalTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.batch.sample; +package org.springframework.batch.sample.partition.file; import java.util.ArrayList; import java.util.LinkedHashSet; @@ -41,8 +41,8 @@ import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; -@SpringJUnitConfig( - locations = { "/simple-job-launcher-context.xml", "/jobs/partitionFileJob.xml", "/job-runner-context.xml" }) +@SpringJUnitConfig(locations = { "/org/springframework/batch/sample/partition/file/job/partitionFileJob.xml", + "/simple-job-launcher-context.xml", "/job-runner-context.xml" }) class PartitionFileJobFunctionalTests implements ApplicationContextAware { @Autowired 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/partition/jdbc/PartitionJdbcJobFunctionalTests.java similarity index 94% rename from spring-batch-samples/src/test/java/org/springframework/batch/sample/PartitionJdbcJobFunctionalTests.java rename to spring-batch-samples/src/test/java/org/springframework/batch/sample/partition/jdbc/PartitionJdbcJobFunctionalTests.java index 067961323..3d035a865 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/partition/jdbc/PartitionJdbcJobFunctionalTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.batch.sample; +package org.springframework.batch.sample.partition.jdbc; import java.util.ArrayList; import java.util.LinkedHashSet; @@ -41,8 +41,8 @@ import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; -@SpringJUnitConfig( - locations = { "/simple-job-launcher-context.xml", "/jobs/partitionJdbcJob.xml", "/job-runner-context.xml" }) +@SpringJUnitConfig(locations = { "/org/springframework/batch/sample/partition/jdbc/partitionJdbcJob.xml", + "/simple-job-launcher-context.xml", "/job-runner-context.xml" }) class PartitionJdbcJobFunctionalTests implements ApplicationContextAware { @Autowired diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/RemotePartitioningJobFunctionalTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/partition/remote/RemotePartitioningJobFunctionalTests.java similarity index 95% rename from spring-batch-samples/src/test/java/org/springframework/batch/sample/RemotePartitioningJobFunctionalTests.java rename to spring-batch-samples/src/test/java/org/springframework/batch/sample/partition/remote/RemotePartitioningJobFunctionalTests.java index 2a2c73bb6..0bcaff1df 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/RemotePartitioningJobFunctionalTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/partition/remote/RemotePartitioningJobFunctionalTests.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.batch.sample; +package org.springframework.batch.sample.partition.remote; import javax.sql.DataSource; @@ -46,7 +46,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; */ @SpringJUnitConfig -@PropertySource("classpath:remote-partitioning.properties") +@PropertySource("classpath:org/springframework/batch/sample/partitioning/remote/remote-partitioning.properties") public abstract class RemotePartitioningJobFunctionalTests { private static final String BROKER_DATA_DIRECTORY = "target/activemq-data"; diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/RemotePartitioningJobWithMessageAggregationFunctionalTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/partition/remote/RemotePartitioningJobWithMessageAggregationFunctionalTests.java similarity index 83% rename from spring-batch-samples/src/test/java/org/springframework/batch/sample/RemotePartitioningJobWithMessageAggregationFunctionalTests.java rename to spring-batch-samples/src/test/java/org/springframework/batch/sample/partition/remote/RemotePartitioningJobWithMessageAggregationFunctionalTests.java index c6e837814..c79d33acf 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/RemotePartitioningJobWithMessageAggregationFunctionalTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/partition/remote/RemotePartitioningJobWithMessageAggregationFunctionalTests.java @@ -13,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.batch.sample; +package org.springframework.batch.sample.partition.remote; import org.springframework.batch.sample.config.JobRunnerConfiguration; -import org.springframework.batch.sample.remotepartitioning.aggregating.ManagerConfiguration; -import org.springframework.batch.sample.remotepartitioning.aggregating.WorkerConfiguration; +import org.springframework.batch.sample.partitioning.remote.aggregating.ManagerConfiguration; +import org.springframework.batch.sample.partitioning.remote.aggregating.WorkerConfiguration; import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; /** diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/RemotePartitioningJobWithRepositoryPollingFunctionalTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/partition/remote/RemotePartitioningJobWithRepositoryPollingFunctionalTests.java similarity index 83% rename from spring-batch-samples/src/test/java/org/springframework/batch/sample/RemotePartitioningJobWithRepositoryPollingFunctionalTests.java rename to spring-batch-samples/src/test/java/org/springframework/batch/sample/partition/remote/RemotePartitioningJobWithRepositoryPollingFunctionalTests.java index db404d4c8..818af2ed1 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/RemotePartitioningJobWithRepositoryPollingFunctionalTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/partition/remote/RemotePartitioningJobWithRepositoryPollingFunctionalTests.java @@ -13,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.batch.sample; +package org.springframework.batch.sample.partition.remote; import org.springframework.batch.sample.config.JobRunnerConfiguration; -import org.springframework.batch.sample.remotepartitioning.polling.ManagerConfiguration; -import org.springframework.batch.sample.remotepartitioning.polling.WorkerConfiguration; +import org.springframework.batch.sample.partitioning.remote.polling.ManagerConfiguration; +import org.springframework.batch.sample.partitioning.remote.polling.WorkerConfiguration; import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; /** diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/ParallelJobFunctionalTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/processindicator/ProcessIndicatorJobFunctionalTests.java similarity index 86% rename from spring-batch-samples/src/test/java/org/springframework/batch/sample/ParallelJobFunctionalTests.java rename to spring-batch-samples/src/test/java/org/springframework/batch/sample/processindicator/ProcessIndicatorJobFunctionalTests.java index b5f7a4a29..c913c1698 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/ParallelJobFunctionalTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/processindicator/ProcessIndicatorJobFunctionalTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.batch.sample; +package org.springframework.batch.sample.processindicator; import javax.sql.DataSource; @@ -30,9 +30,9 @@ import org.springframework.test.jdbc.JdbcTestUtils; import static org.junit.jupiter.api.Assertions.assertEquals; -@SpringJUnitConfig( - locations = { "/simple-job-launcher-context.xml", "/jobs/parallelJob.xml", "/job-runner-context.xml" }) -class ParallelJobFunctionalTests { +@SpringJUnitConfig(locations = { "/org/springframework/batch/sample/processindicator/job/parallelJob.xml", + "/simple-job-launcher-context.xml", "/job-runner-context.xml" }) +class ProcessIndicatorJobFunctionalTests { @Autowired private JobLauncherTestUtils jobLauncherTestUtils; diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/RestartFileSampleFunctionalTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/restart/fail/RestartFileSampleFunctionalTests.java similarity index 92% rename from spring-batch-samples/src/test/java/org/springframework/batch/sample/RestartFileSampleFunctionalTests.java rename to spring-batch-samples/src/test/java/org/springframework/batch/sample/restart/fail/RestartFileSampleFunctionalTests.java index 8a1ef4fec..127a8183b 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/RestartFileSampleFunctionalTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/restart/fail/RestartFileSampleFunctionalTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.batch.sample; +package org.springframework.batch.sample.restart.fail; import java.nio.file.Files; import java.nio.file.Path; @@ -41,8 +41,8 @@ import static org.junit.jupiter.api.Assertions.assertEquals; * @author Glenn Renfro * @since 2.0 */ -@SpringJUnitConfig( - locations = { "/simple-job-launcher-context.xml", "/jobs/restartFileSampleJob.xml", "/job-runner-context.xml" }) +@SpringJUnitConfig(locations = { "/simple-job-launcher-context.xml", + "/org/springframework/batch/sample/restart/fail/job/restartFileSampleJob.xml", "/job-runner-context.xml" }) class RestartFileSampleFunctionalTests { @Autowired 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/restart/fail/RestartFunctionalTests.java similarity index 90% rename from spring-batch-samples/src/test/java/org/springframework/batch/sample/RestartFunctionalTests.java rename to spring-batch-samples/src/test/java/org/springframework/batch/sample/restart/fail/RestartFunctionalTests.java index 52e67c68e..adacc08ed 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/restart/fail/RestartFunctionalTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.batch.sample; +package org.springframework.batch.sample.restart.fail; import javax.sql.DataSource; @@ -42,8 +42,8 @@ import static org.junit.jupiter.api.Assertions.assertTrue; * @author Mahmoud Ben Hassine * @author Glenn Renfro */ -@SpringJUnitConfig( - locations = { "/simple-job-launcher-context.xml", "/jobs/restartSample.xml", "/job-runner-context.xml" }) +@SpringJUnitConfig(locations = { "/org/springframework/batch/sample/restart/fail/job/failRestartSample.xml", + "/simple-job-launcher-context.xml", "/job-runner-context.xml" }) class RestartFunctionalTests { private JdbcTemplate jdbcTemplate; @@ -93,7 +93,7 @@ class RestartFunctionalTests { private JobExecution runJobForRestartTest() throws Exception { return jobLauncherTestUtils .launchJob(new DefaultJobParametersConverter().getJobParameters(PropertiesConverter.stringToProperties( - "input.file=classpath:data/fixedLengthImportJob/input/20070122.teststream.ImportTradeDataStep.txt"))); + "input.file=classpath:org/springframework/batch/sample/restart/fail/data/ImportTradeDataStep.txt"))); } } diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/DatabaseShutdownFunctionalTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/restart/stop/DatabaseShutdownFunctionalTests.java similarity index 91% rename from spring-batch-samples/src/test/java/org/springframework/batch/sample/DatabaseShutdownFunctionalTests.java rename to spring-batch-samples/src/test/java/org/springframework/batch/sample/restart/stop/DatabaseShutdownFunctionalTests.java index 91b117db5..471d82afa 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/DatabaseShutdownFunctionalTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/restart/stop/DatabaseShutdownFunctionalTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.batch.sample; +package org.springframework.batch.sample.restart.stop; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -42,8 +42,8 @@ import static org.junit.jupiter.api.Assertions.assertTrue; * */ -@SpringJUnitConfig( - locations = { "/simple-job-launcher-context.xml", "/jobs/infiniteLoopJob.xml", "/job-runner-context.xml" }) +@SpringJUnitConfig(locations = { "/simple-job-launcher-context.xml", + "/org/springframework/batch/sample/restart/stop/stopRestartSample.xml", "/job-runner-context.xml" }) class DatabaseShutdownFunctionalTests { /** Logger */ diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/GracefulShutdownFunctionalTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/restart/stop/GracefulShutdownFunctionalTests.java similarity index 92% rename from spring-batch-samples/src/test/java/org/springframework/batch/sample/GracefulShutdownFunctionalTests.java rename to spring-batch-samples/src/test/java/org/springframework/batch/sample/restart/stop/GracefulShutdownFunctionalTests.java index 91693d069..d55b34dc4 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/GracefulShutdownFunctionalTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/restart/stop/GracefulShutdownFunctionalTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.batch.sample; +package org.springframework.batch.sample.restart.stop; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -43,8 +43,8 @@ import static org.junit.jupiter.api.Assertions.assertTrue; * @author Mahmoud Ben Hassine * */ -@SpringJUnitConfig( - locations = { "/simple-job-launcher-context.xml", "/jobs/infiniteLoopJob.xml", "/job-runner-context.xml" }) +@SpringJUnitConfig(locations = { "/simple-job-launcher-context.xml", + "/org/springframework/batch/sample/restart/stop/stopRestartSample.xml", "/job-runner-context.xml" }) class GracefulShutdownFunctionalTests { /** Logger */ 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/restart/stop/JobOperatorFunctionalTests.java similarity index 97% rename from spring-batch-samples/src/test/java/org/springframework/batch/sample/JobOperatorFunctionalTests.java rename to spring-batch-samples/src/test/java/org/springframework/batch/sample/restart/stop/JobOperatorFunctionalTests.java index 53b5688f4..06af5884a 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/restart/stop/JobOperatorFunctionalTests.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.batch.sample; +package org.springframework.batch.sample.restart.stop; import java.util.List; import java.util.Map; @@ -38,7 +38,8 @@ import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertTrue; -@SpringJUnitConfig(locations = { "/simple-job-launcher-context.xml", "/jobs/infiniteLoopJob.xml" }) +@SpringJUnitConfig(locations = { "/simple-job-launcher-context.xml", + "/org/springframework/batch/sample/restart/stop/stopRestartSample.xml" }) class JobOperatorFunctionalTests { private static final Log LOG = LogFactory.getLog(JobOperatorFunctionalTests.class); diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/RetrySampleConfigurationTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/retry/RetrySampleConfigurationTests.java similarity index 94% rename from spring-batch-samples/src/test/java/org/springframework/batch/sample/RetrySampleConfigurationTests.java rename to spring-batch-samples/src/test/java/org/springframework/batch/sample/retry/RetrySampleConfigurationTests.java index 5576d1e72..ac357e56b 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/RetrySampleConfigurationTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/retry/RetrySampleConfigurationTests.java @@ -13,14 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.batch.sample; +package org.springframework.batch.sample.retry; import org.junit.jupiter.api.Test; import org.springframework.batch.core.Job; import org.springframework.batch.sample.config.DataSourceConfiguration; import org.springframework.batch.sample.config.JobRunnerConfiguration; -import org.springframework.batch.sample.config.RetrySampleConfiguration; import org.springframework.batch.sample.domain.trade.internal.GeneratingTradeItemReader; import org.springframework.batch.sample.support.RetrySampleItemWriter; import org.springframework.batch.test.JobLauncherTestUtils; diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/RetrySampleFunctionalTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/retry/RetrySampleFunctionalTests.java similarity index 89% rename from spring-batch-samples/src/test/java/org/springframework/batch/sample/RetrySampleFunctionalTests.java rename to spring-batch-samples/src/test/java/org/springframework/batch/sample/retry/RetrySampleFunctionalTests.java index bd2a6b389..8503542eb 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/RetrySampleFunctionalTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/retry/RetrySampleFunctionalTests.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.batch.sample; +package org.springframework.batch.sample.retry; import org.junit.jupiter.api.Test; @@ -33,8 +33,8 @@ import static org.junit.jupiter.api.Assertions.assertEquals; * @author Glenn Renfro */ -@SpringJUnitConfig( - locations = { "/simple-job-launcher-context.xml", "/jobs/retrySample.xml", "/job-runner-context.xml" }) +@SpringJUnitConfig(locations = { "/simple-job-launcher-context.xml", + "/org/springframework/batch/sample/retry/retrySample.xml", "/job-runner-context.xml" }) class RetrySampleFunctionalTests { @Autowired diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/SkipSampleFunctionalTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/skip/SkipSampleFunctionalTests.java similarity index 97% rename from spring-batch-samples/src/test/java/org/springframework/batch/sample/SkipSampleFunctionalTests.java rename to spring-batch-samples/src/test/java/org/springframework/batch/sample/skip/SkipSampleFunctionalTests.java index 8dd62a52f..11c7274dc 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/SkipSampleFunctionalTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/skip/SkipSampleFunctionalTests.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.batch.sample; +package org.springframework.batch.sample.skip; import java.math.BigDecimal; import java.util.Map; @@ -41,9 +41,6 @@ import org.springframework.batch.core.repository.JobInstanceAlreadyCompleteExcep import org.springframework.batch.core.repository.JobRestartException; import org.springframework.batch.sample.common.SkipCheckingListener; import org.springframework.batch.sample.domain.trade.internal.TradeWriter; -import org.springframework.batch.sample.skip.SkippableExceptionDuringProcessSample; -import org.springframework.batch.sample.skip.SkippableExceptionDuringReadSample; -import org.springframework.batch.sample.skip.SkippableExceptionDuringWriteSample; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.ApplicationContext; @@ -65,7 +62,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; * @author Dan Garrette * @author Mahmoud Ben Hassine */ -@SpringJUnitConfig(locations = { "/skipSample-job-launcher-context.xml" }) +@SpringJUnitConfig(locations = { "/org/springframework/batch/sample/skip/job/skipSample-job-launcher-context.xml" }) class SkipSampleFunctionalTests { private JdbcTemplate jdbcTemplate; 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/trade/TradeJobFunctionalTests.java similarity index 95% rename from spring-batch-samples/src/test/java/org/springframework/batch/sample/TradeJobFunctionalTests.java rename to spring-batch-samples/src/test/java/org/springframework/batch/sample/trade/TradeJobFunctionalTests.java index 76a519607..6c3b43485 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/trade/TradeJobFunctionalTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.batch.sample; +package org.springframework.batch.sample.trade; import java.math.BigDecimal; import java.util.Arrays; @@ -37,7 +37,8 @@ import org.springframework.test.jdbc.JdbcTestUtils; import static org.junit.jupiter.api.Assertions.assertEquals; -@SpringJUnitConfig(locations = { "/simple-job-launcher-context.xml", "/jobs/tradeJob.xml", "/job-runner-context.xml" }) +@SpringJUnitConfig(locations = { "/org/springframework/batch/sample/trade/job/tradeJob.xml", + "/simple-job-launcher-context.xml", "/job-runner-context.xml" }) class TradeJobFunctionalTests { private static final String GET_TRADES = "select ISIN, QUANTITY, PRICE, CUSTOMER, ID, VERSION from TRADE order by ISIN";