qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ai...@apache.org
Subject svn commit: r886998 [9/14] - in /qpid/trunk: ./ qpid/dotnet/Qpid.Buffer.Tests/ qpid/dotnet/Qpid.Buffer.Tests/Properties/ qpid/dotnet/Qpid.Buffer/ qpid/dotnet/Qpid.Client.Tests/BrokerDetails/ qpid/dotnet/Qpid.Client.Tests/Channel/ qpid/dotnet/Qpid.Clien...
Date Thu, 03 Dec 2009 23:55:56 GMT
Modified: qpid/trunk/qpid/dotnet/Qpid.Integration.Tests/interop/TestClient.cs
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/dotnet/Qpid.Integration.Tests/interop/TestClient.cs?rev=886998&r1=886997&r2=886998&view=diff
==============================================================================
--- qpid/trunk/qpid/dotnet/Qpid.Integration.Tests/interop/TestClient.cs (original)
+++ qpid/trunk/qpid/dotnet/Qpid.Integration.Tests/interop/TestClient.cs Thu Dec  3 23:55:48 2009
@@ -1,379 +1,379 @@
-/*
- *
- * 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.
- *
- */
-using System;
-using System.Collections;
-using System.Text;
-using System.Threading;
-using Apache.Qpid.Messaging;
-using Apache.Qpid.Client.Qms;
-using Apache.Qpid.Client;
-using log4net;
-using Apache.Qpid.Integration.Tests.interop.TestCases;
-
-namespace Apache.Qpid.Integration.Tests.interop
-{
-    /// <summary>
-    /// Implements a test client as described in the interop testing spec
-    /// (http://cwiki.apache.org/confluence/display/qpid/Interop+Testing+Specification). A test client is an agent that
-    /// reacts to control message sequences send by the test coordinator.
-    ///
-    /// <p/><table><caption>Messages Handled by TestClient</caption>
-    /// <tr><th> Message               <th> Action
-    /// <tr><td> Invite(compulsory)    <td> Reply with Enlist.
-    /// <tr><td> Invite(test case)     <td> Reply with Enlist if test case available.
-    /// <tr><td> AssignRole(test case) <td> Reply with Accept Role if matches an enlisted test. Keep test parameters.
-    /// <tr><td> Start                 <td> Send test messages defined by test parameters. Send report on messages sent.
-    /// <tr><td> Status Request        <td> Send report on messages received.
-    /// </table>
-    ///
-    /// <p><table id="crc"><caption>CRC Card</caption>
-    /// <tr><th> Responsibilities <th> Collaborations
-    /// <tr><td> Handle all incoming control messages. <td> {@link InteropClientTestCase}
-    /// <tr><td> Configure and look up test cases by name. <td> {@link InteropClientTestCase}
-    /// </table>
-    /// </summary>
-    public class TestClient
-    {
-        private static ILog log = LogManager.GetLogger(typeof(TestClient));
-      
-        /// <summary> Defines the default broker for the tests, localhost, default port. </summary>
-        public static string DEFAULT_BROKER_URL = "amqp://guest:guest@clientid/?brokerlist='tcp://localhost:5672'";
-      
-        /// <summary> Defines the default virtual host to use for the tests, none. </summary>
-        public static string DEFAULT_VIRTUAL_HOST = "";
-      
-        /// <summary> Defines the default identifying name of this test client. </summary>
-        public static string DEFAULT_CLIENT_NAME = "dotnet";
-
-        /// <summary> Holds the URL of the broker to run the tests on. </summary>
-        public static string brokerUrl;
-
-        /// <summary> Holds the virtual host to run the tests on. If <tt>null</tt>, then the default virtual host is used. </summary>
-        public static string virtualHost;
-
-        /// <summary> The clients identifying name to print in test results and to distinguish from other clients. </summary>
-        private string clientName;
-
-        /// <summary> Holds all the test cases. </summary>
-        private IDictionary testCases = new Hashtable();
-
-        InteropClientTestCase currentTestCase;
-
-        private MessagePublisherBuilder publisherBuilder;
-
-        private IChannel channel;
-
-        /// <summary> Monitor to wait for termination events on. </summary>
-        private static object terminationMonitor = new Object();
-
-        /// <summary>
-        /// Creates a new interop test client, listenting to the specified broker and virtual host, with the specified
-        /// client identifying name.
-        /// </summary>
-        ///
-        /// <param name="brokerUrl"> The url of the broker to connect to. </param>
-        /// <param name="virtualHost"> The virtual host to conect to. </param>
-        /// <param name="clientName">  The client name to use. </param>
-        public TestClient(string brokerUrl, string virtualHost, string clientName)
-        {
-            log.Info("public TestClient(string brokerUrl = " + brokerUrl + ", string virtualHost = " + virtualHost
-                     + ", string clientName = " + clientName + "): called");
-
-            // Retain the connection parameters.
-            TestClient.brokerUrl = brokerUrl;
-            TestClient.virtualHost = virtualHost;
-            this.clientName = clientName;
-        }
-
-    
-        /// <summary>
-        /// The entry point for the interop test coordinator. This client accepts the following command line arguments:
-        /// </summary>
-        /// 
-        /// <p/><table>
-        /// <tr><td> -b         <td> The broker URL.       <td> Optional.
-        /// <tr><td> -h         <td> The virtual host.     <td> Optional.
-        /// <tr><td> -n         <td> The test client name. <td> Optional.
-        /// <tr><td> name=value <td> Trailing argument define name/value pairs. Added to system properties. <td> Optional.
-        /// </table>
-        ///
-        /// <param name="args"> The command line arguments. </param>
-        public static void Main(string[] args)
-        {
-            // Extract the command line options (Not exactly Posix but it will do for now...).
-            string brokerUrl = DEFAULT_BROKER_URL;
-            string virtualHost = DEFAULT_VIRTUAL_HOST;
-            string clientName = DEFAULT_CLIENT_NAME;
-
-            foreach (string nextArg in args)
-            {
-                if (nextArg.StartsWith("-b"))
-                {
-                    brokerUrl = nextArg.Substring(2);
-                }
-                else if (nextArg.StartsWith("-h"))
-                {
-                    virtualHost = nextArg.Substring(2);
-                }
-                else if (nextArg.StartsWith("-n"))
-                {
-                    clientName = nextArg.Substring(2);
-                }
-            }
-            
-            NDC.Push(clientName);
-
-            // Create a test client and start it running.
-            TestClient client = new TestClient(brokerUrl, virtualHost, clientName);
-
-            try
-            {
-                client.Start();
-            }
-            catch (Exception e)
-            {
-                log.Error("The test client was unable to start.", e);
-                System.Environment.Exit(1);
-            }
-
-            // Wait for a signal on the termination monitor before quitting.
-            lock (terminationMonitor)
-            {
-                Monitor.Wait(terminationMonitor);
-            }
-
-            NDC.Pop();
-        }
-
-        /// <summary>
-        /// Starts the interop test client running. This causes it to start listening for incoming test invites.
-        /// </summary>
-        private void Start()
-        {
-            log.Info("private void Start(): called");
-
-            // Use a class path scanner to find all the interop test case implementations.
-            ArrayList testCaseClasses = new ArrayList();
-
-            // ClasspathScanner.getMatches(InteropClientTestCase.class, "^TestCase.*", true);
-            // Hard code the test classes till the classpath scanner is fixed.
-            testCaseClasses.Add(typeof(TestCase1DummyRun));
-            testCaseClasses.Add(typeof(TestCase2BasicP2P));
-            testCaseClasses.Add(typeof(TestCase3BasicPubSub));
-
-            // Create all the test case implementations and index them by the test names.
-            foreach (Type testClass in testCaseClasses)
-            {
-                InteropClientTestCase testCase = (InteropClientTestCase)Activator.CreateInstance(testClass);
-                testCases.Add(testCase.GetName(), testCase);
-
-                log.Info("Found test case: " + testClass);
-            }
-
-            // Open a connection to communicate with the coordinator on.
-            log.Info("brokerUrl = " + brokerUrl);
-            IConnection connection = CreateConnection(brokerUrl, virtualHost);
-
-            channel = connection.CreateChannel(false, AcknowledgeMode.AutoAcknowledge);
-
-            // Set this up to listen for control messages.
-            string responseQueueName = channel.GenerateUniqueName();
-            channel.DeclareQueue(responseQueueName, false, true, true);
-
-            channel.Bind(responseQueueName, ExchangeNameDefaults.TOPIC, "iop.control." + clientName);
-            channel.Bind(responseQueueName, ExchangeNameDefaults.TOPIC, "iop.control");
-
-            IMessageConsumer consumer = channel.CreateConsumerBuilder(responseQueueName)
-                .Create();
-            consumer.OnMessage += new MessageReceivedDelegate(OnMessage);
-
-            // Create a publisher to send replies with.
-            publisherBuilder = channel.CreatePublisherBuilder()
-                .WithExchangeName(ExchangeNameDefaults.DIRECT);
-                
-
-            // Start listening for incoming control messages.
-            connection.Start();
-            Console.WriteLine("Test client " + clientName + " ready to receive test control messages...");
-        }
-
-        /// <summary>
-        /// Establishes an AMQ connection. This is a simple convenience method for code that does not anticipate handling connection failures. 
-        /// All exceptions that indicate that the connection has failed, are allowed to fall through.
-        /// </summary>
-        ///
-        /// <param name="brokerUrl">   The broker url to connect to, <tt>null</tt> to use the default from the properties. </param>
-        /// <param name="virtualHost"> The virtual host to connectio to, <tt>null</tt> to use the default. </param>
-        ///
-        /// <returns> A JMS conneciton. </returns>
-        public static IConnection CreateConnection(string brokerUrl, string virtualHost)
-        {
-            log.Info("public static Connection createConnection(string brokerUrl = " + brokerUrl + ", string virtualHost = " 
-                     + virtualHost + "): called");
-
-            // Create a connection to the broker.
-            IConnectionInfo connectionInfo = QpidConnectionInfo.FromUrl(brokerUrl);
-            connectionInfo.VirtualHost = virtualHost;
-            IConnection connection = new AMQConnection(connectionInfo);
-
-            return connection;
-        }
-        
-        /// <summary>
-        /// Handles all incoming control messages.
-        /// </summary>
-        ///
-        /// <param name="message"> The incoming message. </param>
-        public void OnMessage(IMessage message)
-        {
-            log.Info("public void OnMessage(IMessage message = " + message + "): called");
-
-            try
-            {
-                string controlType = message.Headers.GetString("CONTROL_TYPE");
-                string testName = message.Headers.GetString("TEST_NAME");
-
-                // Check if the message is a test invite.
-                if ("INVITE" == controlType)
-                {
-                    string testCaseName = message.Headers.GetString("TEST_NAME");
-
-                    // Flag used to indicate that an enlist should be sent. Only enlist to compulsory invites or invites
-                    // for which test cases exist.
-                    bool enlist = false;
-
-                    if (testCaseName != null)
-                    {
-                        log.Info("Got an invite to test: " + testCaseName);
-
-                        // Check if the requested test case is available.
-                        InteropClientTestCase testCase = (InteropClientTestCase)testCases[testCaseName];
-    
-                        if (testCase != null)
-                        {
-                            // Make the requested test case the current test case.
-                            currentTestCase = testCase;
-                            enlist = true;
-                        }
-                    }
-                    else
-                    {
-                        log.Info("Got a compulsory invite.");
-
-                        enlist = true;
-                    }
-
-                    log.Info("enlist = " + enlist);
-
-                    if (enlist)
-                    {
-                        // Reply with the client name in an Enlist message.
-                        IMessage enlistMessage = channel.CreateMessage();
-                        enlistMessage.Headers.SetString("CONTROL_TYPE", "ENLIST");
-                        enlistMessage.Headers.SetString("CLIENT_NAME", clientName);
-                        enlistMessage.Headers.SetString("CLIENT_PRIVATE_CONTROL_KEY", "iop.control." + clientName);
-                        enlistMessage.CorrelationId = message.CorrelationId;
-
-                        Send(enlistMessage, message.ReplyToRoutingKey);
-                    }                    
-                }
-                else if ("ASSIGN_ROLE" == controlType)
-                {
-                    // Assign the role to the current test case.
-                    string roleName = message.Headers.GetString("ROLE");
-    
-                    log.Info("Got a role assignment to role: " + roleName);
-    
-                    Roles role;
-
-                    if (roleName == "SENDER")
-                    {
-                        role = Roles.SENDER;
-                    }
-                    else
-                    {
-                        role = Roles.RECEIVER;
-                    }
-    
-                    currentTestCase.AssignRole(role, message);
-
-                    // Reply by accepting the role in an Accept Role message.
-                    IMessage acceptRoleMessage = channel.CreateMessage();
-                    acceptRoleMessage.Headers.SetString("CONTROL_TYPE", "ACCEPT_ROLE");
-                    acceptRoleMessage.CorrelationId = message.CorrelationId;
-
-                    Send(acceptRoleMessage, message.ReplyToRoutingKey);
-                }
-                else if ("START" == controlType || "STATUS_REQUEST" == controlType)
-                {
-                    if ("START" == controlType)
-                    {
-                        log.Info("Got a start notification.");
-
-                        // Start the current test case.
-                        currentTestCase.Start();
-                    }
-                    else
-                    {
-                        log.Info("Got a status request.");
-                    }
-
-                    // Generate the report from the test case and reply with it as a Report message.
-                    IMessage reportMessage = currentTestCase.GetReport(channel);
-                    reportMessage.Headers.SetString("CONTROL_TYPE", "REPORT");
-                    reportMessage.CorrelationId = message.CorrelationId;
-
-                    Send(reportMessage, message.ReplyToRoutingKey);
-                }
-                else if ("TERMINATE" == controlType)
-                {
-                    Console.WriteLine("Received termination instruction from coordinator.");
-
-                    // Is a cleaner shutdown needed?
-                    System.Environment.Exit(1);
-                }
-                else
-                {
-                    // Log a warning about this but otherwise ignore it.
-                    log.Warn("Got an unknown control message, controlType = " + controlType + ", message = " + message);
-                }
-            }
-            catch (QpidException e)
-            {
-                // Log a warning about this, but otherwise ignore it.
-                log.Warn("A QpidException occurred whilst handling a message.");
-                log.Info("Got QpidException whilst handling message: " + message, e);
-            }
-        }
-
-        /// <summary>
-        /// Send the specified message using the specified routing key on the direct exchange.
-        /// </summary>
-        /// 
-        /// <param name="message">    The message to send.</param>
-        /// <param name="routingKey"> The routing key to send the message with.</param>
-        public void Send(IMessage message, string routingKey)
-        {
-            IMessagePublisher publisher = publisherBuilder.WithRoutingKey(routingKey).Create();
-            publisher.Send(message);
-        }
-    }
-}
+/*
+ *
+ * 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.
+ *
+ */
+using System;
+using System.Collections;
+using System.Text;
+using System.Threading;
+using Apache.Qpid.Messaging;
+using Apache.Qpid.Client.Qms;
+using Apache.Qpid.Client;
+using log4net;
+using Apache.Qpid.Integration.Tests.interop.TestCases;
+
+namespace Apache.Qpid.Integration.Tests.interop
+{
+    /// <summary>
+    /// Implements a test client as described in the interop testing spec
+    /// (http://cwiki.apache.org/confluence/display/qpid/Interop+Testing+Specification). A test client is an agent that
+    /// reacts to control message sequences send by the test coordinator.
+    ///
+    /// <p/><table><caption>Messages Handled by TestClient</caption>
+    /// <tr><th> Message               <th> Action
+    /// <tr><td> Invite(compulsory)    <td> Reply with Enlist.
+    /// <tr><td> Invite(test case)     <td> Reply with Enlist if test case available.
+    /// <tr><td> AssignRole(test case) <td> Reply with Accept Role if matches an enlisted test. Keep test parameters.
+    /// <tr><td> Start                 <td> Send test messages defined by test parameters. Send report on messages sent.
+    /// <tr><td> Status Request        <td> Send report on messages received.
+    /// </table>
+    ///
+    /// <p><table id="crc"><caption>CRC Card</caption>
+    /// <tr><th> Responsibilities <th> Collaborations
+    /// <tr><td> Handle all incoming control messages. <td> {@link InteropClientTestCase}
+    /// <tr><td> Configure and look up test cases by name. <td> {@link InteropClientTestCase}
+    /// </table>
+    /// </summary>
+    public class TestClient
+    {
+        private static ILog log = LogManager.GetLogger(typeof(TestClient));
+      
+        /// <summary> Defines the default broker for the tests, localhost, default port. </summary>
+        public static string DEFAULT_BROKER_URL = "amqp://guest:guest@clientid/?brokerlist='tcp://localhost:5672'";
+      
+        /// <summary> Defines the default virtual host to use for the tests, none. </summary>
+        public static string DEFAULT_VIRTUAL_HOST = "";
+      
+        /// <summary> Defines the default identifying name of this test client. </summary>
+        public static string DEFAULT_CLIENT_NAME = "dotnet";
+
+        /// <summary> Holds the URL of the broker to run the tests on. </summary>
+        public static string brokerUrl;
+
+        /// <summary> Holds the virtual host to run the tests on. If <tt>null</tt>, then the default virtual host is used. </summary>
+        public static string virtualHost;
+
+        /// <summary> The clients identifying name to print in test results and to distinguish from other clients. </summary>
+        private string clientName;
+
+        /// <summary> Holds all the test cases. </summary>
+        private IDictionary testCases = new Hashtable();
+
+        InteropClientTestCase currentTestCase;
+
+        private MessagePublisherBuilder publisherBuilder;
+
+        private IChannel channel;
+
+        /// <summary> Monitor to wait for termination events on. </summary>
+        private static object terminationMonitor = new Object();
+
+        /// <summary>
+        /// Creates a new interop test client, listenting to the specified broker and virtual host, with the specified
+        /// client identifying name.
+        /// </summary>
+        ///
+        /// <param name="brokerUrl"> The url of the broker to connect to. </param>
+        /// <param name="virtualHost"> The virtual host to conect to. </param>
+        /// <param name="clientName">  The client name to use. </param>
+        public TestClient(string brokerUrl, string virtualHost, string clientName)
+        {
+            log.Info("public TestClient(string brokerUrl = " + brokerUrl + ", string virtualHost = " + virtualHost
+                     + ", string clientName = " + clientName + "): called");
+
+            // Retain the connection parameters.
+            TestClient.brokerUrl = brokerUrl;
+            TestClient.virtualHost = virtualHost;
+            this.clientName = clientName;
+        }
+
+    
+        /// <summary>
+        /// The entry point for the interop test coordinator. This client accepts the following command line arguments:
+        /// </summary>
+        /// 
+        /// <p/><table>
+        /// <tr><td> -b         <td> The broker URL.       <td> Optional.
+        /// <tr><td> -h         <td> The virtual host.     <td> Optional.
+        /// <tr><td> -n         <td> The test client name. <td> Optional.
+        /// <tr><td> name=value <td> Trailing argument define name/value pairs. Added to system properties. <td> Optional.
+        /// </table>
+        ///
+        /// <param name="args"> The command line arguments. </param>
+        public static void Main(string[] args)
+        {
+            // Extract the command line options (Not exactly Posix but it will do for now...).
+            string brokerUrl = DEFAULT_BROKER_URL;
+            string virtualHost = DEFAULT_VIRTUAL_HOST;
+            string clientName = DEFAULT_CLIENT_NAME;
+
+            foreach (string nextArg in args)
+            {
+                if (nextArg.StartsWith("-b"))
+                {
+                    brokerUrl = nextArg.Substring(2);
+                }
+                else if (nextArg.StartsWith("-h"))
+                {
+                    virtualHost = nextArg.Substring(2);
+                }
+                else if (nextArg.StartsWith("-n"))
+                {
+                    clientName = nextArg.Substring(2);
+                }
+            }
+            
+            NDC.Push(clientName);
+
+            // Create a test client and start it running.
+            TestClient client = new TestClient(brokerUrl, virtualHost, clientName);
+
+            try
+            {
+                client.Start();
+            }
+            catch (Exception e)
+            {
+                log.Error("The test client was unable to start.", e);
+                System.Environment.Exit(1);
+            }
+
+            // Wait for a signal on the termination monitor before quitting.
+            lock (terminationMonitor)
+            {
+                Monitor.Wait(terminationMonitor);
+            }
+
+            NDC.Pop();
+        }
+
+        /// <summary>
+        /// Starts the interop test client running. This causes it to start listening for incoming test invites.
+        /// </summary>
+        private void Start()
+        {
+            log.Info("private void Start(): called");
+
+            // Use a class path scanner to find all the interop test case implementations.
+            ArrayList testCaseClasses = new ArrayList();
+
+            // ClasspathScanner.getMatches(InteropClientTestCase.class, "^TestCase.*", true);
+            // Hard code the test classes till the classpath scanner is fixed.
+            testCaseClasses.Add(typeof(TestCase1DummyRun));
+            testCaseClasses.Add(typeof(TestCase2BasicP2P));
+            testCaseClasses.Add(typeof(TestCase3BasicPubSub));
+
+            // Create all the test case implementations and index them by the test names.
+            foreach (Type testClass in testCaseClasses)
+            {
+                InteropClientTestCase testCase = (InteropClientTestCase)Activator.CreateInstance(testClass);
+                testCases.Add(testCase.GetName(), testCase);
+
+                log.Info("Found test case: " + testClass);
+            }
+
+            // Open a connection to communicate with the coordinator on.
+            log.Info("brokerUrl = " + brokerUrl);
+            IConnection connection = CreateConnection(brokerUrl, virtualHost);
+
+            channel = connection.CreateChannel(false, AcknowledgeMode.AutoAcknowledge);
+
+            // Set this up to listen for control messages.
+            string responseQueueName = channel.GenerateUniqueName();
+            channel.DeclareQueue(responseQueueName, false, true, true);
+
+            channel.Bind(responseQueueName, ExchangeNameDefaults.TOPIC, "iop.control." + clientName);
+            channel.Bind(responseQueueName, ExchangeNameDefaults.TOPIC, "iop.control");
+
+            IMessageConsumer consumer = channel.CreateConsumerBuilder(responseQueueName)
+                .Create();
+            consumer.OnMessage += new MessageReceivedDelegate(OnMessage);
+
+            // Create a publisher to send replies with.
+            publisherBuilder = channel.CreatePublisherBuilder()
+                .WithExchangeName(ExchangeNameDefaults.DIRECT);
+                
+
+            // Start listening for incoming control messages.
+            connection.Start();
+            Console.WriteLine("Test client " + clientName + " ready to receive test control messages...");
+        }
+
+        /// <summary>
+        /// Establishes an AMQ connection. This is a simple convenience method for code that does not anticipate handling connection failures. 
+        /// All exceptions that indicate that the connection has failed, are allowed to fall through.
+        /// </summary>
+        ///
+        /// <param name="brokerUrl">   The broker url to connect to, <tt>null</tt> to use the default from the properties. </param>
+        /// <param name="virtualHost"> The virtual host to connectio to, <tt>null</tt> to use the default. </param>
+        ///
+        /// <returns> A JMS conneciton. </returns>
+        public static IConnection CreateConnection(string brokerUrl, string virtualHost)
+        {
+            log.Info("public static Connection createConnection(string brokerUrl = " + brokerUrl + ", string virtualHost = " 
+                     + virtualHost + "): called");
+
+            // Create a connection to the broker.
+            IConnectionInfo connectionInfo = QpidConnectionInfo.FromUrl(brokerUrl);
+            connectionInfo.VirtualHost = virtualHost;
+            IConnection connection = new AMQConnection(connectionInfo);
+
+            return connection;
+        }
+        
+        /// <summary>
+        /// Handles all incoming control messages.
+        /// </summary>
+        ///
+        /// <param name="message"> The incoming message. </param>
+        public void OnMessage(IMessage message)
+        {
+            log.Info("public void OnMessage(IMessage message = " + message + "): called");
+
+            try
+            {
+                string controlType = message.Headers.GetString("CONTROL_TYPE");
+                string testName = message.Headers.GetString("TEST_NAME");
+
+                // Check if the message is a test invite.
+                if ("INVITE" == controlType)
+                {
+                    string testCaseName = message.Headers.GetString("TEST_NAME");
+
+                    // Flag used to indicate that an enlist should be sent. Only enlist to compulsory invites or invites
+                    // for which test cases exist.
+                    bool enlist = false;
+
+                    if (testCaseName != null)
+                    {
+                        log.Info("Got an invite to test: " + testCaseName);
+
+                        // Check if the requested test case is available.
+                        InteropClientTestCase testCase = (InteropClientTestCase)testCases[testCaseName];
+    
+                        if (testCase != null)
+                        {
+                            // Make the requested test case the current test case.
+                            currentTestCase = testCase;
+                            enlist = true;
+                        }
+                    }
+                    else
+                    {
+                        log.Info("Got a compulsory invite.");
+
+                        enlist = true;
+                    }
+
+                    log.Info("enlist = " + enlist);
+
+                    if (enlist)
+                    {
+                        // Reply with the client name in an Enlist message.
+                        IMessage enlistMessage = channel.CreateMessage();
+                        enlistMessage.Headers.SetString("CONTROL_TYPE", "ENLIST");
+                        enlistMessage.Headers.SetString("CLIENT_NAME", clientName);
+                        enlistMessage.Headers.SetString("CLIENT_PRIVATE_CONTROL_KEY", "iop.control." + clientName);
+                        enlistMessage.CorrelationId = message.CorrelationId;
+
+                        Send(enlistMessage, message.ReplyToRoutingKey);
+                    }                    
+                }
+                else if ("ASSIGN_ROLE" == controlType)
+                {
+                    // Assign the role to the current test case.
+                    string roleName = message.Headers.GetString("ROLE");
+    
+                    log.Info("Got a role assignment to role: " + roleName);
+    
+                    Roles role;
+
+                    if (roleName == "SENDER")
+                    {
+                        role = Roles.SENDER;
+                    }
+                    else
+                    {
+                        role = Roles.RECEIVER;
+                    }
+    
+                    currentTestCase.AssignRole(role, message);
+
+                    // Reply by accepting the role in an Accept Role message.
+                    IMessage acceptRoleMessage = channel.CreateMessage();
+                    acceptRoleMessage.Headers.SetString("CONTROL_TYPE", "ACCEPT_ROLE");
+                    acceptRoleMessage.CorrelationId = message.CorrelationId;
+
+                    Send(acceptRoleMessage, message.ReplyToRoutingKey);
+                }
+                else if ("START" == controlType || "STATUS_REQUEST" == controlType)
+                {
+                    if ("START" == controlType)
+                    {
+                        log.Info("Got a start notification.");
+
+                        // Start the current test case.
+                        currentTestCase.Start();
+                    }
+                    else
+                    {
+                        log.Info("Got a status request.");
+                    }
+
+                    // Generate the report from the test case and reply with it as a Report message.
+                    IMessage reportMessage = currentTestCase.GetReport(channel);
+                    reportMessage.Headers.SetString("CONTROL_TYPE", "REPORT");
+                    reportMessage.CorrelationId = message.CorrelationId;
+
+                    Send(reportMessage, message.ReplyToRoutingKey);
+                }
+                else if ("TERMINATE" == controlType)
+                {
+                    Console.WriteLine("Received termination instruction from coordinator.");
+
+                    // Is a cleaner shutdown needed?
+                    System.Environment.Exit(1);
+                }
+                else
+                {
+                    // Log a warning about this but otherwise ignore it.
+                    log.Warn("Got an unknown control message, controlType = " + controlType + ", message = " + message);
+                }
+            }
+            catch (QpidException e)
+            {
+                // Log a warning about this, but otherwise ignore it.
+                log.Warn("A QpidException occurred whilst handling a message.");
+                log.Info("Got QpidException whilst handling message: " + message, e);
+            }
+        }
+
+        /// <summary>
+        /// Send the specified message using the specified routing key on the direct exchange.
+        /// </summary>
+        /// 
+        /// <param name="message">    The message to send.</param>
+        /// <param name="routingKey"> The routing key to send the message with.</param>
+        public void Send(IMessage message, string routingKey)
+        {
+            IMessagePublisher publisher = publisherBuilder.WithRoutingKey(routingKey).Create();
+            publisher.Send(message);
+        }
+    }
+}

Propchange: qpid/trunk/qpid/dotnet/Qpid.Integration.Tests/interop/TestClient.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: qpid/trunk/qpid/dotnet/Qpid.Integration.Tests/testcases/BaseMessagingTestFixture.cs
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/dotnet/Qpid.Integration.Tests/testcases/BaseMessagingTestFixture.cs?rev=886998&r1=886997&r2=886998&view=diff
==============================================================================
--- qpid/trunk/qpid/dotnet/Qpid.Integration.Tests/testcases/BaseMessagingTestFixture.cs (original)
+++ qpid/trunk/qpid/dotnet/Qpid.Integration.Tests/testcases/BaseMessagingTestFixture.cs Thu Dec  3 23:55:48 2009
@@ -1,261 +1,261 @@
-/*
- *
- * 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.
- *
- */
-using System;
-using System.Text;
-using log4net;
-using NUnit.Framework;
-using Apache.Qpid.Messaging;
-using Apache.Qpid.Client.Qms;
-using Apache.Qpid.Client;
-
-namespace Apache.Qpid.Integration.Tests.testcases
-{
-    /// <summary>
-    /// Provides a basis for writing Unit tests that communicate with an AMQ protocol broker. By default it creates a connection
-    /// to a message broker running on localhost on the standard AMQ port, 5672, using guest:guest login credentials. It also
-    /// creates a standard auto-ack channel on this connection.
-    /// </summary>
-    public class BaseMessagingTestFixture
-    {
-        private static ILog log = LogManager.GetLogger(typeof(BaseMessagingTestFixture));
-
-        /// <summary> Used to build dummy data to fill test messages with. </summary>
-        private const string MESSAGE_DATA_BYTES = "-- Test Message -- Test Message -- Test Message -- Test Message -- Test Message ";
-
-        /// <summary> The default timeout in milliseconds to use on receives. </summary>
-        private const long RECEIVE_WAIT = 2000;
-
-        /// <summary> The default AMQ connection URL to use for tests. </summary>
-        public const string connectionUri = "amqp://guest:guest@test/test?brokerlist='tcp://localhost:5672'";
-
-        /// <summary> The default AMQ connection URL parsed as a connection info. </summary>
-        protected IConnectionInfo connectionInfo;
-
-        /// <summary> Holds an array of connections for building mutiple test end-points. </summary>
-        protected IConnection[] testConnection = new IConnection[10];
-
-        /// <summary> Holds an array of channels for building mutiple test end-points. </summary>
-        protected IChannel[] testChannel = new IChannel[10];
-
-         /// <summary> Holds an array of queues for building mutiple test end-points. </summary>
-        protected String[] testQueue = new String[10];
-        
-        /// <summary> Holds an array of producers for building mutiple test end-points. </summary>
-        protected IMessagePublisher[] testProducer = new IMessagePublisher[10];
-
-        /// <summary> Holds an array of consumers for building mutiple test end-points. </summary>
-        protected IMessageConsumer[] testConsumer = new IMessageConsumer[10];
-
-        /// <summary> A counter used to supply unique ids. </summary>
-        private static int uniqueId = 0;
-
-        /// <summary> Used to hold unique ids per test. </summary>
-        protected Guid testId;
-
-        /// <summary> Creates the test connection and channel. </summary>
-        [SetUp]
-        public virtual void Init()
-        {
-            log.Debug("public virtual void Init(): called");
-
-            // Set up a unique id for this test.
-            testId = System.Guid.NewGuid();
-        }
-
-        /// <summary>
-        /// Disposes of the test connection. This is called manually because the connection is a field so dispose will not be automatically 
-        /// called on it.
-        /// </summary>
-        [TearDown]
-        public virtual void Shutdown()
-        {
-            log.Debug("public virtual void Shutdown(): called");
-        }
-
-        /// <summary> Sets up the nth test end-point. </summary>
-        ///
-        /// <param name="n">The index of the test end-point to set up.</param>
-        /// <param name="producer"><tt>true</tt> to set up a producer on the end-point.</param>
-        /// <param name="consumer"><tt>true</tt> to set up a consumer on the end-point.</param>
-        /// <param name="routingKey">The routing key for the producer to send on.</param>
-        /// <param name="ackMode">The ack mode for the end-points channel.</param>
-        /// <param name="transacted"><tt>true</tt> to use transactions on the end-points channel.</param>
-        /// <param name="exchangeName">The exchange to produce or consume on.</param>
-        /// <param name="declareBind"><tt>true</tt> if the consumers queue should be declared and bound, <tt>false</tt> if it has already been.</param>
-        /// <param name="durable"><tt>true</tt> to declare the consumers queue as durable.</param>
-        /// <param name="subscriptionName">If durable is true, the fixed unique queue name to use.</param>
-        public void SetUpEndPoint(int n, bool producer, bool consumer, string routingKey, AcknowledgeMode ackMode, bool transacted,
-                                  string exchangeName, bool declareBind, bool durable, string subscriptionName)
-        {
-            // Allow client id to be fixed, or undefined.
-            {
-                // Use unique id for end point.
-                connectionInfo = QpidConnectionInfo.FromUrl(connectionUri);
-
-                connectionInfo.ClientName = "test" + n;
-            }
-
-            testConnection[n] = new AMQConnection(connectionInfo);            
-            testConnection[n].Start();
-            testChannel[n] = testConnection[n].CreateChannel(transacted, ackMode);
-            
-            if (producer)
-            {
-                testProducer[n] = testChannel[n].CreatePublisherBuilder()
-                    .WithExchangeName(exchangeName)
-                    .WithRoutingKey(routingKey)
-                    .Create();
-            }
-
-            if (consumer)
-            {
-                string queueName;
-
-                // Use the subscription name as the queue name if the subscription is durable, otherwise use a generated name.
-                if (durable)
-                {
-                    // The durable queue is declared without auto-delete, and passively, in case it has already been declared.
-                    queueName = subscriptionName;
-                    
-                    if (declareBind)
-                    {
-                        testChannel[n].DeclareQueue(queueName, durable, true, false);
-                        testChannel[n].Bind(queueName, exchangeName, routingKey);
-                    }
-                }
-                else
-                {
-                    queueName = testChannel[n].GenerateUniqueName();
-
-                    if (declareBind)
-                    {
-                    	if (durable) 
-                    	{
-                    		testQueue[n] = queueName;
-                    	}
-                        testChannel[n].DeclareQueue(queueName, durable, true, true);
-                        testChannel[n].Bind(queueName, exchangeName, routingKey);
-                    }
-                }
-
-                testConsumer[n] = testChannel[n].CreateConsumerBuilder(queueName).Create();
-            }
-        }
-
-        /// <summary> Closes down the nth test end-point. </summary>
-        public void CloseEndPoint(int n)
-        {
-            log.Debug("public void CloseEndPoint(int n): called");
-
-            if (testProducer[n] != null)
-            {
-                testProducer[n].Close();
-                testProducer[n].Dispose();
-                testProducer[n] = null;
-            }
-
-            if (testConsumer[n] != null)
-            {
-            	if (testQueue[n] != null)
-            	{
-            		testChannel[n].DeleteQueue(testQueue[n], false, false, true);
-            	}
-                testConsumer[n].Close();
-                testConsumer[n].Dispose();
-                testConsumer[n] = null;
-            }
-
-            if (testConnection[n] != null)
-            {
-                testConnection[n].Stop();            
-                testConnection[n].Close();
-                testConnection[n].Dispose();
-                testConnection[n] = null;
-            }
-        }
-
-        /// <summary>
-        /// Consumes n messages, checking that the n+1th is not available within a timeout, and that the consumed messages
-        /// are text messages with contents equal to the specified message body.
-        /// </summary>
-        ///
-        /// <param name="n">The number of messages to consume.</param>
-        /// <param name="body">The body text to match against all messages.</param>
-        /// <param name="consumer">The message consumer to recieve the messages on.</param>
-        public static void ConsumeNMessagesOnly(int n, string body, IMessageConsumer consumer)
-        {
-            ConsumeNMessages(n, body, consumer);
-            
-            // Check that one more than n cannot be received.
-            IMessage msg = consumer.Receive(RECEIVE_WAIT);
-            Assert.IsNull(msg, "Consumer got more messages than the number requested (" + n + ").");
-        }
-
-        /// <summary>
-        /// Consumes n messages, checking that the n+1th is not available within a timeout, and that the consumed messages
-        /// are text messages with contents equal to the specified message body.
-        /// </summary>
-        ///
-        /// <param name="n">The number of messages to consume.</param>
-        /// <param name="body">The body text to match against all messages.</param>
-        /// <param name="consumer">The message consumer to recieve the messages on.</param>
-        public static void ConsumeNMessages(int n, string body, IMessageConsumer consumer)
-        {
-            IMessage msg;
-            
-            // Try to receive n messages.
-            for (int i = 0; i < n; i++)
-            {
-                msg = consumer.Receive(RECEIVE_WAIT);
-                Assert.IsNotNull(msg, "Consumer did not receive message number: " + i);
-                Assert.AreEqual(body, ((ITextMessage)msg).Text, "Incorrect Message recevied on consumer1.");
-            }
-        }
-
-        /// <summary>Creates the requested number of bytes of dummy text. Usually used for filling test messages. </summary>
-        ///
-        /// <param name="size">The number of bytes of dummy text to generate.</param>
-        ///
-        /// <return>The requested number of bytes of dummy text.</return>
-        public static String GetData(int size)
-        {
-            StringBuilder buf = new StringBuilder(size);
-
-            if (size > 0)
-            {
-                int div = MESSAGE_DATA_BYTES.Length / size;
-                int mod = MESSAGE_DATA_BYTES.Length % size;
-
-                for (int i = 0; i < div; i++)
-                {
-                    buf.Append(MESSAGE_DATA_BYTES);
-                }
-
-                if (mod != 0)
-                {
-                    buf.Append(MESSAGE_DATA_BYTES, 0, mod);
-                }
-            }
-            
-            return buf.ToString();
-        }
-    }
-}
+/*
+ *
+ * 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.
+ *
+ */
+using System;
+using System.Text;
+using log4net;
+using NUnit.Framework;
+using Apache.Qpid.Messaging;
+using Apache.Qpid.Client.Qms;
+using Apache.Qpid.Client;
+
+namespace Apache.Qpid.Integration.Tests.testcases
+{
+    /// <summary>
+    /// Provides a basis for writing Unit tests that communicate with an AMQ protocol broker. By default it creates a connection
+    /// to a message broker running on localhost on the standard AMQ port, 5672, using guest:guest login credentials. It also
+    /// creates a standard auto-ack channel on this connection.
+    /// </summary>
+    public class BaseMessagingTestFixture
+    {
+        private static ILog log = LogManager.GetLogger(typeof(BaseMessagingTestFixture));
+
+        /// <summary> Used to build dummy data to fill test messages with. </summary>
+        private const string MESSAGE_DATA_BYTES = "-- Test Message -- Test Message -- Test Message -- Test Message -- Test Message ";
+
+        /// <summary> The default timeout in milliseconds to use on receives. </summary>
+        private const long RECEIVE_WAIT = 2000;
+
+        /// <summary> The default AMQ connection URL to use for tests. </summary>
+        public const string connectionUri = "amqp://guest:guest@test/test?brokerlist='tcp://localhost:5672'";
+
+        /// <summary> The default AMQ connection URL parsed as a connection info. </summary>
+        protected IConnectionInfo connectionInfo;
+
+        /// <summary> Holds an array of connections for building mutiple test end-points. </summary>
+        protected IConnection[] testConnection = new IConnection[10];
+
+        /// <summary> Holds an array of channels for building mutiple test end-points. </summary>
+        protected IChannel[] testChannel = new IChannel[10];
+
+         /// <summary> Holds an array of queues for building mutiple test end-points. </summary>
+        protected String[] testQueue = new String[10];
+        
+        /// <summary> Holds an array of producers for building mutiple test end-points. </summary>
+        protected IMessagePublisher[] testProducer = new IMessagePublisher[10];
+
+        /// <summary> Holds an array of consumers for building mutiple test end-points. </summary>
+        protected IMessageConsumer[] testConsumer = new IMessageConsumer[10];
+
+        /// <summary> A counter used to supply unique ids. </summary>
+        private static int uniqueId = 0;
+
+        /// <summary> Used to hold unique ids per test. </summary>
+        protected Guid testId;
+
+        /// <summary> Creates the test connection and channel. </summary>
+        [SetUp]
+        public virtual void Init()
+        {
+            log.Debug("public virtual void Init(): called");
+
+            // Set up a unique id for this test.
+            testId = System.Guid.NewGuid();
+        }
+
+        /// <summary>
+        /// Disposes of the test connection. This is called manually because the connection is a field so dispose will not be automatically 
+        /// called on it.
+        /// </summary>
+        [TearDown]
+        public virtual void Shutdown()
+        {
+            log.Debug("public virtual void Shutdown(): called");
+        }
+
+        /// <summary> Sets up the nth test end-point. </summary>
+        ///
+        /// <param name="n">The index of the test end-point to set up.</param>
+        /// <param name="producer"><tt>true</tt> to set up a producer on the end-point.</param>
+        /// <param name="consumer"><tt>true</tt> to set up a consumer on the end-point.</param>
+        /// <param name="routingKey">The routing key for the producer to send on.</param>
+        /// <param name="ackMode">The ack mode for the end-points channel.</param>
+        /// <param name="transacted"><tt>true</tt> to use transactions on the end-points channel.</param>
+        /// <param name="exchangeName">The exchange to produce or consume on.</param>
+        /// <param name="declareBind"><tt>true</tt> if the consumers queue should be declared and bound, <tt>false</tt> if it has already been.</param>
+        /// <param name="durable"><tt>true</tt> to declare the consumers queue as durable.</param>
+        /// <param name="subscriptionName">If durable is true, the fixed unique queue name to use.</param>
+        public void SetUpEndPoint(int n, bool producer, bool consumer, string routingKey, AcknowledgeMode ackMode, bool transacted,
+                                  string exchangeName, bool declareBind, bool durable, string subscriptionName)
+        {
+            // Allow client id to be fixed, or undefined.
+            {
+                // Use unique id for end point.
+                connectionInfo = QpidConnectionInfo.FromUrl(connectionUri);
+
+                connectionInfo.ClientName = "test" + n;
+            }
+
+            testConnection[n] = new AMQConnection(connectionInfo);            
+            testConnection[n].Start();
+            testChannel[n] = testConnection[n].CreateChannel(transacted, ackMode);
+            
+            if (producer)
+            {
+                testProducer[n] = testChannel[n].CreatePublisherBuilder()
+                    .WithExchangeName(exchangeName)
+                    .WithRoutingKey(routingKey)
+                    .Create();
+            }
+
+            if (consumer)
+            {
+                string queueName;
+
+                // Use the subscription name as the queue name if the subscription is durable, otherwise use a generated name.
+                if (durable)
+                {
+                    // The durable queue is declared without auto-delete, and passively, in case it has already been declared.
+                    queueName = subscriptionName;
+                    
+                    if (declareBind)
+                    {
+                        testChannel[n].DeclareQueue(queueName, durable, true, false);
+                        testChannel[n].Bind(queueName, exchangeName, routingKey);
+                    }
+                }
+                else
+                {
+                    queueName = testChannel[n].GenerateUniqueName();
+
+                    if (declareBind)
+                    {
+                    	if (durable) 
+                    	{
+                    		testQueue[n] = queueName;
+                    	}
+                        testChannel[n].DeclareQueue(queueName, durable, true, true);
+                        testChannel[n].Bind(queueName, exchangeName, routingKey);
+                    }
+                }
+
+                testConsumer[n] = testChannel[n].CreateConsumerBuilder(queueName).Create();
+            }
+        }
+
+        /// <summary> Closes down the nth test end-point. </summary>
+        public void CloseEndPoint(int n)
+        {
+            log.Debug("public void CloseEndPoint(int n): called");
+
+            if (testProducer[n] != null)
+            {
+                testProducer[n].Close();
+                testProducer[n].Dispose();
+                testProducer[n] = null;
+            }
+
+            if (testConsumer[n] != null)
+            {
+            	if (testQueue[n] != null)
+            	{
+            		testChannel[n].DeleteQueue(testQueue[n], false, false, true);
+            	}
+                testConsumer[n].Close();
+                testConsumer[n].Dispose();
+                testConsumer[n] = null;
+            }
+
+            if (testConnection[n] != null)
+            {
+                testConnection[n].Stop();            
+                testConnection[n].Close();
+                testConnection[n].Dispose();
+                testConnection[n] = null;
+            }
+        }
+
+        /// <summary>
+        /// Consumes n messages, checking that the n+1th is not available within a timeout, and that the consumed messages
+        /// are text messages with contents equal to the specified message body.
+        /// </summary>
+        ///
+        /// <param name="n">The number of messages to consume.</param>
+        /// <param name="body">The body text to match against all messages.</param>
+        /// <param name="consumer">The message consumer to recieve the messages on.</param>
+        public static void ConsumeNMessagesOnly(int n, string body, IMessageConsumer consumer)
+        {
+            ConsumeNMessages(n, body, consumer);
+            
+            // Check that one more than n cannot be received.
+            IMessage msg = consumer.Receive(RECEIVE_WAIT);
+            Assert.IsNull(msg, "Consumer got more messages than the number requested (" + n + ").");
+        }
+
+        /// <summary>
+        /// Consumes n messages, checking that the n+1th is not available within a timeout, and that the consumed messages
+        /// are text messages with contents equal to the specified message body.
+        /// </summary>
+        ///
+        /// <param name="n">The number of messages to consume.</param>
+        /// <param name="body">The body text to match against all messages.</param>
+        /// <param name="consumer">The message consumer to recieve the messages on.</param>
+        public static void ConsumeNMessages(int n, string body, IMessageConsumer consumer)
+        {
+            IMessage msg;
+            
+            // Try to receive n messages.
+            for (int i = 0; i < n; i++)
+            {
+                msg = consumer.Receive(RECEIVE_WAIT);
+                Assert.IsNotNull(msg, "Consumer did not receive message number: " + i);
+                Assert.AreEqual(body, ((ITextMessage)msg).Text, "Incorrect Message recevied on consumer1.");
+            }
+        }
+
+        /// <summary>Creates the requested number of bytes of dummy text. Usually used for filling test messages. </summary>
+        ///
+        /// <param name="size">The number of bytes of dummy text to generate.</param>
+        ///
+        /// <return>The requested number of bytes of dummy text.</return>
+        public static String GetData(int size)
+        {
+            StringBuilder buf = new StringBuilder(size);
+
+            if (size > 0)
+            {
+                int div = MESSAGE_DATA_BYTES.Length / size;
+                int mod = MESSAGE_DATA_BYTES.Length % size;
+
+                for (int i = 0; i < div; i++)
+                {
+                    buf.Append(MESSAGE_DATA_BYTES);
+                }
+
+                if (mod != 0)
+                {
+                    buf.Append(MESSAGE_DATA_BYTES, 0, mod);
+                }
+            }
+            
+            return buf.ToString();
+        }
+    }
+}

