From 26ee6d923adf9f00c36a655a7bac9ca7770f61d2 Mon Sep 17 00:00:00 2001 From: Marco Ziccardi Date: Fri, 16 Sep 2016 21:41:06 +0200 Subject: [PATCH] Split integration tests for TopicSnippets --- .../pubsub/snippets/ITTopicSnippets.java | 33 +++++++++++++------ 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/google-cloud-examples/src/test/java/com/google/cloud/examples/pubsub/snippets/ITTopicSnippets.java b/google-cloud-examples/src/test/java/com/google/cloud/examples/pubsub/snippets/ITTopicSnippets.java index ae9d491b8a80..4a091c45248c 100644 --- a/google-cloud-examples/src/test/java/com/google/cloud/examples/pubsub/snippets/ITTopicSnippets.java +++ b/google-cloud-examples/src/test/java/com/google/cloud/examples/pubsub/snippets/ITTopicSnippets.java @@ -76,18 +76,31 @@ public void testTopic() throws ExecutionException, InterruptedException { assertEquals(2, topicSnippets.publishMessageListAsync().size()); assertEquals(2, topicSnippets.publishMessages().size()); assertEquals(2, topicSnippets.publishMessagesAsync().size()); + } + + @Test + public void testTopicSubscriptions() throws ExecutionException, InterruptedException { + TopicSnippets topicSnippets = new TopicSnippets(topic); pubsub.create(SubscriptionInfo.of(TOPIC, SUBSCRIPTION)); - Page subscriptions = topicSnippets.listSubscriptionsForTopic(); - while (Iterators.size(subscriptions.values().iterator()) < 1) { - subscriptions = topicSnippets.listSubscriptionsForTopic(); - } - assertEquals(SUBSCRIPTION, subscriptions.values().iterator().next().subscription()); - subscriptions = topicSnippets.listSubscriptionsForTopicAsync(); - while (Iterators.size(subscriptions.values().iterator()) < 1) { - subscriptions = topicSnippets.listSubscriptionsForTopic(); + try { + Page subscriptions = topicSnippets.listSubscriptionsForTopic(); + while (Iterators.size(subscriptions.values().iterator()) < 1) { + subscriptions = topicSnippets.listSubscriptionsForTopic(); + } + assertEquals(SUBSCRIPTION, subscriptions.values().iterator().next().subscription()); + subscriptions = topicSnippets.listSubscriptionsForTopicAsync(); + while (Iterators.size(subscriptions.values().iterator()) < 1) { + subscriptions = topicSnippets.listSubscriptionsForTopic(); + } + assertEquals(SUBSCRIPTION, subscriptions.values().iterator().next().subscription()); + } finally { + pubsub.deleteSubscription(SUBSCRIPTION); } - assertEquals(SUBSCRIPTION, subscriptions.values().iterator().next().subscription()); - pubsub.deleteSubscription(SUBSCRIPTION); + } + + @Test + public void testPolicy() throws ExecutionException, InterruptedException { + TopicSnippets topicSnippets = new TopicSnippets(topic); Policy policy = topicSnippets.getPolicy(); assertNotNull(policy); assertEquals(policy, topicSnippets.getPolicyAsync());