Return-Path: Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: (qmail 79046 invoked from network); 1 Jun 2009 23:28:14 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 1 Jun 2009 23:28:14 -0000 Received: (qmail 49919 invoked by uid 500); 1 Jun 2009 23:28:26 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 49866 invoked by uid 500); 1 Jun 2009 23:28:26 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 49853 invoked by uid 99); 1 Jun 2009 23:28:26 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 01 Jun 2009 23:28:26 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 01 Jun 2009 23:28:23 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id AF4482388874; Mon, 1 Jun 2009 23:28:03 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r780880 - in /activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp: DurableTest.cs NMSTestSupport.cs Date: Mon, 01 Jun 2009 23:28:03 -0000 To: commits@activemq.apache.org From: jgomes@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090601232803.AF4482388874@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: jgomes Date: Mon Jun 1 23:28:03 2009 New Revision: 780880 URL: http://svn.apache.org/viewvc?rev=780880&view=rev Log: Remove tests for non-persistent durable messages. All durable consumer message tests must use persistent messages. (c.f., http://activemq.apache.org/why-do-i-not-receive-messages-on-my-durable-topic-subscription.html) Added macro expansion for TIBCOHost, TIBCOBackupHost, MSMQHost, and MSMQBackupHost. Modified: activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/DurableTest.cs activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/NMSTestSupport.cs Modified: activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/DurableTest.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/DurableTest.cs?rev=780880&r1=780879&r2=780880&view=diff ============================================================================== --- activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/DurableTest.cs (original) +++ activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/DurableTest.cs Mon Jun 1 23:28:03 2009 @@ -33,34 +33,44 @@ #if !NET_1_1 [RowTest] - [Row(MsgDeliveryMode.Persistent)] - [Row(MsgDeliveryMode.NonPersistent)] + [Row(AcknowledgementMode.AutoAcknowledge)] + [Row(AcknowledgementMode.ClientAcknowledge)] + [Row(AcknowledgementMode.DupsOkAcknowledge)] + [Row(AcknowledgementMode.Transactional)] #endif - public void TestDurableConsumerSelectorChange(MsgDeliveryMode deliveryMode) + public void TestDurableConsumerSelectorChange(AcknowledgementMode ackMode) { try { using(IConnection connection = CreateConnection(TEST_CLIENT_ID)) { connection.Start(); - using(ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge)) + using(ISession session = connection.CreateSession(ackMode)) { - ITopic topic = SessionUtil.GetTopic(session, DURABLE_TOPIC); + ITopic topic = session.GetTopic(DURABLE_TOPIC); IMessageProducer producer = session.CreateProducer(topic); IMessageConsumer consumer = session.CreateDurableConsumer(topic, CONSUMER_ID, "color='red'", false); - producer.DeliveryMode = deliveryMode; + producer.DeliveryMode = MsgDeliveryMode.Persistent; // Send the messages ITextMessage sendMessage = session.CreateTextMessage("1st"); sendMessage.Properties["color"] = "red"; producer.Send(sendMessage); + if(AcknowledgementMode.Transactional == ackMode) + { + session.Commit(); + } ITextMessage receiveMsg = consumer.Receive(receiveTimeout) as ITextMessage; Assert.IsNotNull(receiveMsg, "Failed to retrieve 1st durable message."); Assert.AreEqual("1st", receiveMsg.Text); - Assert.AreEqual(deliveryMode, receiveMsg.NMSDeliveryMode, "NMSDeliveryMode does not match"); + Assert.AreEqual(MsgDeliveryMode.Persistent, receiveMsg.NMSDeliveryMode, "NMSDeliveryMode does not match"); receiveMsg.Acknowledge(); + if(AcknowledgementMode.Transactional == ackMode) + { + session.Commit(); + } // Change the subscription. consumer.Dispose(); @@ -72,13 +82,21 @@ sendMessage = session.CreateTextMessage("3rd"); sendMessage.Properties["color"] = "blue"; producer.Send(sendMessage); + if(AcknowledgementMode.Transactional == ackMode) + { + session.Commit(); + } // Selector should skip the 2nd message. receiveMsg = consumer.Receive(receiveTimeout) as ITextMessage; Assert.IsNotNull(receiveMsg, "Failed to retrieve durable message."); Assert.AreEqual("3rd", receiveMsg.Text, "Retrieved the wrong durable message."); - Assert.AreEqual(deliveryMode, receiveMsg.NMSDeliveryMode, "NMSDeliveryMode does not match"); + Assert.AreEqual(MsgDeliveryMode.Persistent, receiveMsg.NMSDeliveryMode, "NMSDeliveryMode does not match"); receiveMsg.Acknowledge(); + if(AcknowledgementMode.Transactional == ackMode) + { + session.Commit(); + } // Make sure there are no pending messages. Assert.IsNull(consumer.ReceiveNoWait(), "Wrong number of messages in durable subscription."); @@ -97,25 +115,20 @@ #if !NET_1_1 [RowTest] - [Row(MsgDeliveryMode.Persistent, AcknowledgementMode.AutoAcknowledge)] - [Row(MsgDeliveryMode.Persistent, AcknowledgementMode.ClientAcknowledge)] - [Row(MsgDeliveryMode.Persistent, AcknowledgementMode.DupsOkAcknowledge)] - [Row(MsgDeliveryMode.Persistent, AcknowledgementMode.Transactional)] - - [Row(MsgDeliveryMode.NonPersistent, AcknowledgementMode.AutoAcknowledge)] - [Row(MsgDeliveryMode.NonPersistent, AcknowledgementMode.ClientAcknowledge)] - [Row(MsgDeliveryMode.NonPersistent, AcknowledgementMode.DupsOkAcknowledge)] - [Row(MsgDeliveryMode.NonPersistent, AcknowledgementMode.Transactional)] + [Row(AcknowledgementMode.AutoAcknowledge)] + [Row(AcknowledgementMode.ClientAcknowledge)] + [Row(AcknowledgementMode.DupsOkAcknowledge)] + [Row(AcknowledgementMode.Transactional)] #endif - public void TestDurableConsumer(MsgDeliveryMode deliveryMode, AcknowledgementMode ackMode) + public void TestDurableConsumer(AcknowledgementMode ackMode) { try { RegisterDurableConsumer(TEST_CLIENT_ID, DURABLE_TOPIC, CONSUMER_ID, DURABLE_SELECTOR, false); - RunTestDurableConsumer(deliveryMode, ackMode); + RunTestDurableConsumer(ackMode); if(AcknowledgementMode.Transactional == ackMode) { - RunTestDurableConsumer(deliveryMode, ackMode); + RunTestDurableConsumer(ackMode); } } finally @@ -124,9 +137,9 @@ } } - protected void RunTestDurableConsumer(MsgDeliveryMode deliveryMode, AcknowledgementMode ackMode) + protected void RunTestDurableConsumer(AcknowledgementMode ackMode) { - SendDurableMessage(deliveryMode); + SendDurableMessage(); using(IConnection connection = CreateConnection(TEST_CLIENT_ID)) { @@ -139,7 +152,7 @@ IMessage msg = consumer.Receive(receiveTimeout); Assert.IsNotNull(msg, "Did not receive first durable message."); msg.Acknowledge(); - SendDurableMessage(deliveryMode); + SendDurableMessage(); msg = consumer.Receive(receiveTimeout); Assert.IsNotNull(msg, "Did not receive second durable message."); @@ -154,7 +167,7 @@ } } - protected void SendDurableMessage(MsgDeliveryMode deliveryMode) + protected void SendDurableMessage() { using(IConnection connection = CreateConnection(SEND_CLIENT_ID)) { @@ -166,7 +179,7 @@ { ITextMessage message = session.CreateTextMessage("Durable Hello"); - producer.DeliveryMode = deliveryMode; + producer.DeliveryMode = MsgDeliveryMode.Persistent; producer.RequestTimeout = receiveTimeout; producer.Send(message); } Modified: activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/NMSTestSupport.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/NMSTestSupport.cs?rev=780880&r1=780879&r2=780880&view=diff ============================================================================== --- activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/NMSTestSupport.cs (original) +++ activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/NMSTestSupport.cs Mon Jun 1 23:28:03 2009 @@ -212,31 +212,55 @@ /// public static string ReplaceEnvVar(string srcText) { - // TODO: This should be refactored to be more generic and support full variable + // NOTE: Might be able to refactor to be more generic and support full variable // names that can be pulled from the environment. Currently, we only support limited - // hard-coded variable names: - // - // "${activemqhost}" - defaults to "localhost". - // "${activemqbackuphost}" - defaults to "localhost". + // hard-coded variable names. - srcText = ReplaceEnvVar(srcText, "ActiveMQHost", "localhost"); - srcText = ReplaceEnvVar(srcText, "ActiveMQBackupHost", "localhost"); + string defaultBroker = GetEnvVar("NMSTestBroker", "localhost"); + + srcText = ReplaceEnvVar(srcText, "ActiveMQHost", defaultBroker); + srcText = ReplaceEnvVar(srcText, "ActiveMQBackupHost", defaultBroker); + + srcText = ReplaceEnvVar(srcText, "TIBCOHost", defaultBroker); + srcText = ReplaceEnvVar(srcText, "TIBCOBackupHost", defaultBroker); + + srcText = ReplaceEnvVar(srcText, "MSMQHost", defaultBroker); + srcText = ReplaceEnvVar(srcText, "MSMQBackupHost", defaultBroker); return srcText; } + /// + /// Replace the variable with environment variable. + /// + /// + /// + /// + /// public static string ReplaceEnvVar(string srcText, string varName, string defaultValue) { + string replacementValue = GetEnvVar(varName, defaultValue); + return Regex.Replace(srcText, "\\${" + varName + "}", replacementValue, RegexOptions.IgnoreCase); + } + + /// + /// Get environment variable value. + /// + /// + /// + /// + public static string GetEnvVar(string varName, string defaultValue) + { #if (PocketPC||NETCF||NETCF_2_0) - string replacementValue = null; + string varValue = null; #else - string replacementValue = Environment.GetEnvironmentVariable(varName); + string varValue = Environment.GetEnvironmentVariable(varName); #endif - if(null == replacementValue) + if(null == varValue) { - replacementValue = defaultValue; + varValue = defaultValue; } - return Regex.Replace(srcText, "\\${" + varName + "}", replacementValue, RegexOptions.IgnoreCase); + return varValue; } ///