diff --git a/spring-batch-integration/pom.xml b/spring-batch-integration/pom.xml index bf2fdaf6b..612ee096e 100644 --- a/spring-batch-integration/pom.xml +++ b/spring-batch-integration/pom.xml @@ -62,6 +62,10 @@ junit junit + + org.apache.log4j + com.springsource.org.apache.log4j + org.aspectj com.springsource.org.aspectj.runtime @@ -126,6 +130,6 @@ - 1.0.0.RC2 + 1.0.1.RELEASE \ No newline at end of file diff --git a/spring-batch-integration/src/test/java/org/springframework/batch/integration/retry/RepeatTransactionalPollingIntegrationTests.java b/spring-batch-integration/src/test/java/org/springframework/batch/integration/retry/RepeatTransactionalPollingIntegrationTests.java index 7123be74b..c8fdc2ef2 100644 --- a/spring-batch-integration/src/test/java/org/springframework/batch/integration/retry/RepeatTransactionalPollingIntegrationTests.java +++ b/spring-batch-integration/src/test/java/org/springframework/batch/integration/retry/RepeatTransactionalPollingIntegrationTests.java @@ -8,6 +8,7 @@ import java.util.List; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.batch.support.transaction.TransactionAwareProxyFactory; @@ -15,10 +16,7 @@ import org.springframework.beans.BeansException; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; import org.springframework.context.Lifecycle; -import org.springframework.integration.annotation.ChannelAdapter; import org.springframework.integration.annotation.MessageEndpoint; -import org.springframework.integration.annotation.Poller; -import org.springframework.integration.annotation.ServiceActivator; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -31,23 +29,22 @@ public class RepeatTransactionalPollingIntegrationTests implements ApplicationCo private Log logger = LogFactory.getLog(getClass()); - private List processed = new ArrayList(); + private static List processed = new ArrayList(); - private List expected; + private static List expected; - private List handled = new ArrayList(); + private static List handled = new ArrayList(); - private List list = new ArrayList(); + private static List list = new ArrayList(); private Lifecycle bus; - private volatile int count = 0; + private volatile static int count = 0; public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { bus = (Lifecycle) applicationContext; } - @ServiceActivator(inputChannel = "requests", outputChannel = "replies") public String process(String message) { String result = message + ": " + count; logger.debug("Handling: " + message); @@ -61,8 +58,6 @@ public class RepeatTransactionalPollingIntegrationTests implements ApplicationCo return result; } - @ChannelAdapter("requests") - @Poller(interval=10,adviceChain={"txAdvice","repeatAdvice"}) public String input() { logger.debug("Polling: " + count); if (list.isEmpty()) { @@ -71,12 +66,19 @@ public class RepeatTransactionalPollingIntegrationTests implements ApplicationCo return list.remove(0); } - @ChannelAdapter("replies") public void output(String message) { handled.add(message); logger.debug("Handled: " + message); } + @Before + public void clearLists() { + list.clear(); + handled.clear(); + processed.clear(); + count = 0; + } + @Test @DirtiesContext public void testSunnyDay() throws Exception { diff --git a/spring-batch-integration/src/test/java/org/springframework/batch/integration/retry/RetryRepeatTransactionalPollingIntegrationTests.java b/spring-batch-integration/src/test/java/org/springframework/batch/integration/retry/RetryRepeatTransactionalPollingIntegrationTests.java index 7147acbc2..f4084dee4 100644 --- a/spring-batch-integration/src/test/java/org/springframework/batch/integration/retry/RetryRepeatTransactionalPollingIntegrationTests.java +++ b/spring-batch-integration/src/test/java/org/springframework/batch/integration/retry/RetryRepeatTransactionalPollingIntegrationTests.java @@ -8,6 +8,7 @@ import java.util.List; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.batch.support.transaction.TransactionAwareProxyFactory; @@ -16,9 +17,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; import org.springframework.context.Lifecycle; -import org.springframework.integration.annotation.ChannelAdapter; import org.springframework.integration.annotation.MessageEndpoint; -import org.springframework.integration.annotation.Poller; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -31,7 +30,7 @@ public class RetryRepeatTransactionalPollingIntegrationTests implements Applicat private Log logger = LogFactory.getLog(getClass()); - private List list = new ArrayList(); + private static List list = new ArrayList(); @Autowired private SimpleRecoverer recoverer; @@ -45,10 +44,14 @@ public class RetryRepeatTransactionalPollingIntegrationTests implements Applicat bus = (Lifecycle) applicationContext; } - private volatile int count = 0; + private static volatile int count = 0; - @ChannelAdapter("requests") - @Poller(interval=10,adviceChain={"txAdvice","repeatAdvice"}) + @Before + public void clearLists() { + list.clear(); + count = 0; + } + public String input() { logger.debug("Polling: " + count); if (list.isEmpty()) { @@ -57,7 +60,6 @@ public class RetryRepeatTransactionalPollingIntegrationTests implements Applicat return list.remove(0); } - @ChannelAdapter("replies") public void output(String message) { count++; logger.debug("Handled: " + message); diff --git a/spring-batch-integration/src/test/java/org/springframework/batch/integration/retry/RetryTransactionalPollingIntegrationTests.java b/spring-batch-integration/src/test/java/org/springframework/batch/integration/retry/RetryTransactionalPollingIntegrationTests.java index 31085402e..175670173 100644 --- a/spring-batch-integration/src/test/java/org/springframework/batch/integration/retry/RetryTransactionalPollingIntegrationTests.java +++ b/spring-batch-integration/src/test/java/org/springframework/batch/integration/retry/RetryTransactionalPollingIntegrationTests.java @@ -8,6 +8,7 @@ import java.util.List; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.batch.support.transaction.TransactionAwareProxyFactory; @@ -16,9 +17,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; import org.springframework.context.Lifecycle; -import org.springframework.integration.annotation.ChannelAdapter; import org.springframework.integration.annotation.MessageEndpoint; -import org.springframework.integration.annotation.Poller; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -31,7 +30,7 @@ public class RetryTransactionalPollingIntegrationTests implements ApplicationCon private Log logger = LogFactory.getLog(getClass()); - private List list = new ArrayList(); + private static List list = new ArrayList(); @Autowired private SimpleRecoverer recoverer; @@ -45,10 +44,14 @@ public class RetryTransactionalPollingIntegrationTests implements ApplicationCon bus = (Lifecycle) applicationContext; } - private volatile int count = 0; + private static volatile int count = 0; + + @Before + public void clearLists() { + list.clear(); + count = 0; + } - @ChannelAdapter("requests") - @Poller(interval=10, transactionManager="transactionManager") public String input() { logger.debug("Polling: " + count); if (list.isEmpty()) { @@ -57,7 +60,6 @@ public class RetryTransactionalPollingIntegrationTests implements ApplicationCon return list.remove(0); } - @ChannelAdapter("replies") public void output(String message) { count++; logger.debug("Handled: " + message); @@ -86,7 +88,7 @@ public class RetryTransactionalPollingIntegrationTests implements ApplicationCon .commaDelimitedListToStringArray("a,b,fail,fail,d,e"))); service.setExpected(expected); waitForResults(bus, expected.size(), 60); - waitForResults(bus, 6, 100); // (a,b), (fail), (fail), ([fail],d), (e,f) + waitForResults(bus, 6, 100); // a, b, (fail, fail, [fail]), d, e assertEquals(6,service.getProcessed().size()); // a,b,fail,fail,d,e assertEquals(1,recoverer.getRecovered().size()); // fail assertEquals(expected, service.getProcessed()); diff --git a/spring-batch-integration/src/test/java/org/springframework/batch/integration/retry/TransactionalPollingIntegrationTests.java b/spring-batch-integration/src/test/java/org/springframework/batch/integration/retry/TransactionalPollingIntegrationTests.java index 7cade4203..4de098b94 100644 --- a/spring-batch-integration/src/test/java/org/springframework/batch/integration/retry/TransactionalPollingIntegrationTests.java +++ b/spring-batch-integration/src/test/java/org/springframework/batch/integration/retry/TransactionalPollingIntegrationTests.java @@ -8,6 +8,7 @@ import java.util.List; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.batch.support.transaction.TransactionAwareProxyFactory; @@ -15,9 +16,7 @@ import org.springframework.beans.BeansException; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; import org.springframework.context.Lifecycle; -import org.springframework.integration.annotation.ChannelAdapter; import org.springframework.integration.annotation.MessageEndpoint; -import org.springframework.integration.annotation.Poller; import org.springframework.integration.annotation.ServiceActivator; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; @@ -31,13 +30,13 @@ public class TransactionalPollingIntegrationTests implements ApplicationContextA private Log logger = LogFactory.getLog(getClass()); - private List processed = new ArrayList(); - - private List handled = new ArrayList(); - - private List expected; + private static List processed = new ArrayList(); - private List list = new ArrayList(); + private static List handled = new ArrayList(); + + private static List expected = new ArrayList(); + + private static List list = new ArrayList(); private Lifecycle bus; @@ -45,14 +44,14 @@ public class TransactionalPollingIntegrationTests implements ApplicationContextA bus = (Lifecycle) applicationContext; } - private volatile int count = 0; + private volatile static int count = 0; @ServiceActivator(inputChannel = "requests", outputChannel = "replies") public String process(String message) { String result = message + ": " + count; logger.debug("Handling: " + message); - if (count - + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spring-batch-integration/src/test/resources/org/springframework/batch/integration/retry/RetryRepeatTransactionalPollingIntegrationTests-context.xml b/spring-batch-integration/src/test/resources/org/springframework/batch/integration/retry/RetryRepeatTransactionalPollingIntegrationTests-context.xml index e1ca2836c..a9c59237a 100644 --- a/spring-batch-integration/src/test/resources/org/springframework/batch/integration/retry/RetryRepeatTransactionalPollingIntegrationTests-context.xml +++ b/spring-batch-integration/src/test/resources/org/springframework/batch/integration/retry/RetryRepeatTransactionalPollingIntegrationTests-context.xml @@ -10,7 +10,30 @@ http://www.springframework.org/schema/integration/spring-integration-1.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"> - + + + + + + + + + + + + + + + + + + + + diff --git a/spring-batch-integration/src/test/resources/org/springframework/batch/integration/retry/RetryTransactionalPollingIntegrationTests-context.xml b/spring-batch-integration/src/test/resources/org/springframework/batch/integration/retry/RetryTransactionalPollingIntegrationTests-context.xml index c753ddecb..70a358b24 100644 --- a/spring-batch-integration/src/test/resources/org/springframework/batch/integration/retry/RetryTransactionalPollingIntegrationTests-context.xml +++ b/spring-batch-integration/src/test/resources/org/springframework/batch/integration/retry/RetryTransactionalPollingIntegrationTests-context.xml @@ -10,7 +10,27 @@ http://www.springframework.org/schema/integration/spring-integration-1.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"> - + + + + + + + + + + + + + + + + + diff --git a/spring-batch-integration/src/test/resources/org/springframework/batch/integration/retry/TransactionalPollingIntegrationTests-context.xml b/spring-batch-integration/src/test/resources/org/springframework/batch/integration/retry/TransactionalPollingIntegrationTests-context.xml index 068ed7b32..32645bcf0 100644 --- a/spring-batch-integration/src/test/resources/org/springframework/batch/integration/retry/TransactionalPollingIntegrationTests-context.xml +++ b/spring-batch-integration/src/test/resources/org/springframework/batch/integration/retry/TransactionalPollingIntegrationTests-context.xml @@ -1,7 +1,9 @@ - - - + + + + - + + + + + + + + + + + + + \ No newline at end of file