mirror of https://github.com/apache/activemq.git
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@906071 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
5170a8bba3
commit
caabb6cb3d
|
@ -74,6 +74,10 @@ public interface FrameTranslator {
|
||||||
headers.put(Stomp.Headers.Message.TYPE, message.getJMSType());
|
headers.put(Stomp.Headers.Message.TYPE, message.getJMSType());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (message.getUserID() != null) {
|
||||||
|
headers.put(Stomp.Headers.Message.USERID, message.getUserID());
|
||||||
|
}
|
||||||
|
|
||||||
// now lets add all the message headers
|
// now lets add all the message headers
|
||||||
final Map<String, Object> properties = message.getProperties();
|
final Map<String, Object> properties = message.getProperties();
|
||||||
if (properties != null) {
|
if (properties != null) {
|
||||||
|
|
|
@ -76,6 +76,7 @@ public interface Stomp {
|
||||||
String TIMESTAMP = "timestamp";
|
String TIMESTAMP = "timestamp";
|
||||||
String TYPE = "type";
|
String TYPE = "type";
|
||||||
String SUBSCRIPTION = "subscription";
|
String SUBSCRIPTION = "subscription";
|
||||||
|
String USERID = "JMSXUserID";
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface Subscribe {
|
public interface Subscribe {
|
||||||
|
|
|
@ -470,9 +470,7 @@ public class StompTest extends CombinationTestSupport {
|
||||||
LOG.info("Received frame: " + frame);
|
LOG.info("Received frame: " + frame);
|
||||||
fail("No message should have been received since subscription was removed");
|
fail("No message should have been received since subscription was removed");
|
||||||
} catch (SocketTimeoutException e) {
|
} catch (SocketTimeoutException e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testTransactionCommit() throws Exception {
|
public void testTransactionCommit() throws Exception {
|
||||||
|
@ -563,7 +561,6 @@ public class StompTest extends CombinationTestSupport {
|
||||||
|
|
||||||
assertTrue(f.startsWith("ERROR"));
|
assertTrue(f.startsWith("ERROR"));
|
||||||
assertClients(1);
|
assertClients(1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testConnectNotAuthenticatedWrongPassword() throws Exception {
|
public void testConnectNotAuthenticatedWrongPassword() throws Exception {
|
||||||
|
@ -590,7 +587,6 @@ public class StompTest extends CombinationTestSupport {
|
||||||
stompConnection.sendFrame(frame);
|
stompConnection.sendFrame(frame);
|
||||||
String f = stompConnection.receiveFrame();
|
String f = stompConnection.receiveFrame();
|
||||||
assertTrue(f.startsWith("ERROR"));
|
assertTrue(f.startsWith("ERROR"));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testSubscribeNotAuthorized() throws Exception {
|
public void testSubscribeNotAuthorized() throws Exception {
|
||||||
|
@ -961,8 +957,6 @@ public class StompTest extends CombinationTestSupport {
|
||||||
sendMessage("message 4");
|
sendMessage("message 4");
|
||||||
sendMessage("message 5");
|
sendMessage("message 5");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
StompFrame frame = stompConnection.receive();
|
StompFrame frame = stompConnection.receive();
|
||||||
assertEquals(frame.getBody(), "message 1");
|
assertEquals(frame.getBody(), "message 1");
|
||||||
|
|
||||||
|
@ -1006,7 +1000,6 @@ public class StompTest extends CombinationTestSupport {
|
||||||
stompConnection.commit("tx3");
|
stompConnection.commit("tx3");
|
||||||
|
|
||||||
stompDisconnect();
|
stompDisconnect();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testTransactionsWithMultipleDestinations() throws Exception {
|
public void testTransactionsWithMultipleDestinations() throws Exception {
|
||||||
|
@ -1032,10 +1025,8 @@ public class StompTest extends CombinationTestSupport {
|
||||||
stompConnection.send("/queue/test1", "another message");
|
stompConnection.send("/queue/test1", "another message");
|
||||||
|
|
||||||
StompFrame frame = stompConnection.receive(500);
|
StompFrame frame = stompConnection.receive(500);
|
||||||
System.out.println(frame);
|
|
||||||
assertNotNull(frame);
|
assertNotNull(frame);
|
||||||
|
|
||||||
|
|
||||||
stompConnection.disconnect();
|
stompConnection.disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1057,6 +1048,44 @@ public class StompTest extends CombinationTestSupport {
|
||||||
assertEquals("Hello World", message.getBody());
|
assertEquals("Hello World", message.getBody());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testJMSXUserIDIsSetInMessage() throws Exception {
|
||||||
|
|
||||||
|
MessageConsumer consumer = session.createConsumer(queue);
|
||||||
|
|
||||||
|
String frame = "CONNECT\n" + "login: system\n" + "passcode: manager\n\n" + Stomp.NULL;
|
||||||
|
stompConnection.sendFrame(frame);
|
||||||
|
|
||||||
|
frame = stompConnection.receiveFrame();
|
||||||
|
assertTrue(frame.startsWith("CONNECTED"));
|
||||||
|
|
||||||
|
frame = "SEND\n" + "destination:/queue/" + getQueueName() + "\n\n" + "Hello World" + Stomp.NULL;
|
||||||
|
|
||||||
|
stompConnection.sendFrame(frame);
|
||||||
|
|
||||||
|
TextMessage message = (TextMessage)consumer.receive(1000);
|
||||||
|
assertNotNull(message);
|
||||||
|
assertEquals("system", message.getStringProperty(Stomp.Headers.Message.USERID));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testJMSXUserIDIsSetInStompMessage() throws Exception {
|
||||||
|
|
||||||
|
String frame = "CONNECT\n" + "login: system\n" + "passcode: manager\n\n" + Stomp.NULL;
|
||||||
|
stompConnection.sendFrame(frame);
|
||||||
|
|
||||||
|
frame = stompConnection.receiveFrame();
|
||||||
|
assertTrue(frame.startsWith("CONNECTED"));
|
||||||
|
|
||||||
|
frame = "SUBSCRIBE\n" + "destination:/queue/" + getQueueName() + "\n" + "ack:auto\n\n" + Stomp.NULL;
|
||||||
|
stompConnection.sendFrame(frame);
|
||||||
|
|
||||||
|
frame = "SEND\n" + "destination:/queue/" + getQueueName() + "\n\n" + "Hello World" + Stomp.NULL;
|
||||||
|
stompConnection.sendFrame(frame);
|
||||||
|
|
||||||
|
StompFrame message = stompConnection.receive(1000);
|
||||||
|
assertEquals("system", message.getHeaders().get(Stomp.Headers.Message.USERID));
|
||||||
|
}
|
||||||
|
|
||||||
protected void assertClients(int expected) throws Exception {
|
protected void assertClients(int expected) throws Exception {
|
||||||
org.apache.activemq.broker.Connection[] clients = broker.getBroker().getClients();
|
org.apache.activemq.broker.Connection[] clients = broker.getBroker().getClients();
|
||||||
int actual = clients.length;
|
int actual = clients.length;
|
||||||
|
@ -1071,5 +1100,3 @@ public class StompTest extends CombinationTestSupport {
|
||||||
Thread.sleep(2000);
|
Thread.sleep(2000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue