public void empty_message_has_no_subject() { var rvm = new Rv.Message(); var msg = new ReadOnlyRvMessage(rvm, null); Assert.AreEqual(null, msg.Subject); }
public void can_read_null_TTL() { var rvm = new Rv.Message(); var headers = new ReadOnlyRvMessageHeaders(rvm); Assert.IsNull(headers.TimeToLive); }
public void ContainsKey_returns_false_for_undefined_property(string name) { var rvm = new Rv.Message(); var headers = new ReadOnlyRvMessageHeaders(rvm); Assert.IsFalse(headers.ContainsKey(name)); }
public void can_read_null_Priority() { var rvm = new Rv.Message(); var headers = new ReadOnlyRvMessageHeaders(rvm); Assert.IsNull(headers.Priority); }
public void can_enumerate_zero_pairs() { var rvm = new Rv.Message(); var headers = new ReadOnlyRvMessageHeaders(rvm); Assert.AreEqual(0, headers.Count()); }
public static Message FromRvMessage(Rv.Message rv, Uri source) { Contract.Requires(rv != null); Contract.Requires(source != null); var msg = new Message { Subject = rv.SendSubject }; if (!string.IsNullOrWhiteSpace(rv.ReplySubject)) { msg.Headers.ReplyTo = new Uri(source, rv.ReplySubject.FromRvSubject()); } for (uint i = 0; i < rv.FieldCount; i++) { MessageField f = rv.GetFieldByIndex(i); if (f.Name == Fields.ReplyTo) { var xReplyTo = f.Value?.ToString(); if (!string.IsNullOrWhiteSpace(xReplyTo)) { msg.Headers.ReplyTo = new Uri(f.Value.ToString()); continue; } } msg.Headers.Add(f.Name, f.Value); } return(msg); }
public static Rv.Message ToRvMessge(IReadOnlyMessage msg, Uri source) { Contract.Requires(msg != null); Contract.Requires(source != null); var rvm = new Rv.Message(); if (msg.Subject != null) { rvm.SendSubject = ToRvSubject(msg.Subject); } if (msg.HasHeaders) { if (msg.Headers.ReplyTo != null) { AddReplyTo(source, rvm, msg.Headers.ReplyTo); } if (msg.Headers.Priority.HasValue) { AddPriority(msg, rvm); } foreach (KeyValuePair <string, object> pair in msg.Headers) { AddRvField(rvm, pair.Key, pair.Value); } } if (msg.Body != null) { AddRvField(rvm, Fields.Body, msg.Body); } return(rvm); }
public void empty_message_has_zero_headers() { var rvm = new Rv.Message(); var msg = new ReadOnlyRvMessage(rvm, null); Assert.AreEqual(0, msg.Headers.Count); }
public void can_send_a_message() { var rvt = Rv.IntraProcessTransport.UniqueInstance; var q = Rv.Queue.Default; var listener = new Rv.Listener(q, rvt, "say.hello", null); Rv.Dispatcher dis = null; try { // start a listener that sets the event when it gets a message Rv.Message got = null; var evt = new AutoResetEvent(false); listener.MessageReceived += (sender, args) => { got = args.Message; evt.Set(); }; dis = new Rv.Dispatcher(q, 10.0); Message input = HelloWorldMessage("/say/hello"); using (var trans = new RvMessaging(new Uri("rv+ipc://localhost"), rvt)) trans.Send(input); Assert.IsTrue(evt.WaitOne(2000), "timeouted waiting for RV message"); Assert.IsNotNull(got); } finally { dis.Destroy(); listener.Destroy(); } }
public void empty_message_has_null_body() { var rvm = new Rv.Message(); var msg = new ReadOnlyRvMessage(rvm, null); Assert.AreEqual(null, msg.Body); }
public void empty_message_has_no_reply_uri() { var rvm = new Rv.Message(); var msg = new ReadOnlyRvMessage(rvm, null); Assert.AreEqual(null, msg.Headers.ReplyTo); }
public void cannot_access_the_body_via_the_header() { var rvm = new Rv.Message(); rvm.AddField("Body", "value"); var headers = new ReadOnlyRvMessageHeaders(rvm); var ignoreed = headers["Body"]; }
public void TryGetValue_returns_false_for_undefined_property(string name) { var rvm = new Rv.Message(); var headers = new ReadOnlyRvMessageHeaders(rvm); object valueOut; Assert.IsFalse(headers.TryGetValue(name, out valueOut)); }
public void ReplyTo_is_set_from_source_and_rv_ReplySubject_with_slashes_replacing_dots() { var rvm = new Rv.Message(); rvm.ReplySubject = "test.topic"; var msg = new ReadOnlyRvMessage(rvm, new Uri("rv://service")); Assert.AreEqual(new Uri("rv://service/test/topic"), msg.Headers.ReplyTo); }
public void ContainsKey_returns_true_for_defined_int_property(string name, int value) { var rvm = new Rv.Message(); rvm.AddField(name, value); var headers = new ReadOnlyRvMessageHeaders(rvm); Assert.IsTrue(headers.ContainsKey(name)); }
public void can_create_message_with_body() { var rvm = new Rv.Message(); rvm.AddField("Body", "hello"); var msg = new ReadOnlyRvMessage(rvm, null); Assert.AreEqual("hello", msg.Body); }
public void message_Subject_comes_from_rv_SendSubject() { var rvm = new Rv.Message(); rvm.SendSubject = "test.topic"; var msg = new ReadOnlyRvMessage(rvm, null); Assert.AreEqual("test.topic", msg.Subject); }
public ReadOnlyRvMessage(Rv.Message msg, Uri source) { Contract.Requires(source != null); Contract.Requires(msg != null); _source = source; _msg = msg; _pressure = msg.Size; GC.AddMemoryPressure(_pressure); // RV does not add memory pressure, so we add it here so the CLR knows the underlying RV message contains unmanaged bytes }
public void enumerating_pairs_ignores_Body() { var rvm = new Rv.Message(); rvm.AddField("Body", "value"); var headers = new ReadOnlyRvMessageHeaders(rvm); Assert.AreEqual(0, headers.Count()); }
public void can_read_PriorityFromString() { var rvm = new Rv.Message(); rvm.AddField("Priority", "1"); var headers = new ReadOnlyRvMessageHeaders(rvm); Assert.AreEqual(1, headers.Priority); }
public void can_read_custom_header_int_value(string name, int value) { var rvm = new Rv.Message(); rvm.AddField(name, value); var headers = new ReadOnlyRvMessageHeaders(rvm); Assert.AreEqual(value, headers[name]); Assert.AreEqual(1, headers.Count, "headers.Count"); }
public void can_read_Priority() { var rvm = new Rv.Message(); rvm.AddField("Priority", 1); var headers = new ReadOnlyRvMessageHeaders(rvm); Assert.AreEqual(1, headers.Priority); Assert.AreEqual(1, headers.Count, "headers.Count"); }
public void can_enumerate_one_pair() { var rvm = new Rv.Message(); rvm.AddField("custom", "value"); var headers = new ReadOnlyRvMessageHeaders(rvm); Assert.AreEqual(1, headers.Count()); Assert.AreEqual(new KeyValuePair <string, string>("custom", "value"), headers.First()); }
public void can_read_content_type(string type) { var rvm = new Rv.Message(); rvm.AddField("ContentType", type); var headers = new ReadOnlyRvMessageHeaders(rvm); Assert.AreEqual(type, headers.ContentType); Assert.AreEqual(1, headers.Count, "headers.Count"); }
public void can_enumerate_one_value() { var rvm = new Rv.Message(); rvm.AddField("custom", "value"); var headers = new ReadOnlyRvMessageHeaders(rvm); Assert.AreEqual(1, headers.Values.Count()); Assert.AreEqual("value", headers.Values.First()); }
static void AddReplyTo(Uri source, Rv.Message rvm, Uri replyTo) { if (source.Scheme.IsRvScheme() && source.Host == replyTo.Host && source.Port == replyTo.Port) { rvm.ReplySubject = ToRvSubject(replyTo.AbsolutePath); } else { rvm.AddField(Fields.ReplyTo, replyTo.ToString()); } }
public void can_read_TTL() { var rvm = new Rv.Message(); var ttl = TimeSpan.FromMinutes(1); rvm.AddField("TimeToLive", ttl.ToString()); var headers = new ReadOnlyRvMessageHeaders(rvm); Assert.AreEqual(ttl, headers.TimeToLive); Assert.AreEqual(1, headers.Count, "headers.Count"); }
public void TryGetValue_returns_true_for_defined_int_property(string name, int value) { var rvm = new Rv.Message(); rvm.AddField(name, value); var headers = new ReadOnlyRvMessageHeaders(rvm); object valueOut; Assert.IsTrue(headers.TryGetValue(name, out valueOut)); Assert.AreEqual(value, valueOut, "valueOut"); }
public void can_enumerate_multiple_pairs() { var rvm = new Rv.Message(); rvm.AddField("custom1", "value1"); rvm.AddField("custom2", "value2"); var headers = new ReadOnlyRvMessageHeaders(rvm); Assert.AreEqual(new KeyValuePair <string, string>("custom1", "value1"), headers.First()); Assert.AreEqual(new KeyValuePair <string, string>("custom2", "value2"), headers.ElementAt(1)); Assert.AreEqual(2, headers.Count()); }
/// <summary> /// Test 용 Message Send Function /// </summary> /// <param name="sendMessage"></param> /// <param name="sendMSG"></param> public void SendMessage4Test(TIBCO.Rendezvous.Message sendMessage, string sendMSG) { try { sendMessage.SendSubject = REMOTE_SUBJECT; sendMessage.AddField(FIELD_NAME, sendMSG); tibTrans.Send(sendMessage); //CHECK NEED SystemLogger.Log(Level.Verbose, GetMessageLog(sendMSG, true), ToString(), this.Name); } catch (Exception ex) { //CHECK NEED SystemLogger.Log(ex); } }