[hornetq-commits] JBoss hornetq SVN: r8851 - 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
Wed Jan 27 12:07:28 EST 2010


Author: jmesnil
Date: 2010-01-27 12:07:27 -0500 (Wed, 27 Jan 2010)
New Revision: 8851

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

* test fixes

Modified: trunk/src/main/org/hornetq/core/protocol/stomp/StompMarshaller.java
===================================================================
--- trunk/src/main/org/hornetq/core/protocol/stomp/StompMarshaller.java	2010-01-27 16:25:14 UTC (rev 8850)
+++ trunk/src/main/org/hornetq/core/protocol/stomp/StompMarshaller.java	2010-01-27 17:07:27 UTC (rev 8851)
@@ -61,8 +61,8 @@
         buffer.append(Stomp.NEWLINE);
 
         // Output the headers.
-        for (Iterator iter = stomp.getHeaders().entrySet().iterator(); iter.hasNext();) {
-            Map.Entry entry = (Map.Entry) iter.next();
+        for (Iterator<Map.Entry<String, Object>> iter = stomp.getHeaders().entrySet().iterator(); iter.hasNext();) {
+            Map.Entry<String, Object> entry = iter.next();
             buffer.append(entry.getKey());
             buffer.append(Stomp.Headers.SEPERATOR);
             buffer.append(entry.getValue());
@@ -97,7 +97,7 @@
             }
 
             // Parse the headers
-            HashMap headers = new HashMap(25);
+            HashMap<String, Object> headers = new HashMap<String, Object>(25);
             while (true) {
                 String line = readLine(in, MAX_HEADER_LENGTH, "The maximum header length was exceeded");
                 if (line != null && line.trim().length() > 0) {
@@ -177,15 +177,22 @@
     }
 
     protected String readLine(HornetQBuffer in, int maxLength, String errorMessage) throws IOException {
-        byte b;
-        ByteArrayOutputStream baos = new ByteArrayOutputStream(maxLength);
-        while ((b = in.readByte()) != '\n') {
-            if (baos.size() > maxLength) {
-                throw new StompException(errorMessage, true);
-            }
-            baos.write(b);
-        }
-        byte[] sequence = baos.toByteArray();
-        return new String(sequence, "UTF-8");
+       char[] chars = new char[MAX_HEADER_LENGTH];
+       
+       int count = 0;
+       while (in.readable())
+       {
+          byte b = in.readByte();
+          
+          if (b == (byte)'\n')
+          {
+             break;
+          }             
+          else
+          {
+             chars[count++] = (char)b;
+          }
+       }
+       return new String(chars, 0, count);
     }
 }

Modified: trunk/src/main/org/hornetq/core/protocol/stomp/StompProtocolManager.java
===================================================================
--- trunk/src/main/org/hornetq/core/protocol/stomp/StompProtocolManager.java	2010-01-27 16:25:14 UTC (rev 8850)
+++ trunk/src/main/org/hornetq/core/protocol/stomp/StompProtocolManager.java	2010-01-27 17:07:27 UTC (rev 8851)
@@ -277,7 +277,7 @@
       boolean unsubscribed = stompSession.unsubscribe(subscriptionID);
       if (!unsubscribed)
       {
-         throw new StompException("Cannot unsubscribe as o subscription exists for id: " + subscriptionID);
+         throw new StompException("Cannot unsubscribe as a subscription exists for id: " + subscriptionID);
       }
       return null;
    }
@@ -412,6 +412,8 @@
 
    private StompFrame onDisconnect(StompFrame frame, HornetQServer server, StompConnection connection) throws Exception
    {
+      connection.setValid(false);
+
       StompSession session = sessions.remove(connection);
       if (session != null)
       {
@@ -439,7 +441,6 @@
             iterator.remove();
          }
       }
-      connection.setValid(false);
 
       return null;
    }

Modified: trunk/tests/src/org/hornetq/tests/integration/stomp/StompTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/integration/stomp/StompTest.java	2010-01-27 16:25:14 UTC (rev 8850)
+++ trunk/tests/src/org/hornetq/tests/integration/stomp/StompTest.java	2010-01-27 17:07:27 UTC (rev 8851)
@@ -98,6 +98,8 @@
        connect_frame = "DISCONNECT\n\n" + Stomp.NULL;
        sendFrame(connect_frame);
        
+       waitForFrameToTakeEffect();
+       
        // sending a message will result in an error
        String frame =
           "SEND\n" +
@@ -1193,7 +1195,7 @@
        
        frame =
           "UNSUBSCRIBE\n" +
-                  "destination:/topic/" + getQueueName() + "\n" +
+                  "destination:/queue/" + getQueueName() + "\n" +
                   "\n\n" +
                   Stomp.NULL;
        sendFrame(frame);



More information about the hornetq-commits mailing list