Author: gaohoward
Date: 2011-09-13 11:05:32 -0400 (Tue, 13 Sep 2011)
New Revision: 11345
Modified:
branches/STOMP11/hornetq-core/src/main/java/org/hornetq/core/protocol/stomp/StompConnection.java
branches/STOMP11/hornetq-core/src/main/java/org/hornetq/core/protocol/stomp/v10/StompFrameHandlerV10.java
branches/STOMP11/tests/integration-tests/src/test/java/org/hornetq/tests/integration/stomp/v11/StompTestV11.java
Log:
test
Modified:
branches/STOMP11/hornetq-core/src/main/java/org/hornetq/core/protocol/stomp/StompConnection.java
===================================================================
---
branches/STOMP11/hornetq-core/src/main/java/org/hornetq/core/protocol/stomp/StompConnection.java 2011-09-13
14:44:04 UTC (rev 11344)
+++
branches/STOMP11/hornetq-core/src/main/java/org/hornetq/core/protocol/stomp/StompConnection.java 2011-09-13
15:05:32 UTC (rev 11345)
@@ -371,6 +371,8 @@
{
String acceptVersion = frame.getHeader(Stomp.Headers.ACCEPT_VERSION);
+ log.error("----------------- acceptVersion: " + acceptVersion);
+
if (acceptVersion == null)
{
this.version = StompVersions.V1_0;
@@ -401,6 +403,7 @@
error.setBody("Supported protocol version are " +
manager.getSupportedVersionsAsString());
throw error;
}
+ log.error("------------------ negotiated version is " +
this.version);
}
this.frameHandler = VersionedStompFrameHandler.getHandler(this, this.version);
Modified:
branches/STOMP11/hornetq-core/src/main/java/org/hornetq/core/protocol/stomp/v10/StompFrameHandlerV10.java
===================================================================
---
branches/STOMP11/hornetq-core/src/main/java/org/hornetq/core/protocol/stomp/v10/StompFrameHandlerV10.java 2011-09-13
14:44:04 UTC (rev 11344)
+++
branches/STOMP11/hornetq-core/src/main/java/org/hornetq/core/protocol/stomp/v10/StompFrameHandlerV10.java 2011-09-13
15:05:32 UTC (rev 11345)
@@ -70,6 +70,11 @@
response = new StompFrameV10(Stomp.Responses.CONNECTED);
+ if (frame.hasHeader(Stomp.Headers.ACCEPT_VERSION))
+ {
+ response.addHeader(Stomp.Headers.Connected.VERSION, "1.0");
+ }
+
response.addHeader(Stomp.Headers.Connected.SESSION,
connection.getID().toString());
if (requestID != null)
Modified:
branches/STOMP11/tests/integration-tests/src/test/java/org/hornetq/tests/integration/stomp/v11/StompTestV11.java
===================================================================
---
branches/STOMP11/tests/integration-tests/src/test/java/org/hornetq/tests/integration/stomp/v11/StompTestV11.java 2011-09-13
14:44:04 UTC (rev 11344)
+++
branches/STOMP11/tests/integration-tests/src/test/java/org/hornetq/tests/integration/stomp/v11/StompTestV11.java 2011-09-13
15:05:32 UTC (rev 11345)
@@ -27,22 +27,16 @@
{
private static final transient Logger log = Logger.getLogger(StompTestV11.class);
- private StompClientConnection connV10;
private StompClientConnection connV11;
protected void setUp() throws Exception
{
super.setUp();
- connV10 = StompClientConnectionFactory.createClientConnection("1.0",
hostname, port);
connV11 = StompClientConnectionFactory.createClientConnection("1.1",
hostname, port);
}
protected void tearDown() throws Exception
{
- if (connV10.isConnected())
- {
- connV10.disconnect();
- }
if (connV11.isConnected())
{
connV11.disconnect();
@@ -73,10 +67,18 @@
connection.disconnect();
}
+ /*
+ * test case:
+ * 1 accept-version absent. It is a 1.0 connect
+ * 2 accept-version=1.0, result: 1.0
+ * 3 accept-version=1.0,1.1,1.2, result 1.1
+ * 4 accept-version="1.2,1.3", result error
+ */
public void testNegotiation() throws Exception
{
+ // case 1
ClientStompFrame frame = connV11.createFrame("CONNECT");
- frame.addHeader("accept-version", "1.0,1.1");
+ //frame.addHeader("accept-version", "1.0,1.1,1.2");
frame.addHeader("host", "127.0.0.1");
frame.addHeader("login", this.defUser);
frame.addHeader("passcode", this.defPass);
@@ -86,20 +88,8 @@
assertEquals("CONNECTED", reply.getCommand());
//reply headers: version, session, server
- assertEquals("1.1", reply.getHeader("version"));
+ assertEquals(null, reply.getHeader("version"));
- String sessionId = reply.getHeader("session");
-
- log.info("session id: " + sessionId);
-
- assertNotNull(sessionId);
-
- String server = reply.getHeader("server");
-
- log.info("server: " + server);
-
- assertNotNull(server);
-
connV11.disconnect();
}