Added cleanup code around tests so that StepScope registration was

cleaned up.
This commit is contained in:
Michael Minella
2013-12-16 10:03:52 -06:00
parent 241d9f101f
commit b5d48df0cf
3 changed files with 23 additions and 3 deletions

View File

@@ -53,6 +53,7 @@ public class JobContextFactoryBeanTests {
@After
public void tearDown() throws Exception {
factoryBean.close();
StepSynchronizationManager.close();
}
@Test

View File

@@ -14,7 +14,9 @@ import java.util.concurrent.Future;
import javax.batch.runtime.context.StepContext;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
@@ -32,6 +34,15 @@ public class StepContextFactoryBeanTests {
@Mock
private BatchPropertyContext propertyContext;
/**
* Added to clean up left overs from other tests.
* @throws Exception
*/
@BeforeClass
public static void setUpClass() throws Exception {
StepSynchronizationManager.close();
}
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
@@ -39,6 +50,11 @@ public class StepContextFactoryBeanTests {
factory.setBatchPropertyContext(propertyContext);
}
@After
public void tearDown() throws Exception {
StepSynchronizationManager.close();
}
@Test(expected=FactoryBeanNotInitializedException.class)
public void testNoStepExecutionRegistered() throws Exception {
factory.getObject();
@@ -107,7 +123,7 @@ public class StepContextFactoryBeanTests {
} catch (Throwable ignore) {
return null;
}finally {
StepSynchronizationManager.release();
StepSynchronizationManager.close();
}
}
}));
@@ -148,7 +164,7 @@ public class StepContextFactoryBeanTests {
} catch (Throwable ignore) {
return null;
}finally {
StepSynchronizationManager.release();
StepSynchronizationManager.close();
}
}
}));