public void GetTopic() { Topic topic = new Topic(TestDataFactory.RandomTopicName()); Assert.NotNull(validClient.CreateTopic(topic)); Topic remoteTopic = validClient.GetTopic(topic.Name); Assert.NotNull(remoteTopic); Assert.AreEqual(remoteTopic.Name, topic.Name); }
public void DeleteTopic() { Topic topic = new Topic(TestDataFactory.RandomTopicName()); T("Topic " + topic.Name); Assert.NotNull(validClient.CreateTopic(topic)); bool result = false; Assert.DoesNotThrow( delegate { result = validClient.DeleteTopic(topic.Name); }); Assert.IsTrue(result); }
public void CreateTopic() { string topicName = TestDataFactory.RandomTopicName(); T("Topic " + topicName); Topic topic = new Topic(topicName); topic.Tags.AddRange(new string[] {"test", "csharp"}); Topic topicRemote = validClient.CreateTopic(topic); Assert.NotNull(topicRemote); Assert.AreEqual(topicRemote.Name, topicName); }
public void UpdateTopic() { string topicName = TestDataFactory.RandomTopicName(); T("Topic " + topicName); Topic topic = new Topic(topicName); topic.Tags.AddRange(new string[] { "test", "csharp" }); Topic topicRemote = validClient.CreateTopic(topic); Assert.NotNull(topicRemote); Assert.AreEqual(topicRemote.Name, topicName); string randomString = TestDataFactory.RandomHexString(32); T("Tagging with " + randomString); topicRemote.Tags.Add(randomString); Topic updatedTopic = validClient.UpdateTopic(topicRemote); Assert.NotNull(updatedTopic); Assert.AreEqual(updatedTopic.Name, topic.Name); Assert.IsTrue(updatedTopic.Tags.Contains(randomString)); }
public MessageList PublishToTopic(Topic topic, MessageList messages) { return PublishToTopic(topic.Name, messages); }
public void PushSingleToTopic() { string topicName = TestDataFactory.RandomTopicName(); T("Topic " + topicName); Topic newTopic = new Topic(topicName); Topic topic = validClient.CreateTopic(newTopic); Assert.NotNull(topic); Assert.AreEqual(topicName, topic.Name); string randomBody = TestDataFactory.RandomHexString(); Message msg = new Message(); msg.Fields["test Key"] = TestDataFactory.RandomHexString(10); msg.Body = randomBody; Assert.AreEqual(randomBody, msg.Body); Message returnMsg = validClient.PublishToTopic(topic, msg); Assert.IsNotEmpty(returnMsg.ID); Assert.AreEqual(returnMsg.Body, msg.Body); Assert.AreEqual(returnMsg.Fields["test Key"], msg.Fields["test Key"]); T("Msg ID: " + returnMsg.ID); T("Msg Body: " + returnMsg.Body); T("Msg Field: testKey=" + returnMsg.Fields["test Key"]); }
public Topic GetTopic(string name, bool getSubscriptions = false) { MessagingRequest request = new MessagingRequest("topics/{topicName}", Method.GET); request.AddUrlSegment("topicName", name); request.HttpStatusSuccessCodes.Add(200); request.HttpStatusExceptionMap.Add(404, typeof(TopicNotFoundException)); TopicResponse response = client.Execute<TopicResponse>(request); Topic tmpTopic = new Topic(); tmpTopic.Name = response.name; tmpTopic.Tags = new TagList(response.tags); if (getSubscriptions) { tmpTopic.Subscriptions = GetTopicSubscriptionList(tmpTopic.Name); } return tmpTopic; }
public void DeleteSubscribedTopicFailure() { Topic topic = new Topic(TestDataFactory.RandomTopicName()); T("Topic " + topic.Name); Assert.NotNull(validClient.CreateTopic(topic)); HttpTopicSubscription sub = new HttpTopicSubscription(); sub.HttpMethod = HttpTopicSubscriptionMethod.GET; sub.URL = "http://into.oblivion/"; Assert.NotNull(validClient.CreateTopicSubscription(topic, sub)); bool result = false; Assert.Throws<TopicHasSubscriptionsException>( delegate { result = validClient.DeleteTopic(topic.Name); }); Assert.IsFalse(result); }
public void ListTopicsWithNew() { Topic topic = new Topic(TestDataFactory.RandomTopicName()); Topic newTopic = validClient.CreateTopic(topic); Assert.IsNotNull(newTopic); T("Created topic " + newTopic.Name); List<Topic> topicList = null; Assert.DoesNotThrow( delegate { topicList = validClient.GetTopicList(); }); Assert.IsNotNull(topicList); Assert.IsTrue(topicList.Count > 0); Topic remoteTopic = topicList.Find( delegate(Topic tmpTopic) { return (tmpTopic.Name == newTopic.Name); }); Assert.IsNotNull(remoteTopic); }
public bool DeleteTopicSubscription(Topic topic, ITopicSubscription subscription) { return DeleteTopicSubscription(topic.Name, subscription.GetID()); }
public bool DeleteTopicSubscription(Topic topic, string subscriptionId) { return DeleteTopicSubscription(topic.Name, subscriptionId); }
public TopicSubscriptionList GetTopicSubscriptionList(Topic topic) { return GetTopicSubscriptionList(topic.Name); }
public bool DeleteTopic(Topic topic, bool forceDeletion = false) { return DeleteTopic(topic.Name, forceDeletion); }
public QueueTopicSubscription CreateTopicSubscription(Topic topic, QueueTopicSubscription subscription) { MessagingRequest request = new MessagingRequest("topics/{topicName}/subscriptions", Method.POST); request.AddUrlSegment("topicName", topic.Name); request.HttpStatusSuccessCodes.Add(200); request.HttpStatusExceptionMap.Add(400, typeof(BadRequestException)); request.HttpStatusSuccessCodes.Add(201); object postObj = new { endpoint_type = "queue", endpoint = new { queue_name = subscription.QueueName } }; if (DebugRequests) { Console.WriteLine("-> " + request.JsonSerializer.Serialize(postObj)); } request.AddBody(postObj); SubscriptionResponse response = client.Execute<SubscriptionResponse>(request); subscription.ID = response.id; subscription.QueueName = response.endpoint.queue_name; return subscription; }
public Topic CreateTopic(string topicName) { Topic topic = new Topic(topicName); return CreateOrUpdateTopic(topic, true); }
public HttpTopicSubscription CreateTopicSubscription(Topic topic, HttpTopicSubscription subscription) { MessagingRequest request = new MessagingRequest("topics/{topicName}/subscriptions", Method.POST); request.AddUrlSegment("topicName", topic.Name); request.HttpStatusSuccessCodes.Add(200); request.HttpStatusExceptionMap.Add(400, typeof(BadRequestException)); request.HttpStatusSuccessCodes.Add(201); object postObj = new { endpoint_type = "http", endpoint = new { method = subscription.HttpMethod.ToString(), url = subscription.URL, // Escaping the params member with an @ is required, as "params" is a reserved word in C#. @params = subscription.Parameters, headers = subscription.Headers, body = subscription.Body } }; if (DebugRequests) { Console.WriteLine("-> " + request.JsonSerializer.Serialize(postObj)); } request.AddBody(postObj); SubscriptionResponse response = client.Execute<SubscriptionResponse>(request); subscription.ID = response.id; subscription.URL = response.endpoint.url; subscription.Headers = response.endpoint.headers; subscription.Parameters = response.endpoint.@params; subscription.Body = response.endpoint.body; switch (response.endpoint.method) { case "GET": subscription.HttpMethod = HttpTopicSubscriptionMethod.GET; break; case "POST": subscription.HttpMethod = HttpTopicSubscriptionMethod.POST; break; case "PUT": subscription.HttpMethod = HttpTopicSubscriptionMethod.PUT; break; } return subscription; }
private Topic CreateOrUpdateTopic(Topic topic, bool create = true) { MessagingRequest request = new MessagingRequest("topics/{topicName}", Method.PUT); request.AddUrlSegment("topicName", topic.Name); request.HttpStatusSuccessCodes.Add(200); request.HttpStatusExceptionMap.Add(400, typeof(BadRequestException)); if (create) { request.HttpStatusSuccessCodes.Add(201); } else { request.HttpStatusSuccessCodes.Add(200); } object postObj = new { tags = topic.Tags }; if (DebugRequests) { Console.WriteLine("-> " + request.JsonSerializer.Serialize(postObj)); } request.AddBody(postObj); TopicResponse response = client.Execute<TopicResponse>(request); topic.Name = response.name; topic.Tags = new TagList(response.tags); return topic; }
public Topic UpdateTopic(Topic topic) { return CreateOrUpdateTopic(topic, false); }
public Topic CreateTopic(Topic topic) { return CreateOrUpdateTopic(topic, true); }
public Topic CreateTopic(string topicName, TagList tags) { Topic topic = new Topic(topicName); topic.Tags = tags; return CreateOrUpdateTopic(topic, true); }
public Message PublishToTopic(Topic topic, Message message) { return PublishToTopic(topic.Name, message); }
public TopicList GetTopicList(IEnumerable<string> tagList, bool populateSubscriptions = false) { TopicList topicList = new TopicList(); MessagingRequest request = new MessagingRequest("topics"); request.HttpStatusSuccessCodes.Add(200); if (tagList != null) { request.AddParameter("tags", new TagList(tagList).ToString(",")); } EntityListResponse<TopicResponse> topicListResponse = client.Execute<EntityListResponse<TopicResponse>>(request); foreach (TopicResponse tmpTopic in topicListResponse.items) { Topic topic = new Topic(tmpTopic.name); if (tmpTopic.tags != null) { topic.Tags = new TagList(tmpTopic.tags); } if (populateSubscriptions) { topic.Subscriptions = GetTopicSubscriptionList(topic); } topicList.Add(topic); } return topicList; }