activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r380652 [2/2] - in /incubator/activemq/trunk/openwire-dotnet: src/OpenWire.Client/ src/OpenWire.Client/Commands/ src/OpenWire.Client/Core/ tests/OpenWire.Client/
Date Fri, 24 Feb 2006 12:02:53 GMT
Added: incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Core/PrimitiveMap.cs
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Core/PrimitiveMap.cs?rev=380652&view=auto
==============================================================================
--- incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Core/PrimitiveMap.cs (added)
+++ incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Core/PrimitiveMap.cs Fri
Feb 24 04:02:46 2006
@@ -0,0 +1,241 @@
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed 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;
+
+using OpenWire.Client;
+using OpenWire.Client.Core;
+
+namespace OpenWire.Client.Core
+{
+    /// <summary>
+    /// A default implementation of IPrimitiveMap
+    /// </summary>
+    public class PrimitiveMap : IPrimitiveMap
+    {
+        private IDictionary dictionary = new Hashtable();
+        
+        
+        /// <summary>
+        /// Unmarshalls the map from the given data or if the data is null just
+        /// return an empty map
+        /// </summary>
+        public static PrimitiveMap Unmarshal(byte[] data)
+        {
+            PrimitiveMap answer = new PrimitiveMap();
+            answer.dictionary = DataStreamMarshaller.UnmarshalPrimitiveMap(data);
+            return answer;
+        }
+        
+        public byte[] Marshal()
+        {
+            return DataStreamMarshaller.MarshalPrimitiveMap(dictionary);
+        }
+        
+        
+        public void Clear()
+        {
+            dictionary.Clear();
+        }
+        
+        public bool Contains(Object key)
+        {
+            return dictionary.Contains(key);
+        }
+        
+        public void Remove(Object key)
+        {
+            dictionary.Remove(key);
+        }
+        
+        
+        public int Count
+        {
+            get {
+                return dictionary.Count;
+            }
+        }
+        
+        public ICollection Keys
+        {
+            get {
+                return dictionary.Keys;
+            }
+        }
+        
+        public ICollection Values
+        {
+            get {
+                return dictionary.Values;
+            }
+        }
+        
+        public object this[string key]
+        {
+            get {
+                return GetValue(key);
+            }
+            set {
+                CheckValidType(value);
+                SetValue(key, value);
+            }
+        }
+        
+        public string GetString(string key)
+        {
+            Object value = GetValue(key);
+            CheckValueType(value, typeof(string));
+            return (string) value;
+        }
+        
+        public void SetString(string key, string value)
+        {
+            SetValue(key, value);
+        }
+        
+        public bool GetBool(String key)
+        {
+            Object value = GetValue(key);
+            CheckValueType(value, typeof(bool));
+            return (bool) value;
+        }
+        
+        public void SetByte(String key, bool value)
+        {
+            SetValue(key, value);
+        }
+        
+        public byte GetByte(String key)
+        {
+            Object value = GetValue(key);
+            CheckValueType(value, typeof(byte));
+            return (byte) value;
+        }
+        
+        public void SetByte(String key, byte value)
+        {
+            SetValue(key, value);
+        }
+        
+        public char GetChar(String key)
+        {
+            Object value = GetValue(key);
+            CheckValueType(value, typeof(char));
+            return (char) value;
+        }
+        
+        public void SetChar(String key, char value)
+        {
+            SetValue(key, value);
+        }
+        
+        public short GetShort(String key)
+        {
+            Object value = GetValue(key);
+            CheckValueType(value, typeof(short));
+            return (short) value;
+        }
+        
+        public void SetShort(String key, short value)
+        {
+            SetValue(key, value);
+        }
+        
+        public int GetInt(String key)
+        {
+            Object value = GetValue(key);
+            CheckValueType(value, typeof(int));
+            return (int) value;
+        }
+        
+        public void SetInt(String key, int value)
+        {
+            SetValue(key, value);
+        }
+        
+        public long GetLong(String key)
+        {
+            Object value = GetValue(key);
+            CheckValueType(value, typeof(long));
+            return (long) value;
+        }
+        
+        public void SetLong(String key, long value)
+        {
+            SetValue(key, value);
+        }
+        
+        public float GetFloat(String key)
+        {
+            Object value = GetValue(key);
+            CheckValueType(value, typeof(float));
+            return (float) value;
+        }
+        
+        public void SetFloat(String key, float value)
+        {
+            SetValue(key, value);
+        }
+        
+        public double GetDouble(String key)
+        {
+            Object value = GetValue(key);
+            CheckValueType(value, typeof(double));
+            return (double) value;
+        }
+        
+        public void SetDouble(String key, double value)
+        {
+            SetValue(key, value);
+        }
+        
+        
+        
+        
+        protected virtual void SetValue(String key, Object value)
+        {
+            dictionary[key] = value;
+        }
+        
+        
+        protected virtual Object GetValue(String key)
+        {
+            return dictionary[key];
+        }
+        
+        protected virtual void CheckValueType(Object value, Type type)
+        {
+            if (! type.IsInstanceOfType(value))
+            {
+                throw new OpenWireException("Expected type: " + type.Name + " but was: "
+ value);
+            }
+        }
+        
+        protected virtual void CheckValidType(Object value)
+        {
+            if (value != null)
+            {
+                Type type = value.GetType();
+                if (! type.IsPrimitive && !type.IsValueType && !type.IsAssignableFrom(typeof(string)))
+                {
+                    throw new OpenWireException("Invalid type: " + type.Name + " for value:
" + value);
+                }
+            }
+        }
+        
+    }
+}

Added: incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/IBytesMessage.cs
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/IBytesMessage.cs?rev=380652&view=auto
==============================================================================
--- incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/IBytesMessage.cs (added)
+++ incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/IBytesMessage.cs Fri Feb
24 04:02:46 2006
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed 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 OpenWire.Client.Commands;
+
+namespace OpenWire.Client
+{
+    /// <summary>
+    /// Represents a binary based message
+    /// </summary>
+    public interface IBytesMessage : IMessage
+    {
+        
+        byte[] Content
+        {
+            get;
+            set;
+        }
+    }
+}

Modified: incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/IConnection.cs
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/IConnection.cs?rev=380652&r1=380651&r2=380652&view=diff
==============================================================================
--- incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/IConnection.cs (original)
+++ incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/IConnection.cs Fri Feb 24
04:02:46 2006
@@ -20,14 +20,14 @@
 namespace OpenWire.Client {
 
         public enum AcknowledgementMode {
-                Unknown, AutoAcknowledge, ClientAcknowledge, Transactional 
+                Unknown, AutoAcknowledge, ClientAcknowledge, Transactional
         }
 
 
         /// <summary>
         /// Represents a connection with a message broker
         /// </summary>
-        public interface IConnection : IDisposable, IStartable, IStopable {
+        public interface IConnection : IDisposable, IStartable {
 
                 /// <summary>
                 /// Creates a new session to work on this connection
@@ -44,20 +44,20 @@
 
                 bool Transacted {
                         get;
-                        set; 
+                        set;
                 }
 
                 AcknowledgementMode AcknowledgementMode {
                         get;
-                        set; 
+                        set;
                 }
 
-				String ClientId
-				{
-					get;
-					set; 
-				}
+                String ClientId
+                {
+                    get;
+                    set;
+                }
  
-				
-		}
+                
+        }
 }

Added: incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/IMapMessage.cs
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/IMapMessage.cs?rev=380652&view=auto
==============================================================================
--- incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/IMapMessage.cs (added)
+++ incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/IMapMessage.cs Fri Feb 24
04:02:46 2006
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed 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 OpenWire.Client.Commands;
+
+namespace OpenWire.Client
+{
+    /// <summary>
+    /// Represents a Map message which contains key and value pairs which are
+    /// of primitive types
+    /// </summary>
+    public interface IMapMessage : IMessage
+    {
+        IPrimitiveMap Body {
+            get;
+        }
+    }
+}
+

Modified: incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/IMessage.cs
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/IMessage.cs?rev=380652&r1=380651&r2=380652&view=diff
==============================================================================
--- incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/IMessage.cs (original)
+++ incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/IMessage.cs Fri Feb 24 04:02:46
2006
@@ -17,16 +17,145 @@
 using System;
 using OpenWire.Client.Commands;
 
-namespace OpenWire.Client {
+namespace OpenWire.Client
+{
     /// <summary>
     /// Represents a message either to be sent to a message broker or received from a message
broker
     /// </summary>
-    public interface IMessage {
-
-        IDestination FromDestination {
-                get;
-        }
- 
-
-    } 
+    public interface IMessage
+    {
+        
+        /// <summary>
+        /// Provides access to the message properties (headers)
+        /// </summary>
+        IPrimitiveMap Properties {
+            get;
+        }
+        
+        /// <summary>
+        /// The correlation ID used to correlate messages from conversations or long running
business processes
+        /// </summary>
+        string JMSCorrelationID
+        {
+            get;
+            set;
+        }
+        
+        /// <summary>
+        /// The destination of the message
+        /// </summary>
+        IDestination JMSDestination
+        {
+            get;
+        }
+        
+        /// <summary>
+        /// The time in milliseconds that this message should expire in
+        /// </summary>
+        long JMSExpiration
+        {
+            get;
+            set;
+        }
+        
+        /// <summary>
+        /// The message ID which is set by the provider
+        /// </summary>
+        string JMSMessageId
+        {
+            get;
+        }
+        
+        /// <summary>
+        /// Whether or not this message is persistent
+        /// </summary>
+        bool JMSPersistent
+        {
+            get;
+            set;
+        }
+        
+        /// <summary>
+        /// The Priority on this message
+        /// </summary>
+        byte JMSPriority
+        {
+            get;
+            set;
+        }
+        
+        /// <summary>
+        /// Returns true if this message has been redelivered to this or another consumer
before being acknowledged successfully.
+        /// </summary>
+        bool JMSRedelivered
+        {
+            get;
+        }
+        
+        
+        /// <summary>
+        /// The destination that the consumer of this message should send replies to
+        /// </summary>
+        IDestination JMSReplyTo
+        {
+            get;
+            set;
+        }
+        
+        
+        /// <summary>
+        /// The timestamp the broker added to the message
+        /// </summary>
+        long JMSTimestamp
+        {
+            get;
+        }
+        
+        /// <summary>
+        /// The type name of this message
+        /// </summary>
+        string JMSType
+        {
+            get;
+            set;
+        }
+        
+        
+        // JMS Extension headers
+        
+        /// <summary>
+        /// Returns the number of times this message has been redelivered to other consumers
without being acknowledged successfully.
+        /// </summary>
+        int JMSXDeliveryCount
+        {
+            get;
+        }
+        
+        
+        /// <summary>
+        /// The Message Group ID used to group messages together to the same consumer for
the same group ID value
+        /// </summary>
+        string JMSXGroupID
+        {
+            get;
+            set;
+        }
+        /// <summary>
+        /// The Message Group Sequence counter to indicate the position in a group
+        /// </summary>
+        int JMSXGroupSeq
+        {
+            get;
+            set;
+        }
+        
+        /// <summary>
+        /// Returns the ID of the producers transaction
+        /// </summary>
+        string JMSXProducerTXID
+        {
+            get;
+        }
+        
+    }
 }

Added: incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/IPrimitiveMap.cs
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/IPrimitiveMap.cs?rev=380652&view=auto
==============================================================================
--- incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/IPrimitiveMap.cs (added)
+++ incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/IPrimitiveMap.cs Fri Feb
24 04:02:46 2006
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed 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;
+
+using OpenWire.Client.Commands;
+
+namespace OpenWire.Client
+{
+    /// <summary>
+    /// Represents a Map of primitive types where the keys are all string instances
+    /// and the values are strings or numbers.
+    /// </summary>
+    public interface IPrimitiveMap
+    {
+        
+        void Clear();
+        
+        bool Contains(object key);
+        
+        void Remove(object key);
+        
+        int Count
+        {
+            get;
+        }
+        
+        ICollection Keys
+        {
+            get;
+        }
+        
+        ICollection Values
+        {
+            get;
+        }
+        
+        object this[string key]
+        {
+            get;
+            set;
+        }
+        
+        string GetString(string key);
+        void SetString(string key, string value);
+        
+        bool GetBool(string key);
+        void SetByte(string key, bool value);
+        
+        byte GetByte(string key);
+        void SetByte(string key, byte value);
+        
+        char GetChar(string key);
+        void SetChar(string key, char value);
+        
+        short GetShort(string key);
+        void SetShort(string key, short value);
+        
+        int GetInt(string key);
+        void SetInt(string key, int value);
+        
+        long GetLong(string key);
+        void SetLong(string key, long value);
+        
+        float GetFloat(string key);
+        void SetFloat(string key, float value);
+        
+        double GetDouble(string key);
+        void SetDouble(string key, double value);
+        
+    }
+}

Modified: incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/ISession.cs
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/ISession.cs?rev=380652&r1=380651&r2=380652&view=diff
==============================================================================
--- incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/ISession.cs (original)
+++ incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/ISession.cs Fri Feb 24 04:02:46
2006
@@ -17,34 +17,39 @@
 using System;
 using OpenWire.Client.Commands;
 
-namespace OpenWire.Client {
+namespace OpenWire.Client
+{
     /// <summary>
     /// Represents a single unit of work on an IConnection.
     /// So the ISession can be used to perform transactional receive and sends
     /// </summary>
-    public interface ISession : IDisposable {
-
+    public interface ISession : IDisposable
+    {
+        
+        
+        
+        
         /// <summary>
         /// Creates a producer of messages
         /// </summary>
         IMessageProducer CreateProducer();
-
+        
         /// <summary>
         /// Creates a producer of messages on a given destination
         /// </summary>
-        IMessageProducer CreateProducer(IDestination destination); 
-
+        IMessageProducer CreateProducer(IDestination destination);
+        
         /// <summary>
         /// Creates a consumer of messages on a given destination
         /// </summary>
-        IMessageConsumer CreateConsumer(IDestination destination); 
-
+        IMessageConsumer CreateConsumer(IDestination destination);
+        
         /// <summary>
         /// Creates a consumer of messages on a given destination with a selector
         /// </summary>
         IMessageConsumer CreateConsumer(IDestination destination, string selector);
-
-		/// <summary>
+        
+        /// <summary>
 		/// Creates a named durable consumer of messages on a given destination with a selector
 		/// </summary>
 		IMessageConsumer CreateDurableConsumer(ITopic destination, string name, string selector,
bool noLocal);
@@ -52,26 +57,56 @@
         /// <summary>
         /// Returns the queue for the given name
         /// </summary>
-        IQueue GetQueue(string name); 
+        IQueue GetQueue(string name);
         
         /// <summary>
         /// Returns the topic for the given name
         /// </summary>
-        ITopic GetTopic(string name); 
+        ITopic GetTopic(string name);
+        
+        
+        /// <summary>
+        /// Creates a temporary queue
+        /// </summary>
+        ITemporaryQueue CreateTemporaryQueue();
 
         /// <summary>
+        /// Creates a temporary topic
+        /// </summary>
+        ITemporaryTopic CreateTemporaryTopic();
+
+        
+        // Factory methods to create messages
+        
+        /// <summary>
         /// Creates a new message with an empty body
         /// </summary>
         IMessage CreateMessage();
-
+        
         /// <summary>
         /// Creates a new text message with an empty body
         /// </summary>
         ITextMessage CreateTextMessage();
-
+        
         /// <summary>
         /// Creates a new text message with the given body
         /// </summary>
         ITextMessage CreateTextMessage(string text);
-    } 
+        
+        /// <summary>
+        /// Creates a new Map message which contains primitive key and value pairs
+        /// </summary>
+        IMapMessage CreateMapMessage();
+        
+        /// <summary>
+        /// Creates a new binary message
+        /// </summary>
+        IBytesMessage CreateBytesMessage();
+        
+        /// <summary>
+        /// Creates a new binary message with the given body
+        /// </summary>
+        IBytesMessage CreateBytesMessage(byte[] body);
+        
+    }
 }

Modified: incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/ITextMessage.cs
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/ITextMessage.cs?rev=380652&r1=380651&r2=380652&view=diff
==============================================================================
--- incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/ITextMessage.cs (original)
+++ incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/ITextMessage.cs Fri Feb 24
04:02:46 2006
@@ -17,15 +17,18 @@
 using System;
 using OpenWire.Client.Commands;
 
-namespace OpenWire.Client {
-        /// <summary>
-        /// Represents a text based message
-        /// </summary>
-        public interface ITextMessage : IMessage {
-
-                string Text {
-                        get;
-                        set; 
-                } 
-        } 
+namespace OpenWire.Client
+{
+    /// <summary>
+    /// Represents a text based message
+    /// </summary>
+    public interface ITextMessage : IMessage
+    {
+        
+        string Text
+        {
+            get;
+            set;
+        }
+    }
 }

Modified: incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/MessageConsumer.cs
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/MessageConsumer.cs?rev=380652&r1=380651&r2=380652&view=diff
==============================================================================
--- incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/MessageConsumer.cs (original)
+++ incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/MessageConsumer.cs Fri Feb
24 04:02:46 2006
@@ -18,6 +18,7 @@
 using System.Collections;
 using System.Threading;
 using OpenWire.Client.Commands;
+using OpenWire.Client.Core;
 
 namespace OpenWire.Client
 {

Modified: incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/MessageProducer.cs
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/MessageProducer.cs?rev=380652&r1=380651&r2=380652&view=diff
==============================================================================
--- incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/MessageProducer.cs (original)
+++ incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/MessageProducer.cs Fri Feb
24 04:02:46 2006
@@ -28,13 +28,13 @@
         private Session session;
         private ProducerInfo info;
         private long messageCounter;
-
+        
 		bool persistent;
 		long timeToLive;
 		int priority;
 		bool disableMessageID;
 		bool disableMessageTimestamp;
-
+        
         public MessageProducer(Session session, ProducerInfo info)
         {
             this.session = session;
@@ -57,7 +57,7 @@
             ActiveMQMessage activeMessage = (ActiveMQMessage) message;
             activeMessage.MessageId = id;
             activeMessage.ProducerId = info.ProducerId;
-            activeMessage.Destination = (ActiveMQDestination) destination;
+            activeMessage.Destination = ActiveMQDestination.Transform(destination);
             
             session.DoSend(destination, message);
         }
@@ -71,14 +71,13 @@
 		{
 			get { return persistent; }
 			set { this.persistent = value; }
-		}
+    }
 
 		public long TimeToLive
 		{
 			get { return timeToLive; }
 			set { this.timeToLive = value; }
-		}
-
+}
 		public int Priority
 		{
 			get { return priority; }

Modified: incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Session.cs
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Session.cs?rev=380652&r1=380651&r2=380652&view=diff
==============================================================================
--- incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Session.cs (original)
+++ incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Session.cs Fri Feb 24 04:02:46
2006
@@ -124,6 +124,18 @@
             return new ActiveMQTopic(name);
         }
         
+        public ITemporaryQueue CreateTemporaryQueue()
+        {
+            return new ActiveMQTempQueue(connection.CreateTemporaryDestinationName());
+        }
+        
+        public ITemporaryTopic CreateTemporaryTopic()
+        {
+            return new ActiveMQTempTopic(connection.CreateTemporaryDestinationName());
+        }
+        
+        
+        
         public IMessage CreateMessage()
         {
             ActiveMQMessage answer = new ActiveMQMessage();
@@ -146,6 +158,26 @@
             return answer;
         }
         
+        public IMapMessage CreateMapMessage()
+        {
+            return new ActiveMQMapMessage();
+        }
+        
+        public IBytesMessage CreateBytesMessage()
+        {
+            return new ActiveMQBytesMessage();
+        }
+        
+        public IBytesMessage CreateBytesMessage(byte[] body)
+        {
+            ActiveMQBytesMessage answer = new ActiveMQBytesMessage();
+            answer.Content = body;
+            return answer;
+        }
+        
+        
+        
+        
         // Implementation methods
         public void DoSend(IDestination destination, IMessage message)
         {
@@ -181,7 +213,7 @@
                 id.Value = ++consumerCounter;
             }
             answer.ConsumerId = id;
-            answer.Destination = (ActiveMQDestination) destination;
+            answer.Destination = ActiveMQDestination.Transform(destination);
             answer.Selector = selector;
             answer.PrefetchSize = prefetchSize;
             
@@ -200,7 +232,7 @@
                 id.Value = ++producerCounter;
             }
             answer.ProducerId = id;
-            answer.Destination = (ActiveMQDestination) destination;
+            answer.Destination = ActiveMQDestination.Transform(destination);
             return answer;
         }
         

Added: incubator/activemq/trunk/openwire-dotnet/tests/OpenWire.Client/BytesMessageTest.cs
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-dotnet/tests/OpenWire.Client/BytesMessageTest.cs?rev=380652&view=auto
==============================================================================
--- incubator/activemq/trunk/openwire-dotnet/tests/OpenWire.Client/BytesMessageTest.cs (added)
+++ incubator/activemq/trunk/openwire-dotnet/tests/OpenWire.Client/BytesMessageTest.cs Fri
Feb 24 04:02:46 2006
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed 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 NUnit.Framework;
+
+using OpenWire.Client;
+using OpenWire.Client.Core;
+
+namespace OpenWire.Client
+{
+    [ TestFixture ]
+    public class BytesMessageTest : TestSupport
+    {
+        byte[] expected = {1, 2, 3, 4, 5, 6, 7, 8};
+    
+        [ Test ]
+        public override void SendAndSyncReceive()
+        {
+            base.SendAndSyncReceive();
+        }
+        
+        protected override IMessage CreateMessage(ISession session)
+        {
+            IBytesMessage request = session.CreateBytesMessage(expected);
+            return request;
+        }
+        
+        protected override void AssertValidMessage(IMessage message)
+        {
+            Assert.IsTrue(message is IBytesMessage, "Did not receive a IBytesMessage: " +
message);
+            
+            Console.WriteLine("Received IBytesMessage: " + message);
+            
+            IBytesMessage bytesMessage = (IBytesMessage) message;
+            byte[] actual = bytesMessage.Content;
+            Console.WriteLine("Received message with content: " + actual);
+            Assert.AreEqual(expected, actual, "the message content");
+        }
+        
+    }
+}
+

Modified: incubator/activemq/trunk/openwire-dotnet/tests/OpenWire.Client/ClientTest.cs
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-dotnet/tests/OpenWire.Client/ClientTest.cs?rev=380652&r1=380651&r2=380652&view=diff
==============================================================================
--- incubator/activemq/trunk/openwire-dotnet/tests/OpenWire.Client/ClientTest.cs (original)
+++ incubator/activemq/trunk/openwire-dotnet/tests/OpenWire.Client/ClientTest.cs Fri Feb 24
04:02:46 2006
@@ -27,46 +27,28 @@
     [ TestFixture ]
     public class ClientTest : TestSupport
     {
+        string expected = "Hello World!";
+        
         [ Test ]
-        public void SendAndSyncReceive()
+        public override void SendAndSyncReceive()
         {
-            IConnectionFactory factory = new ConnectionFactory("localhost", 61616);
-            
-            Assert.IsTrue(factory != null, "no factory created");
-            
-            using (IConnection connection = factory.CreateConnection())
-            {
-                try
-                {
-                    Assert.IsTrue(connection != null, "no connection created");
-                    Console.WriteLine("Connected to ActiveMQ!");
-                    
-                    ISession session = connection.CreateSession();
-                    
-                    IDestination destination = session.GetQueue("FOO.BAR");
-                    Assert.IsTrue(destination != null, "No queue available!");
-                    
-                    IMessageConsumer consumer = session.CreateConsumer(destination);
-                    
-                    IMessageProducer producer = session.CreateProducer(destination);
-                    
-                    string expected = "Hello World!";
-                    ITextMessage request = session.CreateTextMessage(expected);
-                    
-                    producer.Send(request);
-                    
-                    ITextMessage message = (ITextMessage) consumer.Receive();
-                    
-                    Assert.IsNotNull(message, "No message returned!");
-                    
-                    Assert.AreEqual(expected, message.Text, "the message text");
-                }
-                catch (Exception e)
-                {
-                    Console.WriteLine("Caught: " + e);
-                }
-            }
+            base.SendAndSyncReceive();
         }
+        
+        protected override IMessage CreateMessage(ISession session)
+        {
+            IMessage request = session.CreateTextMessage(expected);
+            return request;
+        }
+        
+        protected override void AssertValidMessage(IMessage message)
+        {
+            ITextMessage textMessage = (ITextMessage) message;
+            String text = textMessage.Text;
+            Console.WriteLine("Received message with text: " + text);
+            Assert.AreEqual(expected, text, "the message text");
+        }
+        
     }
 }
 

