OPEN - issue BATCH-385: Merge user attributes in StepContext with ExecutionContext

http://jira.springframework.org/browse/BATCH-385
This commit is contained in:
dsyer
2008-02-29 10:52:06 +00:00
parent f4f3adac86
commit 42904865de

View File

@@ -1,41 +0,0 @@
package org.springframework.batch.sample.item.writer;
import org.springframework.batch.core.domain.JobExecution;
import org.springframework.batch.core.domain.JobInstance;
import org.springframework.batch.core.domain.JobParameters;
import org.springframework.batch.core.domain.StepExecution;
import org.springframework.batch.execution.scope.SimpleStepContext;
import org.springframework.batch.execution.scope.StepSynchronizationManager;
import org.springframework.batch.sample.tasklet.JobSupport;
import org.springframework.batch.sample.tasklet.StepSupport;
import org.springframework.test.AbstractTransactionalDataSourceSpringContextTests;
import org.springframework.util.ClassUtils;
public class StagingItemProcessorTests extends AbstractTransactionalDataSourceSpringContextTests {
private StagingItemWriter writer;
public void setProcessor(StagingItemWriter processor) {
this.writer = processor;
}
protected String[] getConfigLocations() {
return new String[] { ClassUtils.addResourcePathToPackagePath(StagingItemWriter.class,
"staging-test-context.xml") };
}
protected void prepareTestInstance() throws Exception {
SimpleStepContext stepScopeContext = new SimpleStepContext(new StepExecution(new StepSupport("stepName"),
new JobExecution(new JobInstance(new Long(12), new JobParameters(), new JobSupport("job")))));
StepSynchronizationManager.register(stepScopeContext);
super.prepareTestInstance();
}
public void testProcessInsertsNewItem() throws Exception {
int before = getJdbcTemplate().queryForInt("SELECT COUNT(*) from BATCH_STAGING");
writer.write("FOO");
int after = getJdbcTemplate().queryForInt("SELECT COUNT(*) from BATCH_STAGING");
assertEquals(before + 1, after);
}
}