diff --git a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/JdbcMessageStoreChannelTests-context.xml b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/JdbcMessageStoreChannelTests-context.xml index ba41b34921..151d920697 100644 --- a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/JdbcMessageStoreChannelTests-context.xml +++ b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/JdbcMessageStoreChannelTests-context.xml @@ -32,7 +32,7 @@ - + diff --git a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/JdbcMessageStoreChannelTests.java b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/JdbcMessageStoreChannelTests.java index 225bf8601d..0cf312f54e 100644 --- a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/JdbcMessageStoreChannelTests.java +++ b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/JdbcMessageStoreChannelTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2011 the original author or authors. + * Copyright 2002-2012 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. @@ -44,7 +44,7 @@ public class JdbcMessageStoreChannelTests { @Autowired private JdbcMessageStore messageStore; - + @BeforeTransaction public void clear() { for (MessageGroup group : messageStore) { @@ -60,7 +60,7 @@ public class JdbcMessageStoreChannelTests { assertEquals(1, Service.messages.size()); assertEquals(0, messageStore.getMessageGroup("JdbcMessageStoreChannelTests").size()); } - + @Test public void testSendAndActivateWithRollback() throws Exception { Service.reset(1); @@ -71,7 +71,7 @@ public class JdbcMessageStoreChannelTests { // After a rollback in the poller the message is still waiting to be delivered assertEquals(1, messageStore.getMessageGroup("JdbcMessageStoreChannelTests").size()); } - + @Test @Transactional public void testSendAndActivateTransactionalSend() throws Exception { @@ -89,13 +89,15 @@ public class JdbcMessageStoreChannelTests { // But inside the transaction the message is still there assertEquals(1, messageStore.getMessageGroup("JdbcMessageStoreChannelTests").size()); } - + public static class Service { private static boolean fail = false; + private static boolean alreadyFailed = false; private static List messages = new CopyOnWriteArrayList(); private static CountDownLatch latch = new CountDownLatch(0); public static void reset(int count) { fail = false; + alreadyFailed = false; messages.clear(); latch = new CountDownLatch(count); } @@ -105,9 +107,12 @@ public class JdbcMessageStoreChannelTests { } } public String echo(String input) { - messages.add(input); - latch.countDown(); + if (!alreadyFailed) { + messages.add(input); + latch.countDown(); + } if (fail) { + alreadyFailed = true; throw new RuntimeException("Planned failure"); } return input;