public virtual bool Equals(ActiveMQMessage that) { MessageId oMsg = that.MessageId; MessageId thisMsg = this.MessageId; return thisMsg != null && oMsg != null && oMsg.Equals(thisMsg); }
public void TestSetReadOnly() { ActiveMQMessage msg = new ActiveMQMessage(); msg.ReadOnlyProperties = true; bool test = false; try { msg.Properties.SetInt("test", 1); } catch(MessageNotWriteableException) { test = true; } catch(NMSException) { test = false; } Assert.IsTrue(test); }
public void WhenProcessingJob_MessagesAreDeleted() { const string Selector = "Selector"; const int Id = 42; var message = new ActiveMQMessage(); message.Properties[ScheduledMessage.AMQ_SCHEDULED_ID] = Id; var messages = new Queue<IMessage>(); messages.Enqueue(message); IMessage sentDeletionMessage = null; var session = this.SetupCreateSession(); var consumer = this.SetupCreateTemporaryTopicConsumer(session, Selector, ""); consumer.Setup(c => c.ReceiveNoWait()).Returns(() => messages.Count > 0 ? messages.Dequeue() : null); var producer = SetupCreateTopicProducer(session, ScheduledMessage.AMQ_SCHEDULER_MANAGEMENT_DESTINATION); producer.Setup(p => p.Send(It.IsAny<IMessage>())).Callback<IMessage>(m => sentDeletionMessage = m); this.testee.Start(); var job = this.testee.CreateActiveMqSchedulerManagementJob(Selector); this.testee.ProcessJob(job); sentDeletionMessage.Should().NotBeNull(); sentDeletionMessage.Properties[ScheduledMessage.AMQ_SCHEDULER_ACTION].Should().Be(ScheduledMessage.AMQ_SCHEDULER_ACTION_REMOVE); sentDeletionMessage.Properties[ScheduledMessage.AMQ_SCHEDULED_ID].Should().Be(Id); }
public void TestShortPropertyConversion() { ActiveMQMessage msg = new ActiveMQMessage(); String propertyName = "property"; msg.Properties.SetShort(propertyName, (short)1); Assert.AreEqual((short)msg.Properties[propertyName], 1); Assert.AreEqual(msg.Properties.GetShort(propertyName), 1); Assert.AreEqual(msg.Properties.GetInt(propertyName), 1); Assert.AreEqual(msg.Properties.GetLong(propertyName), 1); Assert.AreEqual(msg.Properties.GetString(propertyName), "1"); try { msg.Properties.GetBool(propertyName); Assert.Fail("Should have thrown exception"); } catch(MessageFormatException) { } try { msg.Properties.GetByte(propertyName); Assert.Fail("Should have thrown exception"); } catch(MessageFormatException) { } try { msg.Properties.GetFloat(propertyName); Assert.Fail("Should have thrown exception"); } catch(MessageFormatException) { } try { msg.Properties.GetDouble(propertyName); Assert.Fail("Should have thrown exception"); } catch(MessageFormatException) { } }
public void TestSetToForeignNMSID() { ActiveMQMessage msg = new ActiveMQMessage(); msg.NMSMessageId = "ID:EMS-SERVER.8B443C380083:429"; }
public void TestSetNullPropertyName() { ActiveMQMessage msg = new ActiveMQMessage(); try { msg.Properties.SetString(null, "Cheese"); Assert.Fail("Should have thrown exception"); } catch(Exception) { } }
public void TestReadOnlyProperties() { ActiveMQMessage msg = new ActiveMQMessage(); String propertyName = "property"; msg.ReadOnlyProperties = true; try { msg.Properties[propertyName] = new Object(); Assert.Fail("Should have thrown exception"); } catch(MessageNotWriteableException) { } try { msg.Properties.SetString(propertyName, "test"); Assert.Fail("Should have thrown exception"); } catch(MessageNotWriteableException) { } try { msg.Properties.SetBool(propertyName, true); Assert.Fail("Should have thrown exception"); } catch(MessageNotWriteableException) { } try { msg.Properties.SetByte(propertyName, (byte)1); Assert.Fail("Should have thrown exception"); } catch(MessageNotWriteableException) { } try { msg.Properties.SetShort(propertyName, (short)1); Assert.Fail("Should have thrown exception"); } catch(MessageNotWriteableException) { } try { msg.Properties.SetInt(propertyName, 1); Assert.Fail("Should have thrown exception"); } catch(MessageNotWriteableException) { } try { msg.Properties.SetLong(propertyName, 1); Assert.Fail("Should have thrown exception"); } catch(MessageNotWriteableException) { } try { msg.Properties.SetFloat(propertyName, (float)1.5); Assert.Fail("Should have thrown exception"); } catch(MessageNotWriteableException) { } try { msg.Properties.SetDouble(propertyName, 1.5); Assert.Fail("Should have thrown exception"); } catch(MessageNotWriteableException) { } }
public void TestGetStringProperty() { ActiveMQMessage msg = new ActiveMQMessage(); string name = "stringProperty"; msg.Properties.SetString(name, name); Assert.IsTrue(msg.Properties.GetString(name).Equals(name)); }
public void TestGetPropertyNames() { ActiveMQMessage msg = new ActiveMQMessage(); string name = "floatProperty"; msg.Properties.SetFloat(name, 1.3f); foreach(string key in msg.Properties.Keys) { Assert.IsTrue(key.Equals(name)); } }
public void TestGetAndSetNMSPriority() { ActiveMQMessage msg = new ActiveMQMessage(); msg.NMSPriority = this.nmsPriority; Assert.IsTrue(msg.NMSPriority == this.nmsPriority); }
public void TestGetAndSetNMSDestination() { ActiveMQMessage msg = new ActiveMQMessage(); msg.FromDestination = this.nmsDestination; Assert.AreEqual(msg.NMSDestination, this.nmsDestination); }
public void TestGetAndSetNMSDeliveryMode() { ActiveMQMessage msg = new ActiveMQMessage(); msg.NMSDeliveryMode = this.nmsDeliveryMode; Assert.IsTrue(msg.NMSDeliveryMode == this.nmsDeliveryMode); }
public void TestGetAndSetNMSCorrelationID() { ActiveMQMessage msg = new ActiveMQMessage(); msg.NMSCorrelationID = this.nmsCorrelationID; Assert.IsTrue(msg.NMSCorrelationID.Equals(this.nmsCorrelationID)); }
public void TestGetAndSetMSRedelivered() { ActiveMQMessage msg = new ActiveMQMessage(); msg.RedeliveryCounter = 2; Assert.IsTrue(msg.NMSRedelivered == this.nmsRedelivered); }
public void TestFloatPropertyConversion() { ActiveMQMessage msg = new ActiveMQMessage(); String propertyName = "property"; float floatValue = (float)1.5; msg.Properties.SetFloat(propertyName, floatValue); Assert.AreEqual((float)msg.Properties[propertyName], floatValue, 0); Assert.AreEqual(msg.Properties.GetFloat(propertyName), floatValue, 0); Assert.AreEqual(msg.Properties.GetDouble(propertyName), floatValue, 0); Assert.AreEqual(msg.Properties.GetString(propertyName), floatValue.ToString()); try { msg.Properties.GetBool(propertyName); Assert.Fail("Should have thrown exception"); } catch(MessageFormatException) { } try { msg.Properties.GetByte(propertyName); Assert.Fail("Should have thrown exception"); } catch(MessageFormatException) { } try { msg.Properties.GetShort(propertyName); Assert.Fail("Should have thrown exception"); } catch(MessageFormatException) { } try { msg.Properties.GetInt(propertyName); Assert.Fail("Should have thrown exception"); } catch(MessageFormatException) { } try { msg.Properties.GetLong(propertyName); Assert.Fail("Should have thrown exception"); } catch(MessageFormatException) { } }
public void TestGetLongProperty() { ActiveMQMessage msg = new ActiveMQMessage(); string name = "longProperty"; msg.Properties.SetLong(name, 1); Assert.IsTrue(msg.Properties.GetLong(name) == 1); }
public void TestGetObjectProperty() { ActiveMQMessage msg = new ActiveMQMessage(); string name = "floatProperty"; msg.Properties.SetFloat(name, 1.3f); Assert.IsTrue(msg.Properties[name] is float); Assert.IsTrue((float)msg.Properties[name] == 1.3f); }
public void TestGetAndSetNMSReplyTo() { ActiveMQMessage msg = new ActiveMQMessage(); msg.NMSReplyTo = this.nmsReplyTo; Assert.AreEqual(msg.NMSReplyTo, this.nmsReplyTo); }
public void TestGetShortProperty() { ActiveMQMessage msg = new ActiveMQMessage(); string name = "shortProperty"; msg.Properties.SetShort(name, (short)1); Assert.IsTrue(msg.Properties.GetShort(name) == 1); }
public void TestGetAndSetNMSType() { ActiveMQMessage msg = new ActiveMQMessage(); msg.NMSType = this.nmsType; Assert.AreEqual(msg.NMSType, this.nmsType); }
public void TestPropertyExists() { ActiveMQMessage msg = new ActiveMQMessage(); msg.Properties.SetString("test", "test"); Assert.IsTrue(msg.Properties.Contains("test")); }
public void TestGetAndSetNMSXDeliveryCount() { ActiveMQMessage msg = new ActiveMQMessage(); msg.Properties.SetInt("NMSXDeliveryCount", 1); int count = msg.Properties.GetInt("NMSXDeliveryCount"); Assert.IsTrue(count == 1, "expected delivery count = 1 - got: " + count); }
public void TestSetNullProperty() { ActiveMQMessage msg = new ActiveMQMessage(); string name = "cheese"; msg.Properties.SetString(name, "Cheddar"); Assert.AreEqual("Cheddar", msg.Properties.GetString(name)); msg.Properties.SetString(name, null); Assert.AreEqual(null, msg.Properties.GetString(name)); }
public void TestGetBooleanProperty() { ActiveMQMessage msg = new ActiveMQMessage(); string name = "booleanProperty"; msg.Properties.SetBool(name, true); Assert.IsTrue(msg.Properties.GetBool(name)); }
public void TestSetObjectProperty() { ActiveMQMessage msg = new ActiveMQMessage(); string name = "property"; try { msg.Properties[name] = "string"; msg.Properties[name] = (Byte) 1; msg.Properties[name] = (Int16) 1; msg.Properties[name] = (Int32) 1; msg.Properties[name] = (Int64) 1; msg.Properties[name] = (Single) 1.1f; msg.Properties[name] = (Double) 1.1; msg.Properties[name] = (Boolean) true; msg.Properties[name] = null; } catch(MessageFormatException) { Assert.Fail("should accept object primitives and String"); } try { msg.Properties[name] = new Object(); Assert.Fail("should accept only object primitives and String"); } catch(MessageFormatException) { } try { msg.Properties[name] = new StringBuilder(); Assert.Fail("should accept only object primitives and String"); } catch(MessageFormatException) { } }
public void TestGetByteProperty() { ActiveMQMessage msg = new ActiveMQMessage(); string name = "byteProperty"; msg.Properties.SetByte(name, (byte)1); Assert.IsTrue(msg.Properties.GetByte(name) == 1); }
public void TestShallowCopy() { ActiveMQMessage msg1 = new ActiveMQMessage(); msg1.NMSMessageId = nmsMessageID; ActiveMQMessage msg2 = (ActiveMQMessage) msg1.Clone(); Assert.IsTrue(msg1 != msg2 && msg1.Equals(msg2)); }
public void TestGetDoubleProperty() { ActiveMQMessage msg = new ActiveMQMessage(); string name = "doubleProperty"; msg.Properties.SetDouble(name, 1.3d); Assert.IsTrue(msg.Properties.GetDouble(name) == 1.3); }
public void TestStringPropertyConversion() { ActiveMQMessage msg = new ActiveMQMessage(); String propertyName = "property"; String stringValue = "True"; msg.Properties.SetString(propertyName, stringValue); Assert.AreEqual(msg.Properties.GetString(propertyName), stringValue); Assert.AreEqual((string)msg.Properties[propertyName], stringValue); Assert.AreEqual(msg.Properties.GetBool(propertyName), true); stringValue = "1"; msg.Properties.SetString(propertyName, stringValue); Assert.AreEqual(msg.Properties.GetByte(propertyName), 1); Assert.AreEqual(msg.Properties.GetShort(propertyName), 1); Assert.AreEqual(msg.Properties.GetInt(propertyName), 1); Assert.AreEqual(msg.Properties.GetLong(propertyName), 1); Double doubleValue = 1.5; stringValue = doubleValue.ToString(); msg.Properties.SetString(propertyName, stringValue); Assert.AreEqual(msg.Properties.GetFloat(propertyName), 1.5, 0); Assert.AreEqual(msg.Properties.GetDouble(propertyName), 1.5, 0); stringValue = "bad"; msg.Properties.SetString(propertyName, stringValue); try { msg.Properties.GetByte(propertyName); Assert.Fail("Should have thrown exception"); } catch(MessageFormatException) { } try { msg.Properties.GetShort(propertyName); Assert.Fail("Should have thrown exception"); } catch(MessageFormatException) { } try { msg.Properties.GetInt(propertyName); Assert.Fail("Should have thrown exception"); } catch(MessageFormatException) { } try { msg.Properties.GetLong(propertyName); Assert.Fail("Should have thrown exception"); } catch(MessageFormatException) { } try { msg.Properties.GetFloat(propertyName); Assert.Fail("Should have thrown exception"); } catch(MessageFormatException) { } try { msg.Properties.GetDouble(propertyName); Assert.Fail("Should have thrown exception"); } catch(MessageFormatException) { } Assert.IsFalse(msg.Properties.GetBool(propertyName)); }
public void TestGetFloatProperty() { ActiveMQMessage msg = new ActiveMQMessage(); string name = "floatProperty"; msg.Properties.SetFloat(name, 1.3f); Assert.IsTrue(msg.Properties.GetFloat(name) == 1.3f); }