summaryrefslogtreecommitdiff
path: root/RC9/qpid/dotnet/client-010/test
diff options
context:
space:
mode:
authorRafael H. Schloming <rhs@apache.org>2009-01-13 18:11:43 +0000
committerRafael H. Schloming <rhs@apache.org>2009-01-13 18:11:43 +0000
commit7e34266b9a23f4536415bfbc3f161b84615b6550 (patch)
tree484008cf2d413f58b5e4ab80b373303c66200888 /RC9/qpid/dotnet/client-010/test
parent4612263ea692f00a4bd810438bdaf9bc88022091 (diff)
downloadqpid-python-M4.tar.gz
Tag M4 RC9M4
git-svn-id: https://svn.apache.org/repos/asf/qpid/tags/M4@734202 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'RC9/qpid/dotnet/client-010/test')
-rw-r--r--RC9/qpid/dotnet/client-010/test/Properties/AssemblyInfo.cs56
-rw-r--r--RC9/qpid/dotnet/client-010/test/Test.csproj75
-rw-r--r--RC9/qpid/dotnet/client-010/test/default.build55
-rw-r--r--RC9/qpid/dotnet/client-010/test/interop/Admin.cs90
-rw-r--r--RC9/qpid/dotnet/client-010/test/interop/ApplicationHeaders.cs83
-rw-r--r--RC9/qpid/dotnet/client-010/test/interop/Message.cs179
-rw-r--r--RC9/qpid/dotnet/client-010/test/interop/TestCase.cs117
-rw-r--r--RC9/qpid/dotnet/client-010/test/test.config31
-rw-r--r--RC9/qpid/dotnet/client-010/test/transport/util/ByteEncoderTest.cs106
-rw-r--r--RC9/qpid/dotnet/client-010/test/transport/util/CircularBufferTest.cs89
-rw-r--r--RC9/qpid/dotnet/client-010/test/transport/util/ResultFutureTest.cs103
-rw-r--r--RC9/qpid/dotnet/client-010/test/transport/util/SerialTest.cs75
-rw-r--r--RC9/qpid/dotnet/client-010/test/transport/util/UUIDTest.cs41
13 files changed, 1100 insertions, 0 deletions
diff --git a/RC9/qpid/dotnet/client-010/test/Properties/AssemblyInfo.cs b/RC9/qpid/dotnet/client-010/test/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000000..26a40b1f77
--- /dev/null
+++ b/RC9/qpid/dotnet/client-010/test/Properties/AssemblyInfo.cs
@@ -0,0 +1,56 @@
+/*
+ *
+ * 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.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("Qpid Test")]
+[assembly: AssemblyDescription("Built from svn revision number: ")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Apache Software Foundation")]
+[assembly: AssemblyProduct("Qpid Test")]
+[assembly: AssemblyCopyright("Apache Software Foundation")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("3d62cb4f-4353-4eed-9669-3e1bc902081d")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Revision and Build Numbers
+// by using the '*' as shown below:
+[assembly: AssemblyVersion("0.10.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/RC9/qpid/dotnet/client-010/test/Test.csproj b/RC9/qpid/dotnet/client-010/test/Test.csproj
new file mode 100644
index 0000000000..e2680e16bc
--- /dev/null
+++ b/RC9/qpid/dotnet/client-010/test/Test.csproj
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.50727</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95CB4C90-7C53-44A9-B11C-96235F158ACA}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>test</RootNamespace>
+ <AssemblyName>Qpid Test</AssemblyName>
+ <FileUpgradeFlags>
+ </FileUpgradeFlags>
+ <OldToolsVersion>2.0</OldToolsVersion>
+ <UpgradeBackupLocation>
+ </UpgradeBackupLocation>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\lib\log4net\log4net.dll</HintPath>
+ </Reference>
+ <Reference Include="nunit.framework, Version=2.2.8.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\lib\nunit\nunit.framework.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="interop\Admin.cs" />
+ <Compile Include="interop\ApplicationHeaders.cs" />
+ <Compile Include="interop\Message.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="interop\TestCase.cs" />
+ <Compile Include="transport\util\ByteEncoderTest.cs" />
+ <Compile Include="transport\util\CircularBufferTest.cs" />
+ <Compile Include="transport\util\ResultFutureTest.cs" />
+ <Compile Include="transport\util\SerialTest.cs" />
+ <Compile Include="transport\util\UUIDTest.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\client\Client.csproj">
+ <Project>{B911FFD7-754F-4735-A188-218D5065BE79}</Project>
+ <Name>Client</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project> \ No newline at end of file
diff --git a/RC9/qpid/dotnet/client-010/test/default.build b/RC9/qpid/dotnet/client-010/test/default.build
new file mode 100644
index 0000000000..f9dadb174b
--- /dev/null
+++ b/RC9/qpid/dotnet/client-010/test/default.build
@@ -0,0 +1,55 @@
+<?xml version="1.0"?>
+<!--
+
+ 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.
+
+-->
+
+<project name="qpid.client.tests" default="build">
+ <!--
+ Properties that come from master build file
+ - build.dir: root directory for build
+ - build.debug: true if building debug release
+ - build.defines: variables to define during build
+ -->
+
+ <target name="build">
+ <csc target="library"
+ define="${build.defines}"
+ debug="${build.debug}"
+ output="${build.dir}/${project::get-name()}.dll">
+
+ <sources>
+ <include name="**/*.cs" />
+ </sources>
+ <references>
+ <include name="${build.dir}/log4net.dll" />
+ <include name="${build.dir}/nunit.framework.dll" />
+ <include name="${build.dir}/qpid.client.dll" />
+ </references>
+ </csc>
+ </target>
+
+ <target name="test" depends="build">
+ <nunit2>
+ <formatter type="${nant.formatter}" usefile="false" />
+ <test assemblyname="${build.dir}/qpid.client.tests.dll" />
+ </nunit2>
+ </target>
+</project>
+
diff --git a/RC9/qpid/dotnet/client-010/test/interop/Admin.cs b/RC9/qpid/dotnet/client-010/test/interop/Admin.cs
new file mode 100644
index 0000000000..93b24ea505
--- /dev/null
+++ b/RC9/qpid/dotnet/client-010/test/interop/Admin.cs
@@ -0,0 +1,90 @@
+/*
+*
+* 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 NUnit.Framework;
+using org.apache.qpid.client;
+using org.apache.qpid.transport;
+using org.apache.qpid.transport.util;
+
+namespace test.interop
+{
+ public class Admin:TestCase
+ {
+ private static readonly Logger _log = Logger.get(typeof(Admin));
+
+ [Test]
+ public void createSession()
+ {
+ _log.debug("Running: createSession");
+ ClientSession ssn = Client.createSession(0);
+ ssn.close();
+ // This test fails if an exception is thrown
+ }
+
+ [Test]
+ public void queueLifecycle()
+ {
+ _log.debug("Running: queueLifecycle");
+ ClientSession ssn = Client.createSession(0);
+ ssn.queueDeclare("queue1", null, null);
+ ssn.sync();
+ ssn.queueDelete("queue1");
+ ssn.sync();
+ try
+ {
+ ssn.exchangeBind("queue1", "amq.direct", "queue1", null);
+ ssn.sync();
+ }
+ catch (SessionException e)
+ {
+ // as expected
+ }
+ // This test fails if an exception is thrown
+ }
+
+ [Test]
+ public void exchangeCheck()
+ {
+ _log.debug("Running: exchangeCheck");
+ ClientSession ssn = Client.createSession(0);
+ ExchangeQueryResult query = (ExchangeQueryResult) ssn.exchangeQuery("amq.direct").Result;
+ Assert.IsFalse(query.getNotFound());
+ Assert.IsTrue(query.getDurable());
+ query = (ExchangeQueryResult)ssn.exchangeQuery("amq.topic").Result;
+ Assert.IsFalse(query.getNotFound());
+ Assert.IsTrue(query.getDurable());
+ query = (ExchangeQueryResult) ssn.exchangeQuery("foo").Result;
+ Assert.IsTrue(query.getNotFound());
+ }
+
+ [Test]
+ public void exchangeBind()
+ {
+ _log.debug("Running: exchangeBind");
+ ClientSession ssn = Client.createSession(0);
+ ssn.queueDeclare("queue1", null, null);
+ ssn.exchangeBind("queue1", "amq.direct", "queue1", null);
+ // This test fails if an exception is thrown
+ }
+
+
+ }
+}
diff --git a/RC9/qpid/dotnet/client-010/test/interop/ApplicationHeaders.cs b/RC9/qpid/dotnet/client-010/test/interop/ApplicationHeaders.cs
new file mode 100644
index 0000000000..9e27673a49
--- /dev/null
+++ b/RC9/qpid/dotnet/client-010/test/interop/ApplicationHeaders.cs
@@ -0,0 +1,83 @@
+/*
+*
+* 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 common.org.apache.qpid.transport.util;
+using NUnit.Framework;
+using org.apache.qpid.client;
+using org.apache.qpid.transport.util;
+
+namespace test.interop
+{
+ public class ApplicationHeaders:TestCase
+ {
+ private static readonly Logger _log = Logger.get(typeof(ApplicationHeaders));
+
+ [Test]
+ public void setHeaders()
+ {
+ _log.debug("Running: setHeaders");
+ ClientSession ssn = Client.createSession(0);
+ ssn.queueDeclare("queue1");
+ ssn.exchangeBind("queue1", "amq.direct", "queue1");
+ ssn.sync();
+ CircularBuffer<IMessage> buff = new CircularBuffer<IMessage>(10);
+ SyncListener listener = new SyncListener(ssn, buff);
+ ssn.attachMessageListener(listener, "queue1");
+ ssn.messageSubscribe("queue1");
+
+ IMessage message = new org.apache.qpid.client.Message();
+ message.DeliveryProperties.setRoutingKey("queue1");
+ const long someLong = 14444444;
+ message.ApplicationHeaders.Add("someLong", someLong);
+ const int someInt = 14;
+ message.ApplicationHeaders.Add("soneInt", someInt);
+ const float someFloat = 14.001F;
+ message.ApplicationHeaders.Add("soneFloat", someFloat);
+ const double someDouble = 14.5555555;
+ message.ApplicationHeaders.Add("someDouble", someDouble);
+ const byte someByte = 2;
+ message.ApplicationHeaders.Add("someByte", someByte);
+ const string someString = "someString";
+ message.ApplicationHeaders.Add("someString", someString);
+ const char someChar = 'a';
+ message.ApplicationHeaders.Add("someChar", someChar);
+ const Boolean someBoolean = true;
+ message.ApplicationHeaders.Add("someBoolean", someBoolean);
+
+ // transfer the message
+ ssn.messageTransfer("amq.direct", message);
+
+ // get the message and check the headers
+ IMessage messageBack = buff.Dequeue();
+ Assert.IsTrue(((string) messageBack.ApplicationHeaders["someString"]).Equals(someString));
+ Assert.IsTrue(((char)messageBack.ApplicationHeaders["someChar"]).Equals(someChar));
+ Assert.IsTrue((long)messageBack.ApplicationHeaders["someLong"] == someLong);
+ Assert.IsTrue((int)messageBack.ApplicationHeaders["soneInt"] == someInt);
+ Assert.IsTrue((double)messageBack.ApplicationHeaders["someDouble"] == someDouble);
+ Assert.IsTrue((byte) messageBack.ApplicationHeaders["someByte"] == someByte);
+ Assert.IsTrue((Boolean)messageBack.ApplicationHeaders["someBoolean"]);
+ // c# has an conversion precision issue with decimal
+ Assert.IsTrue((float) messageBack.ApplicationHeaders["soneFloat"] <= someFloat);
+ float b = (float) messageBack.ApplicationHeaders["soneFloat"];
+ Assert.IsTrue(Convert.ToInt32(b) == Convert.ToInt32(someFloat));
+ }
+ }
+}
diff --git a/RC9/qpid/dotnet/client-010/test/interop/Message.cs b/RC9/qpid/dotnet/client-010/test/interop/Message.cs
new file mode 100644
index 0000000000..3267af9c0c
--- /dev/null
+++ b/RC9/qpid/dotnet/client-010/test/interop/Message.cs
@@ -0,0 +1,179 @@
+/*
+*
+* 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 System.Threading;
+using NUnit.Framework;
+using org.apache.qpid.client;
+using org.apache.qpid.transport;
+using org.apache.qpid.transport.util;
+
+namespace test.interop
+{
+ public class Message : TestCase
+ {
+ private static readonly Logger _log = Logger.get(typeof (Message));
+
+ [Test]
+ public void sendAndPurge()
+ {
+ _log.debug("Running: exchangeBind");
+ ClientSession ssn = Client.createSession(0);
+ ssn.queueDelete("queue1");
+ QueueQueryResult result = (QueueQueryResult) ssn.queueQuery("queue1").Result;
+ Assert.IsNull(result.getQueue());
+ ssn.queueDeclare("queue1", null, null);
+ ssn.exchangeBind("queue1", "amq.direct", "queue1", null);
+ for (int i = 0; i < 10; i++)
+ {
+ ssn.messageTransfer("amq.direct", MessageAcceptMode.NONE, MessageAcquireMode.PRE_ACQUIRED,
+ new Header(new DeliveryProperties().setRoutingKey("queue1"),
+ new MessageProperties().setMessageId(UUID.randomUUID())),
+ Encoding.UTF8.GetBytes("test: " + i));
+ }
+ ssn.sync();
+ result = (QueueQueryResult) ssn.queueQuery("queue1").Result;
+ Assert.IsTrue(result.getMessageCount() == 10);
+ ssn.queuePurge("queue1");
+ ssn.sync();
+ result = (QueueQueryResult) ssn.queueQuery("queue1").Result;
+ Assert.IsTrue(result.getMessageCount() == 0);
+ }
+
+ [Test]
+ public void sendAndReceiveSmallMessages()
+ {
+ _log.debug("Running: sendAndReceiveSmallMessages");
+ byte[] smallMessage = Encoding.UTF8.GetBytes("test");
+ sendAndReceive(smallMessage, 100);
+ }
+
+ [Test]
+ public void sendAndReceiveLargeMessages()
+ {
+ _log.debug("Running: sendAndReceiveSmallMessages");
+ byte[] largeMessage = new byte[100 * 1024];
+ Random random = new Random();
+ random.NextBytes(largeMessage);
+ sendAndReceive(largeMessage, 10);
+ }
+
+ [Test]
+ public void sendAndReceiveVeryLargeMessages()
+ {
+ _log.debug("Running: sendAndReceiveSmallMessages");
+ byte[] verylargeMessage = new byte[1000 * 1024];
+ Random random = new Random();
+ random.NextBytes(verylargeMessage);
+ sendAndReceive(verylargeMessage, 2);
+ }
+
+ private void sendAndReceive(byte[] messageBody, int count)
+ {
+ ClientSession ssn = Client.createSession(0);
+ ssn.sync();
+ ssn.queueDeclare("queue1", null, null);
+ ssn.queueDelete("queue1");
+ QueueQueryResult result = (QueueQueryResult) ssn.queueQuery("queue1").Result;
+ Assert.IsNull(result.getQueue());
+ ssn.queueDeclare("queue1", null, null);
+ ssn.exchangeBind("queue1", "amq.direct", "queue1", null);
+ Object myLock = new Object();
+ MyListener myListener = new MyListener(myLock, count);
+ ssn.attachMessageListener(myListener, "myDest");
+
+ ssn.messageSubscribe("queue1", "myDest", MessageAcceptMode.EXPLICIT, MessageAcquireMode.PRE_ACQUIRED, null,
+ 0, null);
+
+
+ // issue credits
+ ssn.messageSetFlowMode("myDest", MessageFlowMode.WINDOW);
+ ssn.messageFlow("myDest", MessageCreditUnit.BYTE, ClientSession.MESSAGE_FLOW_MAX_BYTES);
+ ssn.messageFlow("myDest", MessageCreditUnit.MESSAGE, 10000);
+ ssn.sync();
+
+ for (int i = 0; i < count; i++)
+ {
+ ssn.messageTransfer("amq.direct", MessageAcceptMode.NONE, MessageAcquireMode.PRE_ACQUIRED,
+ new Header(new DeliveryProperties().setRoutingKey("queue1"),
+ new MessageProperties().setMessageId(UUID.randomUUID())),
+ messageBody);
+ }
+ ssn.sync();
+
+ lock (myLock)
+ {
+ if (myListener.Count != 0)
+ {
+ Monitor.Wait(myLock, 10000000);
+ }
+ }
+ Assert.IsTrue(myListener.Count == 0);
+ ssn.messageAccept(myListener.UnAck);
+ ssn.sync();
+ // the queue should be empty
+ result = (QueueQueryResult)ssn.queueQuery("queue1").Result;
+ Assert.IsTrue(result.getMessageCount() == 0);
+ ssn.close();
+ }
+
+
+
+ private class MyListener : IMessageListener
+ {
+ private static readonly Logger _log = Logger.get(typeof (MyListener));
+ private readonly Object _wl;
+ private int _count;
+ private RangeSet _rs = new RangeSet();
+
+ public MyListener(Object wl, int count)
+ {
+ _wl = wl;
+ _count = count;
+ }
+
+ public void messageTransfer(IMessage m)
+ {
+ byte[] body = new byte[m.Body.Length - m.Body.Position];
+ _log.debug("Got a message of size: " + body.Length + " count = " + _count);
+ _rs.add(m.Id);
+ lock (_wl)
+ {
+ _count--;
+ if (_count == 0)
+ {
+ Monitor.PulseAll(_wl);
+ }
+ }
+ }
+
+ public int Count
+ {
+ get { return _count; }
+ }
+
+ public RangeSet UnAck
+ {
+ get { return _rs; }
+ }
+ }
+ }
+}
diff --git a/RC9/qpid/dotnet/client-010/test/interop/TestCase.cs b/RC9/qpid/dotnet/client-010/test/interop/TestCase.cs
new file mode 100644
index 0000000000..8877de50cb
--- /dev/null
+++ b/RC9/qpid/dotnet/client-010/test/interop/TestCase.cs
@@ -0,0 +1,117 @@
+/*
+*
+* 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.Generic;
+using System.IO;
+using System.Threading;
+using System.Xml;
+using common.org.apache.qpid.transport.util;
+using log4net.Config;
+using NUnit.Framework;
+using org.apache.qpid.client;
+using org.apache.qpid.transport;
+using org.apache.qpid.transport.util;
+
+namespace test.interop
+{
+ [TestFixture]
+
+ public class TestCase
+ {
+ private readonly Dictionary<string,string> _properties = new Dictionary<string, string>();
+ private Client _client;
+
+ [TestFixtureSetUp]
+ public void Init()
+ {
+ XmlConfigurator.Configure(new FileInfo("/log.xml"));
+ // populate default properties
+ _properties.Add("UserName", "guest");
+ _properties.Add("Password", "guest");
+ _properties.Add("Host", "localhost");
+ _properties.Add("Port", "5672");
+ _properties.Add("VirtualHost", "test");
+ //Read the test config file
+ XmlTextReader reader = new XmlTextReader(Environment.CurrentDirectory + "/test.config");
+ while (reader.Read())
+ {
+ // if node type is an element
+ if (reader.NodeType == XmlNodeType.Element && reader.Name.Equals("add"))
+ {
+ if (_properties.ContainsKey(reader.GetAttribute("key")))
+ {
+ _properties[reader.GetAttribute("key")] = reader.GetAttribute("value");
+ }
+ else
+ {
+ _properties.Add(reader.GetAttribute("key"), reader.GetAttribute("value"));
+ }
+
+ }
+ }
+ // create a client and connect to the broker
+ _client = new Client();
+ _client.connect(Properties["Host"], Convert.ToInt16(Properties["Port"]), Properties["VirtualHost"],
+ Properties["UserName"], Properties["Password"]);
+
+ }
+
+ [TestFixtureTearDown]
+ public void Cleanup()
+ {
+ _client.close();
+ }
+
+ public Client Client
+ {
+ get{ return _client;}
+ }
+
+ public Dictionary<string,string> Properties
+ {
+ get { return _properties; }
+ }
+
+
+ public class SyncListener : IMessageListener
+ {
+ private static readonly Logger _log = Logger.get(typeof(SyncListener));
+ private readonly CircularBuffer<IMessage> _buffer;
+ private readonly RangeSet _range = new RangeSet();
+ private readonly ClientSession _session;
+
+ public SyncListener(ClientSession session, CircularBuffer<IMessage> buffer)
+ {
+ _buffer = buffer;
+ _session = session;
+ }
+
+ public void messageTransfer(IMessage m)
+ {
+ _range.clear();
+ _range.add(m.Id);
+ _session.messageAccept(_range);
+ _buffer.Enqueue(m);
+ }
+ }
+ }
+}
diff --git a/RC9/qpid/dotnet/client-010/test/test.config b/RC9/qpid/dotnet/client-010/test/test.config
new file mode 100644
index 0000000000..e62da47bb3
--- /dev/null
+++ b/RC9/qpid/dotnet/client-010/test/test.config
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!--
+
+ 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.
+
+-->
+
+<configuration>
+ <appSettings>
+ <add key="UserMame" value="guest"/>
+ <add key="Password" value="guest"/>
+ <add key="Host" value="192.168.1.14"/>
+ <add key="Port" value="5673"/>
+ <add key="VirtualHost" value="test"/>
+ </appSettings>
+</configuration>
diff --git a/RC9/qpid/dotnet/client-010/test/transport/util/ByteEncoderTest.cs b/RC9/qpid/dotnet/client-010/test/transport/util/ByteEncoderTest.cs
new file mode 100644
index 0000000000..383970ec79
--- /dev/null
+++ b/RC9/qpid/dotnet/client-010/test/transport/util/ByteEncoderTest.cs
@@ -0,0 +1,106 @@
+/*
+*
+* 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 NUnit.Framework;
+using org.apache.qpid.transport.util;
+
+
+namespace test.transport.util
+{
+ [TestFixture]
+
+ public class ByteEncoderTest
+ {
+ private static readonly Logger _log = Logger.get(typeof(ByteEncoderTest));
+
+ [Test]
+ public void GetBigEndianInt32()
+ {
+ _log.debug("Running: GetBigEndianInt32");
+ const int anInt = -12345;
+ Int32 aNewInt = ByteEncoder.GetBigEndian(anInt);
+ Assert.IsTrue( anInt == ByteEncoder.GetBigEndian(aNewInt) );
+ }
+
+ [Test]
+ public void GetBigEndianUInt16()
+ {
+ _log.debug("Running: GetBigEndianUInt16");
+ const UInt16 anInt = 123;
+ UInt16 aNewInt = ByteEncoder.GetBigEndian(anInt);
+ Assert.IsTrue(anInt == ByteEncoder.GetBigEndian(aNewInt));
+ }
+
+ [Test]
+ public void GetBigEndianUInt32()
+ {
+ _log.debug("Running: GetBigEndianUInt32");
+ const UInt32 anInt = 12345;
+ UInt32 aNewInt = ByteEncoder.GetBigEndian(anInt);
+ Assert.IsTrue(anInt == ByteEncoder.GetBigEndian(aNewInt));
+ }
+
+ [Test]
+ public void GetBigEndianlong()
+ {
+ _log.debug("Running: GetBigEndianlong");
+ const long anInt = 123456660700770;
+ long aNewInt = ByteEncoder.GetBigEndian(anInt);
+ Assert.IsTrue(anInt == ByteEncoder.GetBigEndian(aNewInt));
+ }
+
+ [Test]
+ public void GetLittleEndianInt32()
+ {
+ _log.debug("Running: GetBigEndianInt32");
+ const int anInt = -12345;
+ Int32 aNewInt = ByteEncoder.GetLittleEndian(anInt);
+ Assert.IsTrue(anInt == ByteEncoder.GetLittleEndian(aNewInt));
+ }
+
+ [Test]
+ public void GetLittleEndianUInt16()
+ {
+ _log.debug("Running: GetLittleEndianUInt16");
+ const UInt16 anInt = 123;
+ UInt16 aNewInt = ByteEncoder.GetLittleEndian(anInt);
+ Assert.IsTrue(anInt == ByteEncoder.GetLittleEndian(aNewInt));
+ }
+
+ [Test]
+ public void GetLittleEndianUInt32()
+ {
+ _log.debug("Running: GetLittleEndianUInt32");
+ const UInt32 anInt = 12345;
+ UInt32 aNewInt = ByteEncoder.GetLittleEndian(anInt);
+ Assert.IsTrue(anInt == ByteEncoder.GetLittleEndian(aNewInt));
+ }
+
+ [Test]
+ public void GetLittleEndianlong()
+ {
+ _log.debug("Running: GetLittleEndianlong");
+ const long anInt = 123456660700770;
+ long aNewInt = ByteEncoder.GetLittleEndian(anInt);
+ Assert.IsTrue(anInt == ByteEncoder.GetLittleEndian(aNewInt));
+ }
+ }
+}
diff --git a/RC9/qpid/dotnet/client-010/test/transport/util/CircularBufferTest.cs b/RC9/qpid/dotnet/client-010/test/transport/util/CircularBufferTest.cs
new file mode 100644
index 0000000000..03ac7831c1
--- /dev/null
+++ b/RC9/qpid/dotnet/client-010/test/transport/util/CircularBufferTest.cs
@@ -0,0 +1,89 @@
+/*
+*
+* 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 common.org.apache.qpid.transport.util;
+using NUnit.Framework;
+using org.apache.qpid.transport.util;
+
+namespace test.transport.util
+{
+ [TestFixture]
+
+ public class CircularBufferTest
+ {
+ private CircularBuffer<Object> _buf;
+ private static readonly Logger _log = Logger.get(typeof(CircularBufferTest));
+
+ [Test]
+ public void BlockingEnqueue()
+ {
+ _log.debug("Running: BlockingEnqueue");
+ const int size = 10;
+ _buf = new CircularBuffer<Object>(size);
+ // add size element anc check that the size +1 add blocks
+ for (int i = 1; i < size; i++ )
+ {
+ _buf.Enqueue(new object());
+ }
+ // check tha the buffer is now full
+ Thread t = new Thread(Go);
+ t.Start();
+ Thread.Sleep(100);
+ // the trhead t should block until an element is dequeued
+ Assert.IsTrue(t.ThreadState == ThreadState.WaitSleepJoin);
+ _buf.Dequeue();
+ // t should now be stopped
+ Thread.Sleep(100);
+ Assert.IsTrue(t.ThreadState == ThreadState.Stopped);
+ }
+
+ [Test]
+ public void Close()
+ {
+ _log.debug("Running: BlockingEnqueue");
+ const int size = 10;
+ _buf = new CircularBuffer<Object>(size);
+ // add size element anc check that the size +1 add blocks
+ for (int i = 1; i < size; i++)
+ {
+ _buf.Enqueue(new object());
+ }
+ // check tha the buffer is now full
+ Thread t = new Thread(Go);
+ t.Start();
+ Thread.Sleep(1000);
+ // the trhead t should block until the buffer is closed
+ Assert.IsTrue(t.ThreadState == ThreadState.WaitSleepJoin);
+ _buf.close();
+ Thread.Sleep(100);
+ // t should now be stopped
+ Assert.IsTrue(t.ThreadState == ThreadState.Stopped);
+ }
+
+ void Go()
+ {
+ _buf.Enqueue(new object());
+ }
+
+ }
+}
diff --git a/RC9/qpid/dotnet/client-010/test/transport/util/ResultFutureTest.cs b/RC9/qpid/dotnet/client-010/test/transport/util/ResultFutureTest.cs
new file mode 100644
index 0000000000..6b6397168f
--- /dev/null
+++ b/RC9/qpid/dotnet/client-010/test/transport/util/ResultFutureTest.cs
@@ -0,0 +1,103 @@
+/*
+*
+* 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.Generic;
+using System.Threading;
+using common.org.apache.qpid.transport.util;
+using NUnit.Framework;
+using org.apache.qpid.transport;
+using org.apache.qpid.transport.codec;
+using org.apache.qpid.transport.util;
+
+
+namespace test.transport.util
+{
+ [TestFixture]
+ public class ResultFutureTest
+ {
+ private static readonly Logger _log = Logger.get(typeof (ByteEncoderTest));
+ private static ResultFuture _future;
+
+ [Test]
+ public void getFutureTimeout()
+ {
+ _log.debug("Running: getFutureTimeout");
+ _future = new ResultFuture();
+ _future.Session = new Session(new byte[1]);
+ DateTime start = DateTime.Now;
+ Struct result = _future.get(1000);
+ Assert.IsTrue(DateTime.Now.Subtract(start).TotalMilliseconds >= 1000);
+ Assert.IsNull(result);
+ }
+
+ [Test]
+ public void getFuture()
+ {
+ _log.debug("Running: getFuture");
+ _future = new ResultFuture();
+ _future.Session = new Session(new byte[1]);
+ Thread t = new Thread(Go);
+ t.Start();
+ Struct result = _future.get(2000);
+ Assert.IsNotNull(result);
+ }
+
+
+ void Go()
+ {
+ Thread.Sleep(500);
+ _future.Result = new myStruct();
+ }
+ }
+
+ public class myStruct:Struct
+ {
+ public override int getStructType()
+ {
+ throw new System.NotImplementedException();
+ }
+
+ public override int getSizeWidth()
+ {
+ throw new System.NotImplementedException();
+ }
+
+ public override int getPackWidth()
+ {
+ throw new System.NotImplementedException();
+ }
+
+ public override void read(Decoder dec)
+ {
+ throw new System.NotImplementedException();
+ }
+
+ public override void write(Encoder enc)
+ {
+ throw new System.NotImplementedException();
+ }
+
+ public override Dictionary<string, object> Fields
+ {
+ get { throw new System.NotImplementedException(); }
+ }
+ }
+}
diff --git a/RC9/qpid/dotnet/client-010/test/transport/util/SerialTest.cs b/RC9/qpid/dotnet/client-010/test/transport/util/SerialTest.cs
new file mode 100644
index 0000000000..04a838c13b
--- /dev/null
+++ b/RC9/qpid/dotnet/client-010/test/transport/util/SerialTest.cs
@@ -0,0 +1,75 @@
+/*
+*
+* 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 NUnit.Framework;
+using org.apache.qpid.transport.util;
+
+namespace test.transport.util
+{
+ [TestFixture]
+ public class SerialTest
+ {
+ private static readonly Logger _log = Logger.get(typeof (SerialTest));
+
+ [Test]
+ ///
+ /// Test the key boundaries where wraparound occurs.
+ ///
+ public void testBoundaries()
+ {
+ Assert.IsTrue(Serial.gt(1, 0));
+ Assert.IsTrue(Serial.lt(0, 1));
+
+ Assert.IsTrue(Serial.gt(int.MaxValue, int.MaxValue - 1));
+ Assert.IsTrue(Serial.lt(int.MaxValue - 1, int.MaxValue));
+ }
+
+ ///
+ /// Test the first Corollary of RFC 1982
+ /// For any sequence number s and any integer n such that addition of n
+ /// to s is well defined, (s + n) >= s. Further (s + n) == s only when
+ /// n == 0, in all other defined cases, (s + n) > s.
+ ///
+ public void testCorollary1()
+ {
+ int wrapcount = 0;
+
+ int s = 0;
+
+ for (int i = 0; i < 67108664; i++)
+ {
+ for (int n = 1; n < 4096; n += 512)
+ {
+ Assert.IsTrue(Serial.gt(s + n, s));
+ Assert.IsTrue(Serial.lt(s, s + n));
+ }
+
+ s += 1024;
+
+ if (s == 0)
+ {
+ wrapcount += 1;
+ }
+ }
+
+ Assert.IsTrue(wrapcount > 0);
+ }
+ }
+}
diff --git a/RC9/qpid/dotnet/client-010/test/transport/util/UUIDTest.cs b/RC9/qpid/dotnet/client-010/test/transport/util/UUIDTest.cs
new file mode 100644
index 0000000000..c073f1139a
--- /dev/null
+++ b/RC9/qpid/dotnet/client-010/test/transport/util/UUIDTest.cs
@@ -0,0 +1,41 @@
+/*
+*
+* 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 NUnit.Framework;
+using org.apache.qpid.transport.util;
+
+namespace test.transport.util
+{
+ [TestFixture]
+
+ public class UUIDTest
+ {
+ [Test]
+ public void createUUID()
+ {
+ UUID uuid = UUID.randomUUID();
+ String uuidStr = uuid.ToString();
+ Assert.IsNotNull(uuid);
+ UUID uuid2 = UUID.randomUUID();
+ Assert.AreNotSame(uuid, uuid2);
+ }
+ }
+}