diff --git a/integration/.springBeans b/integration/.springBeans
index eb3bec74c..1128b99cb 100644
--- a/integration/.springBeans
+++ b/integration/.springBeans
@@ -5,9 +5,6 @@
src/test/resources/org/springframework/batch/jms/jms-context.xml
- src/test/resources/org/springframework/jms/asynch.xml
- src/test/resources/org/springframework/jms/synch.xml
- src/test/resources/org/springframework/jms/tx.xml
src/test/resources/data-source.xml
@@ -17,7 +14,6 @@
false
src/test/resources/data-source.xml
- src/test/resources/org/springframework/jms/synch.xml
@@ -35,7 +31,6 @@
false
src/test/resources/data-source.xml
- src/test/resources/org/springframework/jms/asynch.xml
diff --git a/integration/src/test/java/org/springframework/jms/AsynchronousTests.java b/integration/src/test/java/org/springframework/jms/AsynchronousTests.java
deleted file mode 100644
index 8960235e2..000000000
--- a/integration/src/test/java/org/springframework/jms/AsynchronousTests.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * Copyright 2006-2007 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.jms;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.Session;
-
-import org.springframework.jdbc.core.JdbcTemplate;
-import org.springframework.jms.core.JmsTemplate;
-import org.springframework.jms.listener.DefaultMessageListenerContainer;
-import org.springframework.jms.listener.SessionAwareMessageListener;
-import org.springframework.test.AbstractDependencyInjectionSpringContextTests;
-import org.springframework.transaction.PlatformTransactionManager;
-import org.springframework.transaction.TransactionStatus;
-import org.springframework.transaction.support.TransactionCallback;
-import org.springframework.transaction.support.TransactionTemplate;
-import org.springframework.util.ClassUtils;
-
-public class AsynchronousTests extends AbstractDependencyInjectionSpringContextTests {
-
- protected String[] getConfigLocations() {
- return new String[] { ClassUtils.classPackageAsResourcePath(getClass()) + "/asynch.xml" };
- }
-
- private DefaultMessageListenerContainer container;
-
- private JmsTemplate jmsTemplate;
-
- private JdbcTemplate jdbcTemplate;
-
- private PlatformTransactionManager transactionManager;
-
- public void setTransactionManager(PlatformTransactionManager transactionManager) {
- this.transactionManager = transactionManager;
- }
-
- public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
- this.jdbcTemplate = jdbcTemplate;
- }
-
- public void setJmsTemplate(JmsTemplate jmsTemplate) {
- this.jmsTemplate = jmsTemplate;
- }
-
- public void setContainer(DefaultMessageListenerContainer container) {
- this.container = container;
- }
-
- protected void onSetUp() throws Exception {
- super.onSetUp();
- String foo = "";
- int count = 0;
- while (foo != null && count < 100) {
- foo = (String) jmsTemplate.receiveAndConvert("queue");
- count++;
- }
- jdbcTemplate.execute("delete from T_FOOS");
- jmsTemplate.convertAndSend("queue", "foo");
- }
-
- protected void onTearDown() throws Exception {
- super.onTearDown();
- container.stop();
- // Need to give the container time to shutdown
- Thread.sleep(2000L);
- }
-
- List list = new ArrayList();
-
- private void assertInitialState() {
- int count = jdbcTemplate.queryForInt("select count(*) from T_FOOS");
- assertEquals(0, count);
- }
-
- public void testSunnyDay() throws Exception {
-
- assertInitialState();
-
- container.setMessageListener(new SessionAwareMessageListener() {
- public void onMessage(Message message, Session session) throws JMSException {
- list.add(message.toString());
- jdbcTemplate.execute("INSERT into T_FOOS (id,name,foo_date) values (1,'bar',null)");
- }
- });
-
- container.start();
-
- // Need to sleep for at least a second here...
- Thread.sleep(1000L);
-
- assertEquals(1, list.size());
-
- String foo = (String) jmsTemplate.receiveAndConvert("queue");
- assertEquals(null, foo);
-
- int count = jdbcTemplate.queryForInt("select count(*) from T_FOOS");
- assertEquals(1, count);
-
- }
-
- public void testRollback() throws Exception {
-
- assertInitialState();
-
- container.setMessageListener(new SessionAwareMessageListener() {
- public void onMessage(Message message, Session session) throws JMSException {
- list.add(message.toString());
- new TransactionTemplate(transactionManager).execute(new TransactionCallback() {
- public Object doInTransaction(TransactionStatus status) {
- jdbcTemplate.execute("INSERT into T_FOOS (id,name,foo_date) values (1,'bar',null)");
- // This causes the DB to rollback but not the message
- throw new RuntimeException("Rollback!");
- }
- });
- }
- });
-
- container.start();
-
- // Need to sleep for at least a second here...
- Thread.sleep(3000L);
-
- // We rolled back so the message might come in many times...
- assertTrue(list.size() > 1);
-
- int count = jdbcTemplate.queryForInt("select count(*) from T_FOOS");
- assertEquals(0, count);
-
- String foo = (String) jmsTemplate.receiveAndConvert("queue");
- assertEquals("foo", foo);
-
- }
-}
diff --git a/integration/src/test/java/org/springframework/jms/SynchronousTests.java b/integration/src/test/java/org/springframework/jms/SynchronousTests.java
deleted file mode 100644
index b0bc68e78..000000000
--- a/integration/src/test/java/org/springframework/jms/SynchronousTests.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * Copyright 2006-2007 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.jms;
-
-import javax.jms.JMSException;
-import javax.jms.Session;
-
-import org.springframework.jms.connection.SessionProxy;
-import org.springframework.jms.core.JmsTemplate;
-import org.springframework.jms.core.SessionCallback;
-import org.springframework.test.AbstractTransactionalDataSourceSpringContextTests;
-import org.springframework.transaction.support.TransactionSynchronizationAdapter;
-import org.springframework.transaction.support.TransactionSynchronizationManager;
-import org.springframework.util.ClassUtils;
-
-public class SynchronousTests extends AbstractTransactionalDataSourceSpringContextTests {
-
- private JmsTemplate jmsTemplate;
-
- public void setJmsTemplate(JmsTemplate jmsTemplate) {
- this.jmsTemplate = jmsTemplate;
- }
-
- protected String[] getConfigLocations() {
- return new String[] { ClassUtils.classPackageAsResourcePath(getClass()) + "/synch.xml" };
- }
-
- protected void onSetUpBeforeTransaction() throws Exception {
- super.onSetUpBeforeTransaction();
- String foo = "";
- int count = 0;
- while (foo != null && count < 100) {
- foo = (String) jmsTemplate.receiveAndConvert("queue");
- count++;
- }
- jdbcTemplate.execute("delete from T_FOOS");
- jmsTemplate.convertAndSend("queue", "foo");
- }
-
- protected void onSetUpInTransaction() throws Exception {
- super.onSetUpInTransaction();
- }
-
- private void assertInitialState() {
- int count = jdbcTemplate.queryForInt("select count(*) from T_FOOS");
- assertEquals(0, count);
- }
-
- public void testCommit() throws Exception {
-
- assertInitialState();
- String foo = (String) jmsTemplate.receiveAndConvert("queue");
- assertEquals("foo", foo);
- jdbcTemplate.execute("INSERT into T_FOOS (id,name,foo_date) values (1,'bar',null)");
-
- // force commit...
- setComplete();
- endTransaction();
- startNewTransaction();
-
- // Database committed so this resord should be there...
- int count = jdbcTemplate.queryForInt("select count(*) from T_FOOS");
- assertEquals(1, count);
-
- // ... the commit should also have cleared the queue, so this should now
- // be null
- foo = (String) jmsTemplate.receiveAndConvert("queue");
- assertEquals(null, foo);
-
- }
-
- public void testFullRollback() throws Exception {
-
- assertInitialState();
- String foo = (String) jmsTemplate.receiveAndConvert("queue");
- assertEquals("foo", foo);
- jdbcTemplate.execute("INSERT into T_FOOS (id,name,foo_date) values (1,'bar',null)");
-
- // force rollback...
- endTransaction();
- startNewTransaction();
-
- // The database connection rolled back...
- int count = jdbcTemplate.queryForInt("select count(*) from T_FOOS");
- assertEquals(0, count);
-
- // ... and so did the message session. The rollback should have restored
- // the queue, so this should now be non-null
- foo = (String) jmsTemplate.receiveAndConvert("queue");
- assertEquals("foo", foo);
-
- }
-
- public void testPartialRollback() throws Exception {
-
- assertInitialState();
- String foo = (String) jmsTemplate.receiveAndConvert("queue");
- assertEquals("foo", foo);
- jdbcTemplate.execute("INSERT into T_FOOS (id,name,foo_date) values (1,'bar',null)");
-
- TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
- public void beforeCommit(boolean readOnly) {
- // Simulate a message system failure before the main transaction
- // commits...
- jmsTemplate.execute(new SessionCallback() {
- public Object doInJms(Session session) throws JMSException {
- try {
- assertTrue("Not a SessionProxy - wrong spring version?", session instanceof SessionProxy);
- ((SessionProxy) session).getTargetSession().rollback();
- }
- catch (JMSException e) {
- throw e;
- }
- catch (Exception e) {
- // swallow it
- e.printStackTrace();
- }
- return null;
- }
- });
- }
- });
- // force commit...
- setComplete();
- endTransaction();
- startNewTransaction();
-
- // The database portion committed...
- int count = jdbcTemplate.queryForInt("select count(*) from T_FOOS");
- assertEquals(1, count);
-
- // ...but the JMS session rolled back, so the message is still there
- foo = (String) jmsTemplate.receiveAndConvert("queue");
- assertEquals("foo", foo);
-
- }
-}
diff --git a/integration/src/test/java/org/springframework/jms/TransactionPropagationTests.java b/integration/src/test/java/org/springframework/jms/TransactionPropagationTests.java
deleted file mode 100644
index ec07a1112..000000000
--- a/integration/src/test/java/org/springframework/jms/TransactionPropagationTests.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * Copyright 2006-2007 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.jms;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.springframework.jms.core.JmsTemplate;
-import org.springframework.test.AbstractDependencyInjectionSpringContextTests;
-import org.springframework.transaction.PlatformTransactionManager;
-import org.springframework.transaction.TransactionDefinition;
-import org.springframework.transaction.TransactionStatus;
-import org.springframework.transaction.support.DefaultTransactionDefinition;
-import org.springframework.transaction.support.TransactionCallback;
-import org.springframework.transaction.support.TransactionTemplate;
-import org.springframework.util.ClassUtils;
-
-public class TransactionPropagationTests extends AbstractDependencyInjectionSpringContextTests {
-
- protected String[] getConfigLocations() {
- return new String[] { ClassUtils.classPackageAsResourcePath(getClass()) + "/tx.xml" };
- }
-
- private JmsTemplate jmsTemplate;
-
- private PlatformTransactionManager transactionManager;
-
- public void setTransactionManager(PlatformTransactionManager transactionManager) {
- this.transactionManager = transactionManager;
- }
-
- public void setJmsTemplate(JmsTemplate jmsTemplate) {
- this.jmsTemplate = jmsTemplate;
- }
-
- protected void onSetUp() throws Exception {
- super.onSetUp();
- String foo = "";
- int count = 0;
- while (foo != null && count < 100) {
- foo = (String) jmsTemplate.receiveAndConvert("queue");
- count++;
- }
- jmsTemplate.convertAndSend("queue", "foo");
- jmsTemplate.convertAndSend("queue", "bar");
- jmsTemplate.convertAndSend("queue", "spam");
- }
-
- List list = new ArrayList();
-
- public void testRollbackOuterTransaction() throws Exception {
-
- final DefaultTransactionDefinition transactionDefinition = new DefaultTransactionDefinition(
- TransactionDefinition.PROPAGATION_MANDATORY);
-
- try {
-
- new TransactionTemplate(transactionManager).execute(new TransactionCallback() {
-
- public Object doInTransaction(TransactionStatus status) {
-
- new TransactionTemplate(transactionManager, transactionDefinition)
- .execute(new TransactionCallback() {
- public Object doInTransaction(TransactionStatus status) {
- String msg = (String) jmsTemplate.receiveAndConvert("queue");
- list.add(msg);
- return null;
- }
- });
-
- new TransactionTemplate(transactionManager, transactionDefinition)
- .execute(new TransactionCallback() {
- public Object doInTransaction(TransactionStatus status) {
- String msg = (String) jmsTemplate.receiveAndConvert("queue");
- list.add(msg);
- throw new RuntimeException("Rollback!");
- }
- });
-
- return null;
- }
- });
-
- fail("Expected RuntimeException");
-
- }
- catch (RuntimeException e) {
- // Expected
- assertEquals("Rollback!", e.getMessage());
- }
-
- List msgs = getMessages();
- System.err.println(list);
- System.err.println(msgs);
-
- // 2 received
- assertEquals(2, list.size());
- // but both rolled back...
- assertEquals(3, msgs.size());
- }
-
- public void testRollbackSingleTransaction() throws Exception {
-
- try {
-
- new TransactionTemplate(transactionManager).execute(new TransactionCallback() {
-
- public Object doInTransaction(TransactionStatus status) {
-
- String msg = (String) jmsTemplate.receiveAndConvert("queue");
- list.add(msg);
- msg = (String) jmsTemplate.receiveAndConvert("queue");
- list.add(msg);
- throw new RuntimeException("Rollback!");
-
- }
- });
-
- fail("Expected RuntimeException");
-
- }
- catch (RuntimeException e) {
- // Expected
- assertEquals("Rollback!", e.getMessage());
- }
-
- List msgs = getMessages();
- System.err.println(list);
- System.err.println(msgs);
-
- // 2 received
- assertEquals(2, list.size());
- // but both rolled back...
- assertEquals(3, msgs.size());
- }
-
- private List getMessages() {
- String next = "";
- List msgs = new ArrayList();
- while (next != null) {
- next = (String) jmsTemplate.receiveAndConvert("queue");
- if (next != null)
- msgs.add(next);
- }
- return msgs;
- }
-}
diff --git a/integration/src/test/resources/org/springframework/jms/asynch.xml b/integration/src/test/resources/org/springframework/jms/asynch.xml
deleted file mode 100644
index ec60c87f5..000000000
--- a/integration/src/test/resources/org/springframework/jms/asynch.xml
+++ /dev/null
@@ -1,74 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- vm://localhost
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/integration/src/test/resources/org/springframework/jms/synch.xml b/integration/src/test/resources/org/springframework/jms/synch.xml
deleted file mode 100644
index d3f8513fb..000000000
--- a/integration/src/test/resources/org/springframework/jms/synch.xml
+++ /dev/null
@@ -1,46 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- vm://localhost
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/integration/src/test/resources/org/springframework/jms/tx.xml b/integration/src/test/resources/org/springframework/jms/tx.xml
deleted file mode 100644
index 30b40fe9f..000000000
--- a/integration/src/test/resources/org/springframework/jms/tx.xml
+++ /dev/null
@@ -1,44 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- vm://localhost
-
-
-
-
-
-
\ No newline at end of file