Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
import java.net.URI;
import java.util.concurrent.ExecutionException;

import com.microsoft.azure.servicebus.management.*;
import com.microsoft.azure.servicebus.management.EntityNameHelper;
import com.microsoft.azure.servicebus.management.ManagementClientAsync;
import com.microsoft.azure.servicebus.management.QueueDescription;
import com.microsoft.azure.servicebus.management.SubscriptionDescription;
import com.microsoft.azure.servicebus.management.TopicDescription;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
Expand Down Expand Up @@ -76,9 +80,9 @@ public void tearDown() throws ServiceBusException, InterruptedException, Executi
}
if (this.receiveClient != null) {
if (this.receiveClient instanceof SubscriptionClient) {
((SubscriptionClient)this.receiveClient).close();
((SubscriptionClient) this.receiveClient).close();
} else {
((QueueClient)this.receiveClient).close();
((QueueClient) this.receiveClient).close();
}
}

Expand All @@ -91,7 +95,7 @@ public void tearDown() throws ServiceBusException, InterruptedException, Executi

@AfterClass
public static void cleanupAfterAllTest() throws ExecutionException, InterruptedException, IOException {
if (managementClient != null ) {
if (managementClient != null) {
if (ClientSessionTests.entityNameCreatedForAllTests != null) {
managementClient.deleteQueueAsync(ClientSessionTests.entityNameCreatedForAllTests).get();
}
Expand All @@ -103,7 +107,7 @@ public static void cleanupAfterAllTest() throws ExecutionException, InterruptedE
private void createClients(ReceiveMode receiveMode) throws InterruptedException, ServiceBusException {
if (this.isEntityQueue()) {
this.sendClient = new QueueClient(TestUtils.getNamespaceEndpointURI(), this.entityName, TestUtils.getClientSettings(), receiveMode);
this.receiveClient = (QueueClient)this.sendClient;
this.receiveClient = (QueueClient) this.sendClient;
} else {
this.sendClient = new TopicClient(TestUtils.getNamespaceEndpointURI(), this.entityName, TestUtils.getClientSettings());
this.receiveClient = new SubscriptionClient(TestUtils.getNamespaceEndpointURI(), this.receiveEntityPath, TestUtils.getClientSettings(), receiveMode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
import java.net.URI;
import java.util.concurrent.ExecutionException;

import com.microsoft.azure.servicebus.management.*;
import com.microsoft.azure.servicebus.management.EntityNameHelper;
import com.microsoft.azure.servicebus.management.ManagementClientAsync;
import com.microsoft.azure.servicebus.management.QueueDescription;
import com.microsoft.azure.servicebus.management.SubscriptionDescription;
import com.microsoft.azure.servicebus.management.TopicDescription;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
Expand Down Expand Up @@ -74,9 +78,9 @@ public void tearDown() throws ServiceBusException, InterruptedException, Executi
}
if (this.receiveClient != null) {
if (this.receiveClient instanceof SubscriptionClient) {
((SubscriptionClient)this.receiveClient).close();
((SubscriptionClient) this.receiveClient).close();
} else {
((QueueClient)this.receiveClient).close();
((QueueClient) this.receiveClient).close();
}
}

Expand All @@ -99,11 +103,10 @@ public static void cleanupAfterAllTest() throws ExecutionException, InterruptedE
managementClientAsync.close();
}

protected void createClients(ReceiveMode receiveMode) throws InterruptedException, ServiceBusException
{
protected void createClients(ReceiveMode receiveMode) throws InterruptedException, ServiceBusException {
if (this.isEntityQueue()) {
this.sendClient = new QueueClient(TestUtils.getNamespaceEndpointURI(), this.entityName, TestUtils.getClientSettings(), receiveMode);
this.receiveClient = (QueueClient)this.sendClient;
this.receiveClient = (QueueClient) this.sendClient;
} else {
this.sendClient = new TopicClient(TestUtils.getNamespaceEndpointURI(), this.entityName, TestUtils.getClientSettings());
this.receiveClient = new SubscriptionClient(TestUtils.getNamespaceEndpointURI(), this.receiveEntityPath, TestUtils.getClientSettings(), receiveMode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
import java.util.concurrent.ExecutionException;
import java.util.concurrent.atomic.AtomicBoolean;

import com.microsoft.azure.servicebus.management.*;
import com.microsoft.azure.servicebus.management.ManagementClientAsync;
import com.microsoft.azure.servicebus.management.QueueDescription;
import com.microsoft.azure.servicebus.management.SubscriptionDescription;
import com.microsoft.azure.servicebus.management.TopicDescription;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
Expand Down Expand Up @@ -164,8 +167,7 @@ public CompletableFuture<Void> onMessageAsync(IMessageSession session, IMessage

@Override
public void notifyException(Throwable exception, ExceptionPhase phase) {
if(exception instanceof UnsupportedOperationException && phase == ExceptionPhase.ACCEPTSESSION)
{
if (exception instanceof UnsupportedOperationException && phase == ExceptionPhase.ACCEPTSESSION) {
unsupportedExceptionOccured.set(true);
}
}
Expand Down Expand Up @@ -201,8 +203,7 @@ public CompletableFuture<Void> onMessageAsync(IMessageSession session, IMessage

@Override
public void notifyException(Throwable exception, ExceptionPhase phase) {
if(exception instanceof UnsupportedOperationException && phase == ExceptionPhase.ACCEPTSESSION)
{
if (exception instanceof UnsupportedOperationException && phase == ExceptionPhase.ACCEPTSESSION) {
unsupportedExceptionOccured.set(true);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,28 @@

package com.microsoft.azure.servicebus;

import com.microsoft.azure.servicebus.management.*;
import com.microsoft.azure.servicebus.primitives.*;
import com.microsoft.azure.servicebus.rules.*;
import com.microsoft.azure.servicebus.management.AccessRights;
import com.microsoft.azure.servicebus.management.AuthorizationRule;
import com.microsoft.azure.servicebus.management.EntityNameHelper;
import com.microsoft.azure.servicebus.management.ManagementClientAsync;
import com.microsoft.azure.servicebus.management.NamespaceInfo;
import com.microsoft.azure.servicebus.management.NamespaceType;
import com.microsoft.azure.servicebus.management.QueueDescription;
import com.microsoft.azure.servicebus.management.QueueRuntimeInfo;
import com.microsoft.azure.servicebus.management.SharedAccessAuthorizationRule;
import com.microsoft.azure.servicebus.management.SubscriptionDescription;
import com.microsoft.azure.servicebus.management.SubscriptionRuntimeInfo;
import com.microsoft.azure.servicebus.management.TopicDescription;
import com.microsoft.azure.servicebus.management.TopicRuntimeInfo;
import com.microsoft.azure.servicebus.primitives.MessagingEntityAlreadyExistsException;
import com.microsoft.azure.servicebus.primitives.MessagingEntityNotFoundException;
import com.microsoft.azure.servicebus.primitives.MessagingFactory;
import com.microsoft.azure.servicebus.primitives.ServiceBusException;
import com.microsoft.azure.servicebus.rules.CorrelationFilter;
import com.microsoft.azure.servicebus.rules.FalseFilter;
import com.microsoft.azure.servicebus.rules.RuleDescription;
import com.microsoft.azure.servicebus.rules.SqlFilter;
import com.microsoft.azure.servicebus.rules.SqlRuleAction;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
Expand Down Expand Up @@ -246,7 +265,7 @@ public void basicRulesCrudTest() throws InterruptedException, ExecutionException
Assert.assertEquals(rule1, rules.get(1));
Assert.assertEquals(rule2, rules.get(2));

((CorrelationFilter)(rule2.getFilter())).setCorrelationId("correlationIdModified");
((CorrelationFilter) (rule2.getFilter())).setCorrelationId("correlationIdModified");
RuleDescription updatedRule2 = this.managementClientAsync.updateRuleAsync(topicName, subscriptionName, rule2).get();
Assert.assertEquals(rule2, updatedRule2);

Expand Down Expand Up @@ -372,39 +391,39 @@ public void getTopicAndSubscriptionRuntimeInfoTest() throws ExecutionException,
public void messagingEntityNotFoundExceptionTest() throws ServiceBusException, InterruptedException, ExecutionException {
try {
Utils.completeFuture(this.managementClientAsync.getQueueAsync("NonExistingPath"));
} catch (MessagingEntityNotFoundException e) {}
} catch (MessagingEntityNotFoundException e) { }

try {
Utils.completeFuture(this.managementClientAsync.getTopicAsync("NonExistingPath"));
} catch (MessagingEntityNotFoundException e) {}
} catch (MessagingEntityNotFoundException e) { }

try {
Utils.completeFuture(this.managementClientAsync.getSubscriptionAsync("NonExistingTopic", "NonExistingPath"));
} catch (MessagingEntityNotFoundException e) {}
} catch (MessagingEntityNotFoundException e) { }

try {
Utils.completeFuture(this.managementClientAsync.updateQueueAsync(new QueueDescription("NonExistingPath")));
} catch (MessagingEntityNotFoundException e) {}
} catch (MessagingEntityNotFoundException e) { }
Comment thread
conniey marked this conversation as resolved.

try {
Utils.completeFuture(this.managementClientAsync.updateTopicAsync(new TopicDescription("NonExistingPath")));
} catch (MessagingEntityNotFoundException e) {}
} catch (MessagingEntityNotFoundException e) { }

try {
Utils.completeFuture(this.managementClientAsync.updateSubscriptionAsync(new SubscriptionDescription("NonExistingTopic", "NonExistingPath")));
} catch (MessagingEntityNotFoundException e) {}
} catch (MessagingEntityNotFoundException e) { }

try {
Utils.completeFuture(this.managementClientAsync.deleteQueueAsync("NonExistingPath"));
} catch (MessagingEntityNotFoundException e) {}
} catch (MessagingEntityNotFoundException e) { }

try {
Utils.completeFuture(this.managementClientAsync.deleteTopicAsync("NonExistingPath"));
} catch (MessagingEntityNotFoundException e) {}
} catch (MessagingEntityNotFoundException e) { }

try {
Utils.completeFuture(this.managementClientAsync.deleteSubscriptionAsync("nonExistingTopic", "NonExistingPath"));
} catch (MessagingEntityNotFoundException e) {}
} catch (MessagingEntityNotFoundException e) { }

String queueName = UUID.randomUUID().toString().substring(0, 8);
String topicName = UUID.randomUUID().toString().substring(0, 8);
Expand All @@ -414,15 +433,15 @@ public void messagingEntityNotFoundExceptionTest() throws ServiceBusException, I

try {
Utils.completeFuture(this.managementClientAsync.getQueueAsync(topicName));
} catch (MessagingEntityNotFoundException e) {}
} catch (MessagingEntityNotFoundException e) { }

try {
Utils.completeFuture(this.managementClientAsync.getTopicAsync(queueName));
} catch (MessagingEntityNotFoundException e) {}
} catch (MessagingEntityNotFoundException e) { }

try {
Utils.completeFuture(this.managementClientAsync.getSubscriptionAsync(topicName, "NonExistingSubscription"));
} catch (MessagingEntityNotFoundException e) {}
} catch (MessagingEntityNotFoundException e) { }

this.managementClientAsync.deleteQueueAsync(queueName).get();
this.managementClientAsync.deleteTopicAsync(topicName).get();
Expand All @@ -439,15 +458,15 @@ public void messagingEntityAlreadyExistsExceptionTest() throws ServiceBusExcepti

try {
Utils.completeFuture(this.managementClientAsync.createQueueAsync(queueName));
} catch (MessagingEntityAlreadyExistsException e) {}
} catch (MessagingEntityAlreadyExistsException e) { }

try {
Utils.completeFuture(this.managementClientAsync.createTopicAsync(topicName));
} catch (MessagingEntityAlreadyExistsException e) {}
} catch (MessagingEntityAlreadyExistsException e) { }

try {
Utils.completeFuture(this.managementClientAsync.createSubscriptionAsync(topicName, subscriptionName));
} catch (MessagingEntityAlreadyExistsException e) {}
} catch (MessagingEntityAlreadyExistsException e) { }

this.managementClientAsync.deleteQueueAsync(queueName).get();
this.managementClientAsync.deleteSubscriptionAsync(topicName, subscriptionName).get();
Expand Down
Loading