[hornetq-commits] JBoss hornetq SVN: r8882 - in trunk: tests/src/org/hornetq/tests/integration/stomp and 1 other directory.

do-not-reply at jboss.org do-not-reply at jboss.org
Tue Feb 16 10:28:25 EST 2010


Author: jmesnil
Date: 2010-02-16 10:28:23 -0500 (Tue, 16 Feb 2010)
New Revision: 8882

Modified:
   trunk/src/main/org/hornetq/core/protocol/stomp/StompSession.java
   trunk/tests/src/org/hornetq/tests/integration/stomp/StompTest.java
Log:
https://jira.jboss.org/jira/browse/HORNETQ-129: Implement STOMP v1.0

* make sure a text body is encoded with UTF-8
* add testBodyWithUTF8()

Modified: trunk/src/main/org/hornetq/core/protocol/stomp/StompSession.java
===================================================================
--- trunk/src/main/org/hornetq/core/protocol/stomp/StompSession.java	2010-02-16 14:47:14 UTC (rev 8881)
+++ trunk/src/main/org/hornetq/core/protocol/stomp/StompSession.java	2010-02-16 15:28:23 UTC (rev 8882)
@@ -92,7 +92,7 @@
             SimpleString text = serverMessage.getBodyBuffer().readNullableSimpleString();
             if (text != null)
             {
-               data = text.toString().getBytes();
+               data = text.toString().getBytes("UTF-8");
             }
          }
          else

Modified: trunk/tests/src/org/hornetq/tests/integration/stomp/StompTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/integration/stomp/StompTest.java	2010-02-16 14:47:14 UTC (rev 8881)
+++ trunk/tests/src/org/hornetq/tests/integration/stomp/StompTest.java	2010-02-16 15:28:23 UTC (rev 8882)
@@ -497,6 +497,49 @@
        sendFrame(frame);
    }
 
+    public void testBodyWithUTF8() throws Exception {
+
+       String frame =
+               "CONNECT\n" +
+                       "login: brianm\n" +
+                       "passcode: wombats\n\n" +
+                       Stomp.NULL;
+       sendFrame(frame);
+
+       frame = receiveFrame(100000);
+       Assert.assertTrue(frame.startsWith("CONNECTED"));
+
+       frame =
+               "SUBSCRIBE\n" +
+                       "destination:" + getQueuePrefix() + getQueueName() + "\n" +
+                       "ack:auto\n\n" +
+                       Stomp.NULL;
+       sendFrame(frame);
+
+       String text = "A" + "\u00ea" + "\u00f1" + 
+              "\u00fc" + "C";
+       System.out.println(text);
+       sendMessage(text);
+
+       frame = receiveFrame(10000);
+       System.out.println(frame);
+       Assert.assertTrue(frame.startsWith("MESSAGE"));
+       Assert.assertTrue(frame.indexOf("destination:") > 0);
+       Assert.assertTrue(frame.indexOf(text) > 0);
+
+       frame =
+               "DISCONNECT\n" +
+                       "\n\n" +
+                       Stomp.NULL;
+       sendFrame(frame);
+       
+       // message should not be received as it was auto-acked
+       MessageConsumer consumer = session.createConsumer(queue);
+       TextMessage message = (TextMessage) consumer.receive(1000);
+       Assert.assertNull(message);
+
+   }
+    
     public void testMessagesAreInOrder() throws Exception {
         int ctr = 10;
         String[] data = new String[ctr];



More information about the hornetq-commits mailing list