mirror of https://github.com/apache/activemq.git
- Enhanced the NMS test support class so that it creates the connection lazily.
- You can now get a DestinationType from a destination in case you want to know what type of destination you are working with. git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@386712 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9224eeb0a2
commit
8b3fb9b928
|
@ -517,6 +517,13 @@ namespace ActiveMQ.Commands
|
|||
* @return the created Destination
|
||||
*/
|
||||
public abstract ActiveMQDestination CreateDestination(String name);
|
||||
|
||||
|
||||
public abstract DestinationType DestinationType
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,58 +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 NMS;
|
||||
using System;
|
||||
|
||||
namespace ActiveMQ.Commands
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Summary description for ActiveMQQueue.
|
||||
/// </summary>
|
||||
public class ActiveMQQueue : ActiveMQDestination, IQueue
|
||||
{
|
||||
public const byte ID_ActiveMQQueue = 100;
|
||||
|
||||
public ActiveMQQueue() : base()
|
||||
{
|
||||
}
|
||||
public ActiveMQQueue(String name) : base(name)
|
||||
{
|
||||
}
|
||||
|
||||
public String QueueName
|
||||
{
|
||||
get { return PhysicalName; }
|
||||
}
|
||||
|
||||
public override byte GetDataStructureType()
|
||||
{
|
||||
return ID_ActiveMQQueue;
|
||||
}
|
||||
|
||||
public override int GetDestinationType()
|
||||
{
|
||||
return ACTIVEMQ_QUEUE;
|
||||
}
|
||||
|
||||
public override ActiveMQDestination CreateDestination(String name)
|
||||
{
|
||||
return new ActiveMQQueue(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 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 NMS;
|
||||
using System;
|
||||
|
||||
namespace ActiveMQ.Commands
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Summary description for ActiveMQQueue.
|
||||
/// </summary>
|
||||
public class ActiveMQQueue : ActiveMQDestination, IQueue
|
||||
{
|
||||
public const byte ID_ActiveMQQueue = 100;
|
||||
|
||||
public ActiveMQQueue() : base()
|
||||
{
|
||||
}
|
||||
public ActiveMQQueue(String name) : base(name)
|
||||
{
|
||||
}
|
||||
|
||||
override public DestinationType DestinationType
|
||||
{
|
||||
get {
|
||||
return DestinationType.Queue;
|
||||
}
|
||||
}
|
||||
|
||||
public String QueueName
|
||||
{
|
||||
get { return PhysicalName; }
|
||||
}
|
||||
|
||||
public override byte GetDataStructureType()
|
||||
{
|
||||
return ID_ActiveMQQueue;
|
||||
}
|
||||
|
||||
public override int GetDestinationType()
|
||||
{
|
||||
return ACTIVEMQ_QUEUE;
|
||||
}
|
||||
|
||||
public override ActiveMQDestination CreateDestination(String name)
|
||||
{
|
||||
return new ActiveMQQueue(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,50 +1,78 @@
|
|||
/*
|
||||
* 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 ActiveMQ.Commands;
|
||||
using System;
|
||||
|
||||
|
||||
//
|
||||
// Marshalling code for Open Wire Format for ActiveMQTempDestination
|
||||
//
|
||||
//
|
||||
// NOTE!: This file is autogenerated - do not modify!
|
||||
// if you need to make a change, please see the Groovy scripts in the
|
||||
// activemq-core module
|
||||
//
|
||||
namespace ActiveMQ.Commands
|
||||
{
|
||||
public abstract class ActiveMQTempDestination : ActiveMQDestination
|
||||
{
|
||||
public const byte ID_ActiveMQTempDestination = 0;
|
||||
|
||||
public ActiveMQTempDestination() : base()
|
||||
{
|
||||
}
|
||||
|
||||
public ActiveMQTempDestination(String name) : base(name)
|
||||
{
|
||||
}
|
||||
|
||||
public override byte GetDataStructureType()
|
||||
{
|
||||
return ID_ActiveMQTempDestination;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 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 ActiveMQ.Commands;
|
||||
using System;
|
||||
using NMS;
|
||||
|
||||
|
||||
//
|
||||
// Marshalling code for Open Wire Format for ActiveMQTempDestination
|
||||
//
|
||||
//
|
||||
// NOTE!: This file is autogenerated - do not modify!
|
||||
// if you need to make a change, please see the Groovy scripts in the
|
||||
// activemq-core module
|
||||
//
|
||||
namespace ActiveMQ.Commands
|
||||
{
|
||||
public abstract class ActiveMQTempDestination : ActiveMQDestination
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Method GetDestinationType
|
||||
/// </summary>
|
||||
/// <returns>An int</returns>
|
||||
public override int GetDestinationType()
|
||||
{
|
||||
// TODO: Implement this method
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method CreateDestination
|
||||
/// </summary>
|
||||
/// <returns>An ActiveMQDestination</returns>
|
||||
/// <param name="name">A String</param>
|
||||
public override ActiveMQDestination CreateDestination(String name)
|
||||
{
|
||||
// TODO: Implement this method
|
||||
return null;
|
||||
}
|
||||
|
||||
abstract override public DestinationType DestinationType
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
public const byte ID_ActiveMQTempDestination = 0;
|
||||
|
||||
public ActiveMQTempDestination() : base()
|
||||
{
|
||||
}
|
||||
|
||||
public ActiveMQTempDestination(String name) : base(name)
|
||||
{
|
||||
}
|
||||
|
||||
public override byte GetDataStructureType()
|
||||
{
|
||||
return ID_ActiveMQTempDestination;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,59 +1,66 @@
|
|||
/*
|
||||
* 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 NMS;
|
||||
using System;
|
||||
|
||||
namespace ActiveMQ.Commands
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// A Temporary Queue
|
||||
/// </summary>
|
||||
public class ActiveMQTempQueue : ActiveMQTempDestination, ITemporaryQueue
|
||||
{
|
||||
public const byte ID_ActiveMQTempQueue = 102;
|
||||
|
||||
public ActiveMQTempQueue() : base()
|
||||
{
|
||||
}
|
||||
|
||||
public ActiveMQTempQueue(String name) : base(name)
|
||||
{
|
||||
}
|
||||
|
||||
public String GetQueueName()
|
||||
{
|
||||
return PhysicalName;
|
||||
}
|
||||
|
||||
public override byte GetDataStructureType()
|
||||
{
|
||||
return ID_ActiveMQTempQueue;
|
||||
}
|
||||
|
||||
public override int GetDestinationType()
|
||||
{
|
||||
return ACTIVEMQ_QUEUE;
|
||||
}
|
||||
|
||||
public override ActiveMQDestination CreateDestination(String name)
|
||||
{
|
||||
return new ActiveMQTempQueue(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 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 NMS;
|
||||
using System;
|
||||
|
||||
namespace ActiveMQ.Commands
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// A Temporary Queue
|
||||
/// </summary>
|
||||
public class ActiveMQTempQueue : ActiveMQTempDestination, ITemporaryQueue
|
||||
{
|
||||
public const byte ID_ActiveMQTempQueue = 102;
|
||||
|
||||
public ActiveMQTempQueue() : base()
|
||||
{
|
||||
}
|
||||
|
||||
public ActiveMQTempQueue(String name) : base(name)
|
||||
{
|
||||
}
|
||||
|
||||
override public DestinationType DestinationType
|
||||
{
|
||||
get {
|
||||
return DestinationType.TemporaryQueue;
|
||||
}
|
||||
}
|
||||
|
||||
public String GetQueueName()
|
||||
{
|
||||
return PhysicalName;
|
||||
}
|
||||
|
||||
public override byte GetDataStructureType()
|
||||
{
|
||||
return ID_ActiveMQTempQueue;
|
||||
}
|
||||
|
||||
public override int GetDestinationType()
|
||||
{
|
||||
return ACTIVEMQ_QUEUE;
|
||||
}
|
||||
|
||||
public override ActiveMQDestination CreateDestination(String name)
|
||||
{
|
||||
return new ActiveMQTempQueue(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,59 +1,68 @@
|
|||
/*
|
||||
* 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 NMS;
|
||||
using System;
|
||||
|
||||
namespace ActiveMQ.Commands
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// A Temporary Topic
|
||||
/// </summary>
|
||||
public class ActiveMQTempTopic : ActiveMQTempDestination, ITemporaryTopic
|
||||
{
|
||||
public const byte ID_ActiveMQTempTopic = 103;
|
||||
|
||||
public ActiveMQTempTopic() : base()
|
||||
{
|
||||
}
|
||||
|
||||
public ActiveMQTempTopic(String name) : base(name)
|
||||
{
|
||||
}
|
||||
|
||||
public String GetTopicName()
|
||||
{
|
||||
return PhysicalName;
|
||||
}
|
||||
|
||||
public override byte GetDataStructureType()
|
||||
{
|
||||
return ID_ActiveMQTempTopic;
|
||||
}
|
||||
|
||||
public override int GetDestinationType()
|
||||
{
|
||||
return ACTIVEMQ_TOPIC;
|
||||
}
|
||||
|
||||
public override ActiveMQDestination CreateDestination(String name)
|
||||
{
|
||||
return new ActiveMQTempTopic(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 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 NMS;
|
||||
using System;
|
||||
using System.CodeDom.Compiler;
|
||||
|
||||
namespace ActiveMQ.Commands
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// A Temporary Topic
|
||||
/// </summary>
|
||||
public class ActiveMQTempTopic : ActiveMQTempDestination, ITemporaryTopic
|
||||
{
|
||||
public const byte ID_ActiveMQTempTopic = 103;
|
||||
|
||||
public ActiveMQTempTopic() : base()
|
||||
{
|
||||
}
|
||||
|
||||
public ActiveMQTempTopic(String name) : base(name)
|
||||
{
|
||||
}
|
||||
|
||||
override public DestinationType DestinationType
|
||||
{
|
||||
get {
|
||||
return DestinationType.TemporaryTopic;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public String GetTopicName()
|
||||
{
|
||||
return PhysicalName;
|
||||
}
|
||||
|
||||
public override byte GetDataStructureType()
|
||||
{
|
||||
return ID_ActiveMQTempTopic;
|
||||
}
|
||||
|
||||
public override int GetDestinationType()
|
||||
{
|
||||
return ACTIVEMQ_TOPIC;
|
||||
}
|
||||
|
||||
public override ActiveMQDestination CreateDestination(String name)
|
||||
{
|
||||
return new ActiveMQTempTopic(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,58 +1,66 @@
|
|||
/*
|
||||
* 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 NMS;
|
||||
using System;
|
||||
|
||||
namespace ActiveMQ.Commands
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Summary description for ActiveMQTopic.
|
||||
/// </summary>
|
||||
public class ActiveMQTopic : ActiveMQDestination, ITopic
|
||||
{
|
||||
public const byte ID_ActiveMQTopic = 101;
|
||||
|
||||
public ActiveMQTopic() : base()
|
||||
{
|
||||
}
|
||||
public ActiveMQTopic(String name) : base(name)
|
||||
{
|
||||
}
|
||||
|
||||
public String TopicName
|
||||
{
|
||||
get { return PhysicalName; }
|
||||
}
|
||||
|
||||
public override byte GetDataStructureType()
|
||||
{
|
||||
return ID_ActiveMQTopic;
|
||||
}
|
||||
|
||||
public override int GetDestinationType()
|
||||
{
|
||||
return ACTIVEMQ_TOPIC;
|
||||
}
|
||||
|
||||
public override ActiveMQDestination CreateDestination(String name)
|
||||
{
|
||||
return new ActiveMQTopic(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 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 NMS;
|
||||
using System;
|
||||
|
||||
namespace ActiveMQ.Commands
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Summary description for ActiveMQTopic.
|
||||
/// </summary>
|
||||
public class ActiveMQTopic : ActiveMQDestination, ITopic
|
||||
{
|
||||
public const byte ID_ActiveMQTopic = 101;
|
||||
|
||||
public ActiveMQTopic() : base()
|
||||
{
|
||||
}
|
||||
public ActiveMQTopic(String name) : base(name)
|
||||
{
|
||||
}
|
||||
|
||||
override public DestinationType DestinationType
|
||||
{
|
||||
get {
|
||||
return DestinationType.Topic;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public String TopicName
|
||||
{
|
||||
get { return PhysicalName; }
|
||||
}
|
||||
|
||||
public override byte GetDataStructureType()
|
||||
{
|
||||
return ID_ActiveMQTopic;
|
||||
}
|
||||
|
||||
public override int GetDestinationType()
|
||||
{
|
||||
return ACTIVEMQ_TOPIC;
|
||||
}
|
||||
|
||||
public override ActiveMQDestination CreateDestination(String name)
|
||||
{
|
||||
return new ActiveMQTopic(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -38,20 +38,20 @@ namespace ActiveMQ.OpenWire.V1
|
|||
{
|
||||
|
||||
|
||||
public override DataStructure CreateObject()
|
||||
public override DataStructure CreateObject()
|
||||
{
|
||||
return new ActiveMQTempQueue();
|
||||
}
|
||||
|
||||
public override byte GetDataStructureType()
|
||||
public override byte GetDataStructureType()
|
||||
{
|
||||
return ActiveMQTempQueue.ID_ActiveMQTempQueue;
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
// Un-marshal an object instance from the data input stream
|
||||
//
|
||||
public override void TightUnmarshal(OpenWireFormat wireFormat, Object o, BinaryReader dataIn, BooleanStream bs)
|
||||
//
|
||||
public override void TightUnmarshal(OpenWireFormat wireFormat, Object o, BinaryReader dataIn, BooleanStream bs)
|
||||
{
|
||||
base.TightUnmarshal(wireFormat, o, dataIn, bs);
|
||||
|
||||
|
@ -68,7 +68,7 @@ namespace ActiveMQ.OpenWire.V1
|
|||
return rc + 0;
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
// Write a object instance to data output stream
|
||||
//
|
||||
public override void TightMarshal2(OpenWireFormat wireFormat, Object o, BinaryWriter dataOut, BooleanStream bs) {
|
||||
|
@ -76,16 +76,16 @@ namespace ActiveMQ.OpenWire.V1
|
|||
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
// Un-marshal an object instance from the data input stream
|
||||
//
|
||||
public override void LooseUnmarshal(OpenWireFormat wireFormat, Object o, BinaryReader dataIn)
|
||||
//
|
||||
public override void LooseUnmarshal(OpenWireFormat wireFormat, Object o, BinaryReader dataIn)
|
||||
{
|
||||
base.LooseUnmarshal(wireFormat, o, dataIn);
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
// Write a object instance to data output stream
|
||||
//
|
||||
public override void LooseMarshal(OpenWireFormat wireFormat, Object o, BinaryWriter dataOut) {
|
||||
|
|
|
@ -38,20 +38,20 @@ namespace ActiveMQ.OpenWire.V1
|
|||
{
|
||||
|
||||
|
||||
public override DataStructure CreateObject()
|
||||
public override DataStructure CreateObject()
|
||||
{
|
||||
return new ActiveMQTempTopic();
|
||||
}
|
||||
|
||||
public override byte GetDataStructureType()
|
||||
public override byte GetDataStructureType()
|
||||
{
|
||||
return ActiveMQTempTopic.ID_ActiveMQTempTopic;
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
// Un-marshal an object instance from the data input stream
|
||||
//
|
||||
public override void TightUnmarshal(OpenWireFormat wireFormat, Object o, BinaryReader dataIn, BooleanStream bs)
|
||||
//
|
||||
public override void TightUnmarshal(OpenWireFormat wireFormat, Object o, BinaryReader dataIn, BooleanStream bs)
|
||||
{
|
||||
base.TightUnmarshal(wireFormat, o, dataIn, bs);
|
||||
|
||||
|
@ -68,7 +68,7 @@ namespace ActiveMQ.OpenWire.V1
|
|||
return rc + 0;
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
// Write a object instance to data output stream
|
||||
//
|
||||
public override void TightMarshal2(OpenWireFormat wireFormat, Object o, BinaryWriter dataOut, BooleanStream bs) {
|
||||
|
@ -76,16 +76,16 @@ namespace ActiveMQ.OpenWire.V1
|
|||
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
// Un-marshal an object instance from the data input stream
|
||||
//
|
||||
public override void LooseUnmarshal(OpenWireFormat wireFormat, Object o, BinaryReader dataIn)
|
||||
//
|
||||
public override void LooseUnmarshal(OpenWireFormat wireFormat, Object o, BinaryReader dataIn)
|
||||
{
|
||||
base.LooseUnmarshal(wireFormat, o, dataIn);
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
// Write a object instance to data output stream
|
||||
//
|
||||
public override void LooseMarshal(OpenWireFormat wireFormat, Object o, BinaryWriter dataOut) {
|
||||
|
|
|
@ -38,20 +38,20 @@ namespace ActiveMQ.OpenWire.V1
|
|||
{
|
||||
|
||||
|
||||
public override DataStructure CreateObject()
|
||||
public override DataStructure CreateObject()
|
||||
{
|
||||
return new ActiveMQTopic();
|
||||
}
|
||||
|
||||
public override byte GetDataStructureType()
|
||||
public override byte GetDataStructureType()
|
||||
{
|
||||
return ActiveMQTopic.ID_ActiveMQTopic;
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
// Un-marshal an object instance from the data input stream
|
||||
//
|
||||
public override void TightUnmarshal(OpenWireFormat wireFormat, Object o, BinaryReader dataIn, BooleanStream bs)
|
||||
//
|
||||
public override void TightUnmarshal(OpenWireFormat wireFormat, Object o, BinaryReader dataIn, BooleanStream bs)
|
||||
{
|
||||
base.TightUnmarshal(wireFormat, o, dataIn, bs);
|
||||
|
||||
|
@ -68,7 +68,7 @@ namespace ActiveMQ.OpenWire.V1
|
|||
return rc + 0;
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
// Write a object instance to data output stream
|
||||
//
|
||||
public override void TightMarshal2(OpenWireFormat wireFormat, Object o, BinaryWriter dataOut, BooleanStream bs) {
|
||||
|
@ -76,16 +76,16 @@ namespace ActiveMQ.OpenWire.V1
|
|||
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
// Un-marshal an object instance from the data input stream
|
||||
//
|
||||
public override void LooseUnmarshal(OpenWireFormat wireFormat, Object o, BinaryReader dataIn)
|
||||
//
|
||||
public override void LooseUnmarshal(OpenWireFormat wireFormat, Object o, BinaryReader dataIn)
|
||||
{
|
||||
base.LooseUnmarshal(wireFormat, o, dataIn);
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
// Write a object instance to data output stream
|
||||
//
|
||||
public override void LooseMarshal(OpenWireFormat wireFormat, Object o, BinaryWriter dataOut) {
|
||||
|
|
|
@ -1,29 +1,41 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
namespace NMS
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Summary description for Destination.
|
||||
/// </summary>
|
||||
public interface IDestination
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
namespace NMS
|
||||
{
|
||||
public enum DestinationType
|
||||
{
|
||||
Queue,
|
||||
Topic,
|
||||
TemporaryQueue,
|
||||
TemporaryTopic
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Summary description for Destination.
|
||||
/// </summary>
|
||||
public interface IDestination
|
||||
{
|
||||
|
||||
DestinationType DestinationType {
|
||||
get;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,91 +1,91 @@
|
|||
/*
|
||||
* 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 NMS;
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
using System.Threading;
|
||||
|
||||
|
||||
|
||||
namespace NMS
|
||||
{
|
||||
[TestFixture]
|
||||
public class AsyncConsumeTest : JMSTestSupport
|
||||
{
|
||||
protected Object semaphore = new Object();
|
||||
protected bool received;
|
||||
|
||||
[SetUp]
|
||||
override public void SetUp()
|
||||
{
|
||||
base.SetUp();
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
override public void TearDown()
|
||||
{
|
||||
base.TearDown();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestAsynchronousConsume()
|
||||
{
|
||||
|
||||
// lets create an async consumer
|
||||
// START SNIPPET: demo
|
||||
IMessageConsumer consumer = session.CreateConsumer(this.Destination);
|
||||
consumer.Listener += new MessageListener(OnMessage);
|
||||
// END SNIPPET: demo
|
||||
|
||||
// now lets send a message
|
||||
IMessageProducer producer = CreateProducer();
|
||||
IMessage request = CreateMessage();
|
||||
request.NMSCorrelationID = "abc";
|
||||
request.NMSType = "Test";
|
||||
producer.Send(request);
|
||||
|
||||
WaitForMessageToArrive();
|
||||
|
||||
}
|
||||
|
||||
protected void OnMessage(IMessage message)
|
||||
{
|
||||
Console.WriteLine("Received message: " + message);
|
||||
lock (semaphore)
|
||||
{
|
||||
received = true;
|
||||
Monitor.PulseAll(semaphore);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void WaitForMessageToArrive()
|
||||
{
|
||||
lock (semaphore)
|
||||
{
|
||||
if (!received)
|
||||
{
|
||||
Monitor.Wait(semaphore, receiveTimeout);
|
||||
}
|
||||
Assert.AreEqual(true, received, "Should have received a message by now!");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 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 NMS;
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
using System.Threading;
|
||||
|
||||
|
||||
|
||||
namespace NMS
|
||||
{
|
||||
[TestFixture]
|
||||
public class AsyncConsumeTest : JMSTestSupport
|
||||
{
|
||||
protected Object semaphore = new Object();
|
||||
protected bool received;
|
||||
|
||||
[SetUp]
|
||||
override public void SetUp()
|
||||
{
|
||||
base.SetUp();
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
override public void TearDown()
|
||||
{
|
||||
base.TearDown();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestAsynchronousConsume()
|
||||
{
|
||||
|
||||
// lets create an async consumer
|
||||
// START SNIPPET: demo
|
||||
IMessageConsumer consumer = Session.CreateConsumer(this.Destination);
|
||||
consumer.Listener += new MessageListener(OnMessage);
|
||||
// END SNIPPET: demo
|
||||
|
||||
// now lets send a message
|
||||
IMessageProducer producer = CreateProducer();
|
||||
IMessage request = CreateMessage();
|
||||
request.NMSCorrelationID = "abc";
|
||||
request.NMSType = "Test";
|
||||
producer.Send(request);
|
||||
|
||||
WaitForMessageToArrive();
|
||||
|
||||
}
|
||||
|
||||
protected void OnMessage(IMessage message)
|
||||
{
|
||||
Console.WriteLine("Received message: " + message);
|
||||
lock (semaphore)
|
||||
{
|
||||
received = true;
|
||||
Monitor.PulseAll(semaphore);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void WaitForMessageToArrive()
|
||||
{
|
||||
lock (semaphore)
|
||||
{
|
||||
if (!received)
|
||||
{
|
||||
Monitor.Wait(semaphore, receiveTimeout);
|
||||
}
|
||||
Assert.AreEqual(true, received, "Should have received a message by now!");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,58 +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 NMS;
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
|
||||
|
||||
|
||||
namespace NMS
|
||||
{
|
||||
[TestFixture]
|
||||
public class BadConsumeTest : JMSTestSupport
|
||||
{
|
||||
[SetUp]
|
||||
override public void SetUp()
|
||||
{
|
||||
base.SetUp();
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
override public void TearDown()
|
||||
{
|
||||
base.TearDown();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestBadConsumeOperationToTestExceptions()
|
||||
{
|
||||
try
|
||||
{
|
||||
IMessageConsumer consumer = session.CreateConsumer(null);
|
||||
Console.WriteLine("Created consumer: " + consumer);
|
||||
Assert.Fail("Should have thrown an exception!");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine("Caught expected exception: " + e);
|
||||
Console.WriteLine("Stack: " + e.StackTrace);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 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 NMS;
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
|
||||
|
||||
|
||||
namespace NMS
|
||||
{
|
||||
[TestFixture]
|
||||
public class BadConsumeTest : JMSTestSupport
|
||||
{
|
||||
[SetUp]
|
||||
override public void SetUp()
|
||||
{
|
||||
base.SetUp();
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
override public void TearDown()
|
||||
{
|
||||
base.TearDown();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestBadConsumeOperationToTestExceptions()
|
||||
{
|
||||
try
|
||||
{
|
||||
IMessageConsumer consumer = Session.CreateConsumer(null);
|
||||
Console.WriteLine("Created consumer: " + consumer);
|
||||
Assert.Fail("Should have thrown an exception!");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine("Caught expected exception: " + e);
|
||||
Console.WriteLine("Stack: " + e.StackTrace);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,70 +1,70 @@
|
|||
/*
|
||||
* 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 NMS;
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
|
||||
|
||||
|
||||
namespace NMS
|
||||
{
|
||||
[ TestFixture ]
|
||||
public class BytesMessageTest : JMSTestSupport
|
||||
{
|
||||
byte[] expected = {1, 2, 3, 4, 5, 6, 7, 8};
|
||||
|
||||
[SetUp]
|
||||
override public void SetUp()
|
||||
{
|
||||
base.SetUp();
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
override public void TearDown()
|
||||
{
|
||||
base.TearDown();
|
||||
}
|
||||
|
||||
[ Test ]
|
||||
public override void SendAndSyncReceive()
|
||||
{
|
||||
base.SendAndSyncReceive();
|
||||
}
|
||||
|
||||
protected override IMessage CreateMessage()
|
||||
{
|
||||
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");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* 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 NMS;
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
|
||||
|
||||
|
||||
namespace NMS
|
||||
{
|
||||
[ TestFixture ]
|
||||
public class BytesMessageTest : JMSTestSupport
|
||||
{
|
||||
byte[] expected = {1, 2, 3, 4, 5, 6, 7, 8};
|
||||
|
||||
[SetUp]
|
||||
override public void SetUp()
|
||||
{
|
||||
base.SetUp();
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
override public void TearDown()
|
||||
{
|
||||
base.TearDown();
|
||||
}
|
||||
|
||||
[ Test ]
|
||||
public override void SendAndSyncReceive()
|
||||
{
|
||||
base.SendAndSyncReceive();
|
||||
}
|
||||
|
||||
protected override IMessage CreateMessage()
|
||||
{
|
||||
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");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -23,9 +23,15 @@ namespace NMS
|
|||
[TestFixture]
|
||||
public class ConsumerTest : JMSTestSupport
|
||||
{
|
||||
|
||||
public bool persistent;
|
||||
public int prefetch;
|
||||
public bool durableConsumer;
|
||||
|
||||
[SetUp]
|
||||
override public void SetUp()
|
||||
{
|
||||
clientId = "test";
|
||||
base.SetUp();
|
||||
}
|
||||
|
||||
|
@ -35,30 +41,32 @@ namespace NMS
|
|||
base.TearDown();
|
||||
}
|
||||
|
||||
protected override IConnection CreateConnection()
|
||||
{
|
||||
IConnection connection = base.CreateConnection();
|
||||
connection.ClientId = "test";
|
||||
return connection;
|
||||
}
|
||||
|
||||
protected override IDestination CreateDestination()
|
||||
{
|
||||
return session.GetTopic(CreateDestinationName());
|
||||
}
|
||||
|
||||
|
||||
//[Ignore("Not fully implemented yet.")]
|
||||
[Test]
|
||||
public void testDurableConsumerSelectorChange()
|
||||
public void TestDurableConsumerSelectorChangePersistent()
|
||||
{
|
||||
this.destinationType = DestinationType.Topic;
|
||||
this.persistent = true;
|
||||
doTestDurableConsumerSelectorChange();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestDurableConsumerSelectorChangeNonPersistent()
|
||||
{
|
||||
this.destinationType = DestinationType.Topic;
|
||||
this.persistent = true;
|
||||
doTestDurableConsumerSelectorChange();
|
||||
}
|
||||
|
||||
public void doTestDurableConsumerSelectorChange()
|
||||
{
|
||||
|
||||
IMessageProducer producer = session.CreateProducer(Destination);
|
||||
producer.Persistent = true;
|
||||
IMessageConsumer consumer = session.CreateDurableConsumer((ITopic)Destination, "test", "color='red'", false);
|
||||
IMessageProducer producer = Session.CreateProducer(Destination);
|
||||
producer.Persistent = persistent;
|
||||
IMessageConsumer consumer = Session.CreateDurableConsumer((ITopic)Destination, "test", "color='red'", false);
|
||||
|
||||
// Send the messages
|
||||
ITextMessage message = session.CreateTextMessage("1st");
|
||||
ITextMessage message = Session.CreateTextMessage("1st");
|
||||
message.Properties["color"] = "red";
|
||||
producer.Send(message);
|
||||
|
||||
|
@ -68,12 +76,12 @@ namespace NMS
|
|||
|
||||
// Change the subscription.
|
||||
consumer.Dispose();
|
||||
consumer = session.CreateDurableConsumer((ITopic)Destination, "test", "color='blue'", false);
|
||||
consumer = Session.CreateDurableConsumer((ITopic)Destination, "test", "color='blue'", false);
|
||||
|
||||
message = session.CreateTextMessage("2nd");
|
||||
message = Session.CreateTextMessage("2nd");
|
||||
message.Properties["color"] = "red";
|
||||
producer.Send(message);
|
||||
message = session.CreateTextMessage("3rd");
|
||||
message = Session.CreateTextMessage("3rd");
|
||||
message.Properties["color"] = "blue";
|
||||
producer.Send(message);
|
||||
|
||||
|
@ -84,7 +92,7 @@ namespace NMS
|
|||
|
||||
Assert.IsNull(consumer.ReceiveNoWait());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -65,8 +65,8 @@ namespace NMS
|
|||
|
||||
protected override IMessage CreateMessage()
|
||||
{
|
||||
ITextMessage message = session.CreateTextMessage(expectedText);
|
||||
replyTo = session.CreateTemporaryQueue();
|
||||
ITextMessage message = Session.CreateTextMessage(expectedText);
|
||||
replyTo = Session.CreateTemporaryQueue();
|
||||
|
||||
// lets set the headers
|
||||
message.NMSCorrelationID = correlationID;
|
||||
|
|
|
@ -28,17 +28,19 @@ namespace NMS
|
|||
public abstract class JMSTestSupport
|
||||
{
|
||||
|
||||
protected IConnectionFactory factory;
|
||||
protected IConnection connection;
|
||||
protected ISession session;
|
||||
private IConnectionFactory factory;
|
||||
private IConnection connection;
|
||||
private ISession session;
|
||||
private IDestination destination;
|
||||
|
||||
protected int receiveTimeout = 1000;
|
||||
protected string clientId;
|
||||
protected DestinationType destinationType = DestinationType.Queue;
|
||||
protected AcknowledgementMode acknowledgementMode = AcknowledgementMode.ClientAcknowledge;
|
||||
|
||||
[SetUp]
|
||||
virtual public void SetUp()
|
||||
{
|
||||
Connect();
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
|
@ -47,21 +49,58 @@ namespace NMS
|
|||
Disconnect();
|
||||
}
|
||||
|
||||
// Properties
|
||||
public bool Connected
|
||||
{
|
||||
get { return connection!=null; }
|
||||
set { if( value ) Connect(); else Disconnect(); }
|
||||
}
|
||||
|
||||
public IConnectionFactory Factory
|
||||
{
|
||||
get {
|
||||
if( factory == null ) {
|
||||
factory = CreateConnectionFactory();
|
||||
Assert.IsNotNull(factory, "no factory created");
|
||||
}
|
||||
return factory;
|
||||
}
|
||||
set { this.factory = value; }
|
||||
}
|
||||
|
||||
public IConnection Connection
|
||||
{
|
||||
get {
|
||||
if( connection == null ) {
|
||||
Connect();
|
||||
}
|
||||
return connection;
|
||||
}
|
||||
set { this.connection = value; }
|
||||
}
|
||||
|
||||
public ISession Session
|
||||
{
|
||||
get {
|
||||
if( session == null ) {
|
||||
session = Connection.CreateSession(acknowledgementMode);
|
||||
Assert.IsNotNull(connection != null, "no session created");
|
||||
}
|
||||
return session;
|
||||
}
|
||||
set { this.session = value; }
|
||||
}
|
||||
|
||||
virtual protected void Connect()
|
||||
{
|
||||
Console.WriteLine("Connectting...");
|
||||
factory = CreateConnectionFactory();
|
||||
Assert.IsNotNull(factory, "no factory created");
|
||||
connection = CreateConnection();
|
||||
Assert.IsNotNull(connection, "no connection created");
|
||||
connection = CreateConnection();
|
||||
Assert.IsNotNull(connection, "no connection created");
|
||||
connection.Start();
|
||||
session = connection.CreateSession(acknowledgementMode);
|
||||
Assert.IsNotNull(connection != null, "no session created");
|
||||
Console.WriteLine("Connected.");
|
||||
Assert.IsNotNull(connection, "no connection created");
|
||||
}
|
||||
|
||||
|
||||
|
||||
virtual protected void Disconnect()
|
||||
{
|
||||
if (connection != null)
|
||||
|
@ -69,6 +108,7 @@ namespace NMS
|
|||
Console.WriteLine("Disconnecting...");
|
||||
connection.Dispose();
|
||||
connection = null;
|
||||
session=null;
|
||||
Console.WriteLine("Disconnected.");
|
||||
}
|
||||
}
|
||||
|
@ -81,7 +121,7 @@ namespace NMS
|
|||
|
||||
protected virtual void Drain()
|
||||
{
|
||||
using (ISession session = connection.CreateSession())
|
||||
using (ISession session = Connection.CreateSession())
|
||||
{
|
||||
// Tries to consume any messages on the Destination
|
||||
IMessageConsumer consumer = session.CreateConsumer(Destination);
|
||||
|
@ -98,7 +138,7 @@ namespace NMS
|
|||
|
||||
public virtual void SendAndSyncReceive()
|
||||
{
|
||||
using (ISession session = connection.CreateSession())
|
||||
using (ISession session = Connection.CreateSession())
|
||||
{
|
||||
|
||||
IMessageConsumer consumer = session.CreateConsumer(Destination);
|
||||
|
@ -120,24 +160,38 @@ namespace NMS
|
|||
|
||||
protected virtual IConnection CreateConnection()
|
||||
{
|
||||
return factory.CreateConnection();
|
||||
IConnection connection = Factory.CreateConnection();
|
||||
if( clientId!=null ) {
|
||||
connection.ClientId = clientId;
|
||||
}
|
||||
return connection;
|
||||
}
|
||||
|
||||
protected virtual IMessageProducer CreateProducer()
|
||||
{
|
||||
IMessageProducer producer = session.CreateProducer(destination);
|
||||
IMessageProducer producer = Session.CreateProducer(destination);
|
||||
return producer;
|
||||
}
|
||||
|
||||
protected virtual IMessageConsumer CreateConsumer()
|
||||
{
|
||||
IMessageConsumer consumer = session.CreateConsumer(destination);
|
||||
IMessageConsumer consumer = Session.CreateConsumer(destination);
|
||||
return consumer;
|
||||
}
|
||||
|
||||
protected virtual IDestination CreateDestination()
|
||||
{
|
||||
return session.GetQueue(CreateDestinationName());
|
||||
if( destinationType == DestinationType.Queue ) {
|
||||
return Session.GetQueue(CreateDestinationName());
|
||||
} else if( destinationType == DestinationType.Topic ) {
|
||||
return Session.GetTopic(CreateDestinationName());
|
||||
} else if( destinationType == DestinationType.TemporaryQueue ) {
|
||||
return Session.CreateTemporaryQueue();
|
||||
} else if( destinationType == DestinationType.TemporaryTopic ) {
|
||||
return Session.CreateTemporaryTopic();
|
||||
} else {
|
||||
throw new Exception("Unknown destination type: "+destinationType);
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual string CreateDestinationName()
|
||||
|
@ -147,7 +201,7 @@ namespace NMS
|
|||
|
||||
protected virtual IMessage CreateMessage()
|
||||
{
|
||||
return session.CreateMessage();
|
||||
return Session.CreateMessage();
|
||||
}
|
||||
|
||||
protected virtual void AssertValidMessage(IMessage message)
|
||||
|
|
|
@ -1,126 +1,126 @@
|
|||
/*
|
||||
* 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 NMS;
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
|
||||
|
||||
|
||||
namespace NMS
|
||||
{
|
||||
[ TestFixture ]
|
||||
public class MapMessageTest : JMSTestSupport
|
||||
{
|
||||
bool a = true;
|
||||
byte b = 123;
|
||||
char c = 'c';
|
||||
short d = 0x1234;
|
||||
int e = 0x12345678;
|
||||
long f = 0x1234567812345678;
|
||||
string g = "Hello World!";
|
||||
bool h = false;
|
||||
byte i = 0xFF;
|
||||
short j = -0x1234;
|
||||
int k = -0x12345678;
|
||||
long l = -0x1234567812345678;
|
||||
|
||||
[SetUp]
|
||||
override public void SetUp()
|
||||
{
|
||||
base.SetUp();
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
override public void TearDown()
|
||||
{
|
||||
base.TearDown();
|
||||
}
|
||||
|
||||
[ Test ]
|
||||
public override void SendAndSyncReceive()
|
||||
{
|
||||
base.SendAndSyncReceive();
|
||||
}
|
||||
|
||||
protected override IMessage CreateMessage()
|
||||
{
|
||||
IMapMessage message = session.CreateMapMessage();
|
||||
|
||||
message.Body["a"] = a;
|
||||
message.Body["b"] = b;
|
||||
message.Body["c"] = c;
|
||||
message.Body["d"] = d;
|
||||
message.Body["e"] = e;
|
||||
message.Body["f"] = f;
|
||||
message.Body["g"] = g;
|
||||
message.Body["h"] = h;
|
||||
message.Body["i"] = i;
|
||||
message.Body["j"] = j;
|
||||
message.Body["k"] = k;
|
||||
message.Body["l"] = l;
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
protected override void AssertValidMessage(IMessage message)
|
||||
{
|
||||
Assert.IsTrue(message is IMapMessage, "Did not receive a MapMessage!");
|
||||
IMapMessage mapMessage = (IMapMessage) message;
|
||||
|
||||
Console.WriteLine("Received MapMessage: " + message);
|
||||
Console.WriteLine("Received Count: " + mapMessage.Body.Count);
|
||||
|
||||
Assert.AreEqual(ToHex(f), ToHex(mapMessage.Body.GetLong("f")), "map entry: f as hex");
|
||||
|
||||
// use generic API to access entries
|
||||
Assert.AreEqual(a, mapMessage.Body["a"], "generic map entry: a");
|
||||
Assert.AreEqual(b, mapMessage.Body["b"], "generic map entry: b");
|
||||
Assert.AreEqual(c, mapMessage.Body["c"], "generic map entry: c");
|
||||
Assert.AreEqual(d, mapMessage.Body["d"], "generic map entry: d");
|
||||
Assert.AreEqual(e, mapMessage.Body["e"], "generic map entry: e");
|
||||
Assert.AreEqual(f, mapMessage.Body["f"], "generic map entry: f");
|
||||
Assert.AreEqual(g, mapMessage.Body["g"], "generic map entry: g");
|
||||
Assert.AreEqual(h, mapMessage.Body["h"], "generic map entry: h");
|
||||
Assert.AreEqual(i, mapMessage.Body["i"], "generic map entry: i");
|
||||
Assert.AreEqual(j, mapMessage.Body["j"], "generic map entry: j");
|
||||
Assert.AreEqual(k, mapMessage.Body["k"], "generic map entry: k");
|
||||
Assert.AreEqual(l, mapMessage.Body["l"], "generic map entry: l");
|
||||
|
||||
// use type safe APIs
|
||||
Assert.AreEqual(a, mapMessage.Body.GetBool("a"), "map entry: a");
|
||||
Assert.AreEqual(b, mapMessage.Body.GetByte("b"), "map entry: b");
|
||||
Assert.AreEqual(c, mapMessage.Body.GetChar("c"), "map entry: c");
|
||||
Assert.AreEqual(d, mapMessage.Body.GetShort("d"), "map entry: d");
|
||||
Assert.AreEqual(e, mapMessage.Body.GetInt("e"), "map entry: e");
|
||||
Assert.AreEqual(f, mapMessage.Body.GetLong("f"), "map entry: f");
|
||||
Assert.AreEqual(g, mapMessage.Body.GetString("g"), "map entry: g");
|
||||
Assert.AreEqual(h, mapMessage.Body.GetBool("h"), "map entry: h");
|
||||
Assert.AreEqual(i, mapMessage.Body.GetByte("i"), "map entry: i");
|
||||
Assert.AreEqual(j, mapMessage.Body.GetShort("j"), "map entry: j");
|
||||
Assert.AreEqual(k, mapMessage.Body.GetInt("k"), "map entry: k");
|
||||
Assert.AreEqual(l, mapMessage.Body.GetLong("l"), "map entry: l");
|
||||
|
||||
}
|
||||
|
||||
protected string ToHex(long value)
|
||||
{
|
||||
return String.Format("{0:x}", value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 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 NMS;
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
|
||||
|
||||
|
||||
namespace NMS
|
||||
{
|
||||
[ TestFixture ]
|
||||
public class MapMessageTest : JMSTestSupport
|
||||
{
|
||||
bool a = true;
|
||||
byte b = 123;
|
||||
char c = 'c';
|
||||
short d = 0x1234;
|
||||
int e = 0x12345678;
|
||||
long f = 0x1234567812345678;
|
||||
string g = "Hello World!";
|
||||
bool h = false;
|
||||
byte i = 0xFF;
|
||||
short j = -0x1234;
|
||||
int k = -0x12345678;
|
||||
long l = -0x1234567812345678;
|
||||
|
||||
[SetUp]
|
||||
override public void SetUp()
|
||||
{
|
||||
base.SetUp();
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
override public void TearDown()
|
||||
{
|
||||
base.TearDown();
|
||||
}
|
||||
|
||||
[ Test ]
|
||||
public override void SendAndSyncReceive()
|
||||
{
|
||||
base.SendAndSyncReceive();
|
||||
}
|
||||
|
||||
protected override IMessage CreateMessage()
|
||||
{
|
||||
IMapMessage message = Session.CreateMapMessage();
|
||||
|
||||
message.Body["a"] = a;
|
||||
message.Body["b"] = b;
|
||||
message.Body["c"] = c;
|
||||
message.Body["d"] = d;
|
||||
message.Body["e"] = e;
|
||||
message.Body["f"] = f;
|
||||
message.Body["g"] = g;
|
||||
message.Body["h"] = h;
|
||||
message.Body["i"] = i;
|
||||
message.Body["j"] = j;
|
||||
message.Body["k"] = k;
|
||||
message.Body["l"] = l;
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
protected override void AssertValidMessage(IMessage message)
|
||||
{
|
||||
Assert.IsTrue(message is IMapMessage, "Did not receive a MapMessage!");
|
||||
IMapMessage mapMessage = (IMapMessage) message;
|
||||
|
||||
Console.WriteLine("Received MapMessage: " + message);
|
||||
Console.WriteLine("Received Count: " + mapMessage.Body.Count);
|
||||
|
||||
Assert.AreEqual(ToHex(f), ToHex(mapMessage.Body.GetLong("f")), "map entry: f as hex");
|
||||
|
||||
// use generic API to access entries
|
||||
Assert.AreEqual(a, mapMessage.Body["a"], "generic map entry: a");
|
||||
Assert.AreEqual(b, mapMessage.Body["b"], "generic map entry: b");
|
||||
Assert.AreEqual(c, mapMessage.Body["c"], "generic map entry: c");
|
||||
Assert.AreEqual(d, mapMessage.Body["d"], "generic map entry: d");
|
||||
Assert.AreEqual(e, mapMessage.Body["e"], "generic map entry: e");
|
||||
Assert.AreEqual(f, mapMessage.Body["f"], "generic map entry: f");
|
||||
Assert.AreEqual(g, mapMessage.Body["g"], "generic map entry: g");
|
||||
Assert.AreEqual(h, mapMessage.Body["h"], "generic map entry: h");
|
||||
Assert.AreEqual(i, mapMessage.Body["i"], "generic map entry: i");
|
||||
Assert.AreEqual(j, mapMessage.Body["j"], "generic map entry: j");
|
||||
Assert.AreEqual(k, mapMessage.Body["k"], "generic map entry: k");
|
||||
Assert.AreEqual(l, mapMessage.Body["l"], "generic map entry: l");
|
||||
|
||||
// use type safe APIs
|
||||
Assert.AreEqual(a, mapMessage.Body.GetBool("a"), "map entry: a");
|
||||
Assert.AreEqual(b, mapMessage.Body.GetByte("b"), "map entry: b");
|
||||
Assert.AreEqual(c, mapMessage.Body.GetChar("c"), "map entry: c");
|
||||
Assert.AreEqual(d, mapMessage.Body.GetShort("d"), "map entry: d");
|
||||
Assert.AreEqual(e, mapMessage.Body.GetInt("e"), "map entry: e");
|
||||
Assert.AreEqual(f, mapMessage.Body.GetLong("f"), "map entry: f");
|
||||
Assert.AreEqual(g, mapMessage.Body.GetString("g"), "map entry: g");
|
||||
Assert.AreEqual(h, mapMessage.Body.GetBool("h"), "map entry: h");
|
||||
Assert.AreEqual(i, mapMessage.Body.GetByte("i"), "map entry: i");
|
||||
Assert.AreEqual(j, mapMessage.Body.GetShort("j"), "map entry: j");
|
||||
Assert.AreEqual(k, mapMessage.Body.GetInt("k"), "map entry: k");
|
||||
Assert.AreEqual(l, mapMessage.Body.GetLong("l"), "map entry: l");
|
||||
|
||||
}
|
||||
|
||||
protected string ToHex(long value)
|
||||
{
|
||||
return String.Format("{0:x}", value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ namespace NMS
|
|||
|
||||
protected override IMessage CreateMessage()
|
||||
{
|
||||
IMessage message = session.CreateMessage();
|
||||
IMessage message = Session.CreateMessage();
|
||||
|
||||
message.Properties["a"] = a;
|
||||
message.Properties["b"] = b;
|
||||
|
|
|
@ -1,66 +1,66 @@
|
|||
/*
|
||||
* 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 NMS;
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
|
||||
|
||||
|
||||
namespace NMS
|
||||
{
|
||||
[ TestFixture ]
|
||||
public class TextMessage : JMSTestSupport
|
||||
{
|
||||
string expected = "Hello World!";
|
||||
|
||||
[SetUp]
|
||||
override public void SetUp()
|
||||
{
|
||||
base.SetUp();
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
override public void TearDown()
|
||||
{
|
||||
base.TearDown();
|
||||
}
|
||||
|
||||
[ Test ]
|
||||
public override void SendAndSyncReceive()
|
||||
{
|
||||
base.SendAndSyncReceive();
|
||||
}
|
||||
|
||||
protected override IMessage CreateMessage()
|
||||
{
|
||||
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");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* 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 NMS;
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
|
||||
|
||||
|
||||
namespace NMS
|
||||
{
|
||||
[ TestFixture ]
|
||||
public class TextMessage : JMSTestSupport
|
||||
{
|
||||
string expected = "Hello World!";
|
||||
|
||||
[SetUp]
|
||||
override public void SetUp()
|
||||
{
|
||||
base.SetUp();
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
override public void TearDown()
|
||||
{
|
||||
base.TearDown();
|
||||
}
|
||||
|
||||
[ Test ]
|
||||
public override void SendAndSyncReceive()
|
||||
{
|
||||
base.SendAndSyncReceive();
|
||||
}
|
||||
|
||||
protected override IMessage CreateMessage()
|
||||
{
|
||||
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");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
using NMS;
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
using System.Collections;
|
||||
|
@ -33,9 +32,11 @@ namespace NMS
|
|||
[SetUp]
|
||||
override public void SetUp()
|
||||
{
|
||||
acknowledgementMode = AcknowledgementMode.Transactional;
|
||||
base.SetUp();
|
||||
acknowledgementMode = AcknowledgementMode.Transactional;
|
||||
Drain();
|
||||
consumer = Session.CreateConsumer(Destination);
|
||||
producer = Session.CreateProducer(Destination);
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
|
@ -49,21 +50,21 @@ namespace NMS
|
|||
public void TestSendRollback()
|
||||
{
|
||||
IMessage[] outbound = new IMessage[]{
|
||||
session.CreateTextMessage("First Message"),
|
||||
session.CreateTextMessage("Second Message")
|
||||
Session.CreateTextMessage("First Message"),
|
||||
Session.CreateTextMessage("Second Message")
|
||||
};
|
||||
|
||||
//sends a message
|
||||
producer.Send(outbound[0]);
|
||||
session.Commit();
|
||||
Session.Commit();
|
||||
|
||||
//sends a message that gets rollbacked
|
||||
producer.Send(session.CreateTextMessage("I'm going to get rolled back."));
|
||||
session.Rollback();
|
||||
producer.Send(Session.CreateTextMessage("I'm going to get rolled back."));
|
||||
Session.Rollback();
|
||||
|
||||
//sends a message
|
||||
producer.Send(outbound[1]);
|
||||
session.Commit();
|
||||
Session.Commit();
|
||||
|
||||
//receives the first message
|
||||
ArrayList messages = new ArrayList();
|
||||
|
@ -79,7 +80,7 @@ namespace NMS
|
|||
Console.WriteLine("Received: " + message);
|
||||
|
||||
//validates that the rollbacked was not consumed
|
||||
session.Commit();
|
||||
Session.Commit();
|
||||
IMessage[] inbound = new IMessage[messages.Count];
|
||||
messages.CopyTo(inbound);
|
||||
AssertTextMessagesEqual("Rollback did not work.", outbound, inbound);
|
||||
|
@ -89,24 +90,24 @@ namespace NMS
|
|||
public void TestSendSessionClose()
|
||||
{
|
||||
IMessage[] outbound = new IMessage[]{
|
||||
session.CreateTextMessage("First Message"),
|
||||
session.CreateTextMessage("Second Message")
|
||||
Session.CreateTextMessage("First Message"),
|
||||
Session.CreateTextMessage("Second Message")
|
||||
};
|
||||
|
||||
//sends a message
|
||||
producer.Send(outbound[0]);
|
||||
session.Commit();
|
||||
Session.Commit();
|
||||
|
||||
//sends a message that gets rollbacked
|
||||
producer.Send(session.CreateTextMessage("I'm going to get rolled back."));
|
||||
producer.Send(Session.CreateTextMessage("I'm going to get rolled back."));
|
||||
consumer.Dispose();
|
||||
session.Dispose();
|
||||
Session.Dispose();
|
||||
|
||||
Reconnect();
|
||||
|
||||
//sends a message
|
||||
producer.Send(outbound[1]);
|
||||
session.Commit();
|
||||
Session.Commit();
|
||||
|
||||
//receives the first message
|
||||
ArrayList messages = new ArrayList();
|
||||
|
@ -122,7 +123,7 @@ namespace NMS
|
|||
Console.WriteLine("Received: " + message);
|
||||
|
||||
//validates that the rollbacked was not consumed
|
||||
session.Commit();
|
||||
Session.Commit();
|
||||
IMessage[] inbound = new IMessage[messages.Count];
|
||||
messages.CopyTo(inbound);
|
||||
AssertTextMessagesEqual("Rollback did not work.", outbound, inbound);
|
||||
|
@ -132,14 +133,14 @@ namespace NMS
|
|||
public void TestReceiveRollback()
|
||||
{
|
||||
IMessage[] outbound = new IMessage[]{
|
||||
session.CreateTextMessage("First Message"),
|
||||
session.CreateTextMessage("Second Message")
|
||||
Session.CreateTextMessage("First Message"),
|
||||
Session.CreateTextMessage("Second Message")
|
||||
};
|
||||
|
||||
//sent both messages
|
||||
producer.Send(outbound[0]);
|
||||
producer.Send(outbound[1]);
|
||||
session.Commit();
|
||||
Session.Commit();
|
||||
|
||||
Console.WriteLine("Sent 0: " + outbound[0]);
|
||||
Console.WriteLine("Sent 1: " + outbound[1]);
|
||||
|
@ -148,20 +149,20 @@ namespace NMS
|
|||
IMessage message = consumer.Receive(TimeSpan.FromMilliseconds(1000));
|
||||
messages.Add(message);
|
||||
Assert.AreEqual(outbound[0], message);
|
||||
session.Commit();
|
||||
Session.Commit();
|
||||
|
||||
// rollback so we can get that last message again.
|
||||
message = consumer.Receive(TimeSpan.FromMilliseconds(1000));
|
||||
Assert.IsNotNull(message);
|
||||
Assert.AreEqual(outbound[1], message);
|
||||
session.Rollback();
|
||||
Session.Rollback();
|
||||
|
||||
// Consume again.. the previous message should
|
||||
// get redelivered.
|
||||
message = consumer.Receive(TimeSpan.FromMilliseconds(5000));
|
||||
Assert.IsNotNull(message, "Should have re-received the message again!");
|
||||
messages.Add(message);
|
||||
session.Commit();
|
||||
Session.Commit();
|
||||
|
||||
IMessage[] inbound = new IMessage[messages.Count];
|
||||
messages.CopyTo(inbound);
|
||||
|
@ -173,13 +174,13 @@ namespace NMS
|
|||
public void TestReceiveTwoThenRollback()
|
||||
{
|
||||
IMessage[] outbound = new IMessage[]{
|
||||
session.CreateTextMessage("First Message"),
|
||||
session.CreateTextMessage("Second Message")
|
||||
Session.CreateTextMessage("First Message"),
|
||||
Session.CreateTextMessage("Second Message")
|
||||
};
|
||||
|
||||
producer.Send(outbound[0]);
|
||||
producer.Send(outbound[1]);
|
||||
session.Commit();
|
||||
Session.Commit();
|
||||
|
||||
Console.WriteLine("Sent 0: " + outbound[0]);
|
||||
Console.WriteLine("Sent 1: " + outbound[1]);
|
||||
|
@ -191,7 +192,7 @@ namespace NMS
|
|||
message = consumer.Receive(TimeSpan.FromMilliseconds(1000));
|
||||
Assert.IsNotNull(message);
|
||||
AssertTextMessageEqual("second message received before rollback", outbound[1], message);
|
||||
session.Rollback();
|
||||
Session.Rollback();
|
||||
|
||||
// Consume again.. the previous message should
|
||||
// get redelivered.
|
||||
|
@ -206,7 +207,7 @@ namespace NMS
|
|||
AssertTextMessageEqual("second message received after rollback", outbound[1], message);
|
||||
|
||||
Assert.IsNull(consumer.ReceiveNoWait());
|
||||
session.Commit();
|
||||
Session.Commit();
|
||||
|
||||
IMessage[] inbound = new IMessage[messages.Count];
|
||||
messages.CopyTo(inbound);
|
||||
|
@ -239,14 +240,17 @@ namespace NMS
|
|||
|
||||
Assert.AreEqual(expectedText, actualText, message);
|
||||
}
|
||||
|
||||
protected override void Connect()
|
||||
{
|
||||
base.Connect();
|
||||
consumer = session.CreateConsumer(Destination);
|
||||
producer = session.CreateProducer(Destination);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Method Reconnect
|
||||
/// </summary>
|
||||
protected override void Reconnect()
|
||||
{
|
||||
base.Reconnect();
|
||||
consumer = Session.CreateConsumer(Destination);
|
||||
producer = Session.CreateProducer(Destination);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue