You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by or...@apache.org on 2018/01/12 22:56:43 UTC
qpid-jms-amqp-0-x git commit: QPID-8074: [JMS AMQP 0-x][System Tests]
Copy client specific test JMSXUserIDTest from Broker-J sources
Repository: qpid-jms-amqp-0-x
Updated Branches:
refs/heads/master 2dfc8e4d0 -> 738a72b88
QPID-8074: [JMS AMQP 0-x][System Tests] Copy client specific test JMSXUserIDTest from Broker-J sources
Project: http://git-wip-us.apache.org/repos/asf/qpid-jms-amqp-0-x/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms-amqp-0-x/commit/738a72b8
Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms-amqp-0-x/tree/738a72b8
Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms-amqp-0-x/diff/738a72b8
Branch: refs/heads/master
Commit: 738a72b8806757530a36df3496a7ddc9cd291001
Parents: 2dfc8e4
Author: Alex Rudyy <or...@apache.org>
Authored: Fri Jan 12 22:55:55 2018 +0000
Committer: Alex Rudyy <or...@apache.org>
Committed: Fri Jan 12 22:55:55 2018 +0000
----------------------------------------------------------------------
.../qpid/systest/message/JMSXUserIDTest.java | 99 ++++++++++++++++++++
1 file changed, 99 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-jms-amqp-0-x/blob/738a72b8/systests/src/test/java/org/apache/qpid/systest/message/JMSXUserIDTest.java
----------------------------------------------------------------------
diff --git a/systests/src/test/java/org/apache/qpid/systest/message/JMSXUserIDTest.java b/systests/src/test/java/org/apache/qpid/systest/message/JMSXUserIDTest.java
new file mode 100644
index 0000000..558db99
--- /dev/null
+++ b/systests/src/test/java/org/apache/qpid/systest/message/JMSXUserIDTest.java
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.qpid.systest.message;
+
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.util.Collections;
+
+import javax.jms.Connection;
+import javax.jms.Destination;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+
+import org.junit.Test;
+
+import org.apache.qpid.systest.core.BrokerAdmin;
+import org.apache.qpid.systest.core.JmsTestBase;
+
+public class JMSXUserIDTest extends JmsTestBase
+{
+ @Test
+ public void testJMSXUserIDIsSetByDefault() throws Exception
+ {
+ BrokerAdmin brokerAdmin = getBrokerAdmin();
+ Connection connection = getConnection();
+ try
+ {
+ Session session = connection.createSession(true, Session.SESSION_TRANSACTED);
+ Destination destination = session.createQueue(getTestName());
+ MessageConsumer consumer = session.createConsumer(destination);
+ MessageProducer producer = session.createProducer(destination);
+ TextMessage message = session.createTextMessage("test");
+ producer.send(message);
+ assertEquals("Unexpected user ID", brokerAdmin.getValidUsername(), message.getStringProperty("JMSXUserID"));
+ session.commit();
+ connection.start();
+ Message receivedMessage = consumer.receive(getReceiveTimeout());
+ session.commit();
+ assertNotNull("Expected receivedMessage not received", receivedMessage);
+ assertEquals("Unexpected user ID",
+ brokerAdmin.getValidUsername(),
+ receivedMessage.getStringProperty("JMSXUserID"));
+ }
+ finally
+ {
+ connection.close();
+ }
+ }
+
+ @Test
+ public void testJMSXUserIDDisabled() throws Exception
+ {
+
+ Connection connection = getConnection(Collections.singletonMap("populateJMSXUserID", "false"));
+ try
+ {
+ Session session = connection.createSession(true, Session.SESSION_TRANSACTED);
+ Destination destination = session.createQueue(getTestName());
+ MessageConsumer consumer = session.createConsumer(destination);
+ MessageProducer producer = session.createProducer(destination);
+ TextMessage message = session.createTextMessage("test");
+ producer.send(message);
+ String userId = message.getStringProperty("JMSXUserID");
+ assertEquals("Unexpected user ID =[" + userId + "]", null, userId);
+ session.commit();
+ connection.start();
+ Message receivedMessage = consumer.receive(getReceiveTimeout());
+ session.commit();
+ assertNotNull("Expected receivedMessage not received", receivedMessage);
+ String receivedUserId = receivedMessage.getStringProperty("JMSXUserID");
+ assertEquals("Unexpected user ID " + receivedUserId, null, receivedUserId);
+ }
+ finally
+ {
+ connection.close();
+ }
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org