From 43f0dea566c81bb72aea75b825bbd97ec5d1d950 Mon Sep 17 00:00:00 2001 From: Aidan Skinner Date: Thu, 3 Dec 2009 23:55:48 +0000 Subject: Fix eol style property git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@886998 13f79535-47bb-0310-9956-ffa450edef68 --- .../interactive/FailoverTest.cs | 4 +- .../interactive/SendReceiveTest.cs | 360 ++++++++++----------- 2 files changed, 182 insertions(+), 182 deletions(-) (limited to 'dotnet/Qpid.Integration.Tests/interactive') diff --git a/dotnet/Qpid.Integration.Tests/interactive/FailoverTest.cs b/dotnet/Qpid.Integration.Tests/interactive/FailoverTest.cs index 547266a7a5..142ac40b27 100644 --- a/dotnet/Qpid.Integration.Tests/interactive/FailoverTest.cs +++ b/dotnet/Qpid.Integration.Tests/interactive/FailoverTest.cs @@ -73,12 +73,12 @@ namespace Apache.Qpid.Integration.Tests.interactive /// Used to wait for test completion on. private static object testComplete = new Object(); - /// Used to wait for failover completion on. + /// Used to wait for failover completion on. private static object failoverComplete = new Object(); bool failedOver=false; - /// Used to record the extra message count (1) if the message sent right after failover actually made it to the new broker. + /// Used to record the extra message count (1) if the message sent right after failover actually made it to the new broker. int _extraMessage = 0; /// diff --git a/dotnet/Qpid.Integration.Tests/interactive/SendReceiveTest.cs b/dotnet/Qpid.Integration.Tests/interactive/SendReceiveTest.cs index ebc9307c2e..68d7a2ae68 100644 --- a/dotnet/Qpid.Integration.Tests/interactive/SendReceiveTest.cs +++ b/dotnet/Qpid.Integration.Tests/interactive/SendReceiveTest.cs @@ -1,181 +1,181 @@ -/* - * - * 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.Threading; -using log4net; -using NUnit.Framework; -using Apache.Qpid.Messaging; -using Apache.Qpid.Client.Qms; -using Apache.Qpid.Client; -using Apache.Qpid.Integration.Tests.testcases; - -namespace Apache.Qpid.Integration.Tests.interactive -{ - /// - /// SendReceiveTest provides a quick interactive send-receive test, where the user is prompted to trigger each send or receive. - /// - ///

- ///
CRC Card
Responsibilities Collaborations - ///
Run an interactive send-receive loop prompting user to trigger each event. - ///
- ///