Added: incubator/activemq/trunk/openwire-dotnet/tests/OpenWire.Client/JMSPropertyTest.cs
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-dotnet/tests/OpenWire.Client/JMSPropertyTest.cs?rev=380652&view=auto
==============================================================================
--- incubator/activemq/trunk/openwire-dotnet/tests/OpenWire.Client/JMSPropertyTest.cs (added)
+++ incubator/activemq/trunk/openwire-dotnet/tests/OpenWire.Client/JMSPropertyTest.cs Fri
Feb 24 04:02:46 2006
@@ -0,0 +1,127 @@
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed 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 NUnit.Framework;
+
+using OpenWire.Client;
+using OpenWire.Client.Core;
+
+namespace OpenWire.Client
+{
+    [ TestFixture ]
+    public class JMSPropertyTest : TestSupport
+    {
+        // standard JMS properties
+        string expectedText = "Hey this works!";
+        string correlationID = "abc";
+        ITemporaryQueue replyTo;
+        bool persistent = true;
+        byte priority = 5;
+        String type = "FooType";
+        String groupID = "MyGroup";
+        int groupSeq = 1;
+        
+        // custom properties
+        string customText = "Cheese";
+        bool custom1 = true;
+        byte custom2 = 12;
+        short custom3 = 0x1234;
+        int custom4 = 0x12345678;
+        long custom5 = 0x1234567812345678;
+        char custom6 = 'J';
+        
+        [ Test ]
+        public override void SendAndSyncReceive()
+        {
+            base.SendAndSyncReceive();
+        }
+        
+        protected override IMessage CreateMessage(ISession session)
+        {
+            ITextMessage message = session.CreateTextMessage(expectedText);
+            replyTo = session.CreateTemporaryQueue();
+            
+            // lets set the headers
+            message.JMSCorrelationID = correlationID;
+            message.JMSReplyTo = replyTo;
+            message.JMSPersistent = persistent;
+            message.JMSPriority = priority;
+            message.JMSType = type;
+            message.JMSXGroupID = groupID;
+            message.JMSXGroupSeq = groupSeq;
+            
+            // lets set the custom headers
+            message.Properties["customText"] = customText;
+            message.Properties["custom1"] = custom1;
+            message.Properties["custom2"] = custom2;
+            message.Properties["custom3"] = custom3;
+            message.Properties["custom4"] = custom4;
+            message.Properties["custom5"] = custom5;
+            message.Properties["custom6"] = custom6;
+            
+            return message;
+        }
+        
+        protected override void AssertValidMessage(IMessage message)
+        {
+            Assert.IsTrue(message is ITextMessage, "Did not receive a ITextMessage!");
+            
+            Console.WriteLine("Received Message: " + message);
+            
+            ITextMessage textMessage = (ITextMessage) message;
+            String text = textMessage.Text;
+            Assert.AreEqual(expectedText, text, "the message text");
+            
+            // compare standard JMS headers
+            Assert.AreEqual(correlationID, message.JMSCorrelationID, "JMSCorrelationID");
+            Assert.AreEqual(replyTo, message.JMSReplyTo, "JMSReplyTo");
+            Assert.AreEqual(persistent, message.JMSPersistent, "JMSPersistent");
+            Assert.AreEqual(priority, message.JMSPriority, "JMSPriority");
+            Assert.AreEqual(type, message.JMSType, "JMSType");
+            Assert.AreEqual(groupID, message.JMSXGroupID, "JMSXGroupID");
+            Assert.AreEqual(groupSeq, message.JMSXGroupSeq, "JMSXGroupSeq");
+            
+            // compare custom headers
+            Assert.AreEqual(customText, message.Properties["customText"], "customText");
+            Assert.AreEqual(custom1, message.Properties["custom1"], "custom1");
+            Assert.AreEqual(custom2, message.Properties["custom2"], "custom2");
+            Assert.AreEqual(custom3, message.Properties["custom3"], "custom3");
+            Assert.AreEqual(custom4, message.Properties["custom4"], "custom4");
+            // TODO
+            //Assert.AreEqual(custom5, message.Properties["custom5"], "custom5");
+            Assert.AreEqual(custom4, message.Properties["custom6"], "custom6");
+            
+            Assert.AreEqual(custom1, message.Properties.GetBool("custom1"), "custom1");
+            Assert.AreEqual(custom2, message.Properties.GetByte("custom2"), "custom2");
+            Assert.AreEqual(custom3, message.Properties.GetShort("custom3"), "custom3");
+            Assert.AreEqual(custom4, message.Properties.GetInt("custom4"), "custom4");
+            //Assert.AreEqual(custom5, message.Properties.GetLong("custom5"), "custom5");
+            Assert.AreEqual(custom4, message.Properties.GetChar("custom6"), "custom6");
+            
+            // lets now look at some standard JMS headers
+            Console.WriteLine("JMSExpiration: " + message.JMSExpiration);
+            Console.WriteLine("JMSMessageId: " + message.JMSMessageId);
+            Console.WriteLine("JMSRedelivered: " + message.JMSRedelivered);
+            Console.WriteLine("JMSTimestamp: " + message.JMSTimestamp);
+            Console.WriteLine("JMSXDeliveryCount: " + message.JMSXDeliveryCount);
+            Console.WriteLine("JMSXProducerTXID: " + message.JMSXProducerTXID);
+        }
+    }
+}
+

