From 9e02c2e75ac12ede232b439722aedb10adeadce4 Mon Sep 17 00:00:00 2001 From: dhgarrette Date: Fri, 13 Mar 2009 21:52:47 +0000 Subject: [PATCH] BATCH-1139: small refactoring of unit test --- .../xml/TaskletElementParserTests.java | 39 +++++++------------ 1 file changed, 15 insertions(+), 24 deletions(-) diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TaskletElementParserTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TaskletElementParserTests.java index 1fa32b6f8..a6b099ad4 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TaskletElementParserTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TaskletElementParserTests.java @@ -43,11 +43,13 @@ import org.springframework.test.util.ReflectionTestUtils; */ public class TaskletElementParserTests { + ConfigurableApplicationContext taskletElementParentAttributeParserTestsContext = new ClassPathXmlApplicationContext( + "org/springframework/batch/core/configuration/xml/TaskletElementParentAttributeParserTests-context.xml"); + @Test public void testInheritSkippable() throws Exception { - ConfigurableApplicationContext ctx = new ClassPathXmlApplicationContext( - "org/springframework/batch/core/configuration/xml/TaskletElementParentAttributeParserTests-context.xml"); - Collection> skippable = getExceptionClasses("s1", "skippable", ctx); + Collection> skippable = getExceptionClasses("s1", "skippable", + taskletElementParentAttributeParserTestsContext); assertEquals(2, skippable.size()); boolean e = false; boolean f = false; @@ -65,9 +67,7 @@ public class TaskletElementParserTests { @Test public void testInheritFatal() throws Exception { - ConfigurableApplicationContext ctx = new ClassPathXmlApplicationContext( - "org/springframework/batch/core/configuration/xml/TaskletElementParentAttributeParserTests-context.xml"); - Collection> fatal = getExceptionClasses("s1", "fatal", ctx); + Collection> fatal = getExceptionClasses("s1", "fatal", taskletElementParentAttributeParserTestsContext); boolean a = false; boolean b = false; for (Class cls : fatal) { @@ -84,9 +84,7 @@ public class TaskletElementParserTests { @Test public void testInheritStreams() throws Exception { - ConfigurableApplicationContext ctx = new ClassPathXmlApplicationContext( - "org/springframework/batch/core/configuration/xml/TaskletElementParentAttributeParserTests-context.xml"); - Collection streams = getStreams("s1", ctx); + Collection streams = getStreams("s1", taskletElementParentAttributeParserTestsContext); assertEquals(2, streams.size()); boolean c = false; boolean d = false; @@ -104,9 +102,8 @@ public class TaskletElementParserTests { @Test public void testInheritRetryListeners() throws Exception { - ConfigurableApplicationContext ctx = new ClassPathXmlApplicationContext( - "org/springframework/batch/core/configuration/xml/TaskletElementParentAttributeParserTests-context.xml"); - Collection retryListeners = getRetryListeners("s1", ctx); + Collection retryListeners = getRetryListeners("s1", + taskletElementParentAttributeParserTestsContext); assertEquals(2, retryListeners.size()); boolean g = false; boolean h = false; @@ -124,9 +121,8 @@ public class TaskletElementParserTests { @Test public void testInheritSkippable_NoMerge() throws Exception { - ConfigurableApplicationContext ctx = new ClassPathXmlApplicationContext( - "org/springframework/batch/core/configuration/xml/TaskletElementParentAttributeParserTests-context.xml"); - Collection> skippable = getExceptionClasses("s2", "skippable", ctx); + Collection> skippable = getExceptionClasses("s2", "skippable", + taskletElementParentAttributeParserTestsContext); assertEquals(1, skippable.size()); boolean e = false; for (Class cls : skippable) { @@ -139,9 +135,7 @@ public class TaskletElementParserTests { @Test public void testInheritFatal_NoMerge() throws Exception { - ConfigurableApplicationContext ctx = new ClassPathXmlApplicationContext( - "org/springframework/batch/core/configuration/xml/TaskletElementParentAttributeParserTests-context.xml"); - Collection> fatal = getExceptionClasses("s2", "fatal", ctx); + Collection> fatal = getExceptionClasses("s2", "fatal", taskletElementParentAttributeParserTestsContext); boolean a = false; boolean b = false; for (Class cls : fatal) { @@ -158,9 +152,7 @@ public class TaskletElementParserTests { @Test public void testInheritStreams_NoMerge() throws Exception { - ConfigurableApplicationContext ctx = new ClassPathXmlApplicationContext( - "org/springframework/batch/core/configuration/xml/TaskletElementParentAttributeParserTests-context.xml"); - Collection streams = getStreams("s2", ctx); + Collection streams = getStreams("s2", taskletElementParentAttributeParserTestsContext); assertEquals(1, streams.size()); boolean c = false; for (ItemStream o : streams) { @@ -173,9 +165,8 @@ public class TaskletElementParserTests { @Test public void testInheritRetryListeners_NoMerge() throws Exception { - ConfigurableApplicationContext ctx = new ClassPathXmlApplicationContext( - "org/springframework/batch/core/configuration/xml/TaskletElementParentAttributeParserTests-context.xml"); - Collection retryListeners = getRetryListeners("s2", ctx); + Collection retryListeners = getRetryListeners("s2", + taskletElementParentAttributeParserTestsContext); assertEquals(1, retryListeners.size()); boolean h = false; for (RetryListener o : retryListeners) {