IN PROGRESS - BATCH-709: Change all collections to use generics

This commit is contained in:
robokaso
2008-07-17 12:55:50 +00:00
parent 475dce7649
commit 1422352918
18 changed files with 54 additions and 52 deletions

View File

@@ -66,7 +66,7 @@ public class RepeatOperationsInterceptorTests extends TestCase {
}
public void testSetTemplate() throws Exception {
final List calls = new ArrayList();
final List<Object> calls = new ArrayList<Object>();
interceptor.setRepeatOperations(new RepeatOperations() {
public ExitStatus iterate(RepeatCallback callback) {
try {
@@ -85,7 +85,7 @@ public class RepeatOperationsInterceptorTests extends TestCase {
}
public void testCallbackNotExecuted() throws Exception {
final List calls = new ArrayList();
final List<Object> calls = new ArrayList<Object>();
interceptor.setRepeatOperations(new RepeatOperations() {
public ExitStatus iterate(RepeatCallback callback) {
calls.add(null);
@@ -157,7 +157,7 @@ public class RepeatOperationsInterceptorTests extends TestCase {
public void testInterceptorChainWithRetry() throws Exception {
((Advised) service).addAdvice(interceptor);
final List list = new ArrayList();
final List<Object> list = new ArrayList<Object>();
((Advised) service).addAdvice(new MethodInterceptor() {
public Object invoke(MethodInvocation invocation) throws Throwable {
list.add("chain");

View File

@@ -33,7 +33,7 @@ public class CompositeRepeatListenerTests extends TestCase {
private CompositeRepeatListener listener = new CompositeRepeatListener();
private RepeatContext context = new RepeatContextSupport(null);
private List list = new ArrayList();
private List<Object> list = new ArrayList<Object>();
/**
* Test method for {@link CompositeRepeatListener#setListeners(RepeatListener[])}.

View File

@@ -35,7 +35,7 @@ public class RepeatListenerTests extends TestCase {
public void testBeforeInterceptors() throws Exception {
RepeatTemplate template = new RepeatTemplate();
final List calls = new ArrayList();
final List<Object> calls = new ArrayList<Object>();
template.setListeners(new RepeatListener[] { new RepeatListenerSupport() {
public void before(RepeatContext context) {
calls.add("1");
@@ -61,7 +61,7 @@ public class RepeatListenerTests extends TestCase {
public void testBeforeInterceptorCanVeto() throws Exception {
RepeatTemplate template = new RepeatTemplate();
final List calls = new ArrayList();
final List<Object> calls = new ArrayList<Object>();
template.registerListener(new RepeatListenerSupport() {
public void before(RepeatContext context) {
calls.add("1");
@@ -81,7 +81,7 @@ public class RepeatListenerTests extends TestCase {
public void testAfterInterceptors() throws Exception {
RepeatTemplate template = new RepeatTemplate();
final List calls = new ArrayList();
final List<Object> calls = new ArrayList<Object>();
template.setListeners(new RepeatListener[] { new RepeatListenerSupport() {
public void after(RepeatContext context, ExitStatus result) {
calls.add("1");
@@ -105,7 +105,7 @@ public class RepeatListenerTests extends TestCase {
public void testOpenInterceptors() throws Exception {
RepeatTemplate template = new RepeatTemplate();
final List calls = new ArrayList();
final List<Object> calls = new ArrayList<Object>();
template.setListeners(new RepeatListener[] { new RepeatListenerSupport() {
public void open(RepeatContext context) {
calls.add("1");
@@ -128,7 +128,7 @@ public class RepeatListenerTests extends TestCase {
public void testSingleOpenInterceptor() throws Exception {
RepeatTemplate template = new RepeatTemplate();
final List calls = new ArrayList();
final List<Object> calls = new ArrayList<Object>();
template.registerListener(new RepeatListenerSupport() {
public void open(RepeatContext context) {
calls.add("1");
@@ -147,7 +147,7 @@ public class RepeatListenerTests extends TestCase {
public void testCloseInterceptors() throws Exception {
RepeatTemplate template = new RepeatTemplate();
final List calls = new ArrayList();
final List<Object> calls = new ArrayList<Object>();
template.setListeners(new RepeatListener[] { new RepeatListenerSupport() {
public void close(RepeatContext context) {
calls.add("1");
@@ -172,7 +172,7 @@ public class RepeatListenerTests extends TestCase {
public void testOnErrorInterceptors() throws Exception {
RepeatTemplate template = new RepeatTemplate();
final List calls = new ArrayList();
final List<Object> calls = new ArrayList<Object>();
template.setListeners(new RepeatListener[] { new RepeatListenerSupport() {
public void onError(RepeatContext context, Throwable t) {
calls.add("1");
@@ -199,7 +199,7 @@ public class RepeatListenerTests extends TestCase {
public void testOnErrorInterceptorsPrecedence() throws Exception {
RepeatTemplate template = new RepeatTemplate();
final List calls = new ArrayList();
final List<Object> calls = new ArrayList<Object>();
template.setListeners(new RepeatListener[] { new RepeatListenerSupport() {
public void after(RepeatContext context, ExitStatus result) {
calls.add("1");
@@ -228,8 +228,8 @@ public class RepeatListenerTests extends TestCase {
public void testAsynchronousOnErrorInterceptorsPrecedence() throws Exception {
TaskExecutorRepeatTemplate template = new TaskExecutorRepeatTemplate();
template.setTaskExecutor(new SimpleAsyncTaskExecutor());
final List calls = new ArrayList();
final List fails = new ArrayList();
final List<Object> calls = new ArrayList<Object>();
final List<Object> fails = new ArrayList<Object>();
template.setListeners(new RepeatListener[] { new RepeatListenerSupport() {
public void after(RepeatContext context, ExitStatus result) {
calls.add("1");

View File

@@ -39,7 +39,7 @@ public class AsynchronousRepeatTests extends AbstractTradeBatchTests {
template.setTaskExecutor(new SimpleAsyncTaskExecutor());
final String threadName = Thread.currentThread().getName();
final Set threadNames = new HashSet();
final Set<String> threadNames = new HashSet<String>();
final RepeatCallback callback = new RepeatCallback() {
public ExitStatus doInIteration(RepeatContext context) throws Exception {
@@ -75,7 +75,7 @@ public class AsynchronousRepeatTests extends AbstractTradeBatchTests {
jobTemplate.setTaskExecutor(taskExecutor);
final String threadName = Thread.currentThread().getName();
final Set threadNames = new HashSet();
final Set<String> threadNames = new HashSet<String>();
final RepeatCallback stepCallback = new ItemReaderRepeatCallback(provider, processor) {
public ExitStatus doInIteration(RepeatContext context) throws Exception {

View File

@@ -96,7 +96,7 @@ public class SimpleRepeatTemplateTests extends AbstractTradeBatchTests {
*/
public void testContextClosedOnNormalCompletion() throws Exception {
final List list = new ArrayList();
final List<String> list = new ArrayList<String>();
final RepeatContext context = new RepeatContextSupport(null) {
public void close() {
@@ -128,7 +128,7 @@ public class SimpleRepeatTemplateTests extends AbstractTradeBatchTests {
*/
public void testContextClosedOnAbnormalCompletion() throws Exception {
final List list = new ArrayList();
final List<String> list = new ArrayList<String>();
final RepeatContext context = new RepeatContextSupport(null) {
public void close() {
@@ -166,7 +166,7 @@ public class SimpleRepeatTemplateTests extends AbstractTradeBatchTests {
*/
public void testExceptionHandlerCalledOnAbnormalCompletion() throws Exception {
final List list = new ArrayList();
final List<Throwable> list = new ArrayList<Throwable>();
template.setExceptionHandler(new ExceptionHandler() {
public void handleException(RepeatContext context, Throwable throwable) throws RuntimeException {

View File

@@ -27,21 +27,21 @@ import java.util.List;
*/
public class DummySleeper implements Sleeper {
private List backOffs = new ArrayList();
private List<Long> backOffs = new ArrayList<Long>();
/**
* Public getter for the long.
* @return the lastBackOff
*/
public long getLastBackOff() {
return ((Long) backOffs.get(backOffs.size()-1)).longValue();
return backOffs.get(backOffs.size()-1).longValue();
}
public long[] getBackOffs() {
long[] result = new long[backOffs.size()];
int i = 0;
for (Iterator iterator = backOffs.iterator(); iterator.hasNext();) {
Long value = (Long) iterator.next();
for (Iterator<Long> iterator = backOffs.iterator(); iterator.hasNext();) {
Long value = iterator.next();
result[i++] =value.longValue();
}
return result ;

View File

@@ -32,7 +32,7 @@ import org.springframework.batch.retry.support.RetryTemplate;
public class RecoveryRetryCallbackTests extends TestCase {
List calls = new ArrayList();
List<Object> calls = new ArrayList<Object>();
int count = 0;

View File

@@ -67,7 +67,7 @@ public class RetryOperationsInterceptorTests extends TestCase {
public void testInterceptorChainWithRetry() throws Exception {
((Advised) service).addAdvice(interceptor);
final List list = new ArrayList();
final List<String> list = new ArrayList<String>();
((Advised) service).addAdvice(new MethodInterceptor() {
public Object invoke(MethodInvocation invocation) throws Throwable {
list.add("chain");

View File

@@ -96,7 +96,7 @@ public class StatefulRetryOperationsInterceptorTests extends TestCase {
public void testInterceptorChainWithRetry() throws Exception {
((Advised) service).addAdvice(interceptor);
final List list = new ArrayList();
final List<String> list = new ArrayList<String>();
((Advised) service).addAdvice(new MethodInterceptor() {
public Object invoke(MethodInvocation invocation) throws Throwable {
list.add("chain");
@@ -130,7 +130,7 @@ public class StatefulRetryOperationsInterceptorTests extends TestCase {
assertTrue("Wrong message: " + message, message.startsWith("Not enough calls"));
}
assertEquals(1, count);
Collection result = transformer.transform("foo");
Collection<String> result = transformer.transform("foo");
assertEquals(2, count);
assertEquals(1, result.size());
}
@@ -198,7 +198,7 @@ public class StatefulRetryOperationsInterceptorTests extends TestCase {
return Collections.singleton(data);
}
});
Collection result = transformer.transform("foo");
Collection<String> result = transformer.transform("foo");
assertEquals(2, count);
assertEquals(1, result.size());
}
@@ -219,12 +219,12 @@ public class StatefulRetryOperationsInterceptorTests extends TestCase {
}
public static interface Transformer {
Collection transform(String in) throws Exception;
Collection<String> transform(String in) throws Exception;
}
public static class TransformerImpl implements Transformer {
public Collection transform(String in) throws Exception {
public Collection<String> transform(String in) throws Exception {
count++;
if (count < 2) {
throw new Exception("Not enough calls: " + count);

View File

@@ -34,7 +34,7 @@ public class RetryListenerTests extends TestCase {
int count = 0;
List list = new ArrayList();
List<String> list = new ArrayList<String>();
public void testOpenInterceptors() throws Exception {
template.setListeners(new RetryListener[] { new RetryListenerSupport() {

View File

@@ -75,7 +75,7 @@ public class CompositeRetryPolicyTests extends TestCase {
}
public void testNonTrivialPoliciesClose() throws Exception {
final List list = new ArrayList();
final List<String> list = new ArrayList<String>();
CompositeRetryPolicy policy = new CompositeRetryPolicy();
policy.setPolicies(new RetryPolicy[] { new MockRetryPolicySupport() {
public void close(RetryContext context) {
@@ -93,7 +93,7 @@ public class CompositeRetryPolicyTests extends TestCase {
}
public void testExceptionOnPoliciesClose() throws Exception {
final List list = new ArrayList();
final List<String> list = new ArrayList<String>();
CompositeRetryPolicy policy = new CompositeRetryPolicy();
policy.setPolicies(new RetryPolicy[] { new MockRetryPolicySupport() {
public void close(RetryContext context) {

View File

@@ -44,7 +44,7 @@ public class ExceptionClassifierRetryPolicyTests extends TestCase {
}
public void testNullPolicies() throws Exception {
policy.setPolicyMap(new HashMap());
policy.setPolicyMap(new HashMap<String, RetryPolicy>());
try {
policy.open(null, null);
fail("Expected IllegalArgumentException");
@@ -55,7 +55,7 @@ public class ExceptionClassifierRetryPolicyTests extends TestCase {
}
public void testNullContext() throws Exception {
Map map = new HashMap();
Map<String, RetryPolicy> map = new HashMap<String, RetryPolicy>();
map.put(ExceptionClassifierSupport.DEFAULT, new NeverRetryPolicy());
policy.setPolicyMap(map);
@@ -67,7 +67,7 @@ public class ExceptionClassifierRetryPolicyTests extends TestCase {
public void testClassifierOperates() throws Exception {
Map map = new HashMap();
Map<String, RetryPolicy> map = new HashMap<String, RetryPolicy>();
map.put(ExceptionClassifierSupport.DEFAULT, new AlwaysRetryPolicy());
map.put("foo", new NeverRetryPolicy());
policy.setPolicyMap(map);

View File

@@ -37,7 +37,7 @@ public class RecoveryRetryPolicyTests extends TestCase {
private int count = 0;
private List list = new ArrayList();
private List<String> list = new ArrayList<String>();
public void testOpenSunnyDay() throws Exception {

View File

@@ -69,7 +69,7 @@ public class SubclassExceptionClassifierTests extends TestCase {
}
public void testClassifyAncestorMatch() {
classifier.setTypeMap(new LinkedHashMap() {{
classifier.setTypeMap(new LinkedHashMap<Class<?>, String>() {{
put(Exception.class, "bar");
put(IllegalArgumentException.class, "foo");
put(RuntimeException.class, "bucket");

View File

@@ -32,10 +32,11 @@ public class TransactionAwareListFactoryTests extends TestCase {
TransactionTemplate transactionTemplate = new TransactionTemplate(new ResourcelessTransactionManager());
List list;
List<String> list;
@SuppressWarnings("unchecked")
protected void setUp() throws Exception {
list = (List) factory.createInstance();
list = (List<String>) factory.createInstance();
}
public void testAdd() {

View File

@@ -31,15 +31,16 @@ public class TransactionAwareMapFactoryTests extends TestCase {
TransactionTemplate transactionTemplate = new TransactionTemplate(new ResourcelessTransactionManager());
Map map;
Map<String, String> map;
@SuppressWarnings("unchecked")
protected void setUp() throws Exception {
Map seed = new HashMap();
Map<String, String> seed = new HashMap<String, String>();
seed.put("foo", "oof");
seed.put("bar", "bar");
seed.put("spam", "maps");
factory = new TransactionAwareProxyFactory(seed);
map = (Map) factory.createInstance();
map = (Map<String, String>) factory.createInstance();
}
public void testAdd() {

View File

@@ -22,22 +22,23 @@ import java.util.Set;
import junit.framework.TestCase;
@SuppressWarnings("unchecked")
public class TransactionAwareProxyFactoryTests extends TestCase {
public void testCreateList() throws Exception {
List list = TransactionAwareProxyFactory.createTransactionalList();
List<String> list = TransactionAwareProxyFactory.createTransactionalList();
list.add("foo");
assertEquals(1, list.size());
}
public void testCreateSet() throws Exception {
Set set = TransactionAwareProxyFactory.createTransactionalSet();
Set<String> set = TransactionAwareProxyFactory.createTransactionalSet();
set.add("foo");
assertEquals(1, set.size());
}
public void testCreateMap() throws Exception {
Map map = TransactionAwareProxyFactory.createTransactionalMap();
Map<String, String> map = TransactionAwareProxyFactory.createTransactionalMap();
map.put("foo", "bar");
assertEquals(1, map.size());
}

View File

@@ -17,7 +17,6 @@
package test.jdbc.datasource;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
import javax.sql.DataSource;
@@ -99,6 +98,7 @@ public class InitializingDataSourceFactoryBean extends AbstractFactoryBean {
TransactionTemplate transactionTemplate = new TransactionTemplate(new DataSourceTransactionManager(dataSource));
transactionTemplate.execute(new TransactionCallback() {
@SuppressWarnings("unchecked")
public Object doInTransaction(TransactionStatus status) {
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
String[] scripts;
@@ -122,10 +122,9 @@ public class InitializingDataSourceFactoryBean extends AbstractFactoryBean {
}
private String stripComments(List list) {
private String stripComments(List<String> list) {
StringBuffer buffer = new StringBuffer();
for (Iterator iter = list.iterator(); iter.hasNext();) {
String line = (String) iter.next();
for (String line : list) {
if (!line.startsWith("//") && !line.startsWith("--")) {
buffer.append(line + "\n");
}
@@ -133,7 +132,7 @@ public class InitializingDataSourceFactoryBean extends AbstractFactoryBean {
return buffer.toString();
}
public Class getObjectType() {
public Class<DataSource> getObjectType() {
return DataSource.class;
}