Added: incubator/activemq/trunk/openwire-dotnet/tests/OpenWire.Client/MapMessageTest.cs
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-dotnet/tests/OpenWire.Client/MapMessageTest.cs?rev=380652&view=auto
==============================================================================
--- incubator/activemq/trunk/openwire-dotnet/tests/OpenWire.Client/MapMessageTest.cs (added)
+++ incubator/activemq/trunk/openwire-dotnet/tests/OpenWire.Client/MapMessageTest.cs Fri Feb
24 04:02:46 2006
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed 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 NUnit.Framework;
+
+using OpenWire.Client;
+using OpenWire.Client.Core;
+
+namespace OpenWire.Client
+{
+    [ TestFixture ]
+    public class MapMessageTest : TestSupport
+    {
+        bool a = true;
+        byte b = 123;
+        char c = 'c';
+        short d = 0x1234;
+        int e = 0x12345678;
+        long f = 0x1234567812345678;
+        string g = "Hello World!";
+        
+        [ Test ]
+        public override void SendAndSyncReceive()
+        {
+            base.SendAndSyncReceive();
+        }
+        
+        protected override IMessage CreateMessage(ISession session)
+        {
+            IMapMessage request = session.CreateMapMessage();
+            return request;
+        }
+        
+        protected override void AssertValidMessage(IMessage message)
+        {
+            Assert.IsTrue(message is IMapMessage, "Did not receive a MapMessage!");
+            
+            Console.WriteLine("Received MapMessage: " + message);
+
+            IMapMessage mapMessage = (IMapMessage) message;
+            
+            /*
+            String text = mapMessage.Text;
+            Assert.AreEqual(expected, text, "the message text");
+             */
+        }
+        
+    }
+}

