OPEN - issue BATCH-170: Concurrent modification of StepExecution when running an asynchrounous step operation
http://opensource.atlassian.com/projects/spring/browse/BATCH-170 Fix broken tests.
This commit is contained in:
@@ -310,6 +310,7 @@ public class SqlStepDao implements StepDao, InitializingBean {
|
||||
cascadeJobExecution(stepExecution.getJobExecution());
|
||||
|
||||
stepExecution.setId(new Long(stepExecutionIncrementer.nextLongValue()));
|
||||
stepExecution.incrementVersion(); // should be 0 now
|
||||
Object[] parameters = new Object[] { stepExecution.getId(), new Long(0), stepExecution.getStepId(),
|
||||
stepExecution.getJobExecutionId(), stepExecution.getStartTime(), stepExecution.getEndTime(),
|
||||
stepExecution.getStatus().toString(), stepExecution.getCommitCount(), stepExecution.getTaskCount(),
|
||||
|
||||
@@ -1,383 +0,0 @@
|
||||
package org.springframework.batch.execution.repository.dao;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.jdbc.core.BatchPreparedStatementSetter;
|
||||
import org.springframework.jdbc.core.CallableStatementCallback;
|
||||
import org.springframework.jdbc.core.CallableStatementCreator;
|
||||
import org.springframework.jdbc.core.ConnectionCallback;
|
||||
import org.springframework.jdbc.core.JdbcOperations;
|
||||
import org.springframework.jdbc.core.PreparedStatementCallback;
|
||||
import org.springframework.jdbc.core.PreparedStatementCreator;
|
||||
import org.springframework.jdbc.core.PreparedStatementSetter;
|
||||
import org.springframework.jdbc.core.ResultSetExtractor;
|
||||
import org.springframework.jdbc.core.RowCallbackHandler;
|
||||
import org.springframework.jdbc.core.RowMapper;
|
||||
import org.springframework.jdbc.core.StatementCallback;
|
||||
import org.springframework.jdbc.support.KeyHolder;
|
||||
import org.springframework.jdbc.support.rowset.SqlRowSet;
|
||||
|
||||
public class MockJdbcTemplate implements JdbcOperations {
|
||||
|
||||
private String sqlStatement = "";
|
||||
|
||||
public String getSqlStatement() {
|
||||
return sqlStatement;
|
||||
}
|
||||
|
||||
public int[] batchUpdate(String[] sql) throws DataAccessException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public int[] batchUpdate(String sql, BatchPreparedStatementSetter pss)
|
||||
throws DataAccessException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public Map call(CallableStatementCreator csc, List declaredParameters)
|
||||
throws DataAccessException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public Object execute(ConnectionCallback action) throws DataAccessException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public Object execute(StatementCallback action) throws DataAccessException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public void execute(String sql) throws DataAccessException {
|
||||
// TODO Auto-generated method stub
|
||||
sqlStatement = sql;
|
||||
}
|
||||
|
||||
public Object execute(PreparedStatementCreator psc,
|
||||
PreparedStatementCallback action) throws DataAccessException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public Object execute(String sql, PreparedStatementCallback action)
|
||||
throws DataAccessException {
|
||||
// TODO Auto-generated method stub
|
||||
sqlStatement = sql;
|
||||
return null;
|
||||
}
|
||||
|
||||
public Object execute(CallableStatementCreator csc,
|
||||
CallableStatementCallback action) throws DataAccessException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public Object execute(String callString, CallableStatementCallback action)
|
||||
throws DataAccessException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public Object query(String sql, ResultSetExtractor rse)
|
||||
throws DataAccessException {
|
||||
// TODO Auto-generated method stub
|
||||
sqlStatement = sql;
|
||||
return null;
|
||||
}
|
||||
|
||||
public void query(String sql, RowCallbackHandler rch)
|
||||
throws DataAccessException {
|
||||
// TODO Auto-generated method stub
|
||||
sqlStatement = sql;
|
||||
}
|
||||
|
||||
public List query(String sql, RowMapper rowMapper)
|
||||
throws DataAccessException {
|
||||
// TODO Auto-generated method stub
|
||||
sqlStatement = sql;
|
||||
return null;
|
||||
}
|
||||
|
||||
public Object query(PreparedStatementCreator psc, ResultSetExtractor rse)
|
||||
throws DataAccessException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public void query(PreparedStatementCreator psc, RowCallbackHandler rch)
|
||||
throws DataAccessException {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
public List query(PreparedStatementCreator psc, RowMapper rowMapper)
|
||||
throws DataAccessException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public Object query(String sql, PreparedStatementSetter pss,
|
||||
ResultSetExtractor rse) throws DataAccessException {
|
||||
// TODO Auto-generated method stub
|
||||
sqlStatement = sql;
|
||||
return null;
|
||||
}
|
||||
|
||||
public Object query(String sql, Object[] args, ResultSetExtractor rse)
|
||||
throws DataAccessException {
|
||||
// TODO Auto-generated method stub
|
||||
sqlStatement = sql;
|
||||
return null;
|
||||
}
|
||||
|
||||
public void query(String sql, PreparedStatementSetter pss,
|
||||
RowCallbackHandler rch) throws DataAccessException {
|
||||
// TODO Auto-generated method stub
|
||||
sqlStatement = sql;
|
||||
}
|
||||
|
||||
public void query(String sql, Object[] args, RowCallbackHandler rch)
|
||||
throws DataAccessException {
|
||||
// TODO Auto-generated method stub
|
||||
sqlStatement = sql;
|
||||
}
|
||||
|
||||
public List query(String sql, PreparedStatementSetter pss,
|
||||
RowMapper rowMapper) throws DataAccessException {
|
||||
// TODO Auto-generated method stub
|
||||
sqlStatement = sql;
|
||||
return null;
|
||||
}
|
||||
|
||||
public List query(String sql, Object[] args, RowMapper rowMapper)
|
||||
throws DataAccessException {
|
||||
// TODO Auto-generated method stub
|
||||
sqlStatement = sql;
|
||||
return null;
|
||||
}
|
||||
|
||||
public Object query(String sql, Object[] args, int[] argTypes,
|
||||
ResultSetExtractor rse) throws DataAccessException {
|
||||
// TODO Auto-generated method stub
|
||||
sqlStatement = sql;
|
||||
return null;
|
||||
}
|
||||
|
||||
public void query(String sql, Object[] args, int[] argTypes,
|
||||
RowCallbackHandler rch) throws DataAccessException {
|
||||
// TODO Auto-generated method stub
|
||||
sqlStatement = sql;
|
||||
}
|
||||
|
||||
public List query(String sql, Object[] args, int[] argTypes,
|
||||
RowMapper rowMapper) throws DataAccessException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public int queryForInt(String sql) throws DataAccessException {
|
||||
// TODO Auto-generated method stub
|
||||
sqlStatement = sql;
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int queryForInt(String sql, Object[] args)
|
||||
throws DataAccessException {
|
||||
// TODO Auto-generated method stub
|
||||
sqlStatement = sql;
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int queryForInt(String sql, Object[] args, int[] argTypes)
|
||||
throws DataAccessException {
|
||||
// TODO Auto-generated method stub
|
||||
sqlStatement = sql;
|
||||
return 0;
|
||||
}
|
||||
|
||||
public List queryForList(String sql) throws DataAccessException {
|
||||
// TODO Auto-generated method stub
|
||||
sqlStatement = sql;
|
||||
return null;
|
||||
}
|
||||
|
||||
public List queryForList(String sql, Class elementType)
|
||||
throws DataAccessException {
|
||||
// TODO Auto-generated method stub
|
||||
sqlStatement = sql;
|
||||
return null;
|
||||
}
|
||||
|
||||
public List queryForList(String sql, Object[] args)
|
||||
throws DataAccessException {
|
||||
// TODO Auto-generated method stub
|
||||
sqlStatement = sql;
|
||||
return null;
|
||||
}
|
||||
|
||||
public List queryForList(String sql, Object[] args, Class elementType)
|
||||
throws DataAccessException {
|
||||
// TODO Auto-generated method stub
|
||||
sqlStatement = sql;
|
||||
return null;
|
||||
}
|
||||
|
||||
public List queryForList(String sql, Object[] args, int[] argTypes)
|
||||
throws DataAccessException {
|
||||
// TODO Auto-generated method stub
|
||||
sqlStatement = sql;
|
||||
return null;
|
||||
}
|
||||
|
||||
public List queryForList(String sql, Object[] args, int[] argTypes,
|
||||
Class elementType) throws DataAccessException {
|
||||
// TODO Auto-generated method stub
|
||||
sqlStatement = sql;
|
||||
return null;
|
||||
}
|
||||
|
||||
public long queryForLong(String sql) throws DataAccessException {
|
||||
// TODO Auto-generated method stub
|
||||
sqlStatement = sql;
|
||||
return 0;
|
||||
}
|
||||
|
||||
public long queryForLong(String sql, Object[] args)
|
||||
throws DataAccessException {
|
||||
// TODO Auto-generated method stub
|
||||
sqlStatement = sql;
|
||||
return 0;
|
||||
}
|
||||
|
||||
public long queryForLong(String sql, Object[] args, int[] argTypes)
|
||||
throws DataAccessException {
|
||||
// TODO Auto-generated method stub
|
||||
sqlStatement = sql;
|
||||
return 0;
|
||||
}
|
||||
|
||||
public Map queryForMap(String sql) throws DataAccessException {
|
||||
// TODO Auto-generated method stub
|
||||
sqlStatement = sql;
|
||||
return null;
|
||||
}
|
||||
|
||||
public Map queryForMap(String sql, Object[] args)
|
||||
throws DataAccessException {
|
||||
// TODO Auto-generated method stub
|
||||
sqlStatement = sql;
|
||||
return null;
|
||||
}
|
||||
|
||||
public Map queryForMap(String sql, Object[] args, int[] argTypes)
|
||||
throws DataAccessException {
|
||||
// TODO Auto-generated method stub
|
||||
sqlStatement = sql;
|
||||
return null;
|
||||
}
|
||||
|
||||
public Object queryForObject(String sql, RowMapper rowMapper)
|
||||
throws DataAccessException {
|
||||
// TODO Auto-generated method stub
|
||||
sqlStatement = sql;
|
||||
return null;
|
||||
}
|
||||
|
||||
public Object queryForObject(String sql, Class requiredType)
|
||||
throws DataAccessException {
|
||||
// TODO Auto-generated method stub
|
||||
sqlStatement = sql;
|
||||
return null;
|
||||
}
|
||||
|
||||
public Object queryForObject(String sql, Object[] args, RowMapper rowMapper)
|
||||
throws DataAccessException {
|
||||
// TODO Auto-generated method stub
|
||||
sqlStatement = sql;
|
||||
return null;
|
||||
}
|
||||
|
||||
public Object queryForObject(String sql, Object[] args, Class requiredType)
|
||||
throws DataAccessException {
|
||||
// TODO Auto-generated method stub
|
||||
sqlStatement = sql;
|
||||
return null;
|
||||
}
|
||||
|
||||
public Object queryForObject(String sql, Object[] args, int[] argTypes,
|
||||
RowMapper rowMapper) throws DataAccessException {
|
||||
// TODO Auto-generated method stub
|
||||
sqlStatement = sql;
|
||||
return null;
|
||||
}
|
||||
|
||||
public Object queryForObject(String sql, Object[] args, int[] argTypes,
|
||||
Class requiredType) throws DataAccessException {
|
||||
// TODO Auto-generated method stub
|
||||
sqlStatement = sql;
|
||||
return null;
|
||||
}
|
||||
|
||||
public SqlRowSet queryForRowSet(String sql) throws DataAccessException {
|
||||
// TODO Auto-generated method stub
|
||||
sqlStatement = sql;
|
||||
return null;
|
||||
}
|
||||
|
||||
public SqlRowSet queryForRowSet(String sql, Object[] args)
|
||||
throws DataAccessException {
|
||||
// TODO Auto-generated method stub
|
||||
sqlStatement = sql;
|
||||
return null;
|
||||
}
|
||||
|
||||
public SqlRowSet queryForRowSet(String sql, Object[] args, int[] argTypes)
|
||||
throws DataAccessException {
|
||||
// TODO Auto-generated method stub
|
||||
sqlStatement = sql;
|
||||
return null;
|
||||
}
|
||||
|
||||
public int update(String sql) throws DataAccessException {
|
||||
// TODO Auto-generated method stub
|
||||
sqlStatement = sql;
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int update(PreparedStatementCreator psc) throws DataAccessException {
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int update(PreparedStatementCreator psc, KeyHolder generatedKeyHolder)
|
||||
throws DataAccessException {
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int update(String sql, PreparedStatementSetter pss)
|
||||
throws DataAccessException {
|
||||
// TODO Auto-generated method stub
|
||||
sqlStatement = sql;
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int update(String sql, Object[] args) throws DataAccessException {
|
||||
// TODO Auto-generated method stub
|
||||
sqlStatement = sql;
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int update(String sql, Object[] args, int[] argTypes)
|
||||
throws DataAccessException {
|
||||
// TODO Auto-generated method stub
|
||||
sqlStatement = sql;
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package org.springframework.batch.execution.repository.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.easymock.MockControl;
|
||||
@@ -8,6 +10,9 @@ import org.springframework.batch.core.domain.JobExecution;
|
||||
import org.springframework.batch.core.domain.JobInstance;
|
||||
import org.springframework.batch.core.domain.StepExecution;
|
||||
import org.springframework.batch.core.domain.StepInstance;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.jdbc.core.RowMapper;
|
||||
import org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer;
|
||||
|
||||
/**
|
||||
@@ -46,6 +51,7 @@ public class SqlStepDaoPrefixTests extends TestCase {
|
||||
stepDao.setStepExecutionIncrementer(stepExecutionIncrementer);
|
||||
stepDao.setStepIncrementer(stepIncrementer);
|
||||
stepExecution.setId(new Long(1));
|
||||
stepExecution.incrementVersion();
|
||||
step.setStatus(BatchStatus.STARTED);
|
||||
|
||||
job.addStep(step);
|
||||
@@ -156,4 +162,33 @@ public class SqlStepDaoPrefixTests extends TestCase {
|
||||
assertTrue(jdbcTemplate.getSqlStatement().indexOf("BATCH_STEP_EXECUTION") != -1);
|
||||
}
|
||||
|
||||
private class MockJdbcTemplate extends JdbcTemplate {
|
||||
|
||||
private String sqlStatement = "";
|
||||
|
||||
public String getSqlStatement() {
|
||||
return sqlStatement;
|
||||
}
|
||||
|
||||
public List query(String sql, Object[] args, RowMapper rse) throws DataAccessException {
|
||||
// TODO Auto-generated method stub
|
||||
sqlStatement = sql;
|
||||
return null;
|
||||
}
|
||||
|
||||
public int update(String sql, Object[] args, int[] argTypes) throws DataAccessException {
|
||||
// TODO Auto-generated method stub
|
||||
sqlStatement = sql;
|
||||
return 1;
|
||||
}
|
||||
|
||||
public int update(String sql, Object[] args) throws DataAccessException {
|
||||
// TODO Auto-generated method stub
|
||||
sqlStatement = sql;
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user