summaryrefslogtreecommitdiff
path: root/dotnet/client-010/test
diff options
context:
space:
mode:
authorArnaud Simon <arnaudsimon@apache.org>2008-10-02 12:34:45 +0000
committerArnaud Simon <arnaudsimon@apache.org>2008-10-02 12:34:45 +0000
commitc7629d17df713c0acd424c46d62f3ce46a1ba6ef (patch)
tree0e6d4dc2b46dba50d19a29346d1d4968a53ec895 /dotnet/client-010/test
parent656b95438af9400a08d0813bd9af4adea885fbf4 (diff)
downloadqpid-python-c7629d17df713c0acd424c46d62f3ce46a1ba6ef.tar.gz
qpid-1277: fixed header conversion issues + added test
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@701107 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'dotnet/client-010/test')
-rw-r--r--dotnet/client-010/test/Test.csproj1
-rw-r--r--dotnet/client-010/test/interop/ApplicationHeaders.cs83
-rw-r--r--dotnet/client-010/test/interop/TestCase.cs28
3 files changed, 111 insertions, 1 deletions
diff --git a/dotnet/client-010/test/Test.csproj b/dotnet/client-010/test/Test.csproj
index 841e2385a0..e46c9768cc 100644
--- a/dotnet/client-010/test/Test.csproj
+++ b/dotnet/client-010/test/Test.csproj
@@ -42,6 +42,7 @@
</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" />
diff --git a/dotnet/client-010/test/interop/ApplicationHeaders.cs b/dotnet/client-010/test/interop/ApplicationHeaders.cs
new file mode 100644
index 0000000000..9e27673a49
--- /dev/null
+++ b/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/dotnet/client-010/test/interop/TestCase.cs b/dotnet/client-010/test/interop/TestCase.cs
index 9f410a9e9e..16a5522726 100644
--- a/dotnet/client-010/test/interop/TestCase.cs
+++ b/dotnet/client-010/test/interop/TestCase.cs
@@ -22,10 +22,14 @@
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
{
@@ -85,7 +89,29 @@ namespace test.interop
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);
+ }
+ }
}
}