- [TestFixture, Category("Interactive")] - public class SendReceiveTest : BaseMessagingTestFixture - { - /// Used for debugging purposes. - private static ILog log = LogManager.GetLogger(typeof(SendReceiveTest)); - - /// Defines the name of the test topic to use with the tests. - public const string TEST_ROUTING_KEY = "quicktestkey"; - - /// The number of consumers to test. - private const int CONSUMER_COUNT = 5; - - /// The number of test messages to send. - private const int MESSAGE_COUNT = 10; - - /// Monitor used to signal succesfull receipt of all test messages. - AutoResetEvent _finishedEvent; - - /// Used to count test messages received so far. - private int _messageReceivedCount; - - /// Used to hold the expected number of messages to receive. - private int expectedMessageCount; - - /// Flag used to indicate that all messages really were received, and that the test did not just time out. - private bool allReceived; - - /// Creates one producing end-point and many consuming end-points connected on a topic. - [SetUp] - public override void Init() - { - base.Init(); - - // Reset all test counts and flags. - _messageReceivedCount = 0; - allReceived = false; - _finishedEvent = new AutoResetEvent(false); - } - - /// Cleans up all test end-points. - [TearDown] - public override void Shutdown() - { - try - { - // Close all end points for producer and consumers. - // Producer is on 0, and consumers on 1 .. n, so loop is from 0 to n inclusive. - for (int i = 0; i <= CONSUMER_COUNT; i++) - { - CloseEndPoint(i); - } - } - finally - { - base.Shutdown(); - } - } - - /// Check that all consumers on a topic each receive all message on it. - [Test] - public void AllConsumerReceiveAllMessagesOnTopic() - { - // Create end-points for all the consumers in the test. - for (int i = 1; i <= CONSUMER_COUNT; i++) - { - SetUpEndPoint(i, false, true, TEST_ROUTING_KEY + testId, AcknowledgeMode.AutoAcknowledge, false, ExchangeNameDefaults.TOPIC, - true, false, null); - testConsumer[i].OnMessage += new MessageReceivedDelegate(OnMessage); - } - - // Create an end-point to publish to the test topic. - SetUpEndPoint(0, true, false, TEST_ROUTING_KEY + testId, AcknowledgeMode.AutoAcknowledge, false, ExchangeNameDefaults.TOPIC, - true, false, null); - - expectedMessageCount = (MESSAGE_COUNT * CONSUMER_COUNT); - - PromptAndWait("Press to send..."); - - for (int i = 0; i < MESSAGE_COUNT; i++) - { - testProducer[0].Send(testChannel[0].CreateTextMessage("A")); - } - - _finishedEvent.WaitOne(new TimeSpan(0, 0, 0, 10), false); - - PromptAndWait("Press to complete test..."); - - // Check that all messages really were received. - Assert.IsTrue(allReceived, "All messages were not received, only got " + _messageReceivedCount + " but wanted " + expectedMessageCount); - } - - /// Check that consumers on the same queue receive each message once accross all consumers. - //[Test] - public void AllConsumerReceiveAllMessagesOnDirect() - { - // Create end-points for all the consumers in the test. - for (int i = 1; i <= CONSUMER_COUNT; i++) - { - SetUpEndPoint(i, false, true, TEST_ROUTING_KEY + testId, AcknowledgeMode.AutoAcknowledge, false, ExchangeNameDefaults.DIRECT, - true, false, null); - testConsumer[i].OnMessage += new MessageReceivedDelegate(OnMessage); - } - - // Create an end-point to publish to the test topic. - SetUpEndPoint(0, true, false, TEST_ROUTING_KEY + testId, AcknowledgeMode.AutoAcknowledge, false, ExchangeNameDefaults.DIRECT, - true, false, null); - - expectedMessageCount = MESSAGE_COUNT; - - for (int i = 0; i < MESSAGE_COUNT; i++) - { - testProducer[0].Send(testChannel[0].CreateTextMessage("A")); - } - - _finishedEvent.WaitOne(new TimeSpan(0, 0, 0, 10), false); - - // Check that all messages really were received. - Assert.IsTrue(allReceived, "All messages were not received, only got: " + _messageReceivedCount + " but wanted " + expectedMessageCount); - } - - /// Atomically increments the message count on every message, and signals once all messages in the test are received. - public void OnMessage(IMessage m) - { - int newCount = Interlocked.Increment(ref _messageReceivedCount); - - if (newCount >= expectedMessageCount) - { - allReceived = true; - _finishedEvent.Set(); - } - } - - /// Prompts the user on stdout and waits for a reply on stdin, using the specified prompt message. - /// - /// The message to prompt the user with. - private void PromptAndWait(string message) - { - Console.WriteLine("\n" + message); - Console.ReadLine(); - } - } +/* + * + * 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.Threading; +using log4net; +using NUnit.Framework; +using Apache.Qpid.Messaging; +using Apache.Qpid.Client.Qms; +using Apache.Qpid.Client; +using Apache.Qpid.Integration.Tests.testcases; + +namespace Apache.Qpid.Integration.Tests.interactive +{ + /// + /// SendReceiveTest provides a quick interactive send-receive test, where the user is prompted to trigger each send or receive. + /// + ///

+ ///
CRC Card
Responsibilities Collaborations + ///
Run an interactive send-receive loop prompting user to trigger each event. + ///
+ ///

+ [TestFixture, Category("Interactive")] + public class SendReceiveTest : BaseMessagingTestFixture + { + /// Used for debugging purposes. + private static ILog log = LogManager.GetLogger(typeof(SendReceiveTest)); + + /// Defines the name of the test topic to use with the tests. + public const string TEST_ROUTING_KEY = "quicktestkey"; + + /// The number of consumers to test. + private const int CONSUMER_COUNT = 5; + + /// The number of test messages to send. + private const int MESSAGE_COUNT = 10; + + /// Monitor used to signal succesfull receipt of all test messages. + AutoResetEvent _finishedEvent; + + /// Used to count test messages received so far. + private int _messageReceivedCount; + + /// Used to hold the expected number of messages to receive. + private int expectedMessageCount; + + /// Flag used to indicate that all messages really were received, and that the test did not just time out. + private bool allReceived; + + /// Creates one producing end-point and many consuming end-points connected on a topic. + [SetUp] + public override void Init() + { + base.Init(); + + // Reset all test counts and flags. + _messageReceivedCount = 0; + allReceived = false; + _finishedEvent = new AutoResetEvent(false); + } + + /// Cleans up all test end-points. + [TearDown] + public override void Shutdown() + { + try + { + // Close all end points for producer and consumers. + // Producer is on 0, and consumers on 1 .. n, so loop is from 0 to n inclusive. + for (int i = 0; i <= CONSUMER_COUNT; i++) + { + CloseEndPoint(i); + } + } + finally + { + base.Shutdown(); + } + } + + /// Check that all consumers on a topic each receive all message on it. + [Test] + public void AllConsumerReceiveAllMessagesOnTopic() + { + // Create end-points for all the consumers in the test. + for (int i = 1; i <= CONSUMER_COUNT; i++) + { + SetUpEndPoint(i, false, true, TEST_ROUTING_KEY + testId, AcknowledgeMode.AutoAcknowledge, false, ExchangeNameDefaults.TOPIC, + true, false, null); + testConsumer[i].OnMessage += new MessageReceivedDelegate(OnMessage); + } + + // Create an end-point to publish to the test topic. + SetUpEndPoint(0, true, false, TEST_ROUTING_KEY + testId, AcknowledgeMode.AutoAcknowledge, false, ExchangeNameDefaults.TOPIC, + true, false, null); + + expectedMessageCount = (MESSAGE_COUNT * CONSUMER_COUNT); + + PromptAndWait("Press to send..."); + + for (int i = 0; i < MESSAGE_COUNT; i++) + { + testProducer[0].Send(testChannel[0].CreateTextMessage("A")); + } + + _finishedEvent.WaitOne(new TimeSpan(0, 0, 0, 10), false); + + PromptAndWait("Press to complete test..."); + + // Check that all messages really were received. + Assert.IsTrue(allReceived, "All messages were not received, only got " + _messageReceivedCount + " but wanted " + expectedMessageCount); + } + + /// Check that consumers on the same queue receive each message once accross all consumers. + //[Test] + public void AllConsumerReceiveAllMessagesOnDirect() + { + // Create end-points for all the consumers in the test. + for (int i = 1; i <= CONSUMER_COUNT; i++) + { + SetUpEndPoint(i, false, true, TEST_ROUTING_KEY + testId, AcknowledgeMode.AutoAcknowledge, false, ExchangeNameDefaults.DIRECT, + true, false, null); + testConsumer[i].OnMessage += new MessageReceivedDelegate(OnMessage); + } + + // Create an end-point to publish to the test topic. + SetUpEndPoint(0, true, false, TEST_ROUTING_KEY + testId, AcknowledgeMode.AutoAcknowledge, false, ExchangeNameDefaults.DIRECT, + true, false, null); + + expectedMessageCount = MESSAGE_COUNT; + + for (int i = 0; i < MESSAGE_COUNT; i++) + { + testProducer[0].Send(testChannel[0].CreateTextMessage("A")); + } + + _finishedEvent.WaitOne(new TimeSpan(0, 0, 0, 10), false); + + // Check that all messages really were received. + Assert.IsTrue(allReceived, "All messages were not received, only got: " + _messageReceivedCount + " but wanted " + expectedMessageCount); + } + + /// Atomically increments the message count on every message, and signals once all messages in the test are received. + public void OnMessage(IMessage m) + { + int newCount = Interlocked.Increment(ref _messageReceivedCount); + + if (newCount >= expectedMessageCount) + { + allReceived = true; + _finishedEvent.Set(); + } + } + + /// Prompts the user on stdout and waits for a reply on stdin, using the specified prompt message. + /// + /// The message to prompt the user with. + private void PromptAndWait(string message) + { + Console.WriteLine("\n" + message); + Console.ReadLine(); + } + } } \ No newline at end of file -- cgit v1.2.1