Housecleaning of build warnings
This commit is contained in:
@@ -16,7 +16,11 @@
|
||||
|
||||
package org.springframework.batch.core.configuration.xml;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.aop.framework.Advised;
|
||||
import org.springframework.aop.framework.ProxyFactory;
|
||||
import org.springframework.batch.core.StepListener;
|
||||
@@ -44,12 +48,9 @@ import org.springframework.test.util.ReflectionTestUtils;
|
||||
import org.springframework.transaction.annotation.Isolation;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* @author Dan Garrette
|
||||
@@ -317,8 +318,9 @@ public class StepParserStepFactoryBeanTests {
|
||||
assertTrue(handler instanceof SimpleFlow);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private Map<Class<? extends Throwable>, Boolean> getExceptionMap(Class<? extends Throwable>... args) {
|
||||
Map<Class<? extends Throwable>, Boolean> map = new HashMap<Class<? extends Throwable>, Boolean>();
|
||||
Map<Class<? extends Throwable>, Boolean> map = new HashMap<>();
|
||||
for (Class<? extends Throwable> arg : args) {
|
||||
map.put(arg, true);
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ import static org.junit.Assert.assertTrue;
|
||||
public class BatchParserTests {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testRoseyScenario() throws Exception {
|
||||
JsrXmlApplicationContext context = new JsrXmlApplicationContext();
|
||||
Resource batchXml = new ClassPathResource("/org/springframework/batch/core/jsr/configuration/xml/batch.xml");
|
||||
@@ -49,7 +50,7 @@ public class BatchParserTests {
|
||||
context.registerBeanDefinition("postProcessor", bd);
|
||||
context.refresh();
|
||||
|
||||
ItemProcessor itemProcessor = context.getBean(ItemProcessor.class);
|
||||
ItemProcessor<String, String> itemProcessor = context.getBean(ItemProcessor.class);
|
||||
|
||||
assertNotNull(itemProcessor);
|
||||
StepSynchronizationManager.register(new StepExecution("step1", new JobExecution(5l)));
|
||||
@@ -60,7 +61,7 @@ public class BatchParserTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings({"resource", "rawtypes"})
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testOverrideBeansFirst() throws Exception {
|
||||
JsrXmlApplicationContext context = new JsrXmlApplicationContext();
|
||||
Resource overrideXml = new ClassPathResource("/org/springframework/batch/core/jsr/configuration/xml/override_batch.xml");
|
||||
@@ -70,7 +71,7 @@ public class BatchParserTests {
|
||||
context.load(overrideXml, batchXml);
|
||||
context.refresh();
|
||||
|
||||
ItemProcessor itemProcessor = (ItemProcessor) context.getBean("itemProcessor");
|
||||
ItemProcessor<String, String> itemProcessor = context.getBean("itemProcessor", ItemProcessor.class);
|
||||
|
||||
assertNotNull(itemProcessor);
|
||||
StepSynchronizationManager.register(new StepExecution("step1", new JobExecution(5l)));
|
||||
|
||||
@@ -55,6 +55,7 @@ import static org.junit.Assert.assertEquals;
|
||||
* @author Michael Minella
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class StepBuilderTests {
|
||||
|
||||
@Test
|
||||
@@ -115,7 +116,7 @@ public class StepBuilderTests {
|
||||
add("3");
|
||||
}};
|
||||
|
||||
ItemReader<String> reader = new ListItemReader<String>(items);
|
||||
ItemReader<String> reader = new ListItemReader<>(items);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
SimpleStepBuilder<String, String> builder = new StepBuilder("step")
|
||||
@@ -123,7 +124,7 @@ public class StepBuilderTests {
|
||||
.transactionManager(transactionManager)
|
||||
.<String, String>chunk(3)
|
||||
.reader(reader)
|
||||
.processor(new PassThroughItemProcessor<String>())
|
||||
.processor(new PassThroughItemProcessor<>())
|
||||
.writer(new DummyItemWriter())
|
||||
.listener(new AnnotationBasedStepExecutionListener());
|
||||
builder.build().execute(execution);
|
||||
|
||||
@@ -40,8 +40,9 @@ public abstract class AbstractExceptionThrowingItemHandlerStub<T> {
|
||||
exception = SkippableRuntimeException.class.getConstructor(String.class);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void setFailures(T... failures) {
|
||||
this.failures = new ArrayList<T>(Arrays.asList(failures));
|
||||
this.failures = new ArrayList<>(Arrays.asList(failures));
|
||||
}
|
||||
|
||||
public void setExceptionType(Class<? extends Throwable> exceptionType) throws Exception {
|
||||
|
||||
@@ -15,10 +15,6 @@
|
||||
*/
|
||||
package org.springframework.batch.core.step.item;
|
||||
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
@@ -29,6 +25,7 @@ import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.batch.core.BatchStatus;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.JobInstance;
|
||||
@@ -44,13 +41,17 @@ import org.springframework.batch.support.transaction.ResourcelessTransactionMana
|
||||
import org.springframework.batch.support.transaction.TransactionAwareProxyFactory;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
public class FaultTolerantStepFactoryBeanNonBufferingTests {
|
||||
|
||||
protected final Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
private FaultTolerantStepFactoryBean<String, String> factory = new FaultTolerantStepFactoryBean<String, String>();
|
||||
private FaultTolerantStepFactoryBean<String, String> factory = new FaultTolerantStepFactoryBean<>();
|
||||
|
||||
private List<String> items = Arrays.asList(new String[] { "1", "2", "3", "4", "5" });
|
||||
private List<String> items = Arrays.asList("1", "2", "3", "4", "5");
|
||||
|
||||
private ListItemReader<String> reader = new ListItemReader<String>(TransactionAwareProxyFactory
|
||||
.createTransactionalList(items));
|
||||
@@ -86,6 +87,7 @@ public class FaultTolerantStepFactoryBeanNonBufferingTests {
|
||||
* Check items causing errors are skipped as expected.
|
||||
*/
|
||||
@Test
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void testSkip() throws Exception {
|
||||
@SuppressWarnings("unchecked")
|
||||
SkipListener<Integer, String> skipListener = mock(SkipListener.class);
|
||||
|
||||
@@ -15,9 +15,6 @@
|
||||
*/
|
||||
package org.springframework.batch.core.step.item;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
@@ -30,6 +27,7 @@ import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.batch.core.BatchStatus;
|
||||
import org.springframework.batch.core.ExitStatus;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
@@ -60,6 +58,9 @@ import org.springframework.retry.policy.SimpleRetryPolicy;
|
||||
import org.springframework.transaction.support.TransactionSynchronizationManager;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
@@ -756,9 +757,10 @@ public class FaultTolerantStepFactoryBeanRetryTests {
|
||||
assertEquals(0, recovered.size());
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private Map<Class<? extends Throwable>, Boolean> getExceptionMap(
|
||||
Class<? extends Throwable>... args) {
|
||||
Map<Class<? extends Throwable>, Boolean> map = new HashMap<Class<? extends Throwable>, Boolean>();
|
||||
Map<Class<? extends Throwable>, Boolean> map = new HashMap<>();
|
||||
for (Class<? extends Throwable> arg : args) {
|
||||
map.put(arg, true);
|
||||
}
|
||||
|
||||
@@ -15,11 +15,20 @@
|
||||
*/
|
||||
package org.springframework.batch.core.step.item;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.batch.core.BatchStatus;
|
||||
import org.springframework.batch.core.ChunkListener;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
@@ -43,14 +52,6 @@ import org.springframework.transaction.interceptor.TransactionAttribute;
|
||||
import org.springframework.transaction.interceptor.TransactionAttributeEditor;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.instanceOf;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
@@ -272,7 +273,7 @@ public class FaultTolerantStepFactoryBeanRollbackTests {
|
||||
factory.setItemProcessor(processor);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Class<? extends Throwable>> exceptions = Arrays.<Class<? extends Throwable>>asList(Exception.class);
|
||||
List<Class<? extends Throwable>> exceptions = Arrays.asList(Exception.class);
|
||||
factory.setNoRollbackExceptionClasses(exceptions);
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<Class<? extends Throwable>, Boolean> skippable = getExceptionMap(Exception.class);
|
||||
@@ -596,8 +597,9 @@ public class FaultTolerantStepFactoryBeanRollbackTests {
|
||||
return Arrays.<Class<? extends Throwable>> asList(arg);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private Map<Class<? extends Throwable>, Boolean> getExceptionMap(Class<? extends Throwable>... args) {
|
||||
Map<Class<? extends Throwable>, Boolean> map = new HashMap<Class<? extends Throwable>, Boolean>();
|
||||
Map<Class<? extends Throwable>, Boolean> map = new HashMap<>();
|
||||
for (Class<? extends Throwable> arg : args) {
|
||||
map.put(arg, true);
|
||||
}
|
||||
|
||||
@@ -15,12 +15,20 @@
|
||||
*/
|
||||
package org.springframework.batch.core.step.item;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.aopalliance.intercept.MethodInterceptor;
|
||||
import org.aopalliance.intercept.MethodInvocation;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.aop.framework.ProxyFactory;
|
||||
import org.springframework.batch.core.BatchStatus;
|
||||
import org.springframework.batch.core.ChunkListener;
|
||||
@@ -60,13 +68,6 @@ import org.springframework.scheduling.concurrent.ConcurrentTaskExecutor;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
@@ -97,15 +98,15 @@ public class FaultTolerantStepFactoryBeanTests {
|
||||
private boolean closed = false;
|
||||
|
||||
public FaultTolerantStepFactoryBeanTests() throws Exception {
|
||||
reader = new SkipReaderStub<String>();
|
||||
processor = new SkipProcessorStub<String>();
|
||||
writer = new SkipWriterStub<String>();
|
||||
reader = new SkipReaderStub<>();
|
||||
processor = new SkipProcessorStub<>();
|
||||
writer = new SkipWriterStub<>();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
factory = new FaultTolerantStepFactoryBean<String, String>();
|
||||
factory = new FaultTolerantStepFactoryBean<>();
|
||||
|
||||
factory.setBeanName("stepName");
|
||||
factory.setTransactionManager(new ResourcelessTransactionManager());
|
||||
@@ -1116,8 +1117,9 @@ public class FaultTolerantStepFactoryBeanTests {
|
||||
return (SkipPolicy) ReflectionTestUtils.getField(chunkProvider, "skipPolicy");
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private Map<Class<? extends Throwable>, Boolean> getExceptionMap(Class<? extends Throwable>... args) {
|
||||
Map<Class<? extends Throwable>, Boolean> map = new HashMap<Class<? extends Throwable>, Boolean>();
|
||||
Map<Class<? extends Throwable>, Boolean> map = new HashMap<>();
|
||||
for (Class<? extends Throwable> arg : args) {
|
||||
map.put(arg, true);
|
||||
}
|
||||
|
||||
@@ -39,11 +39,13 @@ public class SkipReaderStub<T> extends AbstractExceptionThrowingItemHandlerStub<
|
||||
super();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public SkipReaderStub(T... items) throws Exception {
|
||||
super();
|
||||
this.items = items;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void setItems(T... items) {
|
||||
Assert.isTrue(counter < 0, "Items cannot be set once reading has started");
|
||||
this.items = items;
|
||||
|
||||
@@ -107,7 +107,7 @@ public class DataSourceInitializer implements InitializingBean {
|
||||
String[] scripts;
|
||||
try {
|
||||
scripts = StringUtils.delimitedListToStringArray(stripComments(IOUtils.readLines(scriptResource
|
||||
.getInputStream())), ";");
|
||||
.getInputStream(), "UTF-8")), ";");
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new BeanInitializationException("Cannot load script from [" + scriptResource + "]", e);
|
||||
|
||||
Reference in New Issue
Block a user