Exemple #1
0
        public void test_CreateTempQueue()
        {
            using (MQConnection con = connectToServer(address, null, null)) {
                String      queueName = String.Empty;
                QueueHandle qh        = new QueueHandle();

                // Try and create a temporary queue
                ErrorCode err = con.CreateTempQueue(out queueName, qh);
                Console.WriteLine("queueName:" + queueName);
                Assert.AreEqual(ErrorCode.EC_NOERROR, err, "Creating Queue");

                // Get permissions for that queue
                List <QueuePermissions> perms = new List <QueuePermissions>();
                con.QueueEnumeratePermissions(queueName, perms);
                for (int x = 0; x < perms.Count; ++x)
                {
                    QueuePermissions perm = perms[x];
                    Console.WriteLine(perm.EntityName + ":" + perm.Read + ":" + perm.Write + ":" + perm.Destroy + ":" + perm.ChangeSecurity);
                }
                Assert.IsTrue(perms.Count > 0);

                addAllUsers(con);

                // Try and write to that queue with another user.
                using (MQConnection con2 = connectToServer(simpleAddress, TEST_USERS[0], TEST_USERS[0])) {
                    QueueHandle qh2 = new QueueHandle();
                    ErrorCode   rc  = con2.OpenQueue(queueName, qh2);
                    Assert.IsTrue(rc == ErrorCode.EC_NOERROR, "Open Temp Queue rc:" + rc);
                    QueueMessage msg = new QueueMessage();
                    msg.Label = "Hello World";
                    Assert.IsTrue(ErrorCode.EC_NOERROR == con2.Enqueue(qh2, msg), "Enqueue to temp");
                    con2.CloseQueue(qh2);
                }
            }
        }