Skip to content

Commit

Permalink
Merge pull request Azure#108 from gcheng/updateQueue
Browse files Browse the repository at this point in the history
update queue.
  • Loading branch information
Albert Cheng committed Apr 17, 2013
2 parents 77c9477 + 811ae67 commit 375de7e
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
* Copyright Microsoft Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.microsoft.windowsazure.services.serviceBus;

Expand Down Expand Up @@ -254,8 +254,32 @@ ReceiveSubscriptionMessageResult receiveSubscriptionMessage(String topicPath, St
*/
ListQueuesResult listQueues() throws ServiceException;

/**
* Returns a list of queues.
*
* @param options
* A <code>ListQueueOptions</code> object that represents the options to list the queue.
*
* @return A <code>ListQueuesResult</code> object that represents the result.
*
* @exception ServiceException
* If a service exception is encountered.
*/
ListQueuesResult listQueues(ListQueuesOptions options) throws ServiceException;

/**
* Updates the information of a queue.
*
* @param queueInfo
* The information of a queue to be updated.
*
* @return A <code>QueueInfo</code> object that represents the updated queue.
*
* @throws ServiceException
* If a service exception is encountered.
*/
QueueInfo updateQueue(QueueInfo queueInfo) throws ServiceException;

/**
* Creates a topic.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,19 @@ public ListQueuesResult listQueues() throws ServiceException {
}
}

@Override
public QueueInfo updateQueue(QueueInfo queueInfo) throws ServiceException {
try {
return next.updateQueue(queueInfo);
}
catch (UniformInterfaceException e) {
throw processCatch(new ServiceException(e));
}
catch (ClientHandlerException e) {
throw processCatch(new ServiceException(e));
}
}

@Override
public CreateTopicResult createTopic(TopicInfo topic) throws ServiceException {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,12 @@ public ListQueuesResult listQueues(ListQueuesOptions options) throws ServiceExce
return result;
}

@Override
public QueueInfo updateQueue(QueueInfo queueInfo) throws ServiceException {
return getResource().path(queueInfo.getPath()).type("application/atom+xml;type=entry;charset=utf-8")
.header("If-Match", "*").put(QueueInfo.class, queueInfo);
}

private WebResource listOptions(AbstractListOptions<?> options, WebResource path) {
if (options.getTop() != null) {
path = path.queryParam("$top", options.getTop().toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,20 @@ public void createQueueWorks() throws Exception {
assertEquals("TestCreateQueueWorks", saved.getPath());
}

@Test
public void updateQueueWorks() throws Exception {
// Arrange
QueueInfo queue = new QueueInfo("TestUpdateQueueWorks").setMaxSizeInMegabytes(1024L);
QueueInfo originalQueue = service.createQueue(queue).getValue();
Long expectedMaxSizeInMegaBytes = 512L;

// Act
QueueInfo updatedQueue = service.updateQueue(originalQueue.setMaxSizeInMegabytes(512L));

// Assert
assertEquals(expectedMaxSizeInMegaBytes, updatedQueue.getMaxSizeInMegabytes());
}

@Test
public void getQueueWorks() throws Exception {
// Arrange
Expand Down

0 comments on commit 375de7e

Please sign in to comment.