Return-Path: Delivered-To: apmail-geronimo-activemq-commits-archive@www.apache.org Received: (qmail 57401 invoked from network); 14 Feb 2006 12:44:11 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 14 Feb 2006 12:44:11 -0000 Received: (qmail 50432 invoked by uid 500); 14 Feb 2006 12:44:11 -0000 Delivered-To: apmail-geronimo-activemq-commits-archive@geronimo.apache.org Received: (qmail 50417 invoked by uid 500); 14 Feb 2006 12:44:11 -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 50408 invoked by uid 99); 14 Feb 2006 12:44:10 -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 04:44:10 -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 04:44:10 -0800 Received: (qmail 57265 invoked by uid 65534); 14 Feb 2006 12:43:49 -0000 Message-ID: <20060214124349.57264.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r377712 - in /incubator/activemq/trunk/activemq-core/src: main/java/org/apache/activemq/command/Message.java test/java/org/apache/activemq/transport/stomp/StompTest.java Date: Tue, 14 Feb 2006 12:43:48 -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 04:43:46 2006 New Revision: 377712 URL: http://svn.apache.org/viewcvs?rev=377712&view=rev Log: added test case and fix for the sending of Stomp messages with headers Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/Message.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/command/Message.java URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/Message.java?rev=377712&r1=377711&r2=377712&view=diff ============================================================================== --- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/Message.java (original) +++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/Message.java Tue Feb 14 04:43:46 2006 @@ -142,7 +142,7 @@ public void setProperties(Map properties) throws IOException { lazyCreateProperties(); - properties.putAll(properties); + this.properties.putAll(properties); } public void setProperty(String name, Object value) throws IOException { 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=377712&r1=377711&r2=377712&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 04:43:46 2006 @@ -16,27 +16,25 @@ */ package org.apache.activemq.transport.stomp; +import org.apache.activemq.ActiveMQConnectionFactory; +import org.apache.activemq.CombinationTestSupport; +import org.apache.activemq.broker.BrokerService; +import org.apache.activemq.broker.TransportConnector; +import org.apache.activemq.command.ActiveMQQueue; + +import javax.jms.Connection; +import javax.jms.MessageConsumer; +import javax.jms.MessageProducer; +import javax.jms.Session; +import javax.jms.TextMessage; + import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.Socket; -import java.net.URI; import java.net.SocketTimeoutException; - - -import javax.jms.*; - -import org.apache.activemq.ActiveMQConnectionFactory; -import org.apache.activemq.CombinationTestSupport; -import org.apache.activemq.broker.BrokerService; -import org.apache.activemq.broker.TransportConnector; -import org.apache.activemq.broker.region.policy.SimpleDispatchPolicy; -import org.apache.activemq.broker.region.policy.PolicyEntry; -import org.apache.activemq.broker.region.policy.RoundRobinDispatchPolicy; -import org.apache.activemq.broker.region.policy.PolicyMap; -import org.apache.activemq.command.ActiveMQQueue; -import org.apache.activemq.transport.stomp.Stomp; +import java.net.URI; public class StompTest extends CombinationTestSupport { @@ -62,12 +60,16 @@ ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("vm://localhost"); connection = cf.createConnection(); session = connection.createSession(false,Session.AUTO_ACKNOWLEDGE); - queue = new ActiveMQQueue("TEST"); + queue = new ActiveMQQueue(getQueueName()); connection.start(); } + protected String getQueueName() { + return getClass().getName() + "." + getName(); + } + protected void tearDown() throws Exception { connection.close(); stompSocket.close(); @@ -129,23 +131,51 @@ "passcode: wombats\n\n"+ Stomp.NULL; sendFrame(frame); + + frame = receiveFrame(10000); + assertTrue(frame.startsWith("CONNECTED")); + + frame = + "SEND\n" + + "destination:/queue/" + getQueueName() + "\n\n" + + "Hello World" + + Stomp.NULL; + + sendFrame(frame); + + TextMessage message = (TextMessage) consumer.receive(1000); + assertNotNull(message); + assertEquals("Hello World", message.getText()); + } + + + public void testSendMessageWithHeaders() throws Exception { + + MessageConsumer consumer = session.createConsumer(queue, "foo = 'abc'"); + + String frame = + "CONNECT\n" + + "login: brianm\n" + + "passcode: wombats\n\n"+ + Stomp.NULL; + sendFrame(frame); frame = receiveFrame(10000); assertTrue(frame.startsWith("CONNECTED")); frame = "SEND\n" + - "destination:/queue/TEST\n\n" + + "foo:abc\n" + + "bar:123\n" + + "destination:/queue/" + getQueueName() + "\n\n" + "Hello World" + Stomp.NULL; sendFrame(frame); - TextMessage message = (TextMessage) consumer.receive(1000); + TextMessage message = (TextMessage) consumer.receive(60000); assertNotNull(message); assertEquals("Hello World", message.getText()); - - } public void testSubscribeWithAutoAck() throws Exception { @@ -162,7 +192,7 @@ frame = "SUBSCRIBE\n" + - "destination:/queue/TEST\n" + + "destination:/queue/" + getQueueName() + "\n" + "ack:auto\n\n" + Stomp.NULL; sendFrame(frame); @@ -197,7 +227,7 @@ frame = "SUBSCRIBE\n" + - "destination:/queue/TEST\n" + + "destination:/queue/" + getQueueName() + "\n" + "ack:client\n\n"+ Stomp.NULL; @@ -236,13 +266,13 @@ frame = "SUBSCRIBE\n" + - "destination:/queue/TEST\n" + + "destination:/queue/" + getQueueName() + "\n" + "ack:auto\n\n" + Stomp.NULL; sendFrame(frame); //send a message to our queue - sendMessage(getName()); + sendMessage("first message"); //receive message from socket @@ -252,17 +282,18 @@ //remove suscription frame = "UNSUBSCRIBE\n" + - "destination:/queue/TEST\n" + + "destination:/queue/" + getQueueName() + "\n" + "\n\n" + Stomp.NULL; sendFrame(frame); //send a message to our queue - sendMessage(getName()); + sendMessage("second message"); try { frame = receiveFrame(1000); + System.out.println("Received frame: " + frame); fail("No message should have been received since subscription was removed"); }catch (SocketTimeoutException e){ @@ -291,7 +322,7 @@ frame = "SEND\n" + - "destination:/queue/TEST\n" + + "destination:/queue/" + getQueueName() + "\n" + "transaction: tx1\n" + "\n\n" + "Hello World" + @@ -335,7 +366,7 @@ frame = "SEND\n" + - "destination:/queue/TEST\n" + + "destination:/queue/" + getQueueName() + "\n" + "transaction: tx1\n" + "\n\n" + "first message" + @@ -352,7 +383,7 @@ frame = "SEND\n" + - "destination:/queue/TEST\n" + + "destination:/queue/" + getQueueName() + "\n" + "transaction: tx1\n" + "\n\n" + "second message" +