Author: jstrachan Date: Mon Nov 27 11:01:37 2006 New Revision: 479726 URL: http://svn.apache.org/viewvc?view=rev&rev=479726 Log: added a test case to try reproduce bug AMQ-1054 (unfortunately it doesnt) - also added a patch to try fix AMQ-1054 based on the kind suggestion from Shoaib Akhtar that it could be the cast from getData() causing the ClassCastException; so AMQ-1054 may be fixed but as yet we don't have a test case to prove it
Added: incubator/activemq/trunk/activemq-test-atomikos/ incubator/activemq/trunk/activemq-test-atomikos/pom.xml (with props) incubator/activemq/trunk/activemq-test-atomikos/src/ incubator/activemq/trunk/activemq-test-atomikos/src/test/ incubator/activemq/trunk/activemq-test-atomikos/src/test/java/ incubator/activemq/trunk/activemq-test-atomikos/src/test/java/org/ incubator/activemq/trunk/activemq-test-atomikos/src/test/java/org/apache/ incubator/activemq/trunk/activemq-test-atomikos/src/test/java/org/apache/activemq/ incubator/activemq/trunk/activemq-test-atomikos/src/test/java/org/apache/activemq/atomikos/ incubator/activemq/trunk/activemq-test-atomikos/src/test/java/org/apache/activemq/atomikos/XATest.java (with props) Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/TransactionContext.java incubator/activemq/trunk/pom.xml Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/TransactionContext.java URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/TransactionContext.java?view=diff&rev=479726&r1=479725&r2=479726 ============================================================================== --- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/TransactionContext.java (original) +++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/TransactionContext.java Mon Nov 27 11:01:37 2006 @@ -35,6 +35,7 @@ import org.apache.activemq.command.TransactionId; import org.apache.activemq.command.TransactionInfo; import org.apache.activemq.command.XATransactionId; +import org.apache.activemq.command.DataStructure; import org.apache.activemq.transaction.Synchronization; import org.apache.activemq.util.JMSExceptionSupport; import org.apache.activemq.util.LongSequenceGenerator; @@ -514,7 +515,16 @@ this.connection.ensureConnectionInfoSent(); DataArrayResponse receipt = (DataArrayResponse) this.connection.syncSendPacket(info); - return (XATransactionId[]) receipt.getData(); + DataStructure[] data = receipt.getData(); + XATransactionId[] answer = null; + if (data instanceof XATransactionId[]) { + answer = (XATransactionId[]) data; + } + else { + answer = new XATransactionId[data.length]; + System.arraycopy(data, 0, answer, 0, data.length); + } + return answer; } catch (JMSException e) { throw toXAException(e); } Added: incubator/activemq/trunk/activemq-test-atomikos/pom.xml URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-test-atomikos/pom.xml?view=auto&rev=479726 ============================================================================== --- incubator/activemq/trunk/activemq-test-atomikos/pom.xml (added) +++ incubator/activemq/trunk/activemq-test-atomikos/pom.xml Mon Nov 27 11:01:37 2006 @@ -0,0 +1,101 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You 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. +--> + +<project + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns="http://maven.apache.org/POM/4.0.0"> + + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.apache.activemq</groupId> + <artifactId>activemq-parent</artifactId> + <version>4.2-incubator-SNAPSHOT</version> + </parent> + + <artifactId>activemq-test-atomikos</artifactId> + <packaging>jar</packaging> + <name>ActiveMQ :: Atomikos System Test</name> + + <repositories> + <!-- for the Atomikos jars --> + <repository> + <id>logicblaze.deps</id> + <url>http://repo.logicblaze.com/maven2-all</url> + <snapshots> + <enabled>true</enabled> + </snapshots> + <releases> + <enabled>true</enabled> + </releases> + </repository> + </repositories> + + <dependencies> + <!-- activemq --> + <dependency> + <groupId>${pom.groupId}</groupId> + <artifactId>activemq-core</artifactId> + </dependency> + <dependency> + <groupId>${pom.groupId}</groupId> + <artifactId>activemq-core</artifactId> + <scope>compile</scope> + <type>test-jar</type> + </dependency> + <dependency> + <groupId>${pom.groupId}</groupId> + <artifactId>activeio-core</artifactId> + </dependency> + <dependency> + <groupId>org.apache.derby</groupId> + <artifactId>derby</artifactId> + <optional>true</optional> + </dependency> + + <dependency> + <groupId>com.atomikos</groupId> + <artifactId>transactions</artifactId> + <version>3.1.0</version> + </dependency> + <dependency> + <groupId>com.atomikos</groupId> + <artifactId>transactions-api</artifactId> + <version>3.1.0</version> + </dependency> + <dependency> + <groupId>com.atomikos</groupId> + <artifactId>transactions-jta</artifactId> + <version>3.1.0</version> + </dependency> + <dependency> + <groupId>com.atomikos</groupId> + <artifactId>atomikos-util</artifactId> + <version>3.1.0</version> + </dependency> + + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <scope>compile</scope> + </dependency> + + </dependencies> +</project> Propchange: incubator/activemq/trunk/activemq-test-atomikos/pom.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/activemq/trunk/activemq-test-atomikos/pom.xml ------------------------------------------------------------------------------ svn:executable = * Propchange: incubator/activemq/trunk/activemq-test-atomikos/pom.xml ------------------------------------------------------------------------------ svn:keywords = Date Author Id Revision HeadURL Propchange: incubator/activemq/trunk/activemq-test-atomikos/pom.xml ------------------------------------------------------------------------------ svn:mime-type = text/xml Added: incubator/activemq/trunk/activemq-test-atomikos/src/test/java/org/apache/activemq/atomikos/XATest.java URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-test-atomikos/src/test/java/org/apache/activemq/atomikos/XATest.java?view=auto&rev=479726 ============================================================================== --- incubator/activemq/trunk/activemq-test-atomikos/src/test/java/org/apache/activemq/atomikos/XATest.java (added) +++ incubator/activemq/trunk/activemq-test-atomikos/src/test/java/org/apache/activemq/atomikos/XATest.java Mon Nov 27 11:01:37 2006 @@ -0,0 +1,66 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.activemq.atomikos; + +import com.atomikos.datasource.xa.DefaultXidFactory; +import org.apache.activemq.ActiveMQXAConnectionFactory; +import org.apache.activemq.command.ActiveMQQueue; + +import javax.jms.MessageConsumer; +import javax.jms.XAConnection; +import javax.jms.XASession; +import javax.transaction.xa.XAResource; +import javax.transaction.xa.Xid; + +import junit.framework.TestCase; + + +/** + * @version $Revision$ + */ +public class XATest extends TestCase { + + public void testXA() throws Exception { + //String url = "tcp://localhost:61616"; + String url = "vm://localhost"; + String qName = "MyQueue"; + int timeout = 5; + DefaultXidFactory xidFactory = new DefaultXidFactory(); + ActiveMQXAConnectionFactory xacf = new ActiveMQXAConnectionFactory(); + xacf.setBrokerURL(url); + ActiveMQQueue queue = new ActiveMQQueue(); + queue.setPhysicalName(qName); + XAConnection xaconn = xacf.createXAConnection(); + xaconn.start(); + XASession session = xaconn.createXASession(); + XAResource xares = session.getXAResource(); + MessageConsumer receiver = session.getSession().createConsumer(queue); + xares.recover(XAResource.TMSTARTRSCAN); + xares.recover(XAResource.TMNOFLAGS); + xares.setTransactionTimeout(timeout); + xares.isSameRM(xares); + Xid xid = xidFactory.createXid("part1", "part2"); + xares.start(xid, XAResource.TMNOFLAGS); + receiver.receive(timeout); + xares.end(xid, XAResource.TMSUCCESS); + xares.rollback(xid); + + System.out.println("Done!"); + } + +} Propchange: incubator/activemq/trunk/activemq-test-atomikos/src/test/java/org/apache/activemq/atomikos/XATest.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/activemq/trunk/activemq-test-atomikos/src/test/java/org/apache/activemq/atomikos/XATest.java ------------------------------------------------------------------------------ svn:keywords = Date Author Id Revision HeadURL Propchange: incubator/activemq/trunk/activemq-test-atomikos/src/test/java/org/apache/activemq/atomikos/XATest.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Modified: incubator/activemq/trunk/pom.xml URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/pom.xml?view=diff&rev=479726&r1=479725&r2=479726 ============================================================================== --- incubator/activemq/trunk/pom.xml (original) +++ incubator/activemq/trunk/pom.xml Mon Nov 27 11:01:37 2006 @@ -126,20 +126,21 @@ </distributionManagement> <modules> - <module>activemq-jaas</module> <module>activemq-core</module> <module>activemq-console</module> + <module>activemq-jaas</module> + <module>activemq-jpa-store</module> + <module>activemq-openwire-generator</module> + <module>activemq-optional</module> <module>activemq-ra</module> <module>activemq-rar</module> + <module>activemq-test-atomikos</module> + <module>activemq-tooling</module> <module>activemq-web</module> <module>activemq-web-demo</module> <module>activemq-web-console</module> - <module>activemq-optional</module> - <module>activemq-tooling</module> - <module>activemq-openwire-generator</module> <module>activemq-xmpp</module> <module>assembly</module> - <module>activemq-jpa-store</module> </modules> <scm>