Re-instate tests for optimistic locking in step dao

This commit is contained in:
dsyer
2007-12-19 21:06:31 +00:00
parent 79e7ebedd4
commit 112150566c
3 changed files with 19 additions and 411 deletions

View File

@@ -216,28 +216,25 @@ public abstract class AbstractStepDaoTests extends AbstractTransactionalDataSour
stepDao.save(execution);
assertEquals(2, stepDao.getStepExecutionCount(step1.getId()));
}
// Commenting out, since hibernate dao's are being deprecated for m4.
// public void testUpdateStepExecutionVersion() throws Exception {
// int before = stepExecution.getVersion().intValue();
// stepDao.update(stepExecution);
// int after = stepExecution.getVersion().intValue();
// assertEquals("StepExecution version not updated", before+1, after);
// }
public void testUpdateStepExecutionVersion() throws Exception {
int before = stepExecution.getVersion().intValue();
stepDao.update(stepExecution);
int after = stepExecution.getVersion().intValue();
assertEquals("StepExecution version not updated", before+1, after);
}
// This test currently fails because it's expecting behaviour in the stepExecution that was lost because of
// how SVN handles file renaming, it should be relevant once the code is reintroduced.
// public void testUpdateStepExecutionOptimisticLocking() throws Exception {
// stepExecution.incrementVersion(); // not really allowed outside dao code
// try {
// stepDao.update(stepExecution);
// fail("Expected OptimisticLockingFailureException");
// }
// catch (OptimisticLockingFailureException e) {
// // expected
// assertTrue("Exception message should contain step execution id: "+e.getMessage(), e.getMessage().indexOf(""+stepExecution.getId())>=0);
// assertTrue("Exception message should contain step execution version: "+e.getMessage(), e.getMessage().indexOf(""+stepExecution.getVersion())>=0);
// }
// }
public void testUpdateStepExecutionOptimisticLocking() throws Exception {
stepExecution.incrementVersion(); // not really allowed outside dao code
try {
stepDao.update(stepExecution);
fail("Expected OptimisticLockingFailureException");
}
catch (OptimisticLockingFailureException e) {
// expected
assertTrue("Exception message should contain step execution id: "+e.getMessage(), e.getMessage().indexOf(""+stepExecution.getId())>=0);
assertTrue("Exception message should contain step execution version: "+e.getMessage(), e.getMessage().indexOf(""+stepExecution.getVersion())>=0);
}
}
}

View File

@@ -171,17 +171,11 @@ public class JdbcStepDaoPrefixTests extends TestCase {
return 1;
}
/* (non-Javadoc)
* @see org.springframework.jdbc.core.JdbcTemplate#update(java.lang.String, java.lang.Object[], int[])
*/
public int update(String sql, Object[] args, int[] argTypes) throws DataAccessException {
this.sql = sql;
return 1;
}
/* (non-Javadoc)
* @see org.springframework.jdbc.core.JdbcTemplate#query(java.lang.String, java.lang.Object[], int[], org.springframework.jdbc.core.RowMapper)
*/
public List query(String sql, Object[] args, RowMapper rowMapper) throws DataAccessException {
this.sql = sql;
return null;

View File

@@ -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;
}
}