Skip to content

Commit

Permalink
Merge pull request #293 from gcheng/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
Albert Cheng committed Mar 12, 2013
2 parents bd596d9 + bff956b commit ab6b488
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 28 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.serviceruntime;

Expand Down
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.serviceruntime;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ public QueueRestProxy(HttpURLConnectionClient channel, ServiceFilter[] filters,
public QueueContract withFilter(ServiceFilter filter) {
ServiceFilter[] newFilters = Arrays.copyOf(filters, filters.length + 1);
newFilters[filters.length] = filter;
return new QueueRestProxy(this.channel, newFilters, this.accountName, this.url, this.sharedKeyFilter, this.dateMapper);
return new QueueRestProxy(this.channel, newFilters, this.accountName, this.url, this.sharedKeyFilter,
this.dateMapper);
}

private void ThrowIfError(ClientResponse r) {
Expand Down Expand Up @@ -261,7 +262,10 @@ public void createMessage(String queue, String messageText) throws ServiceExcept
@Override
public void createMessage(String queue, String messageText, CreateMessageOptions options) throws ServiceException {
if (queue == null)
throw new NullPointerException();
throw new NullPointerException("queue");
if (messageText == null) {
throw new NullPointerException("messageText");
}

WebResource webResource = getResource(options).path(queue).path("messages");
webResource = addOptionalQueryParam(webResource, "visibilitytimeout", options.getVisibilityTimeoutInSeconds());
Expand All @@ -286,9 +290,11 @@ public UpdateMessageResult updateMessage(String queue, String messageId, String
public UpdateMessageResult updateMessage(String queue, String messageId, String popReceipt, String messageText,
int visibilityTimeoutInSeconds, QueueServiceOptions options) throws ServiceException {
if (queue == null)
throw new NullPointerException();
throw new NullPointerException("queue");
if (messageId == null)
throw new NullPointerException();
throw new NullPointerException("messageId");
if (messageText == null)
throw new NullPointerException("messageText");

WebResource webResource = getResource(options).path(queue).path("messages").path(messageId);
webResource = addOptionalQueryParam(webResource, "popreceipt", popReceipt);
Expand Down
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.queue;

Expand All @@ -25,7 +25,9 @@

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;

import com.microsoft.windowsazure.services.core.Configuration;
import com.microsoft.windowsazure.services.queue.models.CreateQueueOptions;
Expand Down Expand Up @@ -58,6 +60,9 @@ public class QueueServiceIntegrationTest extends IntegrationTestBase {
private static String[] creatableQueues;
private static String[] testQueues;

@Rule
public ExpectedException expectedException = ExpectedException.none();

@BeforeClass
public static void setup() throws Exception {
// Setup container names array (list of container names used by
Expand Down Expand Up @@ -315,6 +320,17 @@ public void createMessageWorks() throws Exception {
// Assert
}

@Test
public void createNullMessageException() throws Exception {
// Arrange
Configuration config = createConfiguration();
QueueContract service = QueueService.create(config);

// Act
expectedException.expect(NullPointerException.class);
service.createMessage(TEST_QUEUE_FOR_MESSAGES, null);
}

@Test
public void listMessagesWorks() throws Exception {
// Arrange
Expand Down Expand Up @@ -508,6 +524,23 @@ public void deleteMessageWorks() throws Exception {
assertEquals(3, result2.getQueueMessages().size());
}

@Test
public void updateNullMessageException() throws Exception {
// Arrange
Configuration config = createConfiguration();
QueueContract service = QueueService.create(config);
String messageId = "messageId";

String popReceipt = "popReceipt";
String messageText = null;
int visibilityTimeoutInSeconds = 10;

// Act
expectedException.expect(NullPointerException.class);
service.updateMessage(TEST_QUEUE_FOR_MESSAGES_8, messageId, popReceipt, messageText, visibilityTimeoutInSeconds);

}

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

0 comments on commit ab6b488

Please sign in to comment.