示例#1
0
        /// <summary>
        /// ITestStep.Execute() implementation
        /// </summary>
        /// <param name='context'>The context for the test, this holds state that is passed beteen tests</param>
        public override void Execute(Context context)
        {
            // Remote or not?
            if (!string.IsNullOrEmpty(HostName))
            {
                context.LogInfo("Host to connect to: \"{0}\" on port \"{1}\" with channel \"{2}\"", HostName, Port, Channel);
                MQEnvironment.Hostname = HostName;
                MQEnvironment.Port     = Port;
                MQEnvironment.Channel  = Channel;
            }
            var message = MQSeriesHelper.ReadMessage(QueueManager, Queue, WaitTimeout, context);

            context.LogData("MQSeries output message:", message);

            // Validate data...
            var msgData = StreamHelper.LoadMemoryStream(message);

            msgData.Seek(0, SeekOrigin.Begin);
            // Check it against the validate steps to see if it matches one of them
            foreach (var subStep in SubSteps)
            {
                try
                {
                    // Try the validation and catch the exception
                    var strm = subStep.Execute(msgData, context);
                }
                catch (Exception ex)
                {
                    context.LogException(ex);
                    throw;
                }
            }
        }
示例#2
0
        /// <summary>
        /// ITestStep.Execute() implementation
        /// </summary>
        /// <param name='context'>The context for the test, this holds state that is passed beteen tests</param>
        public override void Execute(Context context)
        {
            var    reader   = new StreamReader(MessageBody.Load(context));
            string testData = reader.ReadToEnd();

            context.LogData("MSMQ input message:", testData);

            // Remote or not?
            if (!string.IsNullOrEmpty(HostName))
            {
                context.LogInfo("Host to connect to: \"{0}\" on port \"{1}\" with channel \"{2}\"", HostName, Port, Channel);
                MQEnvironment.Hostname = HostName;
                MQEnvironment.Port     = Port;
                MQEnvironment.Channel  = Channel;
            }
            MQSeriesHelper.WriteMessage(QueueManager, Queue, testData, context);
        }
示例#3
0
        /// <summary>
        /// ITestStep.Execute() implementation
        /// </summary>
        /// <param name='context'>The context for the test, this holds state that is passed beteen tests</param>
        public override void Execute(Context context)
        {
            MQQueueManager queueManager;

            try
            {
                // Remote or not?
                if (!string.IsNullOrEmpty(HostName))
                {
                    context.LogInfo("Host to connect to: \"{0}\" on port \"{1}\" with channel \"{2}\"", HostName, Port, Channel);
                    MQEnvironment.Hostname = HostName;
                    MQEnvironment.Port     = Port;
                    MQEnvironment.Channel  = Channel;
                }
                context.LogInfo("Opening queue manager '{0}'.", QueueManager);
                queueManager = new MQQueueManager(QueueManager);
            }
            catch (Exception e)
            {
                throw new Exception(string.Format("Failed to open queue manager {0}.", QueueManager), e);
            }

            var errors = false;

            try
            {
                foreach (var q in Queues)
                {
                    errors = MQSeriesHelper.Purge(queueManager, q.ToString(), context);
                }
            }
            finally
            {
                if (queueManager != null)
                {
                    queueManager.Close();
                }
                if (errors)
                {
                    throw new Exception("Failed to clear at least one queue.");
                }
            }
        }