Propchange: qpid/trunk/qpid/dotnet/Qpid.Integration.Tests/testcases/BaseMessagingTestFixture.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: qpid/trunk/qpid/dotnet/Qpid.Integration.Tests/testcases/ChannelQueueTest.cs
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/dotnet/Qpid.Integration.Tests/testcases/ChannelQueueTest.cs?rev=886998&r1=886997&r2=886998&view=diff
==============================================================================
--- qpid/trunk/qpid/dotnet/Qpid.Integration.Tests/testcases/ChannelQueueTest.cs (original)
+++ qpid/trunk/qpid/dotnet/Qpid.Integration.Tests/testcases/ChannelQueueTest.cs Thu Dec  3 23:55:48 2009
@@ -1,237 +1,237 @@
-/*
- *
- * 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.
- *
- */
-using System;
-using System.Net;
-using System.Threading;
-using log4net;
-using Apache.Qpid.Client.Qms;
-using Apache.Qpid.Client;
-using Apache.Qpid.Messaging;
-using NUnit.Framework;
-
-namespace Apache.Qpid.Integration.Tests.testcases
-{
-    /// <summary>
-    /// Test the queue methods
-    /// </summary>
-    [TestFixture, Category("Integration")]
-    public class ChannelQueueTest
-    {
-        private static ILog _logger = LogManager.GetLogger(typeof(ChannelQueueTest));
-
-        /// <summary> The default AMQ connection URL to use for tests. </summary>
-        const string DEFAULT_URI = "amqp://guest:guest@default/test?brokerlist='tcp://localhost:5672'";
-        const string _routingKey = "ServiceQ1";
-
-        private ExceptionListenerDelegate _exceptionDelegate;
-        private AutoResetEvent _evt = new AutoResetEvent(false);
-        private Exception _lastException = null;
-
-        private IMessageConsumer _consumer;
-        private IMessagePublisher _publisher;
-        private IChannel _channel;
-        private IConnection _connection;
-
-        private string _queueName;
-
-        [SetUp]
-        public virtual void Init()
-        {
-            _logger.Info("public virtual void Init(): called");
-
-            // Create a connection to the broker.
-            IConnectionInfo connectionInfo = QpidConnectionInfo.FromUrl(DEFAULT_URI);
-            _connection = new AMQConnection(connectionInfo);
-            _logger.Info("Starting...");
-
-            // Register this to listen for exceptions on the test connection.
-            _exceptionDelegate = new ExceptionListenerDelegate(OnException);
-            _connection.ExceptionListener += _exceptionDelegate;
-
-            // Establish a session on the broker.
-            _channel = _connection.CreateChannel(false, AcknowledgeMode.AutoAcknowledge, 1);
-
-            // Create a durable, non-temporary, non-exclusive queue.
-            _queueName = _channel.GenerateUniqueName();
-            _channel.DeclareQueue(_queueName, true, false, false);
-
-            _channel.Bind(_queueName, ExchangeNameDefaults.TOPIC, _routingKey);
-
-            // Clear the most recent message and exception.
-            _lastException = null;
-        }
-
-        [TearDown]
-        public virtual void ShutDown()
-        {
-            _logger.Info("public virtual void Shutdown(): called");
-
-            if (_connection != null)
-            {
-                _logger.Info("Disposing connection.");
-                _connection.Dispose();
-                _logger.Info("Connection disposed.");
-            }
-        }
-        
-        [Test]
-        public void DeleteUsedQueue()
-        {
-            // Create the consumer
-            _consumer = _channel.CreateConsumerBuilder(_queueName)
-                    .WithPrefetchLow(100)
-                    .Create();
-            _logger.Info("Consumer was created...");
-
-            // delete the queue
-            _channel.DeleteQueue(_queueName, false, true, true);
-            _logger.InfoFormat("Queue {0} was delete", _queueName);
-
-            Assert.IsNull(_lastException);
-        }
-
-        [Test]
-        public void DeleteUnusedQueue()
-        {
-            // delete the queue
-            _channel.DeleteQueue(_queueName, true, true, true);
-            _logger.InfoFormat("Queue {0} was delete", _queueName);
-
-            Assert.IsNull(_lastException);
-        }
-
-        [Test]
-        public void DeleteNonEmptyQueue()
-        {
-            // Create the publisher
-            _publisher = _channel.CreatePublisherBuilder()
-                .WithExchangeName(ExchangeNameDefaults.TOPIC)
-                .WithRoutingKey(_routingKey)
-                .Create();
-            _logger.Info("Publisher created...");
-            SendTestMessage("DeleteNonEmptyQueue Message 1");
-
-            try
-            {
-                _channel.DeleteQueue(_queueName, true, false, true);
-            }
-            catch (AMQException)
-            {
-                Assert.Fail("The test fails");
-            }            
-        }
-
-        [Test]
-        public void DeleteEmptyQueue()
-        {
-            // Create the publisher
-            _publisher = _channel.CreatePublisherBuilder()
-                .WithExchangeName(ExchangeNameDefaults.TOPIC)
-                .WithRoutingKey(_routingKey)
-                .Create();
-            _logger.Info("Publisher created...");
-
-            // delete an empty queue with ifEmpty = true
-            _channel.DeleteQueue(_queueName, false, true, true);
-
-            Assert.IsNull(_lastException);
-        }
-
-        [Test]
-        public void DeleteQueueWithResponse()
-        {
-            // Create the publisher
-            _publisher = _channel.CreatePublisherBuilder()
-                .WithExchangeName(ExchangeNameDefaults.TOPIC)
-                .WithRoutingKey(_routingKey)
-                .Create();
-            _logger.Info("Publisher created...");
-
-            SendTestMessage("DeleteQueueWithResponse Message 1");
-            SendTestMessage("DeleteQueueWithResponse Message 2");
-            
-            // delete the queue, the server must respond
-            _channel.DeleteQueue(_queueName, false, false, false);
-        }
-
-        [Test]
-        public void PurgeQueueWithResponse()
-        {
-            _publisher = _channel.CreatePublisherBuilder()
-                .WithExchangeName(ExchangeNameDefaults.TOPIC)
-                .WithRoutingKey(_routingKey)
-                .Create();
-            _logger.Info("Pubisher created");
-
-            SendTestMessage("Message 1");
-            SendTestMessage("Message 2");
-
-            _channel.PurgeQueue(_queueName, false);
-        }
-
-        [Test]
-        public void PurgeQueueWithOutResponse()
-        {
-            _publisher = _channel.CreatePublisherBuilder()
-                .WithExchangeName(ExchangeNameDefaults.TOPIC)
-                .WithRoutingKey(_routingKey)
-                .Create();
-            _logger.Info("Pubisher created");
-
-            SendTestMessage("Message 1");
-            SendTestMessage("Message 2");
-
-            _channel.PurgeQueue(_queueName, true);
-        }
-
-
-        /// <summary>
-        /// Callback method to handle any exceptions raised by the test connection.</summary>        /// 
-        /// <param name="e">The connection exception.</param>
-        public void OnException(Exception e)
-        {
-            // Preserve the most recent exception in case test cases need to examine it.
-            _lastException = e;
-
-            // Notify any waiting threads that an exception event has occurred.
-            _evt.Set();
-        }
-
-        /// <summary>
-        /// Sends the specified message to the test publisher, and confirms that it was received by the test consumer or not
-        /// depending on whether or not the message should be received by the consumer.
-        /// 
-        /// Any exceptions raised by the connection will cause an Assert failure exception to be raised.
-        /// </summary>
-        /// 
-        /// <param name="msgSend">The message to send.</param>
-        private void SendTestMessage(string msg)
-        {
-            // create the IMessage object
-            IMessage msgSend = _channel.CreateTextMessage(msg);
-
-            // send the message
-            _publisher.Send(msgSend);
-            _logger.InfoFormat("The messages \"{0}\" was sent", msg);
-        }
-
-    }
-}
+/*
+ *
+ * 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.
+ *
+ */
+using System;
+using System.Net;
+using System.Threading;
+using log4net;
+using Apache.Qpid.Client.Qms;
+using Apache.Qpid.Client;
+using Apache.Qpid.Messaging;
+using NUnit.Framework;
+
+namespace Apache.Qpid.Integration.Tests.testcases
+{
+    /// <summary>
+    /// Test the queue methods
+    /// </summary>
+    [TestFixture, Category("Integration")]
+    public class ChannelQueueTest
+    {
+        private static ILog _logger = LogManager.GetLogger(typeof(ChannelQueueTest));
+
+        /// <summary> The default AMQ connection URL to use for tests. </summary>
+        const string DEFAULT_URI = "amqp://guest:guest@default/test?brokerlist='tcp://localhost:5672'";
+        const string _routingKey = "ServiceQ1";
+
+        private ExceptionListenerDelegate _exceptionDelegate;
+        private AutoResetEvent _evt = new AutoResetEvent(false);
+        private Exception _lastException = null;
+
+        private IMessageConsumer _consumer;
+        private IMessagePublisher _publisher;
+        private IChannel _channel;
+        private IConnection _connection;
+
+        private string _queueName;
+
+        [SetUp]
+        public virtual void Init()
+        {
+            _logger.Info("public virtual void Init(): called");
+
+            // Create a connection to the broker.
+            IConnectionInfo connectionInfo = QpidConnectionInfo.FromUrl(DEFAULT_URI);
+            _connection = new AMQConnection(connectionInfo);
+            _logger.Info("Starting...");
+
+            // Register this to listen for exceptions on the test connection.
+            _exceptionDelegate = new ExceptionListenerDelegate(OnException);
+            _connection.ExceptionListener += _exceptionDelegate;
+
+            // Establish a session on the broker.
+            _channel = _connection.CreateChannel(false, AcknowledgeMode.AutoAcknowledge, 1);
+
+            // Create a durable, non-temporary, non-exclusive queue.
+            _queueName = _channel.GenerateUniqueName();
+            _channel.DeclareQueue(_queueName, true, false, false);
+
+            _channel.Bind(_queueName, ExchangeNameDefaults.TOPIC, _routingKey);
+
+            // Clear the most recent message and exception.
+            _lastException = null;
+        }
+
+        [TearDown]
+        public virtual void ShutDown()
+        {
+            _logger.Info("public virtual void Shutdown(): called");
+
+            if (_connection != null)
+            {
+                _logger.Info("Disposing connection.");
+                _connection.Dispose();
+                _logger.Info("Connection disposed.");
+            }
+        }
+        
+        [Test]
+        public void DeleteUsedQueue()
+        {
+            // Create the consumer
+            _consumer = _channel.CreateConsumerBuilder(_queueName)
+                    .WithPrefetchLow(100)
+                    .Create();
+            _logger.Info("Consumer was created...");
+
+            // delete the queue
+            _channel.DeleteQueue(_queueName, false, true, true);
+            _logger.InfoFormat("Queue {0} was delete", _queueName);
+
+            Assert.IsNull(_lastException);
+        }
+
+        [Test]
+        public void DeleteUnusedQueue()
+        {
+            // delete the queue
+            _channel.DeleteQueue(_queueName, true, true, true);
+            _logger.InfoFormat("Queue {0} was delete", _queueName);
+
+            Assert.IsNull(_lastException);
+        }
+
+        [Test]
+        public void DeleteNonEmptyQueue()
+        {
+            // Create the publisher
+            _publisher = _channel.CreatePublisherBuilder()
+                .WithExchangeName(ExchangeNameDefaults.TOPIC)
+                .WithRoutingKey(_routingKey)
+                .Create();
+            _logger.Info("Publisher created...");
+            SendTestMessage("DeleteNonEmptyQueue Message 1");
+
+            try
+            {
+                _channel.DeleteQueue(_queueName, true, false, true);
+            }
+            catch (AMQException)
+            {
+                Assert.Fail("The test fails");
+            }            
+        }
+
+        [Test]
+        public void DeleteEmptyQueue()
+        {
+            // Create the publisher
+            _publisher = _channel.CreatePublisherBuilder()
+                .WithExchangeName(ExchangeNameDefaults.TOPIC)
+                .WithRoutingKey(_routingKey)
+                .Create();
+            _logger.Info("Publisher created...");
+
+            // delete an empty queue with ifEmpty = true
+            _channel.DeleteQueue(_queueName, false, true, true);
+
+            Assert.IsNull(_lastException);
+        }
+
+        [Test]
+        public void DeleteQueueWithResponse()
+        {
+            // Create the publisher
+            _publisher = _channel.CreatePublisherBuilder()
+                .WithExchangeName(ExchangeNameDefaults.TOPIC)
+                .WithRoutingKey(_routingKey)
+                .Create();
+            _logger.Info("Publisher created...");
+
+            SendTestMessage("DeleteQueueWithResponse Message 1");
+            SendTestMessage("DeleteQueueWithResponse Message 2");
+            
+            // delete the queue, the server must respond
+            _channel.DeleteQueue(_queueName, false, false, false);
+        }
+
+        [Test]
+        public void PurgeQueueWithResponse()
+        {
+            _publisher = _channel.CreatePublisherBuilder()
+                .WithExchangeName(ExchangeNameDefaults.TOPIC)
+                .WithRoutingKey(_routingKey)
+                .Create();
+            _logger.Info("Pubisher created");
+
+            SendTestMessage("Message 1");
+            SendTestMessage("Message 2");
+
+            _channel.PurgeQueue(_queueName, false);
+        }
+
+        [Test]
+        public void PurgeQueueWithOutResponse()
+        {
+            _publisher = _channel.CreatePublisherBuilder()
+                .WithExchangeName(ExchangeNameDefaults.TOPIC)
+                .WithRoutingKey(_routingKey)
+                .Create();
+            _logger.Info("Pubisher created");
+
+            SendTestMessage("Message 1");
+            SendTestMessage("Message 2");
+
+            _channel.PurgeQueue(_queueName, true);
+        }
+
+
+        /// <summary>
+        /// Callback method to handle any exceptions raised by the test connection.</summary>        /// 
+        /// <param name="e">The connection exception.</param>
+        public void OnException(Exception e)
+        {
+            // Preserve the most recent exception in case test cases need to examine it.
+            _lastException = e;
+
+            // Notify any waiting threads that an exception event has occurred.
+            _evt.Set();
+        }
+
+        /// <summary>
+        /// Sends the specified message to the test publisher, and confirms that it was received by the test consumer or not
+        /// depending on whether or not the message should be received by the consumer.
+        /// 
+        /// Any exceptions raised by the connection will cause an Assert failure exception to be raised.
+        /// </summary>
+        /// 
+        /// <param name="msgSend">The message to send.</param>
+        private void SendTestMessage(string msg)
+        {
+            // create the IMessage object
+            IMessage msgSend = _channel.CreateTextMessage(msg);
+
+            // send the message
+            _publisher.Send(msgSend);
+            _logger.InfoFormat("The messages \"{0}\" was sent", msg);
+        }
+
+    }
+}

Propchange: qpid/trunk/qpid/dotnet/Qpid.Integration.Tests/testcases/ChannelQueueTest.cs
------------------------------------------------------------------------------
    svn:eol-style = native



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org


Mime
View raw message