diff --git a/README.md b/README.md index 22ab0a06a9ec..a8805eb2e326 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ within your project you can also have them installed by the Java package manager com.microsoft.windowsazure microsoft-windowsazure-api - 0.4.1 + 0.4.2 ##Minimum Requirements diff --git a/microsoft-azure-api/pom.xml b/microsoft-azure-api/pom.xml index 1900ba335e49..8306962d4382 100644 --- a/microsoft-azure-api/pom.xml +++ b/microsoft-azure-api/pom.xml @@ -17,7 +17,7 @@ 4.0.0 com.microsoft.windowsazure microsoft-windowsazure-api - 0.4.1 + 0.4.2 jar Microsoft Windows Azure Client API @@ -169,7 +169,7 @@ maven-javadoc-plugin 2.8 - *.implementation.*;*.utils.*;com.microsoft.schemas._2003._10.serialization + *.implementation.*;*.utils.*;com.microsoft.schemas._2003._10.serialization;*.blob.core.storage /**
* Copyright Microsoft Corporation
* diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ChunkedGoalStateDeserializer.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ChunkedGoalStateDeserializer.java index 38ed6c4a4812..9d592a94327d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ChunkedGoalStateDeserializer.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ChunkedGoalStateDeserializer.java @@ -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; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/XmlGoalStateDeserializer.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/XmlGoalStateDeserializer.java index 700e9e33d186..688e5dfc6ef5 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/XmlGoalStateDeserializer.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/XmlGoalStateDeserializer.java @@ -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; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobOperationRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobOperationRestProxy.java index 24adf87f4a23..5b865241508f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobOperationRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobOperationRestProxy.java @@ -16,6 +16,7 @@ package com.microsoft.windowsazure.services.blob.implementation; import java.io.InputStream; +import java.io.UnsupportedEncodingException; import java.util.HashMap; import java.util.Map; @@ -808,7 +809,8 @@ public void breakLease(String container, String blob, String leaseId) throws Ser @Override @Deprecated - public void breakLease(String container, String blob, String leaseId, BlobServiceOptions options) throws ServiceException { + public void breakLease(String container, String blob, String leaseId, BlobServiceOptions options) + throws ServiceException { breakLease(container, blob, options); } @@ -819,8 +821,8 @@ public BreakLeaseResult breakLease(String container, String blob) throws Service @Override public BreakLeaseResult breakLease(String container, String blob, BlobServiceOptions options) - throws ServiceException { - ClientResponse response = doLeaseOperation("break", container, blob, null, options, null); + throws ServiceException { + ClientResponse response = doLeaseOperation("break", container, blob, null, options, null); BreakLeaseResult result = new BreakLeaseResult(); result.setRemainingLeaseTimeInSeconds(Integer.parseInt(response.getHeaders().getFirst("x-ms-lease-time"))); @@ -836,7 +838,8 @@ private AcquireLeaseResult putLeaseImpl(String leaseAction, String container, St return result; } - private ClientResponse doLeaseOperation(String leaseAction, String container, String blob, String leaseId, BlobServiceOptions options, AccessCondition accessCondition) { + private ClientResponse doLeaseOperation(String leaseAction, String container, String blob, String leaseId, + BlobServiceOptions options, AccessCondition accessCondition) { String path = createPathFromContainer(container); WebResource webResource = getResource(options).path(path).path(blob).queryParam("comp", "lease"); @@ -941,7 +944,12 @@ public void createBlobBlock(String container, String blob, String blockId, Input CreateBlobBlockOptions options) throws ServiceException { String path = createPathFromContainer(container); WebResource webResource = getResource(options).path(path).path(blob).queryParam("comp", "block"); - webResource = addOptionalQueryParam(webResource, "blockid", new String(Base64.encode(blockId))); + try { + webResource = addOptionalQueryParam(webResource, "blockid", new String(Base64.encode(blockId), "UTF-8")); + } + catch (UnsupportedEncodingException e) { + throw new RuntimeException(e); + } Builder builder = webResource.header("x-ms-version", API_VERSION); builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/HmacSHA256Sign.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/HmacSHA256Sign.java index 71a68bd061cc..e40607c67522 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/HmacSHA256Sign.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/HmacSHA256Sign.java @@ -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.blob.implementation; @@ -33,8 +33,8 @@ public String sign(String stringToSign) { Mac hmac = Mac.getInstance("hmacSHA256"); hmac.init(new SecretKeySpec(Base64.decode(accessKey), "hmacSHA256")); - byte[] digest = hmac.doFinal(stringToSign.getBytes("UTF8")); - return new String(Base64.encode(digest)); + byte[] digest = hmac.doFinal(stringToSign.getBytes("UTF-8")); + return new String(Base64.encode(digest), "UTF-8"); } catch (Exception e) { throw new IllegalArgumentException("accessKey", e); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/package.html b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/package.html new file mode 100644 index 000000000000..513ca5833c7a --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/package.html @@ -0,0 +1,5 @@ + + +This package contains the core classes across difference services. + + diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/package.html b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/package.html new file mode 100644 index 000000000000..b1450b0ca78a --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/package.html @@ -0,0 +1,5 @@ + + +This package contains the blob service core class and interface, + + diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/Base64StringAdapter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/Base64StringAdapter.java index 975bc675e4bb..f9aedb2faf94 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/Base64StringAdapter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/Base64StringAdapter.java @@ -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.core.utils.pipeline; @@ -25,7 +25,7 @@ public class Base64StringAdapter extends XmlAdapter { @Override public String marshal(String arg0) throws Exception { - return new String(Base64.encode(arg0)); + return new String(Base64.encode(arg0), "UTF-8"); } @Override diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/package.html b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/package.html new file mode 100644 index 000000000000..e7819f147963 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/package.html @@ -0,0 +1,5 @@ + + +This package contains the media service OData operation class, interface, and utility classes. + + diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/package.html b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/package.html new file mode 100644 index 000000000000..719e4d9b595c --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/package.html @@ -0,0 +1,5 @@ + + +This package contains the media service data transfer object classes. + + diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/package.html b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/package.html new file mode 100644 index 000000000000..324cb3246c05 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/package.html @@ -0,0 +1,5 @@ + + +This package contains the media services, interface, and associated configuration and utility classes. + + diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueRestProxy.java index 5f3c663c37db..454f51e44c9d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueRestProxy.java @@ -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) { @@ -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()); @@ -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); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/BrokerPropertiesMapper.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/BrokerPropertiesMapper.java index a01aa2aed43b..3dfa6ea80c5f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/BrokerPropertiesMapper.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/BrokerPropertiesMapper.java @@ -17,6 +17,8 @@ import java.io.IOException; import java.io.StringWriter; import java.io.Writer; +import java.text.SimpleDateFormat; +import java.util.Locale; import org.codehaus.jackson.JsonGenerationException; import org.codehaus.jackson.JsonParseException; @@ -26,9 +28,12 @@ public class BrokerPropertiesMapper { public BrokerProperties fromString(String value) throws IllegalArgumentException { + ObjectMapper mapper = new ObjectMapper(); + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US); + mapper.setDateFormat(simpleDateFormat); try { - return mapper.readValue(value.getBytes(), BrokerProperties.class); + return mapper.readValue(value.getBytes("UTF-8"), BrokerProperties.class); } catch (JsonParseException e) { throw new IllegalArgumentException(e); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/CustomPropertiesMapper.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/CustomPropertiesMapper.java index a12fbb4ee819..89e6fec612bc 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/CustomPropertiesMapper.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/CustomPropertiesMapper.java @@ -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.implementation; @@ -19,6 +19,7 @@ import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; +import java.util.Locale; import java.util.TimeZone; public class CustomPropertiesMapper { @@ -53,14 +54,14 @@ else if (type == Boolean.class) { return value.toString(); } else if (Calendar.class.isAssignableFrom(type)) { - DateFormat format = new SimpleDateFormat(RFC_1123); + DateFormat format = new SimpleDateFormat(RFC_1123, Locale.US); Calendar calendar = (Calendar) value; format.setTimeZone(calendar.getTimeZone()); String formatted = format.format(calendar.getTime()); return "\"" + formatted + "\""; } else if (Date.class.isAssignableFrom(type)) { - DateFormat format = new SimpleDateFormat(RFC_1123); + DateFormat format = new SimpleDateFormat(RFC_1123, Locale.US); format.setTimeZone(TimeZone.getTimeZone("GMT")); String formatted = format.format((Date) value); return "\"" + formatted + "\""; @@ -78,7 +79,7 @@ public Object fromString(String value) throws ParseException { if (value.startsWith("\"") && value.endsWith("\"")) { String text = value.substring(1, value.length() - 1); if (isRFC1123(text)) { - SimpleDateFormat format = new SimpleDateFormat(RFC_1123); + SimpleDateFormat format = new SimpleDateFormat(RFC_1123, Locale.US); return format.parse(text); } @@ -103,7 +104,7 @@ private boolean isRFC1123(String text) { return false; } try { - SimpleDateFormat format = new SimpleDateFormat(RFC_1123); + SimpleDateFormat format = new SimpleDateFormat(RFC_1123, Locale.US); format.parse(text); return true; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/BrokeredMessage.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/BrokeredMessage.java index a2518f45afd9..3c222a52e793 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/BrokeredMessage.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/BrokeredMessage.java @@ -16,6 +16,7 @@ import java.io.ByteArrayInputStream; import java.io.InputStream; +import java.io.UnsupportedEncodingException; import java.util.Date; import java.util.HashMap; import java.util.Map; @@ -70,7 +71,12 @@ public BrokeredMessage(byte[] body) { */ public BrokeredMessage(String body) { this(new BrokerProperties()); - this.body = (body == null) ? null : new ByteArrayInputStream(body.getBytes()); + try { + this.body = (body == null) ? null : new ByteArrayInputStream(body.getBytes("UTF-8")); + } + catch (UnsupportedEncodingException e) { + throw new RuntimeException(e); + } } /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/Exports.java index 485104a66a29..6be3e3c25264 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/Exports.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/Exports.java @@ -17,7 +17,7 @@ import com.microsoft.windowsazure.services.core.Builder; import com.microsoft.windowsazure.services.core.UserAgentFilter; import com.microsoft.windowsazure.services.table.implementation.AtomReaderWriter; -import com.microsoft.windowsazure.services.table.implementation.DefaultEdmValueConterter; +import com.microsoft.windowsazure.services.table.implementation.DefaultEdmValueConverter; import com.microsoft.windowsazure.services.table.implementation.DefaultXMLStreamFactory; import com.microsoft.windowsazure.services.table.implementation.HttpReaderWriter; import com.microsoft.windowsazure.services.table.implementation.MimeReaderWriter; @@ -39,7 +39,7 @@ public void register(Builder.Registry registry) { registry.add(AtomReaderWriter.class); registry.add(MimeReaderWriter.class); registry.add(HttpReaderWriter.class); - registry.add(EdmValueConverter.class, DefaultEdmValueConterter.class); + registry.add(EdmValueConverter.class, DefaultEdmValueConverter.class); registry.add(UserAgentFilter.class); } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/DefaultEdmValueConterter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/DefaultEdmValueConverter.java similarity index 95% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/DefaultEdmValueConterter.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/DefaultEdmValueConverter.java index 8d1aff2334cb..cdf08312d8ae 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/DefaultEdmValueConterter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/DefaultEdmValueConverter.java @@ -25,12 +25,12 @@ import com.microsoft.windowsazure.services.table.models.EdmType; import com.sun.jersey.core.util.Base64; -public class DefaultEdmValueConterter implements EdmValueConverter { +public class DefaultEdmValueConverter implements EdmValueConverter { private final ISO8601DateConverter iso8601DateConverter; @Inject - public DefaultEdmValueConterter(ISO8601DateConverter iso8601DateConverter) { + public DefaultEdmValueConverter(ISO8601DateConverter iso8601DateConverter) { this.iso8601DateConverter = iso8601DateConverter; } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/QueueServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/QueueServiceIntegrationTest.java index 0380a7be8942..ecfeb03a0259 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/QueueServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/QueueServiceIntegrationTest.java @@ -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; @@ -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; @@ -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 @@ -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 @@ -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 diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/BrokerPropertiesMapperTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/BrokerPropertiesMapperTest.java index cef5f5f3b42b..ce827d0430ec 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/BrokerPropertiesMapperTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/BrokerPropertiesMapperTest.java @@ -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; @@ -18,14 +18,40 @@ import java.util.Calendar; import java.util.Date; +import java.util.Locale; import java.util.TimeZone; +import org.junit.BeforeClass; import org.junit.Test; import com.microsoft.windowsazure.services.serviceBus.implementation.BrokerProperties; import com.microsoft.windowsazure.services.serviceBus.implementation.BrokerPropertiesMapper; public class BrokerPropertiesMapperTest { + + private final String testBrokerPropertiesString = "{" + "\"CorrelationId\": \"corid\"," + + "\"SessionId\": \"sesid\"," + "\"DeliveryCount\": 5," + + "\"LockedUntilUtc\": \" Fri, 14 Oct 2011 12:34:56 GMT\"," + "\"LockToken\": \"loctok\"," + + "\"MessageId\": \"mesid\"," + "\"Label\": \"lab\"," + "\"ReplyTo\": \"repto\"," + + "\"SequenceNumber\": 7," + "\"TimeToLive\": 8.123," + "\"To\": \"to\"," + + "\"ScheduledEnqueueTimeUtc\": \" Sun, 06 Nov 1994 08:49:37 GMT\"," + + "\"ReplyToSessionId\": \"reptosesid\"," + "\"MessageLocation\": \"mesloc\"," + + "\"LockLocation\": \"locloc\"" + "}"; + + private static Date schedTimeUtc, lockedUntilUtc; + + @BeforeClass + public static void setup() { + Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT")); + calendar.set(1994, 10, 6, 8, 49, 37); + schedTimeUtc = calendar.getTime(); + + Calendar calendar2 = Calendar.getInstance(TimeZone.getTimeZone("GMT")); + calendar2.set(2011, 9, 14, 12, 34, 56); + lockedUntilUtc = calendar2.getTime(); + + } + @Test public void jsonStringMapsToBrokerPropertiesObject() { // Arrange @@ -61,33 +87,8 @@ public void deserializingAllPossibleValues() { // Arrange BrokerPropertiesMapper mapper = new BrokerPropertiesMapper(); - Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT")); - calendar.set(1994, 10, 6, 8, 49, 37); - Date schedTimeUtc = calendar.getTime(); - - Calendar calendar2 = Calendar.getInstance(TimeZone.getTimeZone("GMT")); - calendar2.set(2011, 9, 14, 12, 34, 56); - Date lockedUntilUtc = calendar2.getTime(); - // Act - BrokerProperties properties = mapper.fromString( - "{" + - "\"CorrelationId\": \"corid\"," + - "\"SessionId\": \"sesid\"," + - "\"DeliveryCount\": 5," + - "\"LockedUntilUtc\": \" Fri, 14 Oct 2011 12:34:56 GMT\"," + - "\"LockToken\": \"loctok\"," + - "\"MessageId\": \"mesid\"," + - "\"Label\": \"lab\"," + - "\"ReplyTo\": \"repto\"," + - "\"SequenceNumber\": 7," + - "\"TimeToLive\": 8.123," + - "\"To\": \"to\"," + - "\"ScheduledEnqueueTimeUtc\": \" Sun, 06 Nov 1994 08:49:37 GMT\"," + - "\"ReplyToSessionId\": \"reptosesid\"," + - "\"MessageLocation\": \"mesloc\"," + - "\"LockLocation\": \"locloc\"" + - "}"); + BrokerProperties properties = mapper.fromString(testBrokerPropertiesString); // Assert assertNotNull(properties); @@ -124,4 +125,53 @@ public void missingDatesDeserializeAsNull() { assertNull(properties.getLockedUntilUtc()); assertNull(properties.getScheduledEnqueueTimeUtc()); } + + @Test + public void deserializeDateInKrKrLocaleCorrectly() { + // Arrange + BrokerPropertiesMapper mapper = new BrokerPropertiesMapper(); + Locale defaultLocale = Locale.getDefault(); + Locale.setDefault(Locale.KOREA); + + // Act + BrokerProperties brokerProperties = mapper.fromString(testBrokerPropertiesString); + Locale.setDefault(defaultLocale); + + // Assert + long lockedUntilDelta = brokerProperties.getLockedUntilUtc().getTime() - lockedUntilUtc.getTime(); + assertTrue(Math.abs(lockedUntilDelta) < 2000); + } + + @Test + public void deserializeDateInEnUsLocaleCorrectly() { + // Arrange + BrokerPropertiesMapper mapper = new BrokerPropertiesMapper(); + Locale defaultLocale = Locale.getDefault(); + Locale.setDefault(Locale.US); + + // Act + BrokerProperties brokerProperties = mapper.fromString(testBrokerPropertiesString); + Locale.setDefault(defaultLocale); + + // Assert + long lockedUntilDelta = brokerProperties.getLockedUntilUtc().getTime() - lockedUntilUtc.getTime(); + assertTrue(Math.abs(lockedUntilDelta) < 2000); + + } + + @Test + public void deserializeDateInZhCnLocaleCorrectly() { + // Arrange + BrokerPropertiesMapper mapper = new BrokerPropertiesMapper(); + Locale defaultLocale = Locale.getDefault(); + Locale.setDefault(Locale.CHINA); + + // Act + BrokerProperties brokerProperties = mapper.fromString(testBrokerPropertiesString); + Locale.setDefault(defaultLocale); + + // Assert + long lockedUntilDelta = brokerProperties.getLockedUntilUtc().getTime() - lockedUntilUtc.getTime(); + assertTrue(Math.abs(lockedUntilDelta) < 2000); + } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/CustomPropertiesMapperTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/CustomPropertiesMapperTest.java index 2ab3572c34db..323912b28277 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/CustomPropertiesMapperTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/CustomPropertiesMapperTest.java @@ -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.implementation; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/implementation/AtomReaderWriterTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/implementation/AtomReaderWriterTests.java index 17578984f68c..1a2fd1ef0895 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/implementation/AtomReaderWriterTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/implementation/AtomReaderWriterTests.java @@ -32,7 +32,7 @@ public class AtomReaderWriterTests extends IntegrationTestBase { public void parseTableEntriesWorks() throws Exception { // Arrange AtomReaderWriter atom = new AtomReaderWriter(new DefaultXMLStreamFactory(), new DefaultDateFactory(), - new ISO8601DateConverter(), new DefaultEdmValueConterter(new ISO8601DateConverter())); + new ISO8601DateConverter(), new DefaultEdmValueConverter(new ISO8601DateConverter())); String feed = "\r\n" + "\r\n" + " Tables\r\n"