Modified: incubator/activemq/trunk/openwire-dotnet/tests/OpenWire.Client/TestSupport.cs
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-dotnet/tests/OpenWire.Client/TestSupport.cs?rev=380652&r1=380651&r2=380652&view=diff
==============================================================================
--- incubator/activemq/trunk/openwire-dotnet/tests/OpenWire.Client/TestSupport.cs (original)
+++ incubator/activemq/trunk/openwire-dotnet/tests/OpenWire.Client/TestSupport.cs Fri Feb
24 04:02:46 2006
@@ -17,13 +17,72 @@
 using System;
 using System.IO;
 
+using NUnit.Framework;
+
 using OpenWire.Client;
+using OpenWire.Client.Core;
+
 
-namespace OpenWire.Client {
+namespace OpenWire.Client
+{
+    
+    /// <summary>
+    /// useful base class for test cases
+    /// </summary>
+    [ TestFixture ]
+    public abstract class TestSupport
+    {
+        
+        [ Test ]
+        public virtual void SendAndSyncReceive()
+        {
+            IConnectionFactory factory = new ConnectionFactory("localhost", 61616);
+            
+            Assert.IsTrue(factory != null, "no factory created");
+            
+            using (IConnection connection = factory.CreateConnection())
+            {
+                try
+                {
+                    Assert.IsTrue(connection != null, "no connection created");
+                    Console.WriteLine("Connected to ActiveMQ!");
+                    
+                    ISession session = connection.CreateSession();
+                    
+                    IDestination destination = CreateDestination(session);
+                    Assert.IsTrue(destination != null, "No queue available!");
+                    
+                    IMessageConsumer consumer = session.CreateConsumer(destination);
+                    
+                    IMessageProducer producer = session.CreateProducer(destination);
+                    
+                    IMessage request = CreateMessage(session);
+                    
+                    producer.Send(request);
+                    
+                    IMessage message = consumer.Receive();
+                    Assert.IsNotNull(message, "No message returned!");
+                    
+                    AssertValidMessage(message);
+                }
+                catch (Exception e)
+                {
+                    Console.WriteLine("Caught: " + e);
+                }
+            }
+        }
 
-        /// <summary>
-        /// useful base class for test cases
-        /// </summary>
-        public abstract class TestSupport {
-        } 
+        protected virtual IDestination CreateDestination(ISession session)
+        {
+            string name = "Test.DotNet." + GetType().Name;
+            IDestination destination = session.GetQueue(name);
+            
+            Console.WriteLine("Using queue: " + destination);
+            return destination;
+        }
+        
+        protected abstract IMessage CreateMessage(ISession session);
+        
+        protected abstract  void AssertValidMessage(IMessage message);
+    }
 }



Mime
View raw message