diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/annotation/DefaultBatchConfigurer.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/annotation/DefaultBatchConfigurer.java index 8ad30f99d..7a672a491 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/annotation/DefaultBatchConfigurer.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/annotation/DefaultBatchConfigurer.java @@ -80,7 +80,7 @@ public class DefaultBatchConfigurer implements BatchConfigurer { factory.setDataSource(dataSource); factory.setTransactionManager(transactionManager); factory.afterPropertiesSet(); - return (JobRepository) factory.getObject(); + return factory.getObject(); } } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/support/AbstractJobRepositoryFactoryBean.java b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/support/AbstractJobRepositoryFactoryBean.java index f6a10fb11..bfda2e121 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/support/AbstractJobRepositoryFactoryBean.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/support/AbstractJobRepositoryFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2013 the original author or authors. + * Copyright 2006-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -47,7 +47,7 @@ import org.springframework.util.Assert; * @author Robert Kasanicky */ @SuppressWarnings("rawtypes") -public abstract class AbstractJobRepositoryFactoryBean implements FactoryBean, InitializingBean { +public abstract class AbstractJobRepositoryFactoryBean implements FactoryBean, InitializingBean { private PlatformTransactionManager transactionManager; @@ -148,9 +148,10 @@ public abstract class AbstractJobRepositoryFactoryBean implements FactoryBean, I * a cast. * @return the {@link JobRepository} from {@link #getObject()} * @throws Exception if the repository could not be created + * @deprecated use {@link #getObject()} instead */ public JobRepository getJobRepository() throws Exception { - return (JobRepository) getObject(); + return getObject(); } private void initializeProxy() throws Exception { @@ -197,11 +198,11 @@ public abstract class AbstractJobRepositoryFactoryBean implements FactoryBean, I } @Override - public Object getObject() throws Exception { + public JobRepository getObject() throws Exception { if (proxyFactory == null) { afterPropertiesSet(); } - return proxyFactory.getProxy(); + return (JobRepository) proxyFactory.getProxy(); } } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/support/JobRepositoryFactoryBean.java b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/support/JobRepositoryFactoryBean.java index 05e1e70f3..f0096491a 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/support/JobRepositoryFactoryBean.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/support/JobRepositoryFactoryBean.java @@ -16,13 +16,6 @@ package org.springframework.batch.core.repository.support; -import static org.springframework.batch.support.DatabaseType.SYBASE; - -import java.lang.reflect.Field; -import java.sql.Types; - -import javax.sql.DataSource; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.batch.core.repository.ExecutionContextSerializer; @@ -48,6 +41,12 @@ import org.springframework.jdbc.support.lob.OracleLobHandler; import org.springframework.util.Assert; import org.springframework.util.StringUtils; +import javax.sql.DataSource; +import java.lang.reflect.Field; +import java.sql.Types; + +import static org.springframework.batch.support.DatabaseType.SYBASE; + /** * A {@link FactoryBean} that automates the creation of a * {@link SimpleJobRepository} using JDBC DAO implementations which persist @@ -92,7 +91,7 @@ public class JobRepositoryFactoryBean extends AbstractJobRepositoryFactoryBean i * A custom implementation of the {@link ExecutionContextSerializer}. * The default, if not injected, is the {@link XStreamExecutionContextStringSerializer}. * - * @param serializer + * @param serializer used to serialize/deserialize {@link org.springframework.batch.item.ExecutionContext} * @see ExecutionContextSerializer */ public void setSerializer(ExecutionContextSerializer serializer) { @@ -156,7 +155,7 @@ public class JobRepositoryFactoryBean extends AbstractJobRepositoryFactoryBean i /** * Sets the table prefix for all the batch meta-data tables. - * @param tablePrefix + * @param tablePrefix prefix prepended to batch meta-data tables */ public void setTablePrefix(String tablePrefix) { this.tablePrefix = tablePrefix; diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/support/MapJobRepositoryFactoryBean.java b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/support/MapJobRepositoryFactoryBean.java index 2d1584540..a66aca255 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/support/MapJobRepositoryFactoryBean.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/support/MapJobRepositoryFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -60,7 +60,7 @@ public class MapJobRepositoryFactoryBean extends AbstractJobRepositoryFactoryBea /** * Create a new instance with the provided transaction manager. * - * @param transactionManager + * @param transactionManager {@link org.springframework.transaction.PlatformTransactionManager} */ public MapJobRepositoryFactoryBean(PlatformTransactionManager transactionManager) { setTransactionManager(transactionManager); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/explore/support/MapJobExplorerFactoryBeanTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/explore/support/MapJobExplorerFactoryBeanTests.java index 983bcd8df..57a88d5d1 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/explore/support/MapJobExplorerFactoryBeanTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/explore/support/MapJobExplorerFactoryBeanTests.java @@ -22,7 +22,7 @@ public class MapJobExplorerFactoryBeanTests { public void testCreateExplorer() throws Exception { MapJobRepositoryFactoryBean repositoryFactory = new MapJobRepositoryFactoryBean(); - ((JobRepository)repositoryFactory.getObject()).createJobExecution("foo", new JobParameters()); + (repositoryFactory.getObject()).createJobExecution("foo", new JobParameters()); MapJobExplorerFactoryBean tested = new MapJobExplorerFactoryBean(repositoryFactory); tested.afterPropertiesSet(); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/explore/support/MapJobExplorerIntegrationTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/explore/support/MapJobExplorerIntegrationTests.java index 1f0987506..bd959b524 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/explore/support/MapJobExplorerIntegrationTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/explore/support/MapJobExplorerIntegrationTests.java @@ -15,10 +15,6 @@ */ package org.springframework.batch.core.explore.support; -import static org.junit.Assert.assertEquals; - -import java.util.Set; - import org.junit.Test; import org.springframework.batch.core.JobExecution; import org.springframework.batch.core.JobParametersBuilder; @@ -34,6 +30,10 @@ import org.springframework.batch.core.step.tasklet.TaskletStep; import org.springframework.batch.repeat.RepeatStatus; import org.springframework.core.task.SimpleAsyncTaskExecutor; +import java.util.Set; + +import static org.junit.Assert.assertEquals; + /** * @author Dave Syer * @@ -48,7 +48,7 @@ public class MapJobExplorerIntegrationTests { SimpleJobLauncher jobLauncher = new SimpleJobLauncher(); MapJobRepositoryFactoryBean repositoryFactory = new MapJobRepositoryFactoryBean(); repositoryFactory.afterPropertiesSet(); - JobRepository jobRepository = (JobRepository) repositoryFactory.getObject(); + JobRepository jobRepository = repositoryFactory.getObject(); jobLauncher.setJobRepository(jobRepository); jobLauncher.setTaskExecutor(new SimpleAsyncTaskExecutor()); jobLauncher.afterPropertiesSet(); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/job/ExtendedAbstractJobTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/job/ExtendedAbstractJobTests.java index f046a2cdb..f938fe647 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/job/ExtendedAbstractJobTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/job/ExtendedAbstractJobTests.java @@ -15,16 +15,6 @@ */ package org.springframework.batch.core.job; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.util.Collection; -import java.util.Collections; -import java.util.Date; - import org.junit.Before; import org.junit.Test; import org.springframework.batch.core.BatchStatus; @@ -39,6 +29,16 @@ import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean; import org.springframework.batch.core.step.StepSupport; +import java.util.Collection; +import java.util.Collections; +import java.util.Date; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + /** * @author Dave Syer * @@ -51,7 +51,7 @@ public class ExtendedAbstractJobTests { @Before public void setUp() throws Exception { MapJobRepositoryFactoryBean factory = new MapJobRepositoryFactoryBean(); - jobRepository = (JobRepository) factory.getObject(); + jobRepository = factory.getObject(); job = new StubJob("job", jobRepository); } @@ -166,7 +166,7 @@ public class ExtendedAbstractJobTests { MapJobRepositoryFactoryBean factory = new MapJobRepositoryFactoryBean(); factory.afterPropertiesSet(); - JobRepository repository = (JobRepository) factory.getObject(); + JobRepository repository = factory.getObject(); job.setJobRepository(repository); job.setRestartable(true); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/job/flow/FlowJobTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/job/flow/FlowJobTests.java index 0ade6b988..84bb1ca38 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/job/flow/FlowJobTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/job/flow/FlowJobTests.java @@ -15,16 +15,6 @@ */ package org.springframework.batch.core.job.flow; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.fail; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - import org.junit.Before; import org.junit.Test; import org.springframework.batch.core.BatchStatus; @@ -52,6 +42,16 @@ import org.springframework.batch.core.repository.dao.JobExecutionDao; import org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean; import org.springframework.batch.core.step.StepSupport; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.fail; + /** * @author Dave Syer * @author Michael Minella @@ -74,7 +74,7 @@ public class FlowJobTests { MapJobRepositoryFactoryBean factory = new MapJobRepositoryFactoryBean(); factory.afterPropertiesSet(); jobExecutionDao = factory.getJobExecutionDao(); - jobRepository = (JobRepository) factory.getObject(); + jobRepository = factory.getObject(); job.setJobRepository(jobRepository); jobExecution = jobRepository.createJobExecution("job", new JobParameters()); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/jsr/job/flow/JsrFlowJobTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/jsr/job/flow/JsrFlowJobTests.java index cf56b0d93..f53bebc45 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/jsr/job/flow/JsrFlowJobTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/jsr/job/flow/JsrFlowJobTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2013 the original author or authors. + * Copyright 2006-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,18 +15,6 @@ */ package org.springframework.batch.core.jsr.job.flow; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.fail; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -import javax.batch.api.Decider; - import org.junit.Before; import org.junit.Test; import org.springframework.batch.core.BatchStatus; @@ -59,6 +47,17 @@ import org.springframework.batch.core.repository.dao.JobExecutionDao; import org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean; import org.springframework.batch.core.step.StepSupport; +import javax.batch.api.Decider; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.fail; + /** * @author Dave Syer * @author Michael Minella @@ -83,7 +82,7 @@ public class JsrFlowJobTests { MapJobRepositoryFactoryBean jobRepositoryFactory = new MapJobRepositoryFactoryBean(); jobRepositoryFactory.afterPropertiesSet(); jobExecutionDao = jobRepositoryFactory.getJobExecutionDao(); - jobRepository = (JobRepository) jobRepositoryFactory.getObject(); + jobRepository = jobRepositoryFactory.getObject(); job.setJobRepository(jobRepository); jobExecution = jobRepository.createJobExecution("job", new JobParameters()); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/partition/support/PartitionStepTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/partition/support/PartitionStepTests.java index 5e2118e15..da0085952 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/partition/support/PartitionStepTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/partition/support/PartitionStepTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2013 the original author or authors. + * Copyright 2006-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,14 +15,6 @@ */ package org.springframework.batch.core.partition.support; -import static org.junit.Assert.assertEquals; - -import java.util.Arrays; -import java.util.Collection; -import java.util.Date; -import java.util.Set; -import java.util.concurrent.atomic.AtomicBoolean; - import org.junit.Before; import org.junit.Test; import org.springframework.batch.core.BatchStatus; @@ -35,6 +27,14 @@ import org.springframework.batch.core.partition.StepExecutionSplitter; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean; +import java.util.Arrays; +import java.util.Collection; +import java.util.Date; +import java.util.Set; +import java.util.concurrent.atomic.AtomicBoolean; + +import static org.junit.Assert.assertEquals; + /** * @author Dave Syer * @@ -48,7 +48,7 @@ public class PartitionStepTests { @Before public void setUp() throws Exception { MapJobRepositoryFactoryBean factory = new MapJobRepositoryFactoryBean(); - jobRepository = (JobRepository) factory.getObject(); + jobRepository = factory.getObject(); step.setJobRepository(jobRepository); step.setName("partitioned"); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/partition/support/RemoteStepExecutionAggregatorTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/partition/support/RemoteStepExecutionAggregatorTests.java index 321b73394..6efdbed7f 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/partition/support/RemoteStepExecutionAggregatorTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/partition/support/RemoteStepExecutionAggregatorTests.java @@ -1,11 +1,5 @@ package org.springframework.batch.core.partition.support; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import java.util.Arrays; -import java.util.Collections; - import org.junit.Before; import org.junit.Test; import org.springframework.batch.core.BatchStatus; @@ -17,6 +11,12 @@ import org.springframework.batch.core.explore.support.MapJobExplorerFactoryBean; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean; +import java.util.Arrays; +import java.util.Collections; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + public class RemoteStepExecutionAggregatorTests { private RemoteStepExecutionAggregator aggregator = new RemoteStepExecutionAggregator(); @@ -32,7 +32,7 @@ public class RemoteStepExecutionAggregatorTests { @Before public void init() throws Exception { MapJobRepositoryFactoryBean factory = new MapJobRepositoryFactoryBean(); - JobRepository jobRepository = (JobRepository) factory.getObject(); + JobRepository jobRepository = factory.getObject(); aggregator.setJobExplorer((JobExplorer) new MapJobExplorerFactoryBean(factory).getObject()); jobExecution = jobRepository.createJobExecution("job", new JobParameters()); result = jobExecution.createStepExecution("aggregate"); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/partition/support/SimpleStepExecutionSplitterTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/partition/support/SimpleStepExecutionSplitterTests.java index 15d621326..143868828 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/partition/support/SimpleStepExecutionSplitterTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/partition/support/SimpleStepExecutionSplitterTests.java @@ -1,16 +1,5 @@ package org.springframework.batch.core.partition.support; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.Date; -import java.util.Map; -import java.util.Set; - import org.junit.Before; import org.junit.Test; import org.springframework.batch.core.BatchStatus; @@ -25,6 +14,17 @@ import org.springframework.batch.core.repository.support.MapJobRepositoryFactory import org.springframework.batch.core.step.tasklet.TaskletStep; import org.springframework.batch.item.ExecutionContext; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.Date; +import java.util.Map; +import java.util.Set; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + public class SimpleStepExecutionSplitterTests { private Step step; @@ -37,7 +37,7 @@ public class SimpleStepExecutionSplitterTests { public void setUp() throws Exception { step = new TaskletStep("step"); MapJobRepositoryFactoryBean factory = new MapJobRepositoryFactoryBean(); - jobRepository = (JobRepository) factory.getObject(); + jobRepository = factory.getObject(); stepExecution = jobRepository.createJobExecution("job", new JobParameters()).createStepExecution("bar"); jobRepository.add(stepExecution); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/support/JobRepositoryFactoryBeanTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/support/JobRepositoryFactoryBeanTests.java index f1a96040d..f40b3ac42 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/support/JobRepositoryFactoryBeanTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/support/JobRepositoryFactoryBeanTests.java @@ -15,20 +15,6 @@ */ package org.springframework.batch.core.repository.support; -import static junit.framework.Assert.assertEquals; -import static junit.framework.Assert.assertNotNull; -import static junit.framework.Assert.assertTrue; -import static junit.framework.Assert.fail; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import java.sql.Connection; -import java.sql.DatabaseMetaData; -import java.sql.Types; -import java.util.Map; - -import javax.sql.DataSource; - import org.junit.Before; import org.junit.Ignore; import org.junit.Test; @@ -50,6 +36,19 @@ import org.springframework.test.util.ReflectionTestUtils; import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.support.DefaultTransactionDefinition; +import javax.sql.DataSource; +import java.sql.Connection; +import java.sql.DatabaseMetaData; +import java.sql.Types; +import java.util.Map; + +import static junit.framework.Assert.assertEquals; +import static junit.framework.Assert.assertNotNull; +import static junit.framework.Assert.assertTrue; +import static junit.framework.Assert.fail; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + /** * @author Lucas Ward * @author Will Schipp @@ -225,7 +224,7 @@ public class JobRepositoryFactoryBeanTests { catch (IllegalArgumentException ex) { // expected String message = ex.getMessage(); - assertTrue("Wrong message: " + message, message.indexOf("DataSource") >= 0); + assertTrue("Wrong message: " + message, message.contains("DataSource")); } } @@ -245,7 +244,7 @@ public class JobRepositoryFactoryBeanTests { catch (IllegalArgumentException ex) { // expected String message = ex.getMessage(); - assertTrue("Wrong message: " + message, message.indexOf("TransactionManager") >= 0); + assertTrue("Wrong message: " + message, message.contains("TransactionManager")); } } @@ -263,7 +262,7 @@ public class JobRepositoryFactoryBeanTests { catch (IllegalArgumentException ex) { // expected String message = ex.getMessage(); - assertTrue("Wrong message: " + message, message.indexOf("foo") >= 0); + assertTrue("Wrong message: " + message, message.contains("foo")); } } @@ -287,7 +286,7 @@ public class JobRepositoryFactoryBeanTests { @Test public void testTransactionAttributesForCreateMethodNullHypothesis() throws Exception { testCreateRepository(); - JobRepository repository = (JobRepository) factory.getObject(); + JobRepository repository = factory.getObject(); DefaultTransactionDefinition transactionDefinition = new DefaultTransactionDefinition( DefaultTransactionDefinition.PROPAGATION_REQUIRES_NEW); when(transactionManager.getTransaction(transactionDefinition)).thenReturn(null); @@ -309,7 +308,7 @@ public class JobRepositoryFactoryBeanTests { public void testTransactionAttributesForCreateMethod() throws Exception { testCreateRepository(); - JobRepository repository = (JobRepository) factory.getObject(); + JobRepository repository = factory.getObject(); DefaultTransactionDefinition transactionDefinition = new DefaultTransactionDefinition( DefaultTransactionDefinition.PROPAGATION_REQUIRES_NEW); transactionDefinition.setIsolationLevel(DefaultTransactionDefinition.ISOLATION_SERIALIZABLE); @@ -334,7 +333,7 @@ public class JobRepositoryFactoryBeanTests { factory.setIsolationLevelForCreate("ISOLATION_READ_UNCOMMITTED"); testCreateRepository(); - JobRepository repository = (JobRepository) factory.getObject(); + JobRepository repository = factory.getObject(); DefaultTransactionDefinition transactionDefinition = new DefaultTransactionDefinition( DefaultTransactionDefinition.PROPAGATION_REQUIRES_NEW); transactionDefinition.setIsolationLevel(DefaultTransactionDefinition.ISOLATION_READ_UNCOMMITTED); @@ -363,7 +362,7 @@ public class JobRepositoryFactoryBeanTests { public void testCustomLobType() throws Exception { factory.setClobType(Types.ARRAY); testCreateRepository(); - JobRepository repository = (JobRepository) factory.getObject(); + JobRepository repository = factory.getObject(); assertNotNull(repository); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/support/MapJobRepositoryFactoryBeanTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/support/MapJobRepositoryFactoryBeanTests.java index 5e04a8303..015fd2860 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/support/MapJobRepositoryFactoryBeanTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/support/MapJobRepositoryFactoryBeanTests.java @@ -1,7 +1,5 @@ package org.springframework.batch.core.repository.support; -import static org.junit.Assert.fail; - import org.junit.Test; import org.springframework.batch.core.Job; import org.springframework.batch.core.JobParameters; @@ -9,6 +7,8 @@ import org.springframework.batch.core.job.JobSupport; import org.springframework.batch.core.repository.JobExecutionAlreadyRunningException; import org.springframework.batch.core.repository.JobRepository; +import static org.junit.Assert.fail; + /** * Tests for {@link MapJobRepositoryFactoryBean}. */ @@ -23,7 +23,7 @@ public class MapJobRepositoryFactoryBeanTests { @Test public void testCreateRepository() throws Exception { tested.afterPropertiesSet(); - JobRepository repository = (JobRepository) tested.getObject(); + JobRepository repository = tested.getObject(); Job job = new JobSupport("jobName"); JobParameters jobParameters = new JobParameters(); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanRollbackTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanRollbackTests.java index 3c72c745a..57ae11bd3 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanRollbackTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanRollbackTests.java @@ -1,20 +1,5 @@ package org.springframework.batch.core.step.item; -import static org.hamcrest.CoreMatchers.instanceOf; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; -import static org.springframework.batch.core.BatchStatus.FAILED; - -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; @@ -43,6 +28,21 @@ 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; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; +import static org.springframework.batch.core.BatchStatus.FAILED; + /** * Tests for {@link FaultTolerantStepFactoryBean}. */ @@ -93,7 +93,7 @@ public class FaultTolerantStepFactoryBeanRollbackTests { MapJobRepositoryFactoryBean repositoryFactory = new MapJobRepositoryFactoryBean(); repositoryFactory.setTransactionManager(transactionManager); repositoryFactory.afterPropertiesSet(); - repository = (JobRepository) repositoryFactory.getObject(); + repository = repositoryFactory.getObject(); factory.setJobRepository(repository); jobExecution = repository.createJobExecution("skipJob", new JobParameters()); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanTests.java index 93b5db364..db552ee47 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanTests.java @@ -1,16 +1,5 @@ package org.springframework.batch.core.step.item; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -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; @@ -56,6 +45,17 @@ 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; + /** * Tests for {@link FaultTolerantStepFactoryBean}. */ @@ -111,7 +111,7 @@ public class FaultTolerantStepFactoryBeanTests { MapJobRepositoryFactoryBean repositoryFactory = new MapJobRepositoryFactoryBean(); repositoryFactory.afterPropertiesSet(); - repository = (JobRepository) repositoryFactory.getObject(); + repository = repositoryFactory.getObject(); factory.setJobRepository(repository); jobExecution = repository.createJobExecution("skipJob", new JobParameters()); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanUnexpectedRollbackTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanUnexpectedRollbackTests.java index 7aed2fe90..cb55f5c40 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanUnexpectedRollbackTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanUnexpectedRollbackTests.java @@ -1,11 +1,5 @@ package org.springframework.batch.core.step.item; -import static org.junit.Assert.assertEquals; - -import java.util.Arrays; - -import javax.sql.DataSource; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.junit.Test; @@ -28,6 +22,11 @@ import org.springframework.transaction.TransactionException; import org.springframework.transaction.UnexpectedRollbackException; import org.springframework.transaction.support.DefaultTransactionStatus; +import javax.sql.DataSource; +import java.util.Arrays; + +import static org.junit.Assert.assertEquals; + /** * Tests for {@link FaultTolerantStepFactoryBean} with unexpected rollback. */ @@ -74,7 +73,7 @@ public class FaultTolerantStepFactoryBeanUnexpectedRollbackTests { repositoryFactory.setDataSource(dataSource); repositoryFactory.setTransactionManager(transactionManager); repositoryFactory.afterPropertiesSet(); - JobRepository repository = (JobRepository) repositoryFactory.getObject(); + JobRepository repository = repositoryFactory.getObject(); factory.setJobRepository(repository); JobExecution jobExecution = repository.createJobExecution("job", new JobParameters()); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/job/JobStepTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/job/JobStepTests.java index 5914fb57a..45a119fd5 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/job/JobStepTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/job/JobStepTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2010 the original author or authors. + * Copyright 2006-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,11 +15,6 @@ */ package org.springframework.batch.core.step.job; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import java.util.Date; - import org.junit.Before; import org.junit.Test; import org.springframework.batch.core.BatchStatus; @@ -33,6 +28,11 @@ import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean; import org.springframework.batch.item.ExecutionContext; +import java.util.Date; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + /** * @author Dave Syer * @@ -49,7 +49,7 @@ public class JobStepTests { public void setUp() throws Exception { step.setName("step"); MapJobRepositoryFactoryBean factory = new MapJobRepositoryFactoryBean(); - jobRepository = (JobRepository) factory.getObject(); + jobRepository = factory.getObject(); step.setJobRepository(jobRepository); JobExecution jobExecution = jobRepository.createJobExecution("job", new JobParameters()); stepExecution = jobExecution.createStepExecution("step");