activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r1058236 - in /activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/Transport/Tcp: ./ TcpFaultyTransport.cs TcpFaultyTransportFactory.cs TcpFaultyTransportTest.cs
Date Wed, 12 Jan 2011 17:08:45 GMT
Author: tabish
Date: Wed Jan 12 17:08:44 2011
New Revision: 1058236

URL: http://svn.apache.org/viewvc?rev=1058236&view=rev
Log:
https://issues.apache.org/jira/browse/AMQNET-306

Adds a simple Tcp transport extension that can be expanded to allow for controlling when and
how a Tcp Transport fails in certain tests. 

Added:
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/Transport/Tcp/
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/Transport/Tcp/TcpFaultyTransport.cs
  (with props)
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/Transport/Tcp/TcpFaultyTransportFactory.cs
  (with props)
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/Transport/Tcp/TcpFaultyTransportTest.cs
  (with props)

Added: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/Transport/Tcp/TcpFaultyTransport.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/Transport/Tcp/TcpFaultyTransport.cs?rev=1058236&view=auto
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/Transport/Tcp/TcpFaultyTransport.cs
(added)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/Transport/Tcp/TcpFaultyTransport.cs
Wed Jan 12 17:08:44 2011
@@ -0,0 +1,67 @@
+/*
+ * 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.IO;
+using System.Net.Sockets;
+using Apache.NMS.ActiveMQ.Commands;
+
+namespace Apache.NMS.ActiveMQ.Transport.Tcp
+{
+    public class TcpFaultyTransport : TcpTransport
+    {		
+		private CommandHandler onewayCommandPreProcessor;
+		private CommandHandler onewayCommandPostProcessor;
+				
+        public TcpFaultyTransport(Uri location, Socket socket, IWireFormat wireFormat) :
+            base(location, socket, wireFormat)
+        {
+        }
+
+        ~TcpFaultyTransport()
+        {
+            Dispose(false);
+        }		
+
+		public CommandHandler OnewayCommandPreProcessor 
+		{
+			get { return this.onewayCommandPreProcessor; }
+			set { this.onewayCommandPreProcessor = value; }
+		}
+
+		public CommandHandler OnewayCommandPostProcessor 
+		{
+			get { return this.onewayCommandPostProcessor; }
+			set { this.onewayCommandPostProcessor = value; }
+		}
+
+        public override void Oneway(Command command)
+        {
+            if(this.onewayCommandPreProcessor != null)
+            {
+                this.onewayCommandPreProcessor(this, command);
+            }
+
+            base.Oneway(command);
+
+            if(this.onewayCommandPostProcessor != null)
+            {
+                this.onewayCommandPostProcessor(this, command);
+            }
+        }
+    }
+}

Propchange: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/Transport/Tcp/TcpFaultyTransport.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/Transport/Tcp/TcpFaultyTransportFactory.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/Transport/Tcp/TcpFaultyTransportFactory.cs?rev=1058236&view=auto
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/Transport/Tcp/TcpFaultyTransportFactory.cs
(added)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/Transport/Tcp/TcpFaultyTransportFactory.cs
Wed Jan 12 17:08:44 2011
@@ -0,0 +1,37 @@
+/*
+ * 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.Sockets;
+
+namespace Apache.NMS.ActiveMQ.Transport.Tcp
+{
+	public class TcpFaultyTransportFactory : TcpTransportFactory
+	{        
+        public TcpFaultyTransportFactory() : base()
+        {
+        }
+
+		protected override ITransport DoCreateTransport(Uri location, Socket socket, IWireFormat
wireFormat )
+		{
+            Tracer.Debug("Creating new instance of the TcpFaulty Transport.");
+			TcpFaultyTransport transport = new TcpFaultyTransport(location, socket, wireFormat);
+            
+            return transport;
+		}		
+	}
+}

Propchange: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/Transport/Tcp/TcpFaultyTransportFactory.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/Transport/Tcp/TcpFaultyTransportTest.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/Transport/Tcp/TcpFaultyTransportTest.cs?rev=1058236&view=auto
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/Transport/Tcp/TcpFaultyTransportTest.cs
(added)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/Transport/Tcp/TcpFaultyTransportTest.cs
Wed Jan 12 17:08:44 2011
@@ -0,0 +1,91 @@
+/*
+ * 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 Apache.NMS.Test;
+using Apache.NMS.ActiveMQ;
+using Apache.NMS.ActiveMQ.Commands;
+using Apache.NMS.ActiveMQ.Transport;
+using Apache.NMS.ActiveMQ.Transport.Tcp;
+using NUnit.Framework;
+
+namespace Apache.NMS.ActiveMQ.Test
+{
+    [TestFixture]
+    public class TcpFaultyTransportTest : NMSTestSupport
+    {
+        private bool preProcessorFired;
+        private bool postProcessorFired;
+
+        public TcpFaultyTransportTest()
+        {
+        }
+
+        [SetUp]
+        public override void SetUp()
+        {
+            base.SetUp();
+            TransportFactory.RegisterTransport("tcpFaulty", typeof(TcpFaultyTransportFactory));
+
+            preProcessorFired = false;
+            postProcessorFired = false;
+        }
+
+        [TearDown]
+        public override void TearDown()
+        {
+        }
+
+        public void OnPreProcessCommand(ITransport transport, Command command)
+        {
+            this.preProcessorFired = true;
+        }
+
+        public void OnPostProcessCommand(ITransport transport, Command command)
+        {
+            this.postProcessorFired = true;
+        }
+
+        [Test, Sequential]
+        public void TestConnectUsingBasicTransport(
+            [Values("tcpfaulty://${activemqhost}:61616", "activemq:tcpfaulty://${activemqhost}:61616")]
+            string connectionURI)
+        {
+            ConnectionFactory factory = new ConnectionFactory(NMSTestSupport.ReplaceEnvVar(connectionURI));
+
+            using(Connection connection = factory.CreateConnection() as Connection)
+            {
+                ITransport transport = connection.ITransport.Narrow(typeof(TcpFaultyTransport))
as ITransport;
+                Assert.IsNotNull(transport);
+
+                TcpFaultyTransport testee = transport as TcpFaultyTransport;
+                testee.OnewayCommandPreProcessor += new CommandHandler(this.OnPreProcessCommand);
+                testee.OnewayCommandPostProcessor += new CommandHandler(this.OnPostProcessCommand);
+
+                using(ISession session = connection.CreateSession())
+                {
+                    Assert.IsTrue(session.Transacted == false);
+                }
+
+                Assert.IsTrue(this.preProcessorFired);
+                Assert.IsTrue(this.postProcessorFired);
+            }
+        }
+
+    }
+}
+

Propchange: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/Transport/Tcp/TcpFaultyTransportTest.cs
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message