Commit in servicemix/base/src on MAIN
main/java/org/servicemix/jbi/nmr/flow/jca/JCAFlow.java+25-131.1 -> 1.2
test/java/org/servicemix/jbi/messaging/AbstractClusteredTransactionTest.java+100added 1.1
                                      /AbstractTransactionTest.java+134added 1.1
                                      /JcaFlowTransactionTest.java+53added 1.1
                                      /JmsFlowTransactionTest.java+32added 1.1
                                      /SedaFlowTransactionTest.java+31added 1.1
                                      /StFlowTransactionTest.java+31added 1.1
                                      /ClusteredTransactionTest.java-2191.1 removed
                                      /TransactionTest.java-1911.1 removed
+406-423
6 added + 2 removed + 1 modified, total 9 files
Rework transactions tests

servicemix/base/src/main/java/org/servicemix/jbi/nmr/flow/jca
JCAFlow.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- JCAFlow.java	3 Oct 2005 20:56:35 -0000	1.1
+++ JCAFlow.java	4 Oct 2005 08:24:46 -0000	1.2
@@ -74,7 +74,7 @@
 /**
  * Use for message routing among a network containers. All routing/registration happens automatically
  * 
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
  */
 public class JCAFlow extends SedaFlow implements ConsumerAdvisoryEventListener, MessageListener {
     private static final Log log = LogFactory.getLog(JCAFlow.class);
@@ -97,6 +97,8 @@
     private JmsTemplate jmsTemplate;
     private BootstrapContext bootstrapContext;
     private ResourceAdapter resourceAdapter;
+    private JCAConnector containerConnector;
+    private JCAConnector broadcastConnector;
 
     /**
      * The type of Flow
@@ -213,12 +215,12 @@
         	ActiveMQActivationSpec ac = new ActiveMQActivationSpec();
         	ac.setDestinationType("javax.jms.Queue");
         	ac.setDestination(INBOUND_PREFIX + broker.getContainerName());
-        	JCAConnector connector = new JCAConnector();
-        	connector.setBootstrapContext(getBootstrapContext());
-        	connector.setActivationSpec(ac);
-        	connector.setResourceAdapter(resourceAdapter);
-        	connector.setEndpointFactory(new JCAFlowEndpointFactory(getTransactionManager()));
-        	connector.afterPropertiesSet();
+        	containerConnector = new JCAConnector();
+        	containerConnector.setBootstrapContext(getBootstrapContext());
+        	containerConnector.setActivationSpec(ac);
+        	containerConnector.setResourceAdapter(resourceAdapter);
+        	containerConnector.setEndpointFactory(new JCAFlowEndpointFactory(getTransactionManager()));
+        	containerConnector.afterPropertiesSet();
         	
         	// Outbound connector
         	ActiveMQManagedConnectionFactory mcf = new ActiveMQManagedConnectionFactory();
@@ -230,12 +232,12 @@
         	ac = new ActiveMQActivationSpec();
         	ac.setDestinationType("javax.jms.Topic");
         	ac.setDestination(broadcastDestinationName);
-        	connector = new JCAConnector();
-        	connector.setBootstrapContext(getBootstrapContext());
-        	connector.setActivationSpec(ac);
-        	connector.setResourceAdapter(resourceAdapter);
-        	connector.setEndpointFactory(new JCAFlowEndpointFactory(null));
-        	connector.afterPropertiesSet();
+        	broadcastConnector = new JCAConnector();
+        	broadcastConnector.setBootstrapContext(getBootstrapContext());
+        	broadcastConnector.setActivationSpec(ac);
+        	broadcastConnector.setResourceAdapter(resourceAdapter);
+        	broadcastConnector.setEndpointFactory(new JCAFlowEndpointFactory(null));
+        	broadcastConnector.afterPropertiesSet();
         	
         	// Outbound broadcast
         	connection = ((ActiveMQResourceAdapter) resourceAdapter).makeConnection();
@@ -296,6 +298,16 @@
         	} catch (Exception e) {
         		log.warn("error closing jca connector", e);
         	}
+        }
+        try {
+        	containerConnector.destroy();
+    	} catch (Exception e) {
+    		log.warn("error closing jca connector", e);
+        }
+        try {
+        	broadcastConnector.destroy();
+    	} catch (Exception e) {
+    		log.warn("error closing jca connector", e);
         }
         // Destroy the resource adapter
     	resourceAdapter.stop();

servicemix/base/src/test/java/org/servicemix/jbi/messaging
AbstractClusteredTransactionTest.java added at 1.1
diff -N AbstractClusteredTransactionTest.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ AbstractClusteredTransactionTest.java	4 Oct 2005 08:24:46 -0000	1.1
@@ -0,0 +1,100 @@
+/** 
+ * 
+ * Copyright 2005 LogicBlaze, Inc. http://www.logicblaze.com
+ * 
+ * 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.servicemix.jbi.messaging;
+
+import org.servicemix.examples.AsyncReceiverPojo;
+import org.servicemix.examples.Receiver;
+import org.servicemix.examples.ReceiverComponent;
+import org.servicemix.examples.SenderComponent;
+import org.servicemix.jbi.container.ActivationSpec;
+import org.servicemix.jbi.container.JBIContainer;
+import org.servicemix.jbi.resolver.ServiceNameEndpointResolver;
+import org.springframework.transaction.TransactionStatus;
+import org.springframework.transaction.support.TransactionCallback;
+
+/**
+ * @version $Revision: 1.1 $
+ */
+public abstract class AbstractClusteredTransactionTest extends AbstractTransactionTest {
+
+    protected JBIContainer receiverContainer;
+    
+    /*
+     * @see TestCase#setUp()
+     */
+    protected void setUp() throws Exception {
+        super.setUp();
+        receiverContainer = createJbiContainer("receiverContainer");
+        Thread.sleep(3000);
+    }
+    
+    protected void tearDown() throws Exception {
+    	super.tearDown();
+    	receiverContainer.shutDown();
+    }
+    
+    protected void runClusteredTest(final boolean syncSend, final boolean syncReceive) throws Exception {
+        final SenderComponent sender = new SenderComponent();
+        sender.setResolver(new ServiceNameEndpointResolver(ReceiverComponent.SERVICE));
+        final Receiver receiver;
+        if (syncReceive) {
+        	receiver = new ReceiverComponent();
+        } else {
+        	receiver = new AsyncReceiverPojo();
+        }
+
+        senderContainer.activateComponent(new ActivationSpec("sender", sender));
+        receiverContainer.activateComponent(new ActivationSpec("receiver", receiver));
+        Thread.sleep(1000);
+        
+        tt.execute(new TransactionCallback() {
+	  		public Object doInTransaction(TransactionStatus status) {
+	  			sender.sendMessages(NUM_MESSAGES, syncSend);
+	  			return null;
+	  		}
+        });
+        receiver.getMessageList().assertMessagesReceived(NUM_MESSAGES);
+    }
+    
+    public void testClusteredSyncSendSyncReceive() throws Exception {
+    	try {
+    		runClusteredTest(true, true);
+    		fail("sendSync can not be used on clustered flows with external components");
+    	} catch (IllegalStateException e) {
+    		// ok
+    	}
+    }
+
+    public void testClusteredAsyncSendSyncReceive() throws Exception {
+    	runClusteredTest(false, true);
+    }
+
+    public void testClusteredSyncSendAsyncReceive() throws Exception {
+    	try {
+    		runClusteredTest(true, false);
+    		fail("sendSync can not be used on clustered flows with external components");
+    	} catch (IllegalStateException e) {
+    		// ok
+    	}
+    }
+
+    public void testClusteredAsyncSendAsyncReceive() throws Exception {
+    	runClusteredTest(false, false);
+    }
+
+}

servicemix/base/src/test/java/org/servicemix/jbi/messaging
AbstractTransactionTest.java added at 1.1
diff -N AbstractTransactionTest.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ AbstractTransactionTest.java	4 Oct 2005 08:24:46 -0000	1.1
@@ -0,0 +1,134 @@
+/** 
+ * 
+ * Copyright 2005 LogicBlaze, Inc. http://www.logicblaze.com
+ * 
+ * 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.servicemix.jbi.messaging;
+
+import javax.transaction.TransactionManager;
+import javax.transaction.UserTransaction;
+
+import junit.framework.TestCase;
+
+import org.apache.geronimo.transaction.ExtendedTransactionManager;
+import org.apache.geronimo.transaction.context.TransactionContextManager;
+import org.jencks.factory.GeronimoTransactionManagerFactoryBean;
+import org.jencks.factory.TransactionContextManagerFactoryBean;
+import org.jencks.factory.TransactionManagerFactoryBean;
+import org.servicemix.examples.AsyncReceiverPojo;
+import org.servicemix.examples.Receiver;
+import org.servicemix.examples.ReceiverComponent;
+import org.servicemix.examples.SenderComponent;
+import org.servicemix.jbi.container.ActivationSpec;
+import org.servicemix.jbi.container.JBIContainer;
+import org.servicemix.jbi.nmr.flow.Flow;
+import org.servicemix.jbi.resolver.ServiceNameEndpointResolver;
+import org.springframework.transaction.TransactionStatus;
+import org.springframework.transaction.jta.JtaTransactionManager;
+import org.springframework.transaction.support.TransactionCallback;
+import org.springframework.transaction.support.TransactionTemplate;
+
+/**
+ * @version $Revision: 1.1 $
+ */
+public abstract class AbstractTransactionTest extends TestCase {
+
+    protected static final int NUM_MESSAGES = 10;
+    
+    protected TransactionTemplate tt;
+    protected TransactionManager tm;
+    protected TransactionContextManager tcm;
+    protected JBIContainer senderContainer;
+    
+    /*
+     * @see TestCase#setUp()
+     */
+    protected void setUp() throws Exception {
+        super.setUp();
+        createTransactionLayer();
+        senderContainer = createJbiContainer("senderContainer");
+    }
+    
+    protected void tearDown() throws Exception {
+    	senderContainer.shutDown();
+    }
+    
+    protected void createTransactionLayer() throws Exception {
+        TransactionManagerFactoryBean tmcf = new TransactionManagerFactoryBean();
+        tmcf.afterPropertiesSet();
+        ExtendedTransactionManager etm = (ExtendedTransactionManager) tmcf.getObject();
+        TransactionContextManagerFactoryBean tcmfb = new TransactionContextManagerFactoryBean();
+        tcmfb.setTransactionManager(etm);
+        tcmfb.afterPropertiesSet();
+        tcm = (TransactionContextManager) tcmfb.getObject();
+        GeronimoTransactionManagerFactoryBean gtmfb = new GeronimoTransactionManagerFactoryBean();
+        gtmfb.setTransactionContextManager(tcm);
+        gtmfb.afterPropertiesSet();
+        tm = (TransactionManager) gtmfb.getObject();
+        tt = new TransactionTemplate(new JtaTransactionManager((UserTransaction) tm));
+    }
+    
+    protected JBIContainer createJbiContainer(String name) throws Exception {
+    	JBIContainer container = new JBIContainer();
+        container.setTransactionManager(tm);
+        container.setName(name);
+        container.setFlow(createFlow());
+        container.setAutoEnlistInTransaction(true);
+        container.init();
+        container.start();
+        return container;
+    }
+    
+    protected abstract Flow createFlow();
+    
+    protected void runSimpleTest(final boolean syncSend, final boolean syncReceive) throws Exception {
+        final SenderComponent sender = new SenderComponent();
+        sender.setResolver(new ServiceNameEndpointResolver(ReceiverComponent.SERVICE));
+        final Receiver receiver;
+        if (syncReceive) {
+        	receiver = new ReceiverComponent();
+        } else {
+        	receiver = new AsyncReceiverPojo();
+        }
+
+        senderContainer.activateComponent(new ActivationSpec("sender", sender));
+        senderContainer.activateComponent(new ActivationSpec("receiver", receiver));
+        
+        tt.execute(new TransactionCallback() {
+	  		public Object doInTransaction(TransactionStatus status) {
+	  			sender.sendMessages(NUM_MESSAGES, syncSend);
+	  			return null;
+	  		}
+        });
+        receiver.getMessageList().assertMessagesReceived(NUM_MESSAGES);
+    }
+    
+    public void testSyncSendSyncReceive() throws Exception {
+    	runSimpleTest(true, true);
+    }
+
+    public void testAsyncSendSyncReceive() throws Exception {
+    	runSimpleTest(false, true);
+    }
+
+    public void testSyncSendAsyncReceive() throws Exception {
+    	runSimpleTest(true, false);
+    }
+
+    public void testAsyncSendAsyncReceive() throws Exception {
+    	runSimpleTest(false, false);
+    }
+
+}

servicemix/base/src/test/java/org/servicemix/jbi/messaging
JcaFlowTransactionTest.java added at 1.1
diff -N JcaFlowTransactionTest.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ JcaFlowTransactionTest.java	4 Oct 2005 08:24:46 -0000	1.1
@@ -0,0 +1,53 @@
+/** 
+ * 
+ * Copyright 2005 LogicBlaze, Inc. http://www.logicblaze.com
+ * 
+ * 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.servicemix.jbi.messaging;
+
+import org.activemq.broker.BrokerContainer;
+import org.activemq.spring.BrokerFactoryBean;
+import org.servicemix.jbi.nmr.flow.Flow;
+import org.servicemix.jbi.nmr.flow.jca.JCAFlow;
+import org.springframework.core.io.ClassPathResource;
+
+/**
+ * @version $Revision: 1.1 $
+ */
+public class JcaFlowTransactionTest extends AbstractClusteredTransactionTest {
+
+	protected BrokerContainer broker;
+    
+    protected void setUp() throws Exception {
+        BrokerFactoryBean bfb = new BrokerFactoryBean();
+        bfb.setConfig(new ClassPathResource("org/servicemix/jbi/nmr/flow/jca/broker.xml"));
+        bfb.afterPropertiesSet();
+        broker = (BrokerContainer) bfb.getObject();
+        super.setUp();
+    }
+    
+    protected void tearDown() throws Exception {
+    	super.tearDown();
+    	broker.stop();
+    }
+    
+    protected Flow createFlow() {
+    	JCAFlow flow = new JCAFlow();
+    	flow.setJmsURL("tcp://localhost:61616");
+    	flow.setTransactionContextManager(tcm);
+    	return flow;
+    }
+
+}

servicemix/base/src/test/java/org/servicemix/jbi/messaging
JmsFlowTransactionTest.java added at 1.1
diff -N JmsFlowTransactionTest.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ JmsFlowTransactionTest.java	4 Oct 2005 08:24:46 -0000	1.1
@@ -0,0 +1,32 @@
+/** 
+ * 
+ * Copyright 2005 LogicBlaze, Inc. http://www.logicblaze.com
+ * 
+ * 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.servicemix.jbi.messaging;
+
+import org.servicemix.jbi.nmr.flow.Flow;
+import org.servicemix.jbi.nmr.flow.jms.JMSFlow;
+
+/**
+ * @version $Revision: 1.1 $
+ */
+public class JmsFlowTransactionTest extends AbstractTransactionTest {
+
+    protected Flow createFlow() {
+    	return new JMSFlow();
+    }
+
+}

servicemix/base/src/test/java/org/servicemix/jbi/messaging
SedaFlowTransactionTest.java added at 1.1
diff -N SedaFlowTransactionTest.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ SedaFlowTransactionTest.java	4 Oct 2005 08:24:46 -0000	1.1
@@ -0,0 +1,31 @@
+/** 
+ * 
+ * Copyright 2005 LogicBlaze, Inc. http://www.logicblaze.com
+ * 
+ * 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.servicemix.jbi.messaging;
+
+import org.servicemix.jbi.nmr.flow.Flow;
+import org.servicemix.jbi.nmr.flow.seda.SedaFlow;
+
+/**
+ * @version $Revision: 1.1 $
+ */
+public class SedaFlowTransactionTest extends AbstractTransactionTest {
+
+	protected Flow createFlow() {
+		return new SedaFlow();
+	}
+}

servicemix/base/src/test/java/org/servicemix/jbi/messaging
StFlowTransactionTest.java added at 1.1
diff -N StFlowTransactionTest.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ StFlowTransactionTest.java	4 Oct 2005 08:24:46 -0000	1.1
@@ -0,0 +1,31 @@
+/** 
+ * 
+ * Copyright 2005 LogicBlaze, Inc. http://www.logicblaze.com
+ * 
+ * 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.servicemix.jbi.messaging;
+
+import org.servicemix.jbi.nmr.flow.Flow;
+import org.servicemix.jbi.nmr.flow.st.STFlow;
+
+/**
+ * @version $Revision: 1.1 $
+ */
+public class StFlowTransactionTest extends AbstractTransactionTest {
+
+	protected Flow createFlow() {
+		return new STFlow();
+	}
+}

servicemix/base/src/test/java/org/servicemix/jbi/messaging
ClusteredTransactionTest.java removed after 1.1
diff -N ClusteredTransactionTest.java
--- ClusteredTransactionTest.java	3 Oct 2005 20:56:35 -0000	1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,219 +0,0 @@
-/** 
- * 
- * Copyright 2005 LogicBlaze, Inc. http://www.logicblaze.com
- * 
- * 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.servicemix.jbi.messaging;
-
-import javax.transaction.TransactionManager;
-import javax.transaction.UserTransaction;
-
-import junit.framework.TestCase;
-
-import org.activemq.broker.BrokerContainer;
-import org.activemq.spring.BrokerFactoryBean;
-import org.apache.geronimo.transaction.ExtendedTransactionManager;
-import org.apache.geronimo.transaction.context.TransactionContextManager;
-import org.jencks.factory.GeronimoTransactionManagerFactoryBean;
-import org.jencks.factory.TransactionContextManagerFactoryBean;
-import org.jencks.factory.TransactionManagerFactoryBean;
-import org.servicemix.examples.AsyncReceiverPojo;
-import org.servicemix.examples.Receiver;
-import org.servicemix.examples.ReceiverComponent;
-import org.servicemix.examples.SenderComponent;
-import org.servicemix.jbi.container.ActivationSpec;
-import org.servicemix.jbi.container.JBIContainer;
-import org.servicemix.jbi.nmr.flow.jca.JCAFlow;
-import org.servicemix.jbi.resolver.ServiceNameEndpointResolver;
-import org.springframework.core.io.ClassPathResource;
-import org.springframework.transaction.TransactionStatus;
-import org.springframework.transaction.jta.JtaTransactionManager;
-import org.springframework.transaction.support.TransactionCallback;
-import org.springframework.transaction.support.TransactionTemplate;
-
-/**
- * @version $Revision: 1.1 $
- */
-public class ClusteredTransactionTest extends TestCase {
-
-    private static final int NUM_MESSAGES = 100;
-    private TransactionTemplate tt;
-    private TransactionManager tm;
-    private TransactionContextManager tcm;
-    
-    /*
-     * @see TestCase#setUp()
-     */
-    protected void setUp() throws Exception {
-        super.setUp();
-        TransactionManagerFactoryBean tmcf = new TransactionManagerFactoryBean();
-        tmcf.afterPropertiesSet();
-        ExtendedTransactionManager etm = (ExtendedTransactionManager) tmcf.getObject();
-        TransactionContextManagerFactoryBean tcmfb = new TransactionContextManagerFactoryBean();
-        tcmfb.setTransactionManager(etm);
-        tcmfb.afterPropertiesSet();
-        tcm = (TransactionContextManager) tcmfb.getObject();
-        GeronimoTransactionManagerFactoryBean gtmfb = new GeronimoTransactionManagerFactoryBean();
-        gtmfb.setTransactionContextManager(tcm);
-        gtmfb.afterPropertiesSet();
-        tm = (TransactionManager) gtmfb.getObject();
-        tt = new TransactionTemplate(new JtaTransactionManager((UserTransaction) tm));
-    }
-    
-    protected void runAutoEnlistTest(String flowName, Receiver receiver, final boolean sync) throws Exception {
-        JBIContainer senderContainer = new JBIContainer();
-        JBIContainer receiverContainer = new JBIContainer();
-    	try {
-    		senderContainer.setTransactionManager(tm);
-    		senderContainer.setName("senderContainer");
-	        if (flowName.equals("jca")) {
-	        	JCAFlow flow = new JCAFlow();
-	        	flow.setJmsURL("tcp://localhost:61616");
-	        	flow.setTransactionContextManager(tcm);
-	        	senderContainer.setFlow(flow);
-	        } else {
-	        	senderContainer.setFlowName(flowName);
-	        }
-	        senderContainer.setAutoEnlistInTransaction(true);
-	        senderContainer.init();
-	        senderContainer.start();
-	        
-	        receiverContainer.setTransactionManager(tm);
-	        receiverContainer.setName("receiverContainer");
-	        if (flowName.equals("jca")) {
-	        	JCAFlow flow = new JCAFlow();
-	        	flow.setJmsURL("tcp://localhost:61616");
-	        	flow.setTransactionContextManager(tcm);
-	        	receiverContainer.setFlow(flow);
-	        } else {
-	        	receiverContainer.setFlowName(flowName);
-	        }
-	        receiverContainer.setAutoEnlistInTransaction(true);
-	        receiverContainer.init();
-	        receiverContainer.start();
-
-	        final SenderComponent sender = new SenderComponent();
-	        sender.setResolver(new ServiceNameEndpointResolver(ReceiverComponent.SERVICE));
-	        senderContainer.activateComponent(new ActivationSpec("sender", sender));
-	        receiverContainer.activateComponent(new ActivationSpec("receiver", receiver));
-	        Thread.sleep(1000);
-	        
-	        tt.execute(new TransactionCallback() {
-	  		public Object doInTransaction(TransactionStatus status) {
-	  			sender.sendMessages(NUM_MESSAGES, sync);
-	  			return null;
-	  		}
-	        });
-	        receiver.getMessageList().assertMessagesReceived(NUM_MESSAGES);
-	        
-    	} finally {
-    		senderContainer.shutDown();
-    		receiverContainer.shutDown();
-    	}
-    }
-    
-    /*
-    public void testStSyncSendSyncReceive() throws Exception {
-    	runAutoEnlistTest("st", new ReceiverComponent(), true);
-    }
-
-    public void testStAsyncSendSyncReceive() throws Exception {
-    	runAutoEnlistTest("st", new ReceiverComponent(), false);
-    }
-
-    public void testStSyncSendAsyncReceive() throws Exception {
-    	runAutoEnlistTest("st", new AsyncReceiverPojo(), true);
-    }
-
-    public void testStAsyncSendAsyncReceive() throws Exception {
-    	runAutoEnlistTest("st", new AsyncReceiverPojo(), false);
-    }
-
-    public void testSedaSyncSendSyncReceive() throws Exception {
-    	runAutoEnlistTest("seda", new ReceiverComponent(), true);
-    }
-
-    public void testSedaAsyncSendSyncReceive() throws Exception {
-    	runAutoEnlistTest("seda", new ReceiverComponent(), false);
-    }
-
-    public void testSedaSyncSendAsyncReceive() throws Exception {
-    	runAutoEnlistTest("seda", new AsyncReceiverPojo(), true);
-    }
-
-    public void testSedaAsyncSendAsyncReceive() throws Exception {
-    	runAutoEnlistTest("seda", new AsyncReceiverPojo(), false);
-    }
-    */
-
-    public void testJmsSyncSendSyncReceive() throws Exception {
-    	try {
-	        BrokerFactoryBean bfb = new BrokerFactoryBean();
-	        bfb.setConfig(new ClassPathResource("org/servicemix/jbi/nmr/flow/jca/broker.xml"));
-	        bfb.afterPropertiesSet();
-	        BrokerContainer broker = (BrokerContainer) bfb.getObject();
-	        try {
-	        	runAutoEnlistTest("jca", new ReceiverComponent(), true);
-	        } finally {
-	        	broker.stop();
-	        }
-	        fail("sendSync can not be used on jca flow with external components");
-    	} catch (IllegalStateException e) {
-    		// sendSync can not be used on jca flow with external components
-    	}
-    }
-
-    public void testJmsAsyncSendSyncReceive() throws Exception {
-        BrokerFactoryBean bfb = new BrokerFactoryBean();
-        bfb.setConfig(new ClassPathResource("org/servicemix/jbi/nmr/flow/jca/broker.xml"));
-        bfb.afterPropertiesSet();
-        BrokerContainer broker = (BrokerContainer) bfb.getObject();
-        try {
-        	runAutoEnlistTest("jca", new ReceiverComponent(), false);
-        } finally {
-        	broker.stop();
-        }
-    }
-
-    public void testJmsSyncSendAsyncReceive() throws Exception {
-    	try {
-	        BrokerFactoryBean bfb = new BrokerFactoryBean();
-	        bfb.setConfig(new ClassPathResource("org/servicemix/jbi/nmr/flow/jca/broker.xml"));
-	        bfb.afterPropertiesSet();
-	        BrokerContainer broker = (BrokerContainer) bfb.getObject();
-	        try {
-	        	runAutoEnlistTest("jca", new AsyncReceiverPojo(), true);
-	        } finally {
-	        	broker.stop();
-	        }
-	        fail("sendSync can not be used on jca flow with external components");
-    	} catch (IllegalStateException e) {
-    		// sendSync can not be used on jca flow with external components
-    	}
-    }
-
-    public void testJmsAsyncSendAsyncReceive() throws Exception {
-        BrokerFactoryBean bfb = new BrokerFactoryBean();
-        bfb.setConfig(new ClassPathResource("org/servicemix/jbi/nmr/flow/jca/broker.xml"));
-        bfb.afterPropertiesSet();
-        BrokerContainer broker = (BrokerContainer) bfb.getObject();
-        try {
-        	runAutoEnlistTest("jca", new AsyncReceiverPojo(), false);
-        } finally {
-        	broker.stop();
-        }
-    }
-
-}

servicemix/base/src/test/java/org/servicemix/jbi/messaging
TransactionTest.java removed after 1.1
diff -N TransactionTest.java
--- TransactionTest.java	3 Oct 2005 20:56:35 -0000	1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,191 +0,0 @@
-/** 
- * 
- * Copyright 2005 LogicBlaze, Inc. http://www.logicblaze.com
- * 
- * 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.servicemix.jbi.messaging;
-
-import javax.transaction.TransactionManager;
-import javax.transaction.UserTransaction;
-
-import junit.framework.TestCase;
-
-import org.activemq.broker.BrokerContainer;
-import org.activemq.spring.BrokerFactoryBean;
-import org.apache.geronimo.transaction.ExtendedTransactionManager;
-import org.apache.geronimo.transaction.context.TransactionContextManager;
-import org.jencks.factory.GeronimoTransactionManagerFactoryBean;
-import org.jencks.factory.TransactionContextManagerFactoryBean;
-import org.jencks.factory.TransactionManagerFactoryBean;
-import org.servicemix.examples.AsyncReceiverPojo;
-import org.servicemix.examples.Receiver;
-import org.servicemix.examples.ReceiverComponent;
-import org.servicemix.examples.SenderComponent;
-import org.servicemix.jbi.container.ActivationSpec;
-import org.servicemix.jbi.container.JBIContainer;
-import org.servicemix.jbi.nmr.flow.jca.JCAFlow;
-import org.servicemix.jbi.resolver.ServiceNameEndpointResolver;
-import org.springframework.core.io.ClassPathResource;
-import org.springframework.transaction.TransactionStatus;
-import org.springframework.transaction.jta.JtaTransactionManager;
-import org.springframework.transaction.support.TransactionCallback;
-import org.springframework.transaction.support.TransactionTemplate;
-
-/**
- * @version $Revision: 1.1 $
- */
-public class TransactionTest extends TestCase {
-
-    private static final int NUM_MESSAGES = 10;
-    private TransactionTemplate tt;
-    private TransactionManager tm;
-    private TransactionContextManager tcm;
-    
-    /*
-     * @see TestCase#setUp()
-     */
-    protected void setUp() throws Exception {
-        super.setUp();
-        TransactionManagerFactoryBean tmcf = new TransactionManagerFactoryBean();
-        tmcf.afterPropertiesSet();
-        ExtendedTransactionManager etm = (ExtendedTransactionManager) tmcf.getObject();
-        TransactionContextManagerFactoryBean tcmfb = new TransactionContextManagerFactoryBean();
-        tcmfb.setTransactionManager(etm);
-        tcmfb.afterPropertiesSet();
-        tcm = (TransactionContextManager) tcmfb.getObject();
-        GeronimoTransactionManagerFactoryBean gtmfb = new GeronimoTransactionManagerFactoryBean();
-        gtmfb.setTransactionContextManager(tcm);
-        gtmfb.afterPropertiesSet();
-        tm = (TransactionManager) gtmfb.getObject();
-        tt = new TransactionTemplate(new JtaTransactionManager((UserTransaction) tm));
-     }
-    
-    protected void runAutoEnlistTest(String flowName, Receiver receiver, final boolean sync) throws Exception {
-        JBIContainer container = new JBIContainer();
-    	try {
-	        container.setTransactionManager(tm);
-	        container.setName("senderContainer");
-	        if (flowName.equals("jca")) {
-	        	JCAFlow flow = new JCAFlow();
-	        	flow.setJmsURL("tcp://localhost:61616");
-	        	flow.setTransactionContextManager(tcm);
-	        	container.setFlow(flow);
-	        } else {
-	        	container.setFlowName(flowName);
-	        }
-	        container.setAutoEnlistInTransaction(true);
-	        container.init();
-	        container.start();
-	        
-	        final SenderComponent sender = new SenderComponent();
-	        sender.setResolver(new ServiceNameEndpointResolver(ReceiverComponent.SERVICE));
-	
-	        container.activateComponent(new ActivationSpec("sender", sender));
-	        container.activateComponent(new ActivationSpec("receiver", receiver));
-	        
-	        tt.execute(new TransactionCallback() {
-	  		public Object doInTransaction(TransactionStatus status) {
-	  			sender.sendMessages(NUM_MESSAGES, sync);
-	  			return null;
-	  		}
-	        });
-	        receiver.getMessageList().assertMessagesReceived(NUM_MESSAGES);
-	        
-    	} finally {
-    		container.shutDown();
-    	}
-    }
-    
-    public void testStSyncSendSyncReceive() throws Exception {
-    	runAutoEnlistTest("st", new ReceiverComponent(), true);
-    }
-
-    public void testStAsyncSendSyncReceive() throws Exception {
-    	runAutoEnlistTest("st", new ReceiverComponent(), false);
-    }
-
-    public void testStSyncSendAsyncReceive() throws Exception {
-    	runAutoEnlistTest("st", new AsyncReceiverPojo(), true);
-    }
-
-    public void testStAsyncSendAsyncReceive() throws Exception {
-    	runAutoEnlistTest("st", new AsyncReceiverPojo(), false);
-    }
-
-    public void testSedaSyncSendSyncReceive() throws Exception {
-    	runAutoEnlistTest("seda", new ReceiverComponent(), true);
-    }
-
-    public void testSedaAsyncSendSyncReceive() throws Exception {
-    	runAutoEnlistTest("seda", new ReceiverComponent(), false);
-    }
-
-    public void testSedaSyncSendAsyncReceive() throws Exception {
-    	runAutoEnlistTest("seda", new AsyncReceiverPojo(), true);
-    }
-
-    public void testSedaAsyncSendAsyncReceive() throws Exception {
-    	runAutoEnlistTest("seda", new AsyncReceiverPojo(), false);
-    }
-
-    public void testJmsSyncSendSyncReceive() throws Exception {
-        BrokerFactoryBean bfb = new BrokerFactoryBean();
-        bfb.setConfig(new ClassPathResource("org/servicemix/jbi/nmr/flow/jca/broker.xml"));
-        bfb.afterPropertiesSet();
-        BrokerContainer broker = (BrokerContainer) bfb.getObject();
-        try {
-        	runAutoEnlistTest("jca", new ReceiverComponent(), true);
-        } finally {
-        	broker.stop();
-        }
-    }
-
-    public void testJmsAsyncSendSyncReceive() throws Exception {
-        BrokerFactoryBean bfb = new BrokerFactoryBean();
-        bfb.setConfig(new ClassPathResource("org/servicemix/jbi/nmr/flow/jca/broker.xml"));
-        bfb.afterPropertiesSet();
-        BrokerContainer broker = (BrokerContainer) bfb.getObject();
-        try {
-        	runAutoEnlistTest("jca", new ReceiverComponent(), false);
-        } finally {
-        	broker.stop();
-        }
-    }
-
-    public void testJmsSyncSendAsyncReceive() throws Exception {
-        BrokerFactoryBean bfb = new BrokerFactoryBean();
-        bfb.setConfig(new ClassPathResource("org/servicemix/jbi/nmr/flow/jca/broker.xml"));
-        bfb.afterPropertiesSet();
-        BrokerContainer broker = (BrokerContainer) bfb.getObject();
-        try {
-        	runAutoEnlistTest("jca", new AsyncReceiverPojo(), true);
-        } finally {
-        	broker.stop();
-        }
-    }
-
-    public void testJmsAsyncSendAsyncReceive() throws Exception {
-        BrokerFactoryBean bfb = new BrokerFactoryBean();
-        bfb.setConfig(new ClassPathResource("org/servicemix/jbi/nmr/flow/jca/broker.xml"));
-        bfb.afterPropertiesSet();
-        BrokerContainer broker = (BrokerContainer) bfb.getObject();
-        try {
-        	runAutoEnlistTest("jca", new AsyncReceiverPojo(), false);
-        } finally {
-        	broker.stop();
-        }
-    }
-
-}
CVSspam 0.2.8



Reply via email to