Skip to content

Commit

Permalink
Merge pull request #14 from christav/sb-test-cleanup-118
Browse files Browse the repository at this point in the history
Clean up service bus assets created as part of test at the end.
  • Loading branch information
Chris Tavares committed Feb 27, 2013
2 parents 53350d6 + 742b0e2 commit 731245a
Showing 1 changed file with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import static com.microsoft.windowsazure.services.serviceBus.Util.*;

import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;

Expand Down Expand Up @@ -54,14 +55,32 @@ public void initialize() throws Exception {
for (TopicInfo topic : iterateTopics(service)) {
String topicName = topic.getPath();
if (topicName.startsWith("Test") || topicName.startsWith("test")) {
service.deleteQueue(topicName);
service.deleteTopic(topicName);
}
}
if (!testAlphaExists) {
service.createQueue(new QueueInfo("TestAlpha"));
}
}

@AfterClass
public static void cleanUpTestArtifacts() throws Exception {
Configuration config = createConfiguration();
ServiceBusContract service = ServiceBusService.create(config);
for (QueueInfo queue : iterateQueues(service)) {
String queueName = queue.getPath();
if (queueName.startsWith("Test") || queueName.startsWith("test")) {
service.deleteQueue(queueName);
}
}
for (TopicInfo topic : iterateTopics(service)) {
String topicName = topic.getPath();
if (topicName.startsWith("Test") || topicName.startsWith("test")) {
service.deleteTopic(topicName);
}
}
}

protected static Configuration createConfiguration() throws Exception {
Configuration config = Configuration.load();
overrideWithEnv(config, ServiceBusConfiguration.CONNECTION_STRING);
Expand Down

0 comments on commit 731245a

Please sign in to comment.