RESOLVED - BATCH-616: Possible overflow in exit description if a stream.open() throws exception

exit description is now truncated also on save
This commit is contained in:
robokaso
2008-05-12 08:48:07 +00:00
parent 2ac85e454b
commit 879b9fcb12
3 changed files with 60 additions and 16 deletions

View File

@@ -38,17 +38,17 @@ import org.springframework.test.AbstractTransactionalDataSourceSpringContextTest
*/
public abstract class AbstractStepExecutionDaoTests extends AbstractTransactionalDataSourceSpringContextTests {
private StepExecutionDao dao;
protected StepExecutionDao dao;
private JobInstance jobInstance;
protected JobInstance jobInstance;
private JobExecution jobExecution;
protected JobExecution jobExecution;
private Step step;
protected Step step;
private StepExecution stepExecution;
protected StepExecution stepExecution;
private JobRepository repository;
protected JobRepository repository;
/**
* @return {@link StepExecutionDao} implementation ready for use.

View File

@@ -1,6 +1,8 @@
package org.springframework.batch.core.repository.dao;
import org.springframework.batch.core.StepExecution;
import org.springframework.batch.core.repository.JobRepository;
import org.springframework.batch.repeat.ExitStatus;
public class JdbcStepExecutionDaoTests extends AbstractStepExecutionDaoTests {
@@ -17,5 +19,34 @@ public class JdbcStepExecutionDaoTests extends AbstractStepExecutionDaoTests {
protected String[] getConfigLocations() {
return new String[] { "sql-dao-test.xml" };
}
/**
* Long exit descriptions are truncated on both save and update.
*/
public void testTruncateExitDescription() {
StringBuffer sb = new StringBuffer();
for (int i = 0; i < 100; i++) {
sb.append("too long exit description");
}
String longDescription = sb.toString();
ExitStatus exitStatus = ExitStatus.FAILED.addExitDescription(longDescription);
stepExecution.setExitStatus(exitStatus);
dao.saveStepExecution(stepExecution);
StepExecution retrievedAfterSave = dao.getStepExecution(jobExecution, step);
assertTrue("Exit description should be truncated", retrievedAfterSave.getExitStatus().getExitDescription()
.length() < stepExecution.getExitStatus().getExitDescription().length());
dao.updateStepExecution(stepExecution);
StepExecution retrievedAfterUpdate = dao.getStepExecution(jobExecution, step);
assertTrue("Exit description should be truncated", retrievedAfterUpdate.getExitStatus().getExitDescription()
.length() < stepExecution.getExitStatus().getExitDescription().length());
}
}