[BATCH-430] Removed the batch.io.exception package and moved classes to their approved locations

This commit is contained in:
nebhale
2008-03-07 14:18:49 +00:00
parent b2396b3ef4
commit 609ce9d347
94 changed files with 216 additions and 566 deletions

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.batch.io.exception;
package org.springframework.batch.core;
/**
* Indicates to the framework that a critical error has occurred and processing

View File

@@ -16,7 +16,6 @@
package org.springframework.batch.core;
import org.springframework.batch.io.exception.InfrastructureException;
/**
* Exception to indicate the the job has been interrupted. The exception state

View File

@@ -22,7 +22,6 @@ import java.util.List;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.Step;
import org.springframework.batch.io.exception.InfrastructureException;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.util.ClassUtils;

View File

@@ -18,7 +18,6 @@ package org.springframework.batch.core;
import org.springframework.batch.core.JobInterruptedException;
import org.springframework.batch.core.Step;
import org.springframework.batch.core.StepExecution;
import org.springframework.batch.io.exception.InfrastructureException;
import org.springframework.beans.factory.BeanNameAware;
/**

View File

@@ -21,6 +21,7 @@ import java.util.Iterator;
import java.util.List;
import org.springframework.batch.core.BatchStatus;
import org.springframework.batch.core.InfrastructureException;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.JobExecutionException;
import org.springframework.batch.core.JobInstance;
@@ -30,7 +31,6 @@ import org.springframework.batch.core.Step;
import org.springframework.batch.core.StepExecution;
import org.springframework.batch.core.repository.JobRepository;
import org.springframework.batch.execution.listener.CompositeJobListener;
import org.springframework.batch.io.exception.InfrastructureException;
import org.springframework.batch.repeat.ExitStatus;
/**

View File

@@ -13,10 +13,10 @@ import org.apache.commons.lang.SerializationUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.batch.core.BatchStatus;
import org.springframework.batch.core.InfrastructureException;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.Step;
import org.springframework.batch.core.StepExecution;
import org.springframework.batch.io.exception.InfrastructureException;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.batch.repeat.ExitStatus;
import org.springframework.beans.factory.InitializingBean;

View File

@@ -15,10 +15,10 @@
*/
package org.springframework.batch.execution.step;
import org.springframework.batch.core.InfrastructureException;
import org.springframework.batch.core.JobInterruptedException;
import org.springframework.batch.core.Step;
import org.springframework.batch.core.StepExecution;
import org.springframework.batch.io.exception.InfrastructureException;
/**
* A {@link Step} implementation that provides common behaviour to subclasses.

View File

@@ -20,6 +20,7 @@ import java.util.Date;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.batch.core.BatchStatus;
import org.springframework.batch.core.InfrastructureException;
import org.springframework.batch.core.JobInstance;
import org.springframework.batch.core.JobInterruptedException;
import org.springframework.batch.core.StepContribution;
@@ -34,7 +35,6 @@ import org.springframework.batch.execution.step.support.SimpleExitStatusExceptio
import org.springframework.batch.execution.step.support.StepExecutionSynchronizer;
import org.springframework.batch.execution.step.support.StepInterruptionPolicy;
import org.springframework.batch.execution.step.support.ThreadStepInterruptionPolicy;
import org.springframework.batch.io.exception.InfrastructureException;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.batch.item.ItemReader;
import org.springframework.batch.item.ItemStream;

View File

@@ -20,6 +20,7 @@ import java.util.Date;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.batch.core.BatchStatus;
import org.springframework.batch.core.InfrastructureException;
import org.springframework.batch.core.JobInterruptedException;
import org.springframework.batch.core.Step;
import org.springframework.batch.core.StepExecution;
@@ -27,7 +28,6 @@ import org.springframework.batch.core.StepListener;
import org.springframework.batch.core.repository.JobRepository;
import org.springframework.batch.core.tasklet.Tasklet;
import org.springframework.batch.execution.listener.CompositeStepListener;
import org.springframework.batch.io.exception.InfrastructureException;
import org.springframework.batch.repeat.ExitStatus;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.InitializingBean;

View File

@@ -27,7 +27,7 @@ import org.springframework.batch.common.SubclassExceptionClassifier;
import org.springframework.batch.core.ItemSkipPolicy;
import org.springframework.batch.core.Step;
import org.springframework.batch.core.StepExecution;
import org.springframework.batch.io.exception.FlatFileParsingException;
import org.springframework.batch.item.file.FlatFileParseException;
/**
* <p>
@@ -35,14 +35,14 @@ import org.springframework.batch.io.exception.FlatFileParsingException;
* based upon how many items have been skipped. This is extremely useful
* behavior, as it allows you to skip records, but will throw a
* {@link SkipLimitExceededException} if a set limit has been exceeded. For
* example, it is generally advisable to skip {@link FlatFileParsingException}s,
* example, it is generally advisable to skip {@link FlatFileParseException}s,
* however, if the vast majority of records are causing exceptions, the file is
* likely bad.
* </p>
*
* <p>
* Furthermore, it is also likely that you only want to skip certain exceptions.
* {@link FlatFileParsingException} is a good example of an exception you will
* {@link FlatFileParseException} is a good example of an exception you will
* likely want to skip, but a {@link FileNotFoundException} should cause
* immediate termination of the {@link Step}. Because it would be impossible
* for a general purpose policy to determine all the types of exceptions that

View File

@@ -15,7 +15,7 @@
*/
package org.springframework.batch.execution.step.support;
import org.springframework.batch.io.exception.InfrastructureException;
import org.springframework.batch.core.InfrastructureException;
/**
* Exception indicating that the skip limit for a particular {@Step} has

View File

@@ -19,10 +19,10 @@ package org.springframework.batch.execution.job;
import java.util.ArrayList;
import java.util.List;
import org.springframework.batch.core.InfrastructureException;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.Step;
import org.springframework.batch.io.exception.InfrastructureException;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.util.ClassUtils;

View File

@@ -22,6 +22,7 @@ import java.util.List;
import junit.framework.TestCase;
import org.springframework.batch.core.BatchStatus;
import org.springframework.batch.core.InfrastructureException;
import org.springframework.batch.core.ItemSkipPolicy;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.JobExecutionException;
@@ -41,7 +42,6 @@ import org.springframework.batch.execution.repository.dao.MapStepExecutionDao;
import org.springframework.batch.execution.repository.dao.StepExecutionDao;
import org.springframework.batch.execution.step.AbstractStep;
import org.springframework.batch.execution.step.support.NeverSkipItemSkipPolicy;
import org.springframework.batch.io.exception.InfrastructureException;
import org.springframework.batch.item.AbstractItemReader;
import org.springframework.batch.item.ItemReader;
import org.springframework.batch.item.ItemWriter;

View File

@@ -23,6 +23,7 @@ import java.util.List;
import junit.framework.TestCase;
import org.springframework.batch.core.BatchStatus;
import org.springframework.batch.core.InfrastructureException;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.JobInstance;
import org.springframework.batch.core.JobInterruptedException;
@@ -39,7 +40,6 @@ import org.springframework.batch.execution.repository.dao.MapStepExecutionDao;
import org.springframework.batch.execution.step.support.JobRepositorySupport;
import org.springframework.batch.execution.step.support.SimpleItemHandler;
import org.springframework.batch.execution.step.support.StepInterruptionPolicy;
import org.springframework.batch.io.exception.InfrastructureException;
import org.springframework.batch.item.AbstractItemReader;
import org.springframework.batch.item.AbstractItemWriter;
import org.springframework.batch.item.ExecutionContext;

View File

@@ -15,10 +15,10 @@
*/
package org.springframework.batch.execution.step;
import org.springframework.batch.core.InfrastructureException;
import org.springframework.batch.core.JobInterruptedException;
import org.springframework.batch.core.Step;
import org.springframework.batch.core.StepExecution;
import org.springframework.batch.io.exception.InfrastructureException;
import org.springframework.beans.factory.BeanNameAware;
/**

View File

@@ -6,6 +6,7 @@ import java.util.List;
import junit.framework.TestCase;
import org.springframework.batch.core.BatchStatus;
import org.springframework.batch.core.InfrastructureException;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.JobInstance;
import org.springframework.batch.core.JobInterruptedException;
@@ -16,7 +17,6 @@ import org.springframework.batch.core.listener.StepListenerSupport;
import org.springframework.batch.core.tasklet.Tasklet;
import org.springframework.batch.execution.job.JobSupport;
import org.springframework.batch.execution.step.support.JobRepositorySupport;
import org.springframework.batch.io.exception.InfrastructureException;
import org.springframework.batch.repeat.ExitStatus;
public class TaskletStepTests extends TestCase {

View File

@@ -21,7 +21,7 @@ import java.util.List;
import junit.framework.TestCase;
import org.springframework.batch.io.exception.FlatFileParsingException;
import org.springframework.batch.item.file.FlatFileParseException;
/**
* @author Lucas Ward
@@ -35,14 +35,14 @@ public class SkipLimitReadFailurePolicyTests extends TestCase {
super.setUp();
List skippableExceptions = new ArrayList();
skippableExceptions.add(FlatFileParsingException.class);
skippableExceptions.add(FlatFileParseException.class);
failurePolicy = new LimitCheckingItemSkipPolicy(1, skippableExceptions);
}
public void testLimitExceed(){
try{
failurePolicy.shouldSkip(new FlatFileParsingException("", ""), 2);
failurePolicy.shouldSkip(new FlatFileParseException("", ""), 2);
fail();
}
catch(SkipLimitExceededException ex){
@@ -55,7 +55,7 @@ public class SkipLimitReadFailurePolicyTests extends TestCase {
}
public void testSkip(){
assertTrue(failurePolicy.shouldSkip(new FlatFileParsingException("",""), 0));
assertTrue(failurePolicy.shouldSkip(new FlatFileParseException("",""), 0));
}
}

View File

@@ -1,49 +0,0 @@
/*
* Copyright 2006-2007 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.batch.io.exception;
/**
* This exception is thrown when there is a critical configuration error and the
* current job or module execution cannot continue.
*
* @author Kerry O'Brien
*/
public class ConfigurationException extends InfrastructureException {
private static final long serialVersionUID = 759498454063502984L;
/**
* @param msg
* @param ex
*/
public ConfigurationException(String msg, Throwable ex) {
super(msg, ex);
}
/**
* @param msg
*/
public ConfigurationException(String msg) {
super(msg);
}
/**
* @param nested
*/
public ConfigurationException(Throwable nested) {
super(nested);
}
}

View File

@@ -1,42 +0,0 @@
/*
* Copyright 2006-2007 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.batch.io.exception;
import org.springframework.batch.item.ItemReader;
/**
* This exception indicates an error encountered while reading. It should generally
* be thrown by classes that implement the {@link ItemReader} interface.
*
* @author Lucas Ward
*/
public class ReadFailureException extends InfrastructureException {
private static final long serialVersionUID = 4113323182216735223L;
public ReadFailureException(String msg, Throwable ex) {
super(msg, ex);
}
public ReadFailureException(String msg) {
super(msg);
}
public ReadFailureException(Throwable nested) {
super(nested);
}
}

View File

@@ -1,57 +0,0 @@
/*
* Copyright 2006-2007 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.batch.io.exception;
import org.springframework.batch.item.ItemWriter;
/**
* Exception thrown after encountering an error during a write. It should
* generally be thrown by classes that implement the {@link ItemWriter}
* interface.
*
* @author Lucas Ward
*/
public class WriteFailureException extends InfrastructureException {
private static final long serialVersionUID = -1933213086873834098L;
private final Object item;
public WriteFailureException(String msg, Throwable ex, Object item) {
super(msg, ex);
this.item = item;
}
public WriteFailureException(String msg) {
this(msg, null, null);
}
public WriteFailureException(Throwable nested) {
this("", nested, null);
}
public WriteFailureException(String msg, Object item){
this(msg, null, item);
}
public WriteFailureException(Throwable nested, Object item){
this("", nested, item);
}
public Object getItem() {
return item;
}
}

View File

@@ -1,7 +0,0 @@
<html>
<body>
<p>
Infrastructure implementations of io exception concerns.
</p>
</body>
</html>

View File

@@ -1,7 +0,0 @@
<html>
<body>
<p>
Infrastructure implementations of io concerns.
</p>
</body>
</html>

View File

@@ -41,7 +41,7 @@ public interface ItemReader {
*
* @throws Exception if an underlying resource is unavailable.
*/
Object read() throws Exception, UnexpectedInputException, NoWorkFoundException;
Object read() throws Exception, UnexpectedInputException, NoWorkFoundException, ParseException;
/**
* Mark the stream so that it can be reset later and the items backed out.<br/>

View File

@@ -13,28 +13,33 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.batch.io.exception;
package org.springframework.batch.item;
/**
* Exception indicating that an error has been encountered
* parsing io, typically from a file.
*
* Exception indicating that an error has been encountered parsing io, typically from a file.
*
* @author Lucas Ward
*
* @author Ben Hale
*/
public class ParsingException extends RuntimeException {
public class ParseException extends ItemReaderException {
private static final long serialVersionUID = 2953386084409312312L;
public ParsingException(String message) {
super(message);
}
public ParsingException(String message, Throwable cause) {
/**
* Create a new {@link ParseException} based on a message and another exception.
*
* @param message the message for this exception
* @param cause the other exception
*/
public ParseException(String message, Throwable cause) {
super(message, cause);
}
public ParsingException(Throwable cause) {
super(cause);
/**
* Create a new {@link ParseException} based on a message.
*
* @param message the message for this exception
*/
public ParseException(String message) {
super(message);
}
}

View File

@@ -22,7 +22,6 @@ import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.batch.io.exception.FlatFileParsingException;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.batch.item.ExecutionContextUserSupport;
import org.springframework.batch.item.ItemReader;
@@ -188,7 +187,7 @@ public class FlatFileItemReader extends ExecutionContextUserSupport implements I
} catch (RuntimeException ex) {
// add current line count to message and re-throw
int lineCount = getReader().getPosition();
throw new FlatFileParsingException("Parsing error at line: " + lineCount + " in resource=" + path
throw new FlatFileParseException("Parsing error at line: " + lineCount + " in resource=" + path
+ ", input=[" + line + "]", ex, line, lineCount);
}
}

View File

@@ -25,8 +25,6 @@ import java.nio.channels.Channels;
import java.nio.channels.FileChannel;
import java.nio.charset.UnsupportedCharsetException;
import org.springframework.batch.io.exception.ConfigurationException;
import org.springframework.batch.io.exception.InfrastructureException;
import org.springframework.batch.item.ClearFailedException;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.batch.item.ExecutionContextUserSupport;
@@ -34,6 +32,8 @@ import org.springframework.batch.item.FlushFailedException;
import org.springframework.batch.item.ItemStream;
import org.springframework.batch.item.ItemStreamException;
import org.springframework.batch.item.ItemWriter;
import org.springframework.batch.item.MarkFailedException;
import org.springframework.batch.item.ResetFailedException;
import org.springframework.batch.item.file.mapping.FieldSet;
import org.springframework.batch.item.file.mapping.FieldSetCreator;
import org.springframework.batch.item.file.transform.DelimitedLineAggregator;
@@ -191,7 +191,13 @@ public class FlatFileItemWriter extends ExecutionContextUserSupport implements I
throw new ItemStreamException("ItemStream not open or already closed.");
}
Assert.notNull(executionContext, "ExecutionContext must not be null");
executionContext.putLong(getKey(RESTART_DATA_NAME), state.position());
try {
executionContext.putLong(getKey(RESTART_DATA_NAME), state.position());
} catch (IOException e) {
throw new ItemStreamException("ItemStream does not return current position properly", e);
}
executionContext.putLong(getKey(WRITTEN_STATISTICS_NAME), state.linesWritten);
executionContext.putLong(getKey(RESTART_COUNT_STATISTICS_NAME), state.restartCount);
}
@@ -240,19 +246,15 @@ public class FlatFileItemWriter extends ExecutionContextUserSupport implements I
/**
* Return the byte offset position of the cursor in the output file as a long integer.
*/
public long position() {
public long position() throws IOException {
long pos = 0;
if (fileChannel == null) {
return 0;
}
try {
outputBufferedWriter.flush();
pos = fileChannel.position();
} catch (IOException e) {
throw new InfrastructureException("An Error occured while trying to get filechannel position", e);
}
outputBufferedWriter.flush();
pos = fileChannel.position();
return pos;
@@ -308,38 +310,37 @@ public class FlatFileItemWriter extends ExecutionContextUserSupport implements I
* @param data
* @param offset
* @param length
* @throws IOException
*/
public void write(String line) {
public void write(String line) throws IOException {
if (!initialized) {
initializeBufferedWriter();
}
try {
outputBufferedWriter.write(line);
outputBufferedWriter.flush();
linesWritten++;
} catch (IOException e) {
throw new InfrastructureException("An Error occured while trying to write to FlatFileItemWriter", e);
}
outputBufferedWriter.write(line);
outputBufferedWriter.flush();
linesWritten++;
}
/**
* Truncate the output at the last known good point.
*
* @throws IOException
*/
public void truncate() {
try {
fileChannel.truncate(lastMarkedByteOffsetPosition);
fileChannel.position(lastMarkedByteOffsetPosition);
} catch (IOException e) {
throw new InfrastructureException("An Error occured while truncating output file", e);
}
public void truncate() throws IOException {
fileChannel.truncate(lastMarkedByteOffsetPosition);
fileChannel.position(lastMarkedByteOffsetPosition);
}
/**
* Mark the current position.
*/
public void mark() {
lastMarkedByteOffsetPosition = this.position();
try {
lastMarkedByteOffsetPosition = this.position();
} catch (IOException e) {
throw new MarkFailedException("Unable to get position for mark", e);
}
}
/**
@@ -381,12 +382,12 @@ public class FlatFileItemWriter extends ExecutionContextUserSupport implements I
try {
fileChannel = (new FileOutputStream(file.getAbsolutePath(), true)).getChannel();
} catch (FileNotFoundException fnfe) {
throw new ConfigurationException("Bad filename property parameter " + file, fnfe);
throw new ItemStreamException("Bad filename property parameter " + file, fnfe);
}
outputBufferedWriter = getBufferedWriter(fileChannel, encoding, bufferSize);
// in case of restarting reset position to last commited point
// in case of restarting reset position to last committed point
if (restarted) {
this.reset();
}
@@ -423,9 +424,13 @@ public class FlatFileItemWriter extends ExecutionContextUserSupport implements I
* moved to (if it is, throws an environment exception), then it truncates the file to that reset position, and
* set the cursor to start writing at that point.
*/
public void reset() throws InfrastructureException {
public void reset() throws ResetFailedException {
checkFileSize();
getOutputState().truncate();
try {
getOutputState().truncate();
} catch (IOException e) {
throw new ResetFailedException("Unable to truncate file", e);
}
}
/**
@@ -440,11 +445,11 @@ public class FlatFileItemWriter extends ExecutionContextUserSupport implements I
outputBufferedWriter.flush();
size = fileChannel.size();
} catch (IOException e) {
throw new InfrastructureException("An Error occured while checking file size", e);
throw new ResetFailedException("An Error occured while checking file size", e);
}
if (size < lastMarkedByteOffsetPosition) {
throw new InfrastructureException("Current file size is smaller than size at last commit");
throw new ResetFailedException("Current file size is smaller than size at last commit");
}
}
@@ -453,7 +458,7 @@ public class FlatFileItemWriter extends ExecutionContextUserSupport implements I
public void clear() throws ClearFailedException {
try {
getOutputState().reset();
} catch (InfrastructureException e) {
} catch (Exception e) {
throw new ClearFailedException("Could not reset the state of the writer", e);
}
}

View File

@@ -13,7 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.batch.io.exception;
package org.springframework.batch.item.file;
import org.springframework.batch.item.ParseException;
/**
* Exception thrown when errors are encountered
@@ -23,37 +25,31 @@ package org.springframework.batch.io.exception;
* an error table.
*
* @author Lucas Ward
*
* @author Ben Hale
*/
public class FlatFileParsingException extends ParsingException {
private static final long serialVersionUID = 2529197834044942724L;
public class FlatFileParseException extends ParseException {
private String input;
private int lineNumber;
public FlatFileParsingException(String message, String input) {
public FlatFileParseException(String message, String input) {
super(message);
this.input = input;
}
public FlatFileParsingException(String message, String input, int lineNumber) {
public FlatFileParseException(String message, String input, int lineNumber) {
super(message);
this.input = input;
this.lineNumber = lineNumber;
}
public FlatFileParsingException(String message, Throwable cause, String input, int lineNumber) {
public FlatFileParseException(String message, Throwable cause, String input, int lineNumber) {
super(message, cause);
this.input = input;
this.lineNumber = lineNumber;
}
public FlatFileParsingException(Throwable cause, String input) {
super(cause);
this.input = input;
}
public String getInput() {
return input;
}

View File

@@ -19,7 +19,7 @@ package org.springframework.batch.item.file.transform;
import java.util.ArrayList;
import java.util.List;
import org.springframework.batch.io.exception.ConfigurationException;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
/**
@@ -40,8 +40,7 @@ public class DelimitedLineTokenizer extends AbstractLineTokenizer {
public static final char DELIMITER_COMMA = ',';
/**
* Convenient constant for the common case of a " character used to escape
* delimiters or line endings.
* Convenient constant for the common case of a " character used to escape delimiters or line endings.
*/
public static final char DEFAULT_QUOTE_CHARACTER = '"';
@@ -53,8 +52,8 @@ public class DelimitedLineTokenizer extends AbstractLineTokenizer {
private String quoteString;
/**
* Create a new instance of the {@link DelimitedLineTokenizer} class for the
* common case where the delimiter is a {@link #DELIMITER_COMMA comma}.
* Create a new instance of the {@link DelimitedLineTokenizer} class for the common case where the delimiter is a
* {@link #DELIMITER_COMMA comma}.
*
* @see #DelimitedLineTokenizer(char)
* @see #DELIMITER_COMMA
@@ -69,10 +68,8 @@ public class DelimitedLineTokenizer extends AbstractLineTokenizer {
* @param delimiter the desired delimiter
*/
public DelimitedLineTokenizer(char delimiter) {
if (delimiter == DEFAULT_QUOTE_CHARACTER) {
throw new ConfigurationException("'" + DEFAULT_QUOTE_CHARACTER
+ "' is not allowed as delimiter for tokenizers.");
}
Assert.state(delimiter != DEFAULT_QUOTE_CHARACTER, "[" + DEFAULT_QUOTE_CHARACTER
+ "] is not allowed as delimiter for tokenizers.");
this.delimiter = delimiter;
setQuoteCharacter(DEFAULT_QUOTE_CHARACTER);
@@ -80,6 +77,7 @@ public class DelimitedLineTokenizer extends AbstractLineTokenizer {
/**
* Setter for the delimiter character.
*
* @param delimiter
*/
public void setDelimiter(char delimiter) {
@@ -87,10 +85,9 @@ public class DelimitedLineTokenizer extends AbstractLineTokenizer {
}
/**
* Public setter for the quoteCharacter. The quote character can be used to
* extend a field across line endings or to enclose a String which contains
* the delimiter. Inside a quoted token the quote character can be used to
* escape itself, thus "a""b""c" is tokenized to a"b"c.
* Public setter for the quoteCharacter. The quote character can be used to extend a field across line endings or to
* enclose a String which contains the delimiter. Inside a quoted token the quote character can be used to escape
* itself, thus "a""b""c" is tokenized to a"b"c.
*
* @param quoteCharacter the quoteCharacter to set
*
@@ -102,8 +99,7 @@ public class DelimitedLineTokenizer extends AbstractLineTokenizer {
}
/**
* Yields the tokens resulting from the splitting of the supplied
* <code>line</code>.
* Yields the tokens resulting from the splitting of the supplied <code>line</code>.
*
* @param line the line to be tokenized
*
@@ -143,8 +139,7 @@ public class DelimitedLineTokenizer extends AbstractLineTokenizer {
}
lastCut = i + 1;
}
else if (isQuoteCharacter(currentChar)) {
} else if (isQuoteCharacter(currentChar)) {
inQuoted = !inQuoted;
}
@@ -154,9 +149,9 @@ public class DelimitedLineTokenizer extends AbstractLineTokenizer {
}
/**
* If the string is quoted strip (possibly with whitespace outside the
* quotes (which will be stripped), replace escaped quotes inside the
* string. Quotes are escaped with double instances of the quote character.
* If the string is quoted strip (possibly with whitespace outside the quotes (which will be stripped), replace
* escaped quotes inside the string. Quotes are escaped with double instances of the quote character.
*
* @param string
* @return the same string but stripped and unescaped if necessary
*/
@@ -166,7 +161,7 @@ public class DelimitedLineTokenizer extends AbstractLineTokenizer {
value = StringUtils.replace(value, "" + quoteCharacter + quoteCharacter, "" + quoteCharacter);
int endLength = value.length() - 1;
// used to deal with empty quoted values
if(endLength == 0) {
if (endLength == 0) {
endLength = 1;
}
string = value.substring(1, endLength);
@@ -176,9 +171,9 @@ public class DelimitedLineTokenizer extends AbstractLineTokenizer {
/**
* Is this string surrounded by quite characters?
*
* @param value
* @return true if the value starts and ends with the
* {@link #quoteCharacter}
* @return true if the value starts and ends with the {@link #quoteCharacter}
*/
private boolean isQuoted(String value) {
if (value.startsWith(quoteString) && value.endsWith(quoteString)) {
@@ -191,8 +186,7 @@ public class DelimitedLineTokenizer extends AbstractLineTokenizer {
* Is the supplied character the delimiter character?
*
* @param c the character to be checked
* @return <code>true</code> if the supplied character is the delimiter
* character
* @return <code>true</code> if the supplied character is the delimiter character
* @see DelimitedLineTokenizer#DelimitedLineTokenizer(char)
*/
private boolean isDelimiterCharacter(char c) {
@@ -203,8 +197,7 @@ public class DelimitedLineTokenizer extends AbstractLineTokenizer {
* Is the supplied character a quote character?
*
* @param c the character to be checked
* @return <code>true</code> if the supplied character is an quote
* character
* @return <code>true</code> if the supplied character is an quote character
* @see #setQuoteCharacter(char)
*/
protected boolean isQuoteCharacter(char c) {

View File

@@ -20,7 +20,6 @@ import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.batch.io.exception.ValidationException;
import org.springframework.validation.BeanPropertyBindingResult;
import org.springframework.validation.FieldError;

View File

@@ -14,21 +14,34 @@
* limitations under the License.
*/
package org.springframework.batch.io.exception;
package org.springframework.batch.item.validator;
import org.springframework.batch.item.ItemReaderException;
/**
* This exception should be thrown when there are validation errors.
*
* @author Ben Hale
*/
public class ValidationException extends ReadFailureException {
private static final long serialVersionUID = 7926495144451758088L;
public ValidationException(String message) {
super(message);
}
public class ValidationException extends ItemReaderException {
/**
* Create a new {@link ValidationException} based on a message and another exception.
*
* @param message the message for this exception
* @param cause the other exception
*/
public ValidationException(String message, Throwable cause) {
super(message, cause);
}
/**
* Create a new {@link ValidationException} based on a message.
*
* @param message the message for this exception
*/
public ValidationException(String message) {
super(message);
}
}

View File

@@ -16,7 +16,6 @@
package org.springframework.batch.item.validator;
import org.springframework.batch.io.exception.ValidationException;
/**
* Interface used to validate objects.

View File

@@ -19,7 +19,6 @@ package org.springframework.batch.support;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import org.springframework.batch.io.exception.DynamicMethodInvocationException;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.util.Assert;
import org.springframework.util.MethodInvoker;

View File

@@ -1,4 +1,4 @@
package org.springframework.batch.io.exception;
package org.springframework.batch.support;
import org.springframework.util.MethodInvoker;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.batch.io.exception;
package org.springframework.batch.common;
import junit.framework.TestCase;

View File

@@ -1,34 +0,0 @@
/*
* Copyright 2006-2007 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.batch.io.exception;
public class ConfigurationExceptionTests extends AbstractExceptionTests {
public Exception getException(String msg) throws Exception {
return new ConfigurationException(msg);
}
public Exception getException(Throwable t) throws Exception {
return new ConfigurationException(t);
}
public Exception getException(String msg, Throwable t) throws Exception {
return new ConfigurationException(msg, t);
}
}

View File

@@ -1,34 +0,0 @@
/*
* Copyright 2006-2007 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.batch.io.exception;
public class InfrastructureExceptionTests extends AbstractExceptionTests {
public Exception getException(String msg) throws Exception {
return new InfrastructureException(msg);
}
public Exception getException(Throwable t) throws Exception {
return new InfrastructureException(t);
}
public Exception getException(String msg, Throwable t) throws Exception {
return new InfrastructureException(msg, t);
}
}

View File

@@ -1,37 +0,0 @@
/*
* Copyright 2006-2007 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.batch.io.exception;
public class TransactionInvalidExceptionTests extends AbstractExceptionTests {
public Exception getException(String msg) throws Exception {
return new WriteFailureException(msg);
}
public Exception getException(Throwable t) throws Exception {
return new WriteFailureException(t);
}
public Exception getException(String msg, Throwable t) throws Exception {
return new WriteFailureException(msg, t);
}
public void testNothing() throws Exception {
// fool coverage tools...
}
}

View File

@@ -1,37 +0,0 @@
/*
* Copyright 2006-2007 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.batch.io.exception;
public class TransactionValidExceptionTests extends AbstractExceptionTests {
public Exception getException(String msg) throws Exception {
return new ReadFailureException(msg);
}
public Exception getException(Throwable t) throws Exception {
return new ReadFailureException(t);
}
public Exception getException(String msg, Throwable t) throws Exception {
return new ReadFailureException(msg, t);
}
public void testNothing() throws Exception {
// fool coverage tools...
}
}

View File

@@ -16,7 +16,7 @@
package org.springframework.batch.item;
import org.springframework.batch.io.exception.AbstractExceptionTests;
import org.springframework.batch.common.AbstractExceptionTests;
public class ItemStreamExceptionTests extends AbstractExceptionTests {

View File

@@ -16,7 +16,7 @@
package org.springframework.batch.item;
import org.springframework.batch.io.exception.AbstractExceptionTests;
import org.springframework.batch.common.AbstractExceptionTests;
public class MarkFailedExceptionTests extends AbstractExceptionTests {

View File

@@ -16,7 +16,7 @@
package org.springframework.batch.item;
import org.springframework.batch.io.exception.AbstractExceptionTests;
import org.springframework.batch.common.AbstractExceptionTests;
public class ResetFailedExceptionTests extends AbstractExceptionTests {

View File

@@ -3,8 +3,7 @@ package org.springframework.batch.item.adapter;
import java.util.ArrayList;
import java.util.List;
import org.springframework.batch.io.sample.domain.FooService;
import org.springframework.batch.item.adapter.ItemReaderAdapter;
import org.springframework.batch.item.sample.FooService;
import org.springframework.test.AbstractDependencyInjectionSpringContextTests;
/**
@@ -23,8 +22,7 @@ public class ItemReaderAdapterTests extends AbstractDependencyInjectionSpringCon
}
/**
* Regular usage scenario - items are retrieved from the service injected
* invoker points to.
* Regular usage scenario - items are retrieved from the service injected invoker points to.
*/
public void testNext() throws Exception {
List returnedItems = new ArrayList();

View File

@@ -2,10 +2,9 @@ package org.springframework.batch.item.adapter;
import java.util.List;
import org.springframework.batch.io.sample.domain.Foo;
import org.springframework.batch.io.sample.domain.FooService;
import org.springframework.batch.item.ItemWriter;
import org.springframework.batch.item.adapter.ItemWriterAdapter;
import org.springframework.batch.item.sample.Foo;
import org.springframework.batch.item.sample.FooService;
import org.springframework.test.AbstractDependencyInjectionSpringContextTests;
/**
@@ -16,41 +15,39 @@ import org.springframework.test.AbstractDependencyInjectionSpringContextTests;
public class ItemWriterAdapterTests extends AbstractDependencyInjectionSpringContextTests {
private ItemWriter processor;
private FooService fooService;
protected String getConfigPath() {
return "delegating-item-writer.xml";
}
/**
* Regular usage scenario - input object should be passed to
* the service the injected invoker points to.
* Regular usage scenario - input object should be passed to the service the injected invoker points to.
*/
public void testProcess() throws Exception {
Foo foo;
while ((foo = fooService.generateFoo()) != null) {
processor.write(foo);
}
List input = fooService.getGeneratedFoos();
List processed = fooService.getProcessedFoos();
assertEquals(input.size(), processed.size());
assertFalse(fooService.getProcessedFoos().isEmpty());
for (int i = 0; i < input.size(); i++) {
assertSame(input.get(i), processed.get(i));
}
}
//setter for auto-injection
// setter for auto-injection
public void setProcessor(ItemWriter processor) {
this.processor = processor;
}
//setter for auto-injection
// setter for auto-injection
public void setFooService(FooService fooService) {
this.fooService = fooService;
}

View File

@@ -2,9 +2,8 @@ package org.springframework.batch.item.adapter;
import java.util.List;
import org.springframework.batch.io.sample.domain.Foo;
import org.springframework.batch.io.sample.domain.FooService;
import org.springframework.batch.item.adapter.PropertyExtractingDelegatingItemWriter;
import org.springframework.batch.item.sample.Foo;
import org.springframework.batch.item.sample.FooService;
import org.springframework.test.AbstractDependencyInjectionSpringContextTests;
/**
@@ -12,32 +11,31 @@ import org.springframework.test.AbstractDependencyInjectionSpringContextTests;
*
* @author Robert Kasanicky
*/
public class PropertyExtractingDelegatingItemProccessorIntegrationTests
extends AbstractDependencyInjectionSpringContextTests {
public class PropertyExtractingDelegatingItemProccessorIntegrationTests extends
AbstractDependencyInjectionSpringContextTests {
private PropertyExtractingDelegatingItemWriter processor;
private FooService fooService;
protected String getConfigPath() {
return "pe-delegating-item-writer.xml";
}
/**
* Regular usage scenario - input object should be passed to
* the service the injected invoker points to.
* Regular usage scenario - input object should be passed to the service the injected invoker points to.
*/
public void testProcess() throws Exception {
Foo foo;
while ((foo = fooService.generateFoo()) != null) {
processor.write(foo);
}
List input = fooService.getGeneratedFoos();
List processed = fooService.getProcessedFooNameValuePairs();
assertEquals(input.size(), processed.size());
assertFalse(fooService.getProcessedFooNameValuePairs().isEmpty());
for (int i = 0; i < input.size(); i++) {
Foo inputFoo = (Foo) input.get(i);
Foo outputFoo = (Foo) processed.get(i);
@@ -45,7 +43,7 @@ public class PropertyExtractingDelegatingItemProccessorIntegrationTests
assertEquals(inputFoo.getValue(), outputFoo.getValue());
assertEquals(0, outputFoo.getId());
}
}
public void setProcessor(PropertyExtractingDelegatingItemWriter processor) {

View File

@@ -1,10 +1,10 @@
package org.springframework.batch.item.database;
import org.springframework.batch.io.sample.domain.Foo;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.batch.item.ItemReader;
import org.springframework.batch.item.ItemStream;
import org.springframework.batch.item.Skippable;
import org.springframework.batch.item.sample.Foo;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.test.AbstractTransactionalDataSourceSpringContextTests;
import org.springframework.util.Assert;

View File

@@ -1,9 +1,9 @@
package org.springframework.batch.item.database;
import org.springframework.batch.io.sample.domain.Foo;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.batch.item.ItemReader;
import org.springframework.batch.item.ItemStream;
import org.springframework.batch.item.sample.Foo;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.test.AbstractTransactionalDataSourceSpringContextTests;

View File

@@ -27,8 +27,6 @@ import java.util.Map;
import junit.framework.TestCase;
import org.easymock.MockControl;
import org.springframework.batch.item.database.BatchSqlUpdateItemWriter;
import org.springframework.batch.item.database.ItemPreparedStatementSetter;
import org.springframework.batch.repeat.RepeatContext;
import org.springframework.batch.repeat.context.RepeatContextSupport;
import org.springframework.batch.repeat.synch.RepeatSynchronizationManager;

View File

@@ -19,7 +19,7 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Map;
import org.springframework.batch.io.sample.domain.Foo;
import org.springframework.batch.item.sample.Foo;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.jdbc.core.support.JdbcDaoSupport;

View File

@@ -6,13 +6,11 @@ import java.util.Properties;
import junit.framework.TestCase;
import org.springframework.batch.io.sample.domain.Foo;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.batch.item.ItemReader;
import org.springframework.batch.item.ItemStream;
import org.springframework.batch.item.NoWorkFoundException;
import org.springframework.batch.item.database.DrivingQueryItemReader;
import org.springframework.batch.item.database.KeyGenerator;
import org.springframework.batch.item.sample.Foo;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.transaction.support.TransactionSynchronizationManager;
import org.springframework.util.Assert;

View File

@@ -15,7 +15,7 @@
*/
package org.springframework.batch.item.database;
import org.springframework.batch.io.sample.domain.Foo;
import org.springframework.batch.item.sample.Foo;
import org.springframework.jdbc.core.JdbcTemplate;
/**

View File

@@ -3,7 +3,6 @@ package org.springframework.batch.item.database;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.batch.item.ItemReader;
import org.springframework.batch.item.ItemStream;
import org.springframework.batch.item.database.DrivingQueryItemReader;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.jdbc.core.JdbcTemplate;

View File

@@ -3,7 +3,7 @@ package org.springframework.batch.item.database;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.springframework.batch.io.sample.domain.Foo;
import org.springframework.batch.item.sample.Foo;
import org.springframework.jdbc.core.RowMapper;

View File

@@ -25,7 +25,6 @@ import junit.framework.TestCase;
import org.springframework.batch.item.ClearFailedException;
import org.springframework.batch.item.FlushFailedException;
import org.springframework.batch.item.ItemWriter;
import org.springframework.batch.item.database.HibernateAwareItemWriter;
import org.springframework.batch.repeat.context.RepeatContextSupport;
import org.springframework.batch.repeat.synch.RepeatSynchronizationManager;
import org.springframework.dao.DataAccessException;

View File

@@ -4,7 +4,6 @@ import org.hibernate.SessionFactory;
import org.hibernate.StatelessSession;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.batch.item.ItemReader;
import org.springframework.batch.item.database.HibernateCursorItemReader;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.orm.hibernate3.LocalSessionFactoryBean;

View File

@@ -1,7 +1,6 @@
package org.springframework.batch.item.database;
import org.hibernate.Session;
import org.springframework.batch.item.database.HibernateCursorItemReader;
/**
* Tests for {@link HibernateCursorItemReader} using standard hibernate {@link Session}.

View File

@@ -1,7 +1,6 @@
package org.springframework.batch.item.database;
import org.springframework.batch.item.ItemReader;
import org.springframework.batch.item.database.IbatisDrivingQueryItemReader;
import org.springframework.batch.item.database.support.IbatisKeyGenerator;
import org.springframework.core.io.ClassPathResource;
import org.springframework.orm.ibatis.SqlMapClientFactoryBean;

View File

@@ -1,7 +1,6 @@
package org.springframework.batch.item.database;
import org.springframework.batch.item.ItemReader;
import org.springframework.batch.item.database.JdbcCursorItemReader;
/**
* Tests for {@link JdbcCursorItemReader}

View File

@@ -16,7 +16,6 @@
package org.springframework.batch.item.database;
import org.springframework.batch.item.ItemReader;
import org.springframework.batch.item.database.DrivingQueryItemReader;
import org.springframework.batch.item.database.support.MultipleColumnJdbcKeyGenerator;
/**

View File

@@ -1,7 +1,6 @@
package org.springframework.batch.item.database;
import org.springframework.batch.item.ItemReader;
import org.springframework.batch.item.database.DrivingQueryItemReader;
import org.springframework.batch.item.database.support.SingleColumnJdbcKeyGenerator;
public class SingleColumnJdbcDrivingQueryItemReaderIntegrationTests extends AbstractJdbcItemReaderIntegrationTests {

View File

@@ -3,7 +3,7 @@ package org.springframework.batch.item.database;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.springframework.batch.io.sample.domain.Foo;
import org.springframework.batch.item.sample.Foo;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.jdbc.core.support.JdbcDaoSupport;

View File

@@ -12,7 +12,6 @@ import junit.framework.TestCase;
import org.easymock.MockControl;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.batch.item.database.support.ColumnMapExecutionContextRowMapper;
import org.springframework.core.CollectionFactory;
import org.springframework.jdbc.core.PreparedStatementSetter;

View File

@@ -12,9 +12,6 @@ import java.util.Properties;
import java.util.Map.Entry;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.batch.item.database.support.ColumnMapExecutionContextRowMapper;
import org.springframework.batch.item.database.support.ExecutionContextRowMapper;
import org.springframework.batch.item.database.support.MultipleColumnJdbcKeyGenerator;
import org.springframework.core.CollectionFactory;
import org.springframework.jdbc.core.PreparedStatementSetter;
import org.springframework.test.AbstractTransactionalDataSourceSpringContextTests;

View File

@@ -3,7 +3,6 @@ package org.springframework.batch.item.database.support;
import java.util.List;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.batch.item.database.support.SingleColumnJdbcKeyGenerator;
import org.springframework.test.AbstractTransactionalDataSourceSpringContextTests;
/**

View File

@@ -21,7 +21,6 @@ import java.io.InputStream;
import junit.framework.TestCase;
import org.springframework.batch.io.exception.FlatFileParsingException;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.batch.item.ItemStreamException;
import org.springframework.batch.item.ReaderNotOpenException;
@@ -120,7 +119,7 @@ public class FlatFileItemReaderBasicTests extends TestCase {
itemReader.open(executionContext);
itemReader.read();
fail("Expected ParsingException");
} catch (FlatFileParsingException e) {
} catch (FlatFileParseException e) {
assertEquals(e.getInput(), TEST_STRING);
assertEquals(e.getLineNumber(), 1);
}
@@ -137,7 +136,7 @@ public class FlatFileItemReaderBasicTests extends TestCase {
itemReader.open(executionContext);
itemReader.read();
fail("Expected ParsingException");
} catch (FlatFileParsingException e) {
} catch (FlatFileParseException e) {
assertEquals(e.getInput(), TEST_STRING);
assertEquals(e.getLineNumber(), 1);
}

View File

@@ -14,25 +14,23 @@
* limitations under the License.
*/
package org.springframework.batch.io.exception;
package org.springframework.batch.item.file;
import org.springframework.batch.common.AbstractExceptionTests;
public class FlatFileParsingExceptionTests extends AbstractExceptionTests {
public class FlatFileParseExceptionTests extends AbstractExceptionTests {
public Exception getException(String msg) throws Exception {
return new FlatFileParsingException(msg, "bar");
}
public Exception getException(Throwable t) throws Exception {
return new FlatFileParsingException(t, "bar");
return new FlatFileParseException(msg, "bar");
}
public Exception getException(String msg, Throwable t) throws Exception {
return new FlatFileParsingException(msg, t, "bar", 100);
return new FlatFileParseException(msg, t, "bar", 100);
}
public void testMessageInputLineCount() throws Exception {
FlatFileParsingException exception = new FlatFileParsingException("foo", "bar", 100);
FlatFileParseException exception = new FlatFileParseException("foo", "bar", 100);
assertEquals("foo", exception.getMessage());
assertEquals("bar", exception.getInput());
assertEquals(100, exception.getLineNumber());

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.batch.io.sample.domain;
package org.springframework.batch.item.sample;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;

View File

@@ -1,4 +1,4 @@
package org.springframework.batch.io.sample.domain;
package org.springframework.batch.item.sample;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;

View File

@@ -1,4 +1,4 @@
package org.springframework.batch.io.sample.domain;
package org.springframework.batch.item.sample;
import java.util.ArrayList;
import java.util.List;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.batch.io.sample.domain;
package org.springframework.batch.item.sample;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.batch.io.sample.domain;
package org.springframework.batch.item.sample;
import java.util.Date;
import java.util.List;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.batch.io.sample.domain;
package org.springframework.batch.item.sample;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;

View File

@@ -7,7 +7,6 @@ import java.io.IOException;
import junit.framework.TestCase;
import org.springframework.batch.item.support.FileUtils;
import org.springframework.dao.DataAccessResourceFailureException;
import org.springframework.util.Assert;

View File

@@ -5,8 +5,6 @@ import java.util.ArrayList;
import junit.framework.TestCase;
import org.easymock.MockControl;
import org.springframework.batch.item.transform.CompositeItemTransformer;
import org.springframework.batch.item.transform.ItemTransformer;
/**
* Tests for {@link CompositeItemTransformer}.

View File

@@ -4,8 +4,6 @@ import junit.framework.TestCase;
import org.easymock.MockControl;
import org.springframework.batch.item.ItemWriter;
import org.springframework.batch.item.transform.ItemTransformer;
import org.springframework.batch.item.transform.ItemTransformerItemWriter;
/**
* Tests for {@link ItemTransformerItemWriter}.

View File

@@ -18,7 +18,6 @@ package org.springframework.batch.item.validator;
import junit.framework.TestCase;
import org.springframework.batch.io.exception.ValidationException;
import org.springframework.validation.Errors;
import org.springframework.validation.Validator;

View File

@@ -18,11 +18,8 @@ package org.springframework.batch.item.validator;
import junit.framework.TestCase;
import org.easymock.MockControl;
import org.springframework.batch.io.exception.ValidationException;
import org.springframework.batch.item.AbstractItemReader;
import org.springframework.batch.item.ItemReader;
import org.springframework.batch.item.validator.ValidatingItemReader;
import org.springframework.batch.item.validator.Validator;
/**
* @author Lucas Ward

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.batch.io.exception;
package org.springframework.batch.item.validator;
import org.springframework.batch.repeat.exception.AbstractExceptionTests;

View File

@@ -22,7 +22,6 @@ import java.util.List;
import junit.framework.TestCase;
import org.springframework.batch.io.exception.WriteFailureException;
import org.springframework.batch.repeat.context.RepeatContextSupport;
/**
@@ -45,8 +44,7 @@ public class SimpleLimitExceptionHandlerTests extends TestCase {
}
}
public void testInitializeWithNullContextAndNullException()
throws Exception {
public void testInitializeWithNullContextAndNullException() throws Exception {
try {
handler.handleException(null, null);
} catch (NullPointerException e) {
@@ -55,8 +53,7 @@ public class SimpleLimitExceptionHandlerTests extends TestCase {
}
/**
* Other than nominated exception type should be rethrown, ignoring the
* exception limit.
* Other than nominated exception type should be rethrown, ignoring the exception limit.
*
* @throws Exception
*/
@@ -71,15 +68,13 @@ public class SimpleLimitExceptionHandlerTests extends TestCase {
handler.handleException(new RepeatContextSupport(null), throwable);
fail("Exception swallowed.");
} catch (RuntimeException expected) {
assertTrue("Exception is rethrown, ignoring the exception limit",
true);
assertTrue("Exception is rethrown, ignoring the exception limit", true);
assertSame(expected, throwable);
}
}
/**
* TransactionInvalidException should only be rethrown below the exception
* limit.
* TransactionInvalidException should only be rethrown below the exception limit.
*
* @throws Exception
*/
@@ -89,16 +84,14 @@ public class SimpleLimitExceptionHandlerTests extends TestCase {
handler.setType(RuntimeException.class);
try {
handler.handleException(new RepeatContextSupport(null),
new RuntimeException("foo"));
handler.handleException(new RepeatContextSupport(null), new RuntimeException("foo"));
} catch (RuntimeException expected) {
fail("Unexpected exception.");
}
}
/**
* TransactionInvalidException should only be rethrown below the exception
* limit.
* TransactionInvalidException should only be rethrown below the exception limit.
*
* @throws Exception
*/
@@ -122,13 +115,11 @@ public class SimpleLimitExceptionHandlerTests extends TestCase {
}
/**
* TransactionInvalidException should only be rethrown below the exception
* limit.
* TransactionInvalidException should only be rethrown below the exception limit.
*
* @throws Exception
*/
public void testLimitedExceptionThrownFromSiblingsWhenUsingParent()
throws Exception {
public void testLimitedExceptionThrownFromSiblingsWhenUsingParent() throws Exception {
Throwable throwable = new RuntimeException("foo");
final int MORE_THAN_ZERO = 1;
@@ -150,9 +141,8 @@ public class SimpleLimitExceptionHandlerTests extends TestCase {
}
/**
* TransactionInvalidExceptions are swallowed until the exception limit is
* exceeded. After the limit is exceeded exceptions are rethrown as
* BatchCriticalExceptions
* TransactionInvalidExceptions are swallowed until the exception limit is exceeded. After the limit is exceeded
* exceptions are rethrown as BatchCriticalExceptions
*/
public void testExceptionNotThrownBelowLimit() throws Exception {
@@ -162,7 +152,7 @@ public class SimpleLimitExceptionHandlerTests extends TestCase {
List throwables = new ArrayList() {
{
for (int i = 0; i < (EXCEPTION_LIMIT); i++) {
add(new WriteFailureException("below exception limit"));
add(new RuntimeException("below exception limit"));
}
}
};
@@ -184,9 +174,8 @@ public class SimpleLimitExceptionHandlerTests extends TestCase {
}
/**
* TransactionInvalidExceptions are swallowed until the exception limit is
* exceeded. After the limit is exceeded exceptions are rethrown as
* BatchCriticalExceptions
* TransactionInvalidExceptions are swallowed until the exception limit is exceeded. After the limit is exceeded
* exceptions are rethrown as BatchCriticalExceptions
*/
public void testExceptionThrownAboveLimit() throws Exception {
@@ -196,13 +185,12 @@ public class SimpleLimitExceptionHandlerTests extends TestCase {
List throwables = new ArrayList() {
{
for (int i = 0; i < (EXCEPTION_LIMIT); i++) {
add(new WriteFailureException("below exception limit"));
add(new RuntimeException("below exception limit"));
}
}
};
throwables
.add(new WriteFailureException("above exception limit"));
throwables.add(new RuntimeException("above exception limit"));
RepeatContextSupport context = new RepeatContextSupport(null);
@@ -214,7 +202,7 @@ public class SimpleLimitExceptionHandlerTests extends TestCase {
assertTrue("exceptions up to limit are swallowed", true);
}
} catch (WriteFailureException expected) {
} catch (RuntimeException expected) {
assertEquals("above exception limit", expected.getMessage());
}

View File

@@ -2,9 +2,8 @@ package org.springframework.batch.support;
import junit.framework.TestCase;
import org.springframework.batch.io.exception.DynamicMethodInvocationException;
import org.springframework.batch.io.sample.domain.Foo;
import org.springframework.batch.io.sample.domain.FooService;
import org.springframework.batch.item.sample.Foo;
import org.springframework.batch.item.sample.FooService;
import org.springframework.util.Assert;
/**

View File

@@ -21,8 +21,6 @@ import java.util.Properties;
import junit.framework.TestCase;
import org.springframework.batch.support.DefaultPropertyEditorRegistrar;
import org.springframework.batch.support.IntArrayPropertyEditor;
import org.springframework.beans.BeanWrapperImpl;
import org.springframework.beans.propertyeditors.CustomNumberEditor;
import org.springframework.beans.propertyeditors.PropertiesEditor;

View File

@@ -7,6 +7,6 @@
<property name="targetMethod" value="generateFoo" />
</bean>
<bean id="fooService" class="org.springframework.batch.io.sample.domain.FooService" />
<bean id="fooService" class="org.springframework.batch.item.sample.FooService" />
</beans>

View File

@@ -7,6 +7,6 @@
<property name="targetMethod" value="processFoo" />
</bean>
<bean id="fooService" class="org.springframework.batch.io.sample.domain.FooService" />
<bean id="fooService" class="org.springframework.batch.item.sample.FooService" />
</beans>

View File

@@ -8,6 +8,6 @@
<property name="fieldsUsedAsTargetMethodArguments" value="name,value" />
</bean>
<bean id="fooService" class="org.springframework.batch.io.sample.domain.FooService" />
<bean id="fooService" class="org.springframework.batch.item.sample.FooService" />
</beans>

View File

@@ -4,7 +4,7 @@
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="org.springframework.batch.io.sample.domain.Foo" table="T_WRITE_FOOS">
<class name="org.springframework.batch.item.sample.Foo" table="T_WRITE_FOOS">
<id name="id" column="ID">
<generator class="increment"/>
</id>

View File

@@ -4,7 +4,7 @@
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="org.springframework.batch.io.sample.domain.Foo" table="T_FOOS">
<class name="org.springframework.batch.item.sample.Foo" table="T_FOOS">
<id name="id" column="ID">
<generator class="increment"/>
</id>

View File

@@ -4,7 +4,7 @@
<sqlMap namespace="Foo">
<resultMap id="fooResult" class="org.springframework.batch.io.sample.domain.Foo">
<resultMap id="fooResult" class="org.springframework.batch.item.sample.Foo">
<result property="id" column="ID" />
<result property="name" column="NAME" />
<result property="value" column="VALUE" />
@@ -26,15 +26,15 @@
select ID from T_FOOS where ID > #id#
</select>
<insert id="insertFoo" parameterClass="org.springframework.batch.io.sample.domain.Foo">
<insert id="insertFoo" parameterClass="org.springframework.batch.item.sample.Foo">
insert INTO T_WRITE_FOOS (ID, NAME, VALUE) VALUES (#id#, #name#, #value#)
</insert>
<update id="updateFoo" parameterClass="org.springframework.batch.io.sample.domain.Foo">
<update id="updateFoo" parameterClass="org.springframework.batch.item.sample.Foo">
update T_WRITE_FOOS set NAME = #name#, VALUE = #value# where ID = #id#
</update>
<delete id="deleteFoo" parameterClass="org.springframework.batch.io.sample.domain.Foo">
<delete id="deleteFoo" parameterClass="org.springframework.batch.item.sample.Foo">
delete from T_WRITE_FOOS where ID = #id#
</delete>

View File

@@ -16,7 +16,7 @@
package org.springframework.batch.sample.item.writer;
import org.springframework.batch.io.exception.InfrastructureException;
import org.springframework.batch.core.InfrastructureException;
import org.springframework.batch.item.writer.DelegatingItemWriter;
import org.springframework.batch.sample.domain.Order;

View File

@@ -17,7 +17,7 @@
package org.springframework.batch.sample.tasklet;
import org.springframework.batch.io.exception.InfrastructureException;
import org.springframework.batch.core.InfrastructureException;
import org.springframework.batch.item.ItemReader;
import org.springframework.batch.item.reader.DelegatingItemReader;

View File

@@ -20,7 +20,7 @@
<bean id="step1" parent="simpleStep">
<property name="itemReader">
<bean
class="org.springframework.batch.item.reader.ItemReaderAdapter">
class="org.springframework.batch.item.adapter.ItemReaderAdapter">
<property name="targetObject"
ref="delegatingObject" />
<property name="targetMethod" value="getData" />
@@ -28,7 +28,7 @@
</property>
<property name="itemWriter">
<bean
class="org.springframework.batch.item.writer.PropertyExtractingDelegatingItemWriter">
class="org.springframework.batch.item.adapter.PropertyExtractingDelegatingItemWriter">
<property name="targetObject"
ref="delegatingObject" />
<property name="targetMethod"

View File

@@ -16,8 +16,8 @@
package org.springframework.batch.sample;
import org.springframework.batch.core.InfrastructureException;
import org.springframework.batch.core.JobParameters;
import org.springframework.batch.io.exception.InfrastructureException;
import org.springframework.jdbc.core.JdbcOperations;
/**

View File

@@ -3,7 +3,7 @@ package org.springframework.batch.sample.item.writer;
import junit.framework.TestCase;
import org.easymock.MockControl;
import org.springframework.batch.io.exception.InfrastructureException;
import org.springframework.batch.core.InfrastructureException;
import org.springframework.batch.item.ItemWriter;
import org.springframework.batch.sample.domain.Order;
import org.springframework.batch.sample.item.writer.OrderWriter;

View File

@@ -4,7 +4,7 @@ import java.util.ArrayList;
import junit.framework.TestCase;
import org.springframework.batch.io.exception.InfrastructureException;
import org.springframework.batch.core.InfrastructureException;
import org.springframework.batch.item.reader.ListItemReader;
import org.springframework.batch.repeat.context.RepeatContextSupport;
import org.springframework.batch.repeat.synch.RepeatSynchronizationManager;

View File

@@ -19,10 +19,10 @@ package org.springframework.batch.sample.tasklet;
import java.util.ArrayList;
import java.util.List;
import org.springframework.batch.core.InfrastructureException;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.Step;
import org.springframework.batch.io.exception.InfrastructureException;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.util.ClassUtils;

View File

@@ -15,10 +15,10 @@
*/
package org.springframework.batch.sample.tasklet;
import org.springframework.batch.core.InfrastructureException;
import org.springframework.batch.core.JobInterruptedException;
import org.springframework.batch.core.Step;
import org.springframework.batch.core.StepExecution;
import org.springframework.batch.io.exception.InfrastructureException;
import org.springframework.beans.factory.BeanNameAware;
/**