azure 0.7.1 → 0.7.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +31 -0
- data/azure.gemspec +2 -1
- data/lib/azure.rb +1 -0
- data/lib/azure/base_management/management_http_request.rb +3 -12
- data/lib/azure/blob/auth/shared_access_signature.rb +4 -0
- data/lib/azure/blob/blob_service.rb +2 -2
- data/lib/azure/client_services.rb +13 -13
- data/lib/azure/core/http/http_request.rb +3 -14
- data/lib/azure/core/service.rb +2 -1
- data/lib/azure/http_client.rb +1 -17
- data/lib/azure/http_response_helper.rb +38 -0
- data/lib/azure/sql_database_management/serialization.rb +4 -0
- data/lib/azure/sql_database_management/sql_database_management_service.rb +10 -9
- data/lib/azure/version.rb +1 -1
- data/lib/azure/virtual_machine_image_management/virtual_machine_image_management_service.rb +2 -2
- data/lib/azure/virtual_machine_management/serialization.rb +21 -12
- data/lib/azure/virtual_machine_management/virtual_machine_management_service.rb +8 -3
- metadata +17 -199
- data/test/fixtures/32px-fulls-black.jpg +0 -0
- data/test/fixtures/affinity_group.xml +0 -33
- data/test/fixtures/all_containers.xml +0 -20
- data/test/fixtures/all_tables.xml +0 -22
- data/test/fixtures/container_acl.xml +0 -11
- data/test/fixtures/create_sql_database_server.xml +0 -2
- data/test/fixtures/create_storage_desc_error.xml +0 -5
- data/test/fixtures/create_storage_extendedprop_error.xml +0 -8
- data/test/fixtures/create_storage_extendedpropname_error.xml +0 -6
- data/test/fixtures/create_storage_full_error.xml +0 -6
- data/test/fixtures/create_storage_label_error.xml +0 -5
- data/test/fixtures/create_storage_location_error.xml +0 -5
- data/test/fixtures/create_storage_name_error.xml +0 -6
- data/test/fixtures/create_table_response_entry.xml +0 -15
- data/test/fixtures/delete_storage_container_error.xml +0 -5
- data/test/fixtures/delete_storage_error.xml +0 -5
- data/test/fixtures/deployment_error.xml +0 -5
- data/test/fixtures/empty_xml_file +0 -0
- data/test/fixtures/get_storage_account_error.xml +0 -5
- data/test/fixtures/get_storage_account_properties.xml +0 -34
- data/test/fixtures/get_storage_account_properties_new.xml +0 -32
- data/test/fixtures/http_error.xml +0 -5
- data/test/fixtures/insert_entity_response_entry.xml +0 -25
- data/test/fixtures/list_affinity_groups.xml +0 -22
- data/test/fixtures/list_blobs.xml +0 -121
- data/test/fixtures/list_block_all_with_none_committed.xml +0 -22
- data/test/fixtures/list_blocks_all.xml +0 -23
- data/test/fixtures/list_blocks_committed.xml +0 -13
- data/test/fixtures/list_cloud_services.xml +0 -39
- data/test/fixtures/list_containers.xml +0 -38
- data/test/fixtures/list_firewall_management_endpoint.xml +0 -27
- data/test/fixtures/list_locations.xml +0 -212
- data/test/fixtures/list_os_images.xml +0 -110
- data/test/fixtures/list_page_ranges.xml +0 -11
- data/test/fixtures/list_sql_database.xml +0 -24
- data/test/fixtures/list_sql_server_firewall.xml +0 -23
- data/test/fixtures/list_storage_account_single.xml +0 -25
- data/test/fixtures/list_storage_accounts.xml +0 -48
- data/test/fixtures/list_virtual_networks.xml +0 -91
- data/test/fixtures/list_vm_images.xml +0 -21
- data/test/fixtures/logging.xml +0 -11
- data/test/fixtures/management_certificate.pem +0 -55
- data/test/fixtures/management_certificate.pfx +0 -0
- data/test/fixtures/management_certificate.publishsettings +0 -12
- data/test/fixtures/messages.xml +0 -12
- data/test/fixtures/metrics.xml +0 -10
- data/test/fixtures/privatekey.key +0 -28
- data/test/fixtures/query_entities_empty_response.xml +0 -7
- data/test/fixtures/query_entities_response.xml +0 -45
- data/test/fixtures/queue_service_properties.xml +0 -22
- data/test/fixtures/queue_service_properties_original.xml +0 -19
- data/test/fixtures/queues.xml +0 -16
- data/test/fixtures/retention_policy.xml +0 -5
- data/test/fixtures/sb_default_create_queue_response.xml +0 -23
- data/test/fixtures/sb_default_create_relay_response.xml +0 -15
- data/test/fixtures/sb_default_create_topic_response.xml +0 -18
- data/test/fixtures/sb_get_access_token_response.txt +0 -1
- data/test/fixtures/sb_queues_runtime_peek_message_response_headers.txt +0 -9
- data/test/fixtures/storage_service_keys.xml +0 -8
- data/test/fixtures/storage_service_properties.xml +0 -55
- data/test/fixtures/update_storage_account.xml +0 -16
- data/test/fixtures/update_storage_error.xml +0 -5
- data/test/fixtures/updated_storage_accounts.xml +0 -55
- data/test/fixtures/virtual_machine.xml +0 -116
- data/test/fixtures/windows_virtual_machine.xml +0 -106
- data/test/integration/affinity_group/Affinity_test.rb +0 -55
- data/test/integration/affinity_group/Create_Affinity_test.rb +0 -64
- data/test/integration/affinity_group/Delete_Affinity_test.rb +0 -56
- data/test/integration/affinity_group/List_Affinity_test.rb +0 -41
- data/test/integration/affinity_group/Update_Affinity_test.rb +0 -87
- data/test/integration/blob/blob_gb18030_test.rb +0 -199
- data/test/integration/blob/blob_metadata_test.rb +0 -75
- data/test/integration/blob/blob_pages_test.rb +0 -119
- data/test/integration/blob/blob_properties_test.rb +0 -77
- data/test/integration/blob/block_blob_test.rb +0 -303
- data/test/integration/blob/container/container_acl_test.rb +0 -69
- data/test/integration/blob/container/container_metadata_test.rb +0 -50
- data/test/integration/blob/container/create_container_test.rb +0 -60
- data/test/integration/blob/container/delete_container_test.rb +0 -39
- data/test/integration/blob/container/get_container_properties_test.rb +0 -48
- data/test/integration/blob/container/list_containers_test.rb +0 -79
- data/test/integration/blob/container/root_container_test.rb +0 -55
- data/test/integration/blob/copy_blob_test.rb +0 -113
- data/test/integration/blob/create_blob_snapshot_test.rb +0 -80
- data/test/integration/blob/create_page_blob_test.rb +0 -83
- data/test/integration/blob/delete_blob_test.rb +0 -159
- data/test/integration/blob/get_blob_test.rb +0 -65
- data/test/integration/blob/informative_errors_test.rb +0 -39
- data/test/integration/blob/lease/acquire_lease_test.rb +0 -36
- data/test/integration/blob/lease/break_lease_test.rb +0 -40
- data/test/integration/blob/lease/release_lease_test.rb +0 -40
- data/test/integration/blob/lease/renew_lease_test.rb +0 -42
- data/test/integration/blob/list_blobs_test.rb +0 -113
- data/test/integration/cloud_service/Cloud_Create_test.rb +0 -45
- data/test/integration/cloud_service/Cloud_Delete_test.rb +0 -45
- data/test/integration/database/create_sql_server_firewall_test.rb +0 -81
- data/test/integration/database/create_sql_server_test.rb +0 -53
- data/test/integration/database/delete_sql_server_firewall_test.rb +0 -63
- data/test/integration/database/delete_sql_server_test.rb +0 -44
- data/test/integration/database/list_sql_server_firewall_test.rb +0 -44
- data/test/integration/database/list_sql_servers_test.rb +0 -44
- data/test/integration/database/reset_password_sql_server_test.rb +0 -53
- data/test/integration/location/Location_List_test.rb +0 -38
- data/test/integration/location/RoleSize_List_test.rb +0 -34
- data/test/integration/queue/clear_messages_test.rb +0 -42
- data/test/integration/queue/create_message_test.rb +0 -75
- data/test/integration/queue/create_queue_test.rb +0 -50
- data/test/integration/queue/delete_message_test.rb +0 -67
- data/test/integration/queue/delete_queue_test.rb +0 -45
- data/test/integration/queue/informative_errors_test.rb +0 -42
- data/test/integration/queue/list_messages_encoded_test.rb +0 -79
- data/test/integration/queue/list_messages_test.rb +0 -79
- data/test/integration/queue/list_queues_test.rb +0 -43
- data/test/integration/queue/peek_messages_test.rb +0 -59
- data/test/integration/queue/queue_gb18030_test.rb +0 -131
- data/test/integration/queue/queue_metadata_test.rb +0 -40
- data/test/integration/queue/update_message_test.rb +0 -74
- data/test/integration/service_bus/informative_errors_test.rb +0 -37
- data/test/integration/service_bus/queues_scenario_test.rb +0 -200
- data/test/integration/service_bus/queues_test.rb +0 -266
- data/test/integration/service_bus/relay_test.rb +0 -132
- data/test/integration/service_bus/rules_test.rb +0 -145
- data/test/integration/service_bus/sb_queue_gb18030_test.rb +0 -182
- data/test/integration/service_bus/scenario_test.rb +0 -101
- data/test/integration/service_bus/subscriptions_test.rb +0 -211
- data/test/integration/service_bus/topics_scenario_test.rb +0 -406
- data/test/integration/service_bus/topics_test.rb +0 -129
- data/test/integration/storage_management/storage_management_test.rb +0 -185
- data/test/integration/table/create_table_test.rb +0 -36
- data/test/integration/table/delete_entity_batch_test.rb +0 -107
- data/test/integration/table/delete_entity_test.rb +0 -94
- data/test/integration/table/delete_table_test.rb +0 -40
- data/test/integration/table/get_table_test.rb +0 -37
- data/test/integration/table/informative_errors_test.rb +0 -39
- data/test/integration/table/insert_entity_batch_test.rb +0 -100
- data/test/integration/table/insert_entity_test.rb +0 -88
- data/test/integration/table/insert_or_merge_entity_batch_test.rb +0 -159
- data/test/integration/table/insert_or_merge_entity_test.rb +0 -143
- data/test/integration/table/insert_or_replace_entity_batch_test.rb +0 -152
- data/test/integration/table/insert_or_replace_entity_test.rb +0 -137
- data/test/integration/table/merge_entity_batch_test.rb +0 -128
- data/test/integration/table/merge_entity_test.rb +0 -113
- data/test/integration/table/query_entities_test.rb +0 -196
- data/test/integration/table/query_tables_test.rb +0 -43
- data/test/integration/table/query_test.rb +0 -251
- data/test/integration/table/table_acl_test.rb +0 -52
- data/test/integration/table/table_gb18030_test.rb +0 -355
- data/test/integration/table/update_entity_batch_test.rb +0 -149
- data/test/integration/table/update_entity_test.rb +0 -131
- data/test/integration/test_helper.rb +0 -40
- data/test/integration/vm/VM_Create_test.rb +0 -262
- data/test/integration/vm/VM_Delete_test.rb +0 -53
- data/test/integration/vm/VM_Operations_test.rb +0 -172
- data/test/integration/vm_image/virtual_machine_disk_test.rb +0 -37
- data/test/integration/vm_image/virtual_machine_image_test.rb +0 -37
- data/test/integration/vnet/Virtual_Network_Create_test.rb +0 -116
- data/test/integration/vnet/Virtual_Network_list_test.rb +0 -48
- data/test/support/env.rb +0 -19
- data/test/support/fixtures.rb +0 -36
- data/test/support/name_generator.rb +0 -168
- data/test/support/stubs.rb +0 -42
- data/test/support/virtual_machine_name_generator.rb +0 -102
- data/test/support/virtual_network_helper.rb +0 -73
- data/test/test_helper.rb +0 -47
- data/test/unit/affinity_group/affinity_group_test.rb +0 -189
- data/test/unit/affinity_group/serialization_test.rb +0 -87
- data/test/unit/base_management/base_management_service_test.rb +0 -19
- data/test/unit/base_management/location_test.rb +0 -56
- data/test/unit/base_management/role_size_test.rb +0 -50
- data/test/unit/blob/auth/shared_access_signature_test.rb +0 -71
- data/test/unit/blob/blob_service_test.rb +0 -1970
- data/test/unit/cloud_service_management/cloud_service_management_service_test.rb +0 -94
- data/test/unit/cloud_service_management/serialization_test.rb +0 -169
- data/test/unit/config/azure_test.rb +0 -131
- data/test/unit/config/client_test.rb +0 -37
- data/test/unit/core/auth/shared_key_lite_test.rb +0 -51
- data/test/unit/core/auth/shared_key_test.rb +0 -58
- data/test/unit/core/auth/signer_test.rb +0 -30
- data/test/unit/core/http/http_error_test.rb +0 -61
- data/test/unit/core/http/http_request_test.rb +0 -138
- data/test/unit/core/http/http_response_test.rb +0 -20
- data/test/unit/core/http/retry_policy_test.rb +0 -23
- data/test/unit/core/utility_test.rb +0 -122
- data/test/unit/database/serialization_test.rb +0 -94
- data/test/unit/database/sql_database_server_service_test.rb +0 -341
- data/test/unit/http_client_test.rb +0 -74
- data/test/unit/service/serialization_test.rb +0 -533
- data/test/unit/service/storage_service_test.rb +0 -297
- data/test/unit/storage_management/serialization_test.rb +0 -244
- data/test/unit/storage_management/storage_management_service_test.rb +0 -247
- data/test/unit/table/edmtype_test.rb +0 -108
- data/test/unit/virtual_machine_image_management/serialization_test.rb +0 -50
- data/test/unit/virtual_machine_image_management/virtual_machine_image_management_service_test.rb +0 -114
- data/test/unit/virtual_machine_management/serialization_test.rb +0 -316
- data/test/unit/virtual_machine_management/virtual_machine_management_service_test.rb +0 -480
- data/test/unit/vnet/serialization_test.rb +0 -187
- data/test/unit/vnet/virtual_network_management_service_test.rb +0 -131
@@ -1,266 +0,0 @@
|
|
1
|
-
#-------------------------------------------------------------------------
|
2
|
-
# # Copyright (c) Microsoft and contributors. All rights reserved.
|
3
|
-
#
|
4
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
# you may not use this file except in compliance with the License.
|
6
|
-
# You may obtain a copy of the License at
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
#--------------------------------------------------------------------------
|
15
|
-
require 'integration/test_helper'
|
16
|
-
|
17
|
-
describe 'ServiceBus Queues' do
|
18
|
-
|
19
|
-
subject { Azure::ServiceBus::ServiceBusService.new }
|
20
|
-
let(:queue_name) { ServiceBusQueueNameHelper.name }
|
21
|
-
let(:name_alternative) { ServiceBusQueueNameHelper.name }
|
22
|
-
let(:description) {{
|
23
|
-
:default_message_time_to_live => 'P10675199DT2H48M5.4775807S',
|
24
|
-
:duplicate_detection_history_time_window => 'PT10M',
|
25
|
-
:dead_lettering_on_message_expiration => "false",
|
26
|
-
:lock_duration => 'PT30S',
|
27
|
-
:max_delivery_count => "10",
|
28
|
-
:max_size_in_megabytes => "1",
|
29
|
-
:requires_duplicate_detection => "true",
|
30
|
-
:requires_session => "false"
|
31
|
-
}}
|
32
|
-
let(:description_alternative) {{
|
33
|
-
:lock_duration => 'PT30S',
|
34
|
-
:max_size_in_megabytes => 2048,
|
35
|
-
:requires_duplicate_detection => true,
|
36
|
-
:requires_session => true,
|
37
|
-
:default_message_time_to_live => 'PT30M',
|
38
|
-
:dead_lettering_on_message_expiration => true,
|
39
|
-
:duplicate_detection_history_time_window => 'PT20M',
|
40
|
-
:max_delivery_count => 20,
|
41
|
-
:enable_batched_operations => true
|
42
|
-
}}
|
43
|
-
|
44
|
-
after { ServiceBusQueueNameHelper.clean }
|
45
|
-
|
46
|
-
it "should be able to create a new queue from a string" do
|
47
|
-
queue = subject.create_queue queue_name
|
48
|
-
queue.must_be_kind_of Azure::ServiceBus::Queue
|
49
|
-
queue.name.must_equal queue_name
|
50
|
-
end
|
51
|
-
|
52
|
-
it "should be able to create a new queue from a Queue" do
|
53
|
-
queue = subject.create_queue Azure::ServiceBus::Queue.new(queue_name)
|
54
|
-
queue.must_be_kind_of Azure::ServiceBus::Queue
|
55
|
-
queue.name.must_equal queue_name
|
56
|
-
end
|
57
|
-
|
58
|
-
it "should be able to create a new queue from a string and description Hash" do
|
59
|
-
queue = subject.create_queue name_alternative, description_alternative
|
60
|
-
queue.must_be_kind_of Azure::ServiceBus::Queue
|
61
|
-
queue.name.must_equal name_alternative
|
62
|
-
|
63
|
-
queue.lock_duration.must_equal 30.0
|
64
|
-
queue.max_size_in_megabytes.must_equal description_alternative[:max_size_in_megabytes]
|
65
|
-
queue.requires_duplicate_detection.must_equal description_alternative[:requires_duplicate_detection]
|
66
|
-
queue.requires_session.must_equal description_alternative[:requires_session]
|
67
|
-
queue.default_message_time_to_live.must_equal 1800.0
|
68
|
-
queue.dead_lettering_on_message_expiration.must_equal description_alternative[:dead_lettering_on_message_expiration]
|
69
|
-
queue.duplicate_detection_history_time_window.must_equal 1200.0
|
70
|
-
queue.max_delivery_count.must_equal description_alternative[:max_delivery_count]
|
71
|
-
queue.enable_batched_operations.must_equal description_alternative[:enable_batched_operations]
|
72
|
-
end
|
73
|
-
|
74
|
-
it "should be able to create a new queue from a Queue with a description Hash" do
|
75
|
-
queue = subject.create_queue Azure::ServiceBus::Queue.new(name_alternative, description_alternative)
|
76
|
-
queue.must_be_kind_of Azure::ServiceBus::Queue
|
77
|
-
queue.name.must_equal name_alternative
|
78
|
-
|
79
|
-
queue.lock_duration.must_equal 30.0
|
80
|
-
queue.max_size_in_megabytes.must_equal description_alternative[:max_size_in_megabytes]
|
81
|
-
queue.requires_duplicate_detection.must_equal description_alternative[:requires_duplicate_detection]
|
82
|
-
queue.requires_session.must_equal description_alternative[:requires_session]
|
83
|
-
queue.default_message_time_to_live.must_equal 1800.0
|
84
|
-
queue.dead_lettering_on_message_expiration.must_equal description_alternative[:dead_lettering_on_message_expiration]
|
85
|
-
queue.duplicate_detection_history_time_window.must_equal 1200.0
|
86
|
-
queue.max_delivery_count.must_equal description_alternative[:max_delivery_count]
|
87
|
-
queue.enable_batched_operations.must_equal description_alternative[:enable_batched_operations]
|
88
|
-
end
|
89
|
-
|
90
|
-
describe 'when a queue exists' do
|
91
|
-
before { subject.create_queue queue_name }
|
92
|
-
|
93
|
-
describe '#delete_queue' do
|
94
|
-
it "should raise exception if the queue cannot be deleted" do
|
95
|
-
assert_raises(Azure::Core::Http::HTTPError) do
|
96
|
-
subject.delete_queue ServiceBusQueueNameHelper.name
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
it "should be able to delete the queue" do
|
101
|
-
response = subject.delete_queue queue_name
|
102
|
-
response.must_equal nil
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
describe "#get_queue" do
|
107
|
-
it "should be able to get a queue by name" do
|
108
|
-
result = subject.get_queue queue_name
|
109
|
-
|
110
|
-
result.must_be_kind_of Azure::ServiceBus::Queue
|
111
|
-
result.name.must_equal queue_name
|
112
|
-
end
|
113
|
-
|
114
|
-
it "if the queue doesn't exists it should throw" do
|
115
|
-
assert_raises(Azure::Core::Http::HTTPError) do
|
116
|
-
subject.get_queue ServiceBusQueueNameHelper.name
|
117
|
-
end
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
describe 'when there are multiple queues' do
|
122
|
-
let(:name1) { ServiceBusQueueNameHelper.name }
|
123
|
-
let(:name2) { ServiceBusQueueNameHelper.name }
|
124
|
-
before {
|
125
|
-
subject.create_queue name1
|
126
|
-
subject.create_queue name2
|
127
|
-
}
|
128
|
-
|
129
|
-
it "should be able to get a list of queues" do
|
130
|
-
result = subject.list_queues
|
131
|
-
|
132
|
-
result.must_be :kind_of?, Array
|
133
|
-
q_found = false
|
134
|
-
q1_found = false
|
135
|
-
q2_found = false
|
136
|
-
result.each { |q|
|
137
|
-
q_found = true if q.name == queue_name
|
138
|
-
q1_found = true if q.name == name1
|
139
|
-
q2_found = true if q.name == name2
|
140
|
-
}
|
141
|
-
assert (q_found and q1_found and q2_found), "list_queues did not return expected queues"
|
142
|
-
end
|
143
|
-
|
144
|
-
it "should be able to use $skip token with list_queues" do
|
145
|
-
result = subject.list_queues
|
146
|
-
result2 = subject.list_queues({ :skip => 1 })
|
147
|
-
result2.length.must_equal result.length - 1
|
148
|
-
result2[0].id.must_equal result[1].id
|
149
|
-
end
|
150
|
-
|
151
|
-
it "should be able to use $top token with list_queues" do
|
152
|
-
result = subject.list_queues
|
153
|
-
result.length.wont_equal 1
|
154
|
-
|
155
|
-
result2 = subject.list_queues({ :top => 1 })
|
156
|
-
result2.length.must_equal 1
|
157
|
-
end
|
158
|
-
|
159
|
-
it "should be able to use $skip and $top token together with list_queues" do
|
160
|
-
result = subject.list_queues
|
161
|
-
result2 = subject.list_queues({ :skip => 1, :top => 1 })
|
162
|
-
result2.length.must_equal 1
|
163
|
-
result2[0].id.must_equal result[1].id
|
164
|
-
end
|
165
|
-
end
|
166
|
-
|
167
|
-
it "should be able to send a message to a queue" do
|
168
|
-
msg = Azure::ServiceBus::BrokeredMessage.new("some text") do |m|
|
169
|
-
m.to = "yo"
|
170
|
-
end
|
171
|
-
res = subject.send_queue_message queue_name, msg
|
172
|
-
res.must_be_nil
|
173
|
-
end
|
174
|
-
|
175
|
-
describe "when the queue has messages" do
|
176
|
-
let(:messageContent) { 'messagecontent' }
|
177
|
-
let(:to) { 'yo' }
|
178
|
-
let(:label) { 'my_label' }
|
179
|
-
let(:properties) {{
|
180
|
-
"CustomDoubleProperty" => 3.141592,
|
181
|
-
"CustomInt32Property" => 37,
|
182
|
-
"CustomInt64Property" => 2**32,
|
183
|
-
"CustomInt64NegProperty" => -(2**32),
|
184
|
-
"CustomStringProperty" => "CustomPropertyValue",
|
185
|
-
"CustomDateProperty" => Time.now,
|
186
|
-
"CustomTrueProperty" => true,
|
187
|
-
"CustomFalseProperty" => false,
|
188
|
-
"CustomNilProperty" => nil,
|
189
|
-
"CustomJSONProperty" => "testingpa\n\"{}\\rtition"
|
190
|
-
}}
|
191
|
-
let(:msg) { m = Azure::ServiceBus::BrokeredMessage.new(messageContent, properties); m.to = 'me'; m }
|
192
|
-
|
193
|
-
before { subject.send_queue_message queue_name, msg }
|
194
|
-
|
195
|
-
it "should be able to peek a message from a queue" do
|
196
|
-
retrieved = subject.peek_lock_queue_message queue_name
|
197
|
-
retrieved.must_be :kind_of?, Azure::ServiceBus::BrokeredMessage
|
198
|
-
|
199
|
-
retrieved.body.must_equal msg.body
|
200
|
-
retrieved.to.must_equal msg.to
|
201
|
-
retrieved.label.must_equal msg.label
|
202
|
-
|
203
|
-
properties.each { |k,v|
|
204
|
-
unless properties[k].class == Time
|
205
|
-
retrieved.properties[k.downcase].must_equal properties[k]
|
206
|
-
else
|
207
|
-
# Time comes back as string as there is no good way to distinguish
|
208
|
-
retrieved.properties[k.downcase].to_s.must_equal properties[k].httpdate
|
209
|
-
end
|
210
|
-
}
|
211
|
-
|
212
|
-
refute retrieved.lock_token.nil?
|
213
|
-
refute retrieved.sequence_number.nil?
|
214
|
-
end
|
215
|
-
|
216
|
-
it "should be able to read-delete a message from a queue" do
|
217
|
-
retrieved = subject.read_delete_queue_message queue_name
|
218
|
-
|
219
|
-
retrieved.must_be :kind_of?, Azure::ServiceBus::BrokeredMessage
|
220
|
-
retrieved.body.must_equal msg.body
|
221
|
-
retrieved.to.must_equal msg.to
|
222
|
-
|
223
|
-
# it should be deleted
|
224
|
-
retrieved = subject.read_delete_queue_message queue_name, { :timeout => 2 }
|
225
|
-
retrieved.must_be_nil
|
226
|
-
end
|
227
|
-
|
228
|
-
it "should be able to unlock a message from a queue" do
|
229
|
-
retrieved = subject.peek_lock_queue_message queue_name, { :timeout => 2 }
|
230
|
-
|
231
|
-
# There shouldn't be an available message in the queue
|
232
|
-
retrieved2 = subject.peek_lock_queue_message queue_name, { :timeout => 2 }
|
233
|
-
retrieved2.must_be_nil
|
234
|
-
|
235
|
-
# Unlock the message
|
236
|
-
res = subject.unlock_queue_message retrieved
|
237
|
-
res.must_be_nil
|
238
|
-
|
239
|
-
# The message should be available once again
|
240
|
-
retrieved = subject.peek_lock_queue_message queue_name, { :timeout => 2 }
|
241
|
-
retrieved.body.must_equal msg.body
|
242
|
-
end
|
243
|
-
|
244
|
-
it "should be able to delete a message from a queue" do
|
245
|
-
|
246
|
-
retrieved = subject.peek_lock_queue_message queue_name
|
247
|
-
retrieved.body.must_equal msg.body
|
248
|
-
|
249
|
-
subject.delete_queue_message retrieved
|
250
|
-
|
251
|
-
# it should be deleted
|
252
|
-
retrieved = subject.peek_lock_queue_message queue_name, { :timeout => 2 }
|
253
|
-
assert_nil retrieved
|
254
|
-
end
|
255
|
-
|
256
|
-
it "should be able to read a message from a queue" do
|
257
|
-
subject.send_queue_message queue_name, msg
|
258
|
-
retrieved = subject.receive_queue_message queue_name
|
259
|
-
|
260
|
-
retrieved.must_be :kind_of?, Azure::ServiceBus::BrokeredMessage
|
261
|
-
retrieved.body.must_equal msg.body
|
262
|
-
retrieved.to.must_equal msg.to
|
263
|
-
end
|
264
|
-
end
|
265
|
-
end
|
266
|
-
end
|
@@ -1,132 +0,0 @@
|
|
1
|
-
#-------------------------------------------------------------------------
|
2
|
-
# # Copyright (c) Microsoft and contributors. All rights reserved.
|
3
|
-
#
|
4
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
# you may not use this file except in compliance with the License.
|
6
|
-
# You may obtain a copy of the License at
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
#--------------------------------------------------------------------------
|
15
|
-
require "integration/test_helper"
|
16
|
-
|
17
|
-
describe "ServiceBus Relay" do
|
18
|
-
|
19
|
-
subject { Azure::ServiceBus::ServiceBusService.new }
|
20
|
-
let(:bus_name) { ServiceBusRelayNameHelper.name }
|
21
|
-
let(:name_alternative) { ServiceBusRelayNameHelper.name }
|
22
|
-
let(:description) {{
|
23
|
-
:relay_type => 'Http',
|
24
|
-
:requires_client_authorization => true,
|
25
|
-
:requires_transport_security => true
|
26
|
-
}}
|
27
|
-
let(:description_alternative) {{
|
28
|
-
:relay_type => 'NetTcp',
|
29
|
-
:requires_client_authorization => false,
|
30
|
-
:requires_transport_security => false
|
31
|
-
}}
|
32
|
-
|
33
|
-
after { ServiceBusRelayNameHelper.clean }
|
34
|
-
|
35
|
-
it "should be able to create a new relay endpoint from a string and description Hash" do
|
36
|
-
relay = subject.create_relay name_alternative, description_alternative
|
37
|
-
relay.must_be_kind_of Azure::ServiceBus::Relay
|
38
|
-
relay.name.must_equal name_alternative
|
39
|
-
|
40
|
-
relay.relay_type.must_equal description_alternative[:relay_type]
|
41
|
-
relay.requires_client_authorization.must_equal description_alternative[:requires_client_authorization]
|
42
|
-
relay.requires_transport_security.must_equal description_alternative[:requires_transport_security]
|
43
|
-
end
|
44
|
-
|
45
|
-
it "should be able to create a new relay from a Relay with a description Hash" do
|
46
|
-
relay = subject.create_relay Azure::ServiceBus::Relay.new(name_alternative, description_alternative)
|
47
|
-
relay.must_be_kind_of Azure::ServiceBus::Relay
|
48
|
-
relay.name.must_equal name_alternative
|
49
|
-
|
50
|
-
relay.relay_type.must_equal description_alternative[:relay_type]
|
51
|
-
relay.requires_client_authorization.must_equal description_alternative[:requires_client_authorization]
|
52
|
-
relay.requires_transport_security.must_equal description_alternative[:requires_transport_security]
|
53
|
-
end
|
54
|
-
|
55
|
-
describe 'when a relay exists' do
|
56
|
-
before { subject.create_relay bus_name, description }
|
57
|
-
|
58
|
-
describe "#get_relay" do
|
59
|
-
it "should be able to get a relay by name" do
|
60
|
-
result = subject.get_relay bus_name
|
61
|
-
|
62
|
-
result.must_be_kind_of Azure::ServiceBus::Relay
|
63
|
-
result.name.must_equal bus_name
|
64
|
-
end
|
65
|
-
|
66
|
-
it "if the relay endpoint doesn't exists it should throw" do
|
67
|
-
assert_raises(Azure::Core::Http::HTTPError) do
|
68
|
-
subject.get_relay ServiceBusRelayNameHelper.name
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
describe '#delete_relay' do
|
74
|
-
it "should raise exception if the relay endpoint cannot be deleted" do
|
75
|
-
assert_raises(Azure::Core::Http::HTTPError) do
|
76
|
-
subject.delete_relay ServiceBusRelayNameHelper.name
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
it "should be able to delete the relay endpoint" do
|
81
|
-
response = subject.delete_relay bus_name
|
82
|
-
response.must_equal nil
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
describe 'when there are multiple relay endpoints' do
|
87
|
-
let(:name1) { ServiceBusRelayNameHelper.name }
|
88
|
-
let(:name2) { ServiceBusRelayNameHelper.name }
|
89
|
-
before {
|
90
|
-
subject.create_relay name1, description
|
91
|
-
subject.create_relay name2, description_alternative
|
92
|
-
}
|
93
|
-
|
94
|
-
it "should be able to get a list of relays" do
|
95
|
-
result = subject.list_relays
|
96
|
-
|
97
|
-
result.must_be :kind_of?, Array
|
98
|
-
q_found = false
|
99
|
-
q1_found = false
|
100
|
-
q2_found = false
|
101
|
-
result.each { |q|
|
102
|
-
q_found = true if q.name == bus_name
|
103
|
-
q1_found = true if q.name == name1
|
104
|
-
q2_found = true if q.name == name2
|
105
|
-
}
|
106
|
-
assert (q_found and q1_found and q2_found), "list_relays did not return expected relay endpoints"
|
107
|
-
end
|
108
|
-
|
109
|
-
it "should be able to use $skip token with list_relays" do
|
110
|
-
result = subject.list_relays
|
111
|
-
result2 = subject.list_relays({ :skip => 1 })
|
112
|
-
result2.length.must_equal result.length - 1
|
113
|
-
result2[0].id.must_equal result[1].id
|
114
|
-
end
|
115
|
-
|
116
|
-
it "should be able to use $top token with list_relays" do
|
117
|
-
result = subject.list_relays
|
118
|
-
result.length.wont_equal 1
|
119
|
-
|
120
|
-
result2 = subject.list_relays({ :top => 1 })
|
121
|
-
result2.length.must_equal 1
|
122
|
-
end
|
123
|
-
|
124
|
-
it "should be able to use $skip and $top token together with list_relays" do
|
125
|
-
result = subject.list_relays
|
126
|
-
result2 = subject.list_relays({ :skip => 1, :top => 1 })
|
127
|
-
result2.length.must_equal 1
|
128
|
-
result2[0].id.must_equal result[1].id
|
129
|
-
end
|
130
|
-
end
|
131
|
-
end
|
132
|
-
end
|
@@ -1,145 +0,0 @@
|
|
1
|
-
#-------------------------------------------------------------------------
|
2
|
-
# # Copyright (c) Microsoft and contributors. All rights reserved.
|
3
|
-
#
|
4
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
# you may not use this file except in compliance with the License.
|
6
|
-
# You may obtain a copy of the License at
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
#--------------------------------------------------------------------------
|
15
|
-
require "integration/test_helper"
|
16
|
-
|
17
|
-
describe "ServiceBus Rules" do
|
18
|
-
subject { Azure::ServiceBus::ServiceBusService.new }
|
19
|
-
after { ServiceBusTopicNameHelper.clean }
|
20
|
-
let(:topic){ ServiceBusTopicNameHelper.name }
|
21
|
-
let(:subscription){ "mySubscription" }
|
22
|
-
let(:rule){ "myRule" }
|
23
|
-
|
24
|
-
before {
|
25
|
-
subject.create_topic topic
|
26
|
-
subject.create_subscription topic, subscription
|
27
|
-
}
|
28
|
-
|
29
|
-
it "should be able to create a new rule" do
|
30
|
-
result = subject.create_rule topic, subscription, rule
|
31
|
-
result.must_be :kind_of?, Azure::ServiceBus::Rule
|
32
|
-
result.filter.must_be_kind_of Azure::ServiceBus::TrueFilter
|
33
|
-
result.filter.sql_expression.must_equal "1=1"
|
34
|
-
result.filter.compatibility_level.must_equal 20
|
35
|
-
end
|
36
|
-
|
37
|
-
it "should be able to create a new rule object" do
|
38
|
-
ruleObject = Azure::ServiceBus::Rule.new "my_other_rule"
|
39
|
-
ruleObject.subscription = subscription
|
40
|
-
ruleObject.topic = topic
|
41
|
-
|
42
|
-
result = subject.create_rule ruleObject
|
43
|
-
result.must_be :kind_of?, Azure::ServiceBus::Rule
|
44
|
-
result.filter.must_be_kind_of Azure::ServiceBus::TrueFilter
|
45
|
-
result.filter.sql_expression.must_equal "1=1"
|
46
|
-
result.filter.compatibility_level.must_equal 20
|
47
|
-
|
48
|
-
subject.delete_rule result
|
49
|
-
end
|
50
|
-
|
51
|
-
it "should be able to create a new rule with an action" do
|
52
|
-
ruleObject = Azure::ServiceBus::Rule.new "my_other_rule"
|
53
|
-
ruleObject.subscription = subscription
|
54
|
-
ruleObject.topic = topic
|
55
|
-
ruleObject.filter = Azure::ServiceBus::SqlFilter.new({ :sql_expression => "MyProperty='XYZ'" })
|
56
|
-
ruleObject.action = Azure::ServiceBus::SqlRuleAction.new({ :sql_expression => "set MyProperty2 = 'ABC'" })
|
57
|
-
|
58
|
-
result = subject.create_rule ruleObject
|
59
|
-
result.must_be :kind_of?, Azure::ServiceBus::Rule
|
60
|
-
result.filter.must_be_kind_of Azure::ServiceBus::SqlFilter
|
61
|
-
result.filter.sql_expression.must_equal "MyProperty='XYZ'"
|
62
|
-
result.filter.compatibility_level.must_equal 20
|
63
|
-
|
64
|
-
result.action.must_be_kind_of Azure::ServiceBus::SqlRuleAction
|
65
|
-
result.action.sql_expression.must_equal "set MyProperty2 = 'ABC'"
|
66
|
-
result.action.compatibility_level.must_equal 20
|
67
|
-
|
68
|
-
subject.delete_rule result
|
69
|
-
end
|
70
|
-
|
71
|
-
it "should be able to create a new rule with a correlation filter" do
|
72
|
-
ruleObject = Azure::ServiceBus::Rule.new "my_other_rule"
|
73
|
-
ruleObject.subscription = subscription
|
74
|
-
ruleObject.topic = topic
|
75
|
-
ruleObject.filter = Azure::ServiceBus::CorrelationFilter.new({ :correlation_id => "identifier" })
|
76
|
-
ruleObject.action = Azure::ServiceBus::SqlRuleAction.new({ :sql_expression => "set MyProperty2 = 'ABC'" })
|
77
|
-
|
78
|
-
result = subject.create_rule ruleObject
|
79
|
-
result.must_be :kind_of?, Azure::ServiceBus::Rule
|
80
|
-
result.filter.must_be_kind_of Azure::ServiceBus::CorrelationFilter
|
81
|
-
result.filter.correlation_id.must_equal "identifier"
|
82
|
-
|
83
|
-
result.action.must_be_kind_of Azure::ServiceBus::SqlRuleAction
|
84
|
-
result.action.sql_expression.must_equal "set MyProperty2 = 'ABC'"
|
85
|
-
result.action.compatibility_level.must_equal 20
|
86
|
-
|
87
|
-
subject.delete_rule result
|
88
|
-
end
|
89
|
-
|
90
|
-
describe "when a rule exists" do
|
91
|
-
before { subject.create_rule topic, subscription, rule }
|
92
|
-
|
93
|
-
it "should be able to delete rules" do
|
94
|
-
subject.delete_rule topic, subscription, rule
|
95
|
-
end
|
96
|
-
|
97
|
-
it "should be able to get rules" do
|
98
|
-
result = subject.get_rule topic, subscription, rule
|
99
|
-
result.must_be :kind_of?, Azure::ServiceBus::Rule
|
100
|
-
result.filter.must_be_kind_of Azure::ServiceBus::TrueFilter
|
101
|
-
result.filter.sql_expression.must_equal "1=1"
|
102
|
-
result.filter.compatibility_level.must_equal 20
|
103
|
-
end
|
104
|
-
|
105
|
-
it "should be able to list rules" do
|
106
|
-
result = subject.list_rules topic, subscription
|
107
|
-
rule_found = false
|
108
|
-
result.each { |r|
|
109
|
-
rule_found = true if r.name == rule
|
110
|
-
}
|
111
|
-
assert rule_found, "list_rules didn't include the expected rule"
|
112
|
-
end
|
113
|
-
|
114
|
-
describe 'when multiple rules exist' do
|
115
|
-
let(:rule1) { "myRule1" }
|
116
|
-
let(:rule2) { "myRule2" }
|
117
|
-
before {
|
118
|
-
subject.create_rule topic, subscription, rule1
|
119
|
-
subject.create_rule topic, subscription, rule2
|
120
|
-
}
|
121
|
-
|
122
|
-
it "should be able to use $skip token" do
|
123
|
-
result = subject.list_rules topic, subscription
|
124
|
-
result2 = subject.list_rules topic, subscription, { :skip => 1 }
|
125
|
-
result2.length.must_equal result.length - 1
|
126
|
-
result2[0].id.must_equal result[1].id
|
127
|
-
end
|
128
|
-
|
129
|
-
it "should be able to use $top token" do
|
130
|
-
result = subject.list_rules topic, subscription
|
131
|
-
result.length.wont_equal 1
|
132
|
-
|
133
|
-
result2 = subject.list_rules topic, subscription, { :top => 1 }
|
134
|
-
result2.length.must_equal 1
|
135
|
-
end
|
136
|
-
|
137
|
-
it "should be able to use $skip and $top token together" do
|
138
|
-
result = subject.list_rules topic, subscription
|
139
|
-
result2 = subject.list_rules topic, subscription, { :skip => 1, :top => 1 }
|
140
|
-
result2.length.must_equal 1
|
141
|
-
result2[0].id.must_equal result[1].id
|
142
|
-
end
|
143
|
-
end
|
144
|
-
end
|
145
|
-
end
|