Return-Path: Delivered-To: apmail-geronimo-activemq-commits-archive@www.apache.org Received: (qmail 14540 invoked from network); 14 Feb 2006 16:57:13 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 14 Feb 2006 16:57:13 -0000 Received: (qmail 37177 invoked by uid 500); 14 Feb 2006 16:56:41 -0000 Delivered-To: apmail-geronimo-activemq-commits-archive@geronimo.apache.org Received: (qmail 37145 invoked by uid 500); 14 Feb 2006 16:56:41 -0000 Mailing-List: contact activemq-commits-help@geronimo.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: activemq-dev@geronimo.apache.org Delivered-To: mailing list activemq-commits@geronimo.apache.org Received: (qmail 37129 invoked by uid 99); 14 Feb 2006 16:56:40 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 14 Feb 2006 08:56:40 -0800 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Tue, 14 Feb 2006 08:56:40 -0800 Received: (qmail 13657 invoked by uid 65534); 14 Feb 2006 16:56:19 -0000 Message-ID: <20060214165619.13654.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r377766 - in /incubator/activemq/trunk/activemq-core/src: main/java/org/apache/activemq/transport/stomp/ test/java/org/apache/activemq/transport/stomp/ Date: Tue, 14 Feb 2006 16:56:17 -0000 To: activemq-commits@geronimo.apache.org From: jstrachan@apache.org X-Mailer: svnmailer-1.0.6 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: jstrachan Date: Tue Feb 14 08:56:15 2006 New Revision: 377766 URL: http://svn.apache.org/viewcvs?rev=377766&view=rev Log: fixed up the Stomp test cases Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/stomp/Abort.java incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/stomp/Begin.java incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/stomp/Commit.java incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/stomp/StompTest.java Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/stomp/Abort.java URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/stomp/Abort.java?rev=377766&r1=377765&r2=377766&view=diff ============================================================================== --- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/stomp/Abort.java (original) +++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/stomp/Abort.java Tue Feb 14 08:56:15 2006 @@ -44,6 +44,7 @@ TransactionId txnId = format.getTransactionId(user_tx_id); TransactionInfo tx = new TransactionInfo(); + tx.setConnectionId(format.getConnectionId()); tx.setTransactionId(txnId); tx.setType(TransactionInfo.ROLLBACK); format.clearTransactionId(user_tx_id); Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/stomp/Begin.java URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/stomp/Begin.java?rev=377766&r1=377765&r2=377766&view=diff ============================================================================== --- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/stomp/Begin.java (original) +++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/stomp/Begin.java Tue Feb 14 08:56:15 2006 @@ -44,6 +44,7 @@ } int tx_id = StompWireFormat.generateTransactionId(); TransactionId transactionId = format.registerTransactionId(user_tx_id, tx_id); + tx.setConnectionId(format.getConnectionId()); tx.setTransactionId(transactionId); tx.setType(TransactionInfo.BEGIN); return new CommandEnvelope(tx, headers); Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/stomp/Commit.java URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/stomp/Commit.java?rev=377766&r1=377765&r2=377766&view=diff ============================================================================== --- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/stomp/Commit.java (original) +++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/stomp/Commit.java Tue Feb 14 08:56:15 2006 @@ -39,12 +39,15 @@ String user_tx_id = headers.getProperty(Stomp.Headers.TRANSACTION); - if (!headers.containsKey(Stomp.Headers.TRANSACTION)) { + if (user_tx_id == null) { throw new ProtocolException("Must specify the transaction you are committing"); } TransactionId tx_id = format.getTransactionId(user_tx_id); + if (tx_id == null) + throw new ProtocolException(user_tx_id + " is an invalid transaction id"); TransactionInfo tx = new TransactionInfo(); + tx.setConnectionId(format.getConnectionId()); tx.setTransactionId(tx_id); tx.setType(TransactionInfo.COMMIT_ONE_PHASE); format.clearTransactionId(user_tx_id); Modified: incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/stomp/StompTest.java URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/stomp/StompTest.java?rev=377766&r1=377765&r2=377766&view=diff ============================================================================== --- incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/stomp/StompTest.java (original) +++ incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/stomp/StompTest.java Tue Feb 14 08:56:15 2006 @@ -314,7 +314,7 @@ //receive message from socket - frame = receiveFrame(10000); + frame = receiveFrame(1000); assertTrue(frame.startsWith("MESSAGE")); //remove suscription @@ -325,8 +325,7 @@ Stomp.NULL; sendFrame(frame); - // lets wait for the unsubscribe to take effect - Thread.sleep(1000); + waitForFrameToTakeEffect(); //send a message to our queue sendMessage("second message"); @@ -344,6 +343,8 @@ public void testTransactionCommit() throws Exception { + MessageConsumer consumer = session.createConsumer(queue); + String frame = "CONNECT\n" + "login: brianm\n" + @@ -353,7 +354,7 @@ String f = receiveFrame(1000); assertTrue(f.startsWith("CONNECTED")); - + frame = "BEGIN\n" + "transaction: tx1\n" + @@ -370,7 +371,6 @@ Stomp.NULL; sendFrame(frame); - frame = "COMMIT\n" + "transaction: tx1\n" + @@ -378,16 +378,15 @@ Stomp.NULL; sendFrame(frame); - // This test case is currently failing - - MessageConsumer consumer = session.createConsumer(queue); + waitForFrameToTakeEffect(); + TextMessage message = (TextMessage) consumer.receive(1000); - assertNotNull(message); - - + assertNotNull("Should have received a message", message); } public void testTransactionRollback() throws Exception { + MessageConsumer consumer = session.createConsumer(queue); + String frame = "CONNECT\n" + "login: brianm\n" + @@ -409,7 +408,7 @@ "SEND\n" + "destination:/queue/" + getQueueName() + "\n" + "transaction: tx1\n" + - "\n\n" + + "\n" + "first message" + Stomp.NULL; sendFrame(frame); @@ -423,10 +422,17 @@ sendFrame(frame); frame = + "BEGIN\n" + + "transaction: tx1\n" + + "\n\n" + + Stomp.NULL; + sendFrame(frame); + + frame = "SEND\n" + "destination:/queue/" + getQueueName() + "\n" + "transaction: tx1\n" + - "\n\n" + + "\n" + "second message" + Stomp.NULL; sendFrame(frame); @@ -439,17 +445,18 @@ sendFrame(frame); // This test case is currently failing + waitForFrameToTakeEffect(); //only second msg should be received since first msg was rolled back - MessageConsumer consumer = session.createConsumer(queue); TextMessage message = (TextMessage) consumer.receive(1000); assertNotNull(message); - assertEquals("second message", message.getText()); - - + assertEquals("second message", message.getText().trim()); } - - - + protected void waitForFrameToTakeEffect() throws InterruptedException { + // bit of a dirty hack :) + // another option would be to force some kind of receipt to be returned + // from the frame + Thread.sleep(2000); + } }