Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -36,6 +36,56 @@ public void find_subscription_by_uri()
subscription.SubscriptionName.ShouldBe("red");
}

[Fact]
public void find_topic_with_hierarchical_name_by_uri()
{
var transport = new AzureServiceBusTransport();
var topic = transport.GetOrCreateEndpoint(
new Uri("asb://topic/" + Uri.EscapeDataString("szrmgr/myevent")))
.ShouldBeOfType<AzureServiceBusTopic>();

topic.TopicName.ShouldBe("szrmgr/myevent");
}

[Fact]
public void find_subscription_on_hierarchical_topic_by_uri()
{
var transport = new AzureServiceBusTransport();
var subscription = transport.GetOrCreateEndpoint(
new Uri("asb://topic/" + Uri.EscapeDataString("szrmgr/myevent") + "/sub1"))
.ShouldBeOfType<AzureServiceBusSubscription>();

subscription.SubscriptionName.ShouldBe("sub1");
subscription.Topic.TopicName.ShouldBe("szrmgr/myevent");
}

[Fact]
public void hierarchical_topic_creates_correct_uri()
{
var transport = new AzureServiceBusTransport();
var topic = new AzureServiceBusTopic(transport, "szrmgr/myevent");

// URI should encode the slash so it's not confused with a path separator
topic.Uri.Host.ShouldBe("topic");
// Round-trip: resolving by URI should return a topic, not a subscription
transport.GetOrCreateEndpoint(topic.Uri)
.ShouldBeOfType<AzureServiceBusTopic>()
.TopicName.ShouldBe("szrmgr/myevent");
}

[Fact]
public void hierarchical_topic_subscription_creates_correct_uri()
{
var transport = new AzureServiceBusTransport();
var topic = new AzureServiceBusTopic(transport, "szrmgr/myevent");
var subscription = new AzureServiceBusSubscription(transport, topic, "sub1");

// Round-trip: resolving by URI should return the subscription
transport.GetOrCreateEndpoint(subscription.Uri)
.ShouldBeOfType<AzureServiceBusSubscription>()
.SubscriptionName.ShouldBe("sub1");
}

[Fact]
public void retry_and_response_queues_are_enabled_by_default()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,10 @@ protected override AzureServiceBusEndpoint findEndpointByUri(Uri uri)
switch (uri.Host)
{
case "queue":
return Queues[uri.Segments[1]];
return Queues[Uri.UnescapeDataString(uri.Segments[1])];

case "topic":
var topicName = uri.Segments[1].TrimEnd('/');
var topicName = Uri.UnescapeDataString(uri.Segments[1].TrimEnd('/'));
if (uri.Segments.Length == 3)
{
var subscription = Subscriptions.FirstOrDefault(x => x.Uri == uri);
Expand All @@ -266,7 +266,7 @@ protected override AzureServiceBusEndpoint findEndpointByUri(Uri uri)
return subscription;
}

var subscriptionName = uri.Segments.Last().TrimEnd('/');
var subscriptionName = Uri.UnescapeDataString(uri.Segments.Last().TrimEnd('/'));
var topic = Topics[topicName];
subscription = new AzureServiceBusSubscription(this, topic, subscriptionName);
Subscriptions.Add(subscription);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class AzureServiceBusQueue : AzureServiceBusEndpoint, IBrokerQueue, IMass

public AzureServiceBusQueue(AzureServiceBusTransport parent, string queueName,
EndpointRole role = EndpointRole.Application) : base(parent,
new Uri($"{parent.Protocol}://queue/{queueName}"), role)
new Uri($"{parent.Protocol}://queue/{Uri.EscapeDataString(queueName)}"), role)
{
if (parent == null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class AzureServiceBusSubscription : AzureServiceBusEndpoint, IBrokerQueue

public AzureServiceBusSubscription(AzureServiceBusTransport parent, AzureServiceBusTopic topic,
string subscriptionName) : base(parent,
new Uri($"{parent.Protocol}://topic/{topic.TopicName}/{subscriptionName}"),
new Uri($"{parent.Protocol}://topic/{Uri.EscapeDataString(topic.TopicName)}/{subscriptionName}"),
EndpointRole.Application)
{
if (parent == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class AzureServiceBusTopic : AzureServiceBusEndpoint
private bool _hasInitialized;

public AzureServiceBusTopic(AzureServiceBusTransport parent, string topicName) : base(parent,
new Uri($"{parent.Protocol}://topic/{topicName}"), EndpointRole.Application)
new Uri($"{parent.Protocol}://topic/{Uri.EscapeDataString(topicName)}"), EndpointRole.Application)
{
if (parent == null)
{
Expand Down
Loading