From 8a143d867d8d1ebbbd37b748c8991a15d4d86910 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Mon, 14 Jan 2013 14:47:26 -0800 Subject: [PATCH 01/17] update the unit tests so that the job integration tests have the right prefixes. --- .../windowsazure/services/media/EncryptionIntegrationTest.java | 2 +- .../windowsazure/services/media/IntegrationTestBase.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java index 7713b82f1cb9..012468b3f9fe 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java @@ -93,7 +93,7 @@ public void uploadAesProtectedAssetAndDownloadSuccess() throws Exception { uploadEncryptedAssetFile(assetInfo, blobWriter, "MPEG4-H264.mp4", encryptedContent, contentKeyId, iv); // submit and execute the decoding job. - JobInfo jobInfo = decodeAsset("uploadAesProtectedAssetSuccess", assetInfo.getId()); + JobInfo jobInfo = decodeAsset(testJobPrefix + "uploadAesProtectedAssetSuccess", assetInfo.getId()); // assert LinkInfo taskLinkInfo = jobInfo.getTasksLink(); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java index e2e893b86b1f..6535237b97d0 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java @@ -99,8 +99,8 @@ protected static void cleanupEnvironment() { removeAllTestLocators(); removeAllTestAssets(); removeAllTestAccessPolicies(); - removeAllTestContentKeys(); removeAllTestJobs(); + removeAllTestContentKeys(); } private static void removeAllTestContentKeys() { From 624cfa209a4969c746b2c360eb60e23bf84adaa9 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Mon, 14 Jan 2013 15:33:25 -0800 Subject: [PATCH 02/17] add TaskHistoricalEvent to the queue. --- .../media/models/TaskHistoricalEvent.java | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskHistoricalEvent.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskHistoricalEvent.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskHistoricalEvent.java new file mode 100644 index 000000000000..14d44fc85142 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskHistoricalEvent.java @@ -0,0 +1,76 @@ +/* + * 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 + * + * 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.media.models; + +import java.util.Date; + +/** + * The Class TaskHistoricalEvent. + */ +public class TaskHistoricalEvent { + + /** The code. */ + private final String code; + + /** The message. */ + private final String message; + + /** The time stamp. */ + private final Date timeStamp; + + /** + * Instantiates a new error detail. + * + * @param code + * the code + * @param message + * the message + * @param timeStamp + * the time stamp + */ + public TaskHistoricalEvent(String code, String message, Date timeStamp) { + this.code = code; + this.message = message; + this.timeStamp = timeStamp; + } + + /** + * Gets the code. + * + * @return the code + */ + public String getCode() { + return this.code; + } + + /** + * Gets the message. + * + * @return the message + */ + public String getMessage() { + return this.message; + } + + /** + * Gets the time stamp. + * + * @return the time stamp + */ + public Date getTimeStamp() { + return this.timeStamp; + } +} From 84c6bd5d8495d52302de49da9158c4dc684c6170 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Mon, 14 Jan 2013 16:56:51 -0800 Subject: [PATCH 03/17] partial checkin for task historical event --- .../services/media/models/TaskInfo.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java index 8e8c3cd11087..6155b441531e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java @@ -86,6 +86,22 @@ public List getErrorDetails() { return null; } + public List getTaskHistoricalEvents() { + List result = new ArrayList(); + List taskHistoricalEventTypes = getContent().getTaskHistoricalEventTypes(); + + if (taskHistoricalEventTypes != null) { + for (TaskHistoricalEventType taskHistoricalEventType : taskHistoricalEventTypes) { + TaskHistoricalEvent taskHistoricalEvent = new TaskHistoricalEvent(taskHistoricalEventType.getCode(), taskHistoricalEventType.getMessage(), taskHistoricalEventType.get) + result.add(taskHistoricalEvent); + } + } + + + + return null; + } + /** * Gets the media processor id. * From 76d9ecc7c05a786a4bdb59d88937fc573b19f9db Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Tue, 15 Jan 2013 14:03:45 -0800 Subject: [PATCH 04/17] initial check in to add task historical event type. --- .../content/TaskHistoricalEventType.java | 80 +++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskHistoricalEventType.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskHistoricalEventType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskHistoricalEventType.java new file mode 100644 index 000000000000..3a5ffdef35f3 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskHistoricalEventType.java @@ -0,0 +1,80 @@ +/** + * 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 + * + * 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.media.implementation.content; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; + +/** + * This type maps the XML returned in the odata ATOM serialization + * for ErrorDetail entities. + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +public class ErrorDetailType implements MediaServiceDTO { + + /** The code. */ + @XmlElement(name = "Code", namespace = Constants.ODATA_DATA_NS) + protected String code; + + /** The message. */ + @XmlElement(name = "Message", namespace = Constants.ODATA_DATA_NS) + protected String message; + + /** + * Gets the code. + * + * @return the code + */ + public String getCode() { + return code; + } + + /** + * Sets the code. + * + * @param code + * the id to set + * @return the error detail type + */ + public ErrorDetailType setCode(String code) { + this.code = code; + return this; + } + + /** + * Gets the message. + * + * @return the message + */ + public String getMessage() { + return message; + } + + /** + * Sets the message. + * + * @param message + * the message to set + * @return the error detail type + */ + public ErrorDetailType setMessage(String message) { + this.message = message; + return this; + } + +} From 7d5b4b63074cee3efae9b85eb0185e80fd27852e Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Tue, 15 Jan 2013 17:39:54 -0800 Subject: [PATCH 05/17] second checkin to support task historical events. --- .../content/TaskHistoricalEventType.java | 36 +++++++++++++++++-- .../implementation/content/TaskType.java | 13 +++++++ .../services/media/models/TaskInfo.java | 10 +++--- 3 files changed, 51 insertions(+), 8 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskHistoricalEventType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskHistoricalEventType.java index 3a5ffdef35f3..d5398864e226 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskHistoricalEventType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskHistoricalEventType.java @@ -15,6 +15,8 @@ package com.microsoft.windowsazure.services.media.implementation.content; +import java.util.Date; + import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; @@ -25,7 +27,7 @@ * */ @XmlAccessorType(XmlAccessType.FIELD) -public class ErrorDetailType implements MediaServiceDTO { +public class TaskHistoricalEventType implements MediaServiceDTO { /** The code. */ @XmlElement(name = "Code", namespace = Constants.ODATA_DATA_NS) @@ -35,7 +37,14 @@ public class ErrorDetailType implements MediaServiceDTO { @XmlElement(name = "Message", namespace = Constants.ODATA_DATA_NS) protected String message; + /** The time stamp. */ + @XmlElement(name = "TimeStamp", namespace = Constants.ODATA_DATA_NS) + protected Date timeStamp; + /** + * The + * + * /** * Gets the code. * * @return the code @@ -51,7 +60,7 @@ public String getCode() { * the id to set * @return the error detail type */ - public ErrorDetailType setCode(String code) { + public TaskHistoricalEventType setCode(String code) { this.code = code; return this; } @@ -72,9 +81,30 @@ public String getMessage() { * the message to set * @return the error detail type */ - public ErrorDetailType setMessage(String message) { + public TaskHistoricalEventType setMessage(String message) { this.message = message; return this; } + /** + * Gets the time stamp. + * + * @return the time stamp + */ + public Date getTimeStamp() { + return timeStamp; + } + + /** + * Sets the time stamp. + * + * @param timeStamp + * the time stamp + * @return the task historical event type + */ + public TaskHistoricalEventType setTimeStamp(Date timeStamp) { + this.timeStamp = timeStamp; + return this; + } + } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskType.java index 9436ca9ab025..a2ca4a59889b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskType.java @@ -44,6 +44,10 @@ public class TaskType implements MediaServiceDTO { @XmlElement(name = "element", namespace = Constants.ODATA_DATA_NS) protected List errorDetails; + @XmlElementWrapper(name = "TaskHistoricalEventDetails", namespace = Constants.ODATA_DATA_NS) + @XmlElement(name = "element", namespace = Constants.ODATA_DATA_NS) + protected List taskHistoricalEventTypes; + @XmlElement(name = "MediaProcessorId", namespace = Constants.ODATA_DATA_NS) protected String mediaProcessorId; @@ -269,4 +273,13 @@ public TaskType setInputMediaAssets(List inputMediaAssets) { this.inputMediaAssets = inputMediaAssets; return this; } + + public List getTaskHistoricalEventTypes() { + return taskHistoricalEventTypes; + } + + public TaskType setTaskHistoricalEventTypes(List taskHistoricalEventTypes) { + this.taskHistoricalEventTypes = taskHistoricalEventTypes; + return this; + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java index 6155b441531e..99b983acfb1b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java @@ -22,6 +22,7 @@ import com.microsoft.windowsazure.services.media.implementation.ODataEntity; import com.microsoft.windowsazure.services.media.implementation.atom.EntryType; import com.microsoft.windowsazure.services.media.implementation.content.ErrorDetailType; +import com.microsoft.windowsazure.services.media.implementation.content.TaskHistoricalEventType; import com.microsoft.windowsazure.services.media.implementation.content.TaskType; /** @@ -89,16 +90,15 @@ public List getErrorDetails() { public List getTaskHistoricalEvents() { List result = new ArrayList(); List taskHistoricalEventTypes = getContent().getTaskHistoricalEventTypes(); - + if (taskHistoricalEventTypes != null) { for (TaskHistoricalEventType taskHistoricalEventType : taskHistoricalEventTypes) { - TaskHistoricalEvent taskHistoricalEvent = new TaskHistoricalEvent(taskHistoricalEventType.getCode(), taskHistoricalEventType.getMessage(), taskHistoricalEventType.get) + TaskHistoricalEvent taskHistoricalEvent = new TaskHistoricalEvent(taskHistoricalEventType.getCode(), + taskHistoricalEventType.getMessage(), taskHistoricalEventType.getTimeStamp()); result.add(taskHistoricalEvent); } } - - - + return null; } From 466c43b9657535f8d6634e196394a3f8a11968c7 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Tue, 22 Jan 2013 17:10:18 -0800 Subject: [PATCH 06/17] add job integration test for taskhistorical event --- .../implementation/content/TaskType.java | 2 +- .../services/media/models/TaskInfo.java | 2 +- .../services/media/JobIntegrationTest.java | 26 +++++++++++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskType.java index a2ca4a59889b..2626a0489a7a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskType.java @@ -44,7 +44,7 @@ public class TaskType implements MediaServiceDTO { @XmlElement(name = "element", namespace = Constants.ODATA_DATA_NS) protected List errorDetails; - @XmlElementWrapper(name = "TaskHistoricalEventDetails", namespace = Constants.ODATA_DATA_NS) + @XmlElementWrapper(name = "HistoricalEvents", namespace = Constants.ODATA_DATA_NS) @XmlElement(name = "element", namespace = Constants.ODATA_DATA_NS) protected List taskHistoricalEventTypes; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java index 99b983acfb1b..e63c8ff4ff9c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java @@ -99,7 +99,7 @@ public List getTaskHistoricalEvents() { } } - return null; + return result; } /** diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java index d93041f2c533..8ce2bd357891 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java @@ -35,6 +35,7 @@ import com.microsoft.windowsazure.services.media.models.ListResult; import com.microsoft.windowsazure.services.media.models.Task; import com.microsoft.windowsazure.services.media.models.Task.CreateBatchOperation; +import com.microsoft.windowsazure.services.media.models.TaskHistoricalEvent; import com.microsoft.windowsazure.services.media.models.TaskInfo; public class JobIntegrationTest extends IntegrationTestBase { @@ -344,4 +345,29 @@ public void canGetInputOutputAssetsFromTask() throws Exception { assertTrue(outputs.get(0).getName().contains(name)); } + @Test + public void canGetTaskHistoricalEventsFromTask() throws Exception { + // Arrange + String jobName = testJobPrefix + "canGetTaskHistoricalEventsFromTask"; + int priority = 3; + int retryCounter = 0; + + // Act + JobInfo actualJobInfo = service.create(Job.create().setName(jobName).setPriority(priority) + .addInputMediaAsset(assetInfo.getId()).addTaskCreator(getTaskCreator(0))); + + while (actualJobInfo.getState().getCode() < 3 && retryCounter < 30) { + Thread.sleep(10000); + actualJobInfo = service.get(Job.get(actualJobInfo.getId())); + retryCounter++; + } + ListResult tasks = service.list(Task.list(actualJobInfo.getTasksLink())); + TaskInfo taskInfo = tasks.get(0); + List taskHistoricalEvents = taskInfo.getTaskHistoricalEvents(); + + // Assert + assertEquals(5, taskHistoricalEvents.size()); + + } + } From f7dce4bd3ed875217afa0b30c5063e09704dfada Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Thu, 24 Jan 2013 16:22:18 -0800 Subject: [PATCH 07/17] code review feedback. --- .../content/TaskHistoricalEventType.java | 3 --- .../implementation/content/TaskType.java | 10 ++++---- .../services/media/models/TaskInfo.java | 23 +++++++++++++------ .../services/media/JobIntegrationTest.java | 9 +++++--- 4 files changed, 27 insertions(+), 18 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskHistoricalEventType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskHistoricalEventType.java index d5398864e226..973b9b53c3e2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskHistoricalEventType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskHistoricalEventType.java @@ -42,9 +42,6 @@ public class TaskHistoricalEventType implements MediaServiceDTO { protected Date timeStamp; /** - * The - * - * /** * Gets the code. * * @return the code diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskType.java index 2626a0489a7a..e6486eb697d0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskType.java @@ -46,7 +46,7 @@ public class TaskType implements MediaServiceDTO { @XmlElementWrapper(name = "HistoricalEvents", namespace = Constants.ODATA_DATA_NS) @XmlElement(name = "element", namespace = Constants.ODATA_DATA_NS) - protected List taskHistoricalEventTypes; + protected List historicalEventTypes; @XmlElement(name = "MediaProcessorId", namespace = Constants.ODATA_DATA_NS) protected String mediaProcessorId; @@ -274,12 +274,12 @@ public TaskType setInputMediaAssets(List inputMediaAssets) { return this; } - public List getTaskHistoricalEventTypes() { - return taskHistoricalEventTypes; + public List getHistoricalEventTypes() { + return historicalEventTypes; } - public TaskType setTaskHistoricalEventTypes(List taskHistoricalEventTypes) { - this.taskHistoricalEventTypes = taskHistoricalEventTypes; + public TaskType setHistoricalEventTypes(List historicalEventTypes) { + this.historicalEventTypes = historicalEventTypes; return this; } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java index e63c8ff4ff9c..6f22c00bb769 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java @@ -87,14 +87,23 @@ public List getErrorDetails() { return null; } - public List getTaskHistoricalEvents() { + /** + * Gets the task historical events. + * + * @return the task historical events + */ + public List getHistoricalEvents() { List result = new ArrayList(); - List taskHistoricalEventTypes = getContent().getTaskHistoricalEventTypes(); + List historicalEventTypes = getContent().getHistoricalEventTypes(); - if (taskHistoricalEventTypes != null) { - for (TaskHistoricalEventType taskHistoricalEventType : taskHistoricalEventTypes) { + if (historicalEventTypes != null) { + for (TaskHistoricalEventType taskHistoricalEventType : historicalEventTypes) { + String message = taskHistoricalEventType.getMessage(); + if ((message != null) && (message.isEmpty())) { + message = null; + } TaskHistoricalEvent taskHistoricalEvent = new TaskHistoricalEvent(taskHistoricalEventType.getCode(), - taskHistoricalEventType.getMessage(), taskHistoricalEventType.getTimeStamp()); + message, taskHistoricalEventType.getTimeStamp()); result.add(taskHistoricalEvent); } } @@ -229,7 +238,7 @@ public String getInitializationVector() { } /** - * Gets link to the task's input assets + * Gets link to the task's input assets. * * @return the link */ @@ -238,7 +247,7 @@ public LinkInfo getInputAssetsLink() { } /** - * Gets link to the task's output assets + * Gets link to the task's output assets. * * @return the link */ diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java index 8ce2bd357891..def737d69d56 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java @@ -363,11 +363,14 @@ public void canGetTaskHistoricalEventsFromTask() throws Exception { } ListResult tasks = service.list(Task.list(actualJobInfo.getTasksLink())); TaskInfo taskInfo = tasks.get(0); - List taskHistoricalEvents = taskInfo.getTaskHistoricalEvents(); + List historicalEvents = taskInfo.getHistoricalEvents(); + TaskHistoricalEvent historicalEvent = historicalEvents.get(0); // Assert - assertEquals(5, taskHistoricalEvents.size()); - + assertEquals(5, historicalEvents.size()); + assertNotNull(historicalEvent.getCode()); + assertNotNull(historicalEvent.getTimeStamp()); + assertNull(historicalEvent.getMessage()); } } From 6db3cad63749441f220db23ea6fe0078578a2a5c Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Thu, 24 Jan 2013 16:44:50 -0800 Subject: [PATCH 08/17] a missed unit test. --- .../windowsazure/services/media/JobIntegrationTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java index def737d69d56..ebfa367250e1 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java @@ -367,7 +367,7 @@ public void canGetTaskHistoricalEventsFromTask() throws Exception { TaskHistoricalEvent historicalEvent = historicalEvents.get(0); // Assert - assertEquals(5, historicalEvents.size()); + assertTrue(historicalEvents.size() >= 5); assertNotNull(historicalEvent.getCode()); assertNotNull(historicalEvent.getTimeStamp()); assertNull(historicalEvent.getMessage()); From 78067fcb4d816044818f4b0daa5024ace55888ec Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" Date: Mon, 28 Jan 2013 14:12:30 -0800 Subject: [PATCH 09/17] Minor changes to address the compile-time warnings --- .../core/utils/ServiceExceptionFactory.java | 2 +- .../implementation/BrokerProperties.java | 20 ++++++------ .../services/table/client/TableQuery.java | 4 +++ .../table/implementation/TableRestProxy.java | 4 +++ .../queue/client/CloudQueueClientTests.java | 32 ++++++++++++++----- .../queue/client/CloudQueueTests.java | 8 +++-- .../serviceBus/ServiceBusIntegrationTest.java | 2 +- 7 files changed, 50 insertions(+), 22 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/ServiceExceptionFactory.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/ServiceExceptionFactory.java index 2efac14c00b0..2d7a029c30c7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/ServiceExceptionFactory.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/ServiceExceptionFactory.java @@ -28,7 +28,7 @@ public static ServiceException process(String serviceName, ServiceException exce Throwable cause = exception.getCause(); for (Throwable scan = cause; scan != null; scan = scan.getCause()) { - Class scanClass = scan.getClass(); + Class scanClass = scan.getClass(); if (ServiceException.class.isAssignableFrom(scanClass)) { return populate(exception, serviceName, (ServiceException) scan); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/BrokerProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/BrokerProperties.java index 2db84273def9..e67717853055 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/BrokerProperties.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/BrokerProperties.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,7 +19,7 @@ import org.codehaus.jackson.annotate.JsonIgnore; import org.codehaus.jackson.annotate.JsonIgnoreProperties; import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.annotate.JsonWriteNullProperties; +import org.codehaus.jackson.map.annotate.JsonSerialize; // // members of this class defined per specification at @@ -27,7 +27,7 @@ // @JsonIgnoreProperties(ignoreUnknown = true) -@JsonWriteNullProperties(false) +@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL) public class BrokerProperties { @JsonProperty("CorrelationId") diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableQuery.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableQuery.java index 6b5e12695101..924ab0fead22 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableQuery.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableQuery.java @@ -202,6 +202,8 @@ public static String generateFilterCondition(String propertyName, String operati for (byte b : value) { formatter.format("%02x", b); } + formatter.flush(); + formatter.close(); return generateFilterCondition(propertyName, operation, sb.toString(), EdmType.BINARY); } @@ -232,6 +234,8 @@ public static String generateFilterCondition(String propertyName, String operati for (byte b : value) { formatter.format("%02x", b); } + formatter.flush(); + formatter.close(); return generateFilterCondition(propertyName, operation, sb.toString(), EdmType.BINARY); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/TableRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/TableRestProxy.java index 72379bb2582b..193f2305b199 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/TableRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/TableRestProxy.java @@ -257,6 +257,8 @@ else if (value.getClass() == byte[].class) { for (byte b : byteArray) { formatter.format("%02x", b); } + formatter.flush(); + formatter.close(); sb.append("'"); } else if (value.getClass() == Byte[].class) { @@ -266,6 +268,8 @@ else if (value.getClass() == Byte[].class) { for (Byte b : byteArray) { formatter.format("%02x", b); } + formatter.flush(); + formatter.close(); sb.append("'"); } else { diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/CloudQueueClientTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/CloudQueueClientTests.java index b3c266fac5ae..0d560e3f9ef2 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/CloudQueueClientTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/CloudQueueClientTests.java @@ -67,7 +67,9 @@ public void testListQueuesSmallNumber() throws URISyntaxException, StorageExcept int initialCount = 0; for (CloudQueue queue : qClient.listQueues()) { - initialCount++; + if (queue != null) { + initialCount++; + } } HashMap metadata1 = new HashMap(); @@ -82,7 +84,9 @@ public void testListQueuesSmallNumber() throws URISyntaxException, StorageExcept int count = 0; for (CloudQueue queue : qClient.listQueues()) { - count++; + if (queue != null) { + count++; + } } Assert.assertEquals(count, initialCount + 25); @@ -99,7 +103,9 @@ public void testListQueuesSmallNumber() throws URISyntaxException, StorageExcept count = 0; for (CloudQueue queue : qClient.listQueues(perfix, QueueListingDetails.METADATA, null, null)) { - count++; + if (queue != null) { + count++; + } Assert.assertTrue(queue.getMetadata().size() == 1 && queue.getMetadata().get("tags").equals(queue.getName())); } @@ -111,7 +117,9 @@ public void testListQueuesSmallNumber() throws URISyntaxException, StorageExcept public void testListQueuesAndListQueuesSegmentedLargeNumber() throws URISyntaxException, StorageException { int count = 0; for (CloudQueue queue : qClient.listQueues()) { - count++; + if (queue != null) { + count++; + } } int totalLimit = 5005; @@ -130,7 +138,9 @@ public void testListQueuesAndListQueuesSegmentedLargeNumber() throws URISyntaxEx count = 0; for (CloudQueue queue : qClient.listQueues()) { - count++; + if (queue != null) { + count++; + } } } @@ -181,17 +191,23 @@ public void testListQueuesSegmented() throws URISyntaxException, StorageExceptio public void testListQueuesEqual() throws URISyntaxException, StorageException { int count1 = 0; for (CloudQueue queue : qClient.listQueues()) { - count1++; + if (queue != null) { + count1++; + } } int count2 = 0; for (CloudQueue queue : qClient.listQueues("")) { - count2++; + if (queue != null) { + count2++; + } } int count3 = 0; for (CloudQueue queue : qClient.listQueues(null)) { - count3++; + if (queue != null) { + count3++; + } } Assert.assertEquals(count1, count2); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/CloudQueueTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/CloudQueueTests.java index d97bb4bdc7b4..bf9b428d9fa8 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/CloudQueueTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/CloudQueueTests.java @@ -487,7 +487,9 @@ public void testClearMessages() throws URISyntaxException, StorageException, Uns int count = 0; for (CloudQueueMessage m : queue.peekMessages(32)) { - count++; + if (m != null) { + count++; + } } Assert.assertTrue(count == 2); @@ -498,7 +500,9 @@ public void testClearMessages() throws URISyntaxException, StorageException, Uns count = 0; for (CloudQueueMessage m : queue.peekMessages(32)) { - count++; + if (m != null) { + count++; + } } Assert.assertTrue(count == 0); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java index bd86d9b7abf9..c09af13305b8 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java @@ -128,7 +128,7 @@ public void getNonExistQueueFail() throws Exception { String queuePath = "testGetNonExistQueueFail"; // Act - GetQueueResult getQueueResult = service.getQueue(queuePath); + service.getQueue(queuePath); // Assert } From 7a8812e48afa72b8fe227a64e8d2122f2e0fd8ee Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" Date: Tue, 29 Jan 2013 09:15:31 -0800 Subject: [PATCH 10/17] Remove trivial TODO comments from tests --- .../Protocol1RuntimeGoalStateClientTests.java | 24 +++++++++---------- .../queue/client/CloudQueueTests.java | 4 ---- .../table/client/TableQueryTests.java | 1 - 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeGoalStateClientTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeGoalStateClientTests.java index 42f4d4acab31..00a669a080ff 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeGoalStateClientTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeGoalStateClientTests.java @@ -2,25 +2,26 @@ * 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; +import static org.hamcrest.Matchers.*; +import static org.junit.Assert.*; + import java.io.InputStream; import java.util.LinkedList; import java.util.List; import org.junit.Test; -import static org.junit.Assert.*; -import static org.hamcrest.Matchers.*; /** * @@ -88,7 +89,7 @@ public void goalStateClientRestartsThread() { Protocol1RuntimeCurrentStateClient currentStateClient = new Protocol1RuntimeCurrentStateClient(null, null); GoalStateDeserializer goalStateDeserializer = new GoalStateDeserializer() { - private ChunkedGoalStateDeserializer deserializer = new ChunkedGoalStateDeserializer(); + private final ChunkedGoalStateDeserializer deserializer = new ChunkedGoalStateDeserializer(); @Override public void initialize(InputStream inputStream) { @@ -148,7 +149,6 @@ public RoleEnvironmentData deserialize(InputStream stream) { client.getCurrentGoalState(); } catch (InterruptedException e) { - // TODO Auto-generated catch block e.printStackTrace(); } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/CloudQueueTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/CloudQueueTests.java index bf9b428d9fa8..543b0b382cd3 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/CloudQueueTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/CloudQueueTests.java @@ -691,7 +691,6 @@ public void testAddMessageWithVisibilityTimeout() throws URISyntaxException, Sto Thread.sleep(2000); } catch (InterruptedException e) { - // TODO Auto-generated catch block e.printStackTrace(); } @@ -841,7 +840,6 @@ public void testRetrieveMessage() throws URISyntaxException, StorageException, U Thread.sleep(2000); } catch (InterruptedException e) { - // TODO Auto-generated catch block e.printStackTrace(); } @@ -934,7 +932,6 @@ public void testDequeueCountIncreases() throws URISyntaxException, StorageExcept Thread.sleep(2000); } catch (InterruptedException e) { - // TODO Auto-generated catch block e.printStackTrace(); } @@ -1170,7 +1167,6 @@ public void testUpdateMessageFullPass() throws URISyntaxException, StorageExcept Thread.sleep(2000); } catch (InterruptedException e) { - // TODO Auto-generated catch block e.printStackTrace(); } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableQueryTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableQueryTests.java index 7bec262714c0..8023517879ac 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableQueryTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableQueryTests.java @@ -364,7 +364,6 @@ public void testQueryOnSupportedTypes() throws StorageException { Thread.sleep(100); } catch (InterruptedException e) { - // TODO Auto-generated catch block e.printStackTrace(); } batch.insert(ent); From dda240d20da918b7529df2b014e5646c3ea079a6 Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" Date: Tue, 29 Jan 2013 09:19:28 -0800 Subject: [PATCH 11/17] Removing trivial TODO Auto-generated comments --- .../serviceruntime/RoleEnvironment.java | 18 ++++++------ .../BrokerPropertiesMapper.java | 28 ++++++------------- .../implementation/MarshallerProvider.java | 23 ++++++--------- .../table/implementation/SharedKeyFilter.java | 2 -- 4 files changed, 26 insertions(+), 45 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironment.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironment.java index 5d8f04727b04..e5e3e865f67c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironment.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironment.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; @@ -50,7 +50,6 @@ public final class RoleEnvironment { JAXBContext.newInstance(RoleEnvironment.class.getPackage().getName()); } catch (JAXBException e) { - // TODO Auto-generated catch block e.printStackTrace(); } clientId = UUID.randomUUID().toString(); @@ -93,6 +92,7 @@ private static synchronized void initialize() { lastState = new AtomicReference(); runtimeClient.addGoalStateChangedListener(new GoalStateChangedListener() { + @Override public void goalStateChanged(GoalState newGoalState) { switch (newGoalState.getExpectedState()) { case STARTED: 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 5a8dda45f9ba..a01aa2aed43b 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 @@ -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; @@ -31,18 +31,12 @@ public BrokerProperties fromString(String value) throws IllegalArgumentException return mapper.readValue(value.getBytes(), BrokerProperties.class); } catch (JsonParseException e) { - // TODO Auto-generated catch block - e.printStackTrace(); throw new IllegalArgumentException(e); } catch (JsonMappingException e) { - // TODO Auto-generated catch block - e.printStackTrace(); throw new IllegalArgumentException(e); } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); throw new IllegalArgumentException(e); } } @@ -54,18 +48,12 @@ public String toString(BrokerProperties value) { mapper.writeValue(writer, value); } catch (JsonGenerationException e) { - // TODO Auto-generated catch block - e.printStackTrace(); throw new RuntimeException(e); } catch (JsonMappingException e) { - // TODO Auto-generated catch block - e.printStackTrace(); throw new RuntimeException(e); } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); throw new RuntimeException(e); } return writer.toString(); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/MarshallerProvider.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/MarshallerProvider.java index fbda9c3f7f5e..3edfc51d87c2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/MarshallerProvider.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/MarshallerProvider.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; @@ -30,19 +30,16 @@ public class MarshallerProvider implements ContextResolver { @Context private ContextResolver jaxbContextResolver; + @Override public Marshaller getContext(Class type) { Marshaller marshaller; try { marshaller = getJAXBContext(type).createMarshaller(); } catch (JAXBException e) { - // TODO Auto-generated catch block - e.printStackTrace(); return null; } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); return null; } com.sun.xml.bind.marshaller.NamespacePrefixMapper mapper = new NamespacePrefixMapperImpl(); @@ -50,8 +47,6 @@ public Marshaller getContext(Class type) { marshaller.setProperty("com.sun.xml.bind.namespacePrefixMapper", mapper); } catch (PropertyException e) { - // TODO Auto-generated catch block - e.printStackTrace(); return null; } return marshaller; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/SharedKeyFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/SharedKeyFilter.java index d14843554216..352115a45dba 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/SharedKeyFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/SharedKeyFilter.java @@ -55,8 +55,6 @@ public void sign(ClientRequest cr) { if (log.isDebugEnabled()) { log.debug(String.format("String to sign: \"%s\"", stringToSign)); } - //TODO: Remove or comment the following line - //System.out.println(String.format("String to sign: \"%s\"", stringToSign)); String signature = this.getSigner().sign(stringToSign); cr.getHeaders().putSingle("Authorization", "SharedKey " + this.getAccountName() + ":" + signature); From 40bd3e5a0eb9bbd70f918fd188c11c2ff0666ad1 Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" Date: Tue, 29 Jan 2013 10:32:33 -0800 Subject: [PATCH 12/17] Replace trivial *if* statement with more useful Assert --- .../queue/client/CloudQueueClientTests.java | 39 +++++++------------ .../queue/client/CloudQueueTests.java | 10 ++--- 2 files changed, 19 insertions(+), 30 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/CloudQueueClientTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/CloudQueueClientTests.java index 0d560e3f9ef2..fd3a57a7f1f1 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/CloudQueueClientTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/CloudQueueClientTests.java @@ -67,9 +67,8 @@ public void testListQueuesSmallNumber() throws URISyntaxException, StorageExcept int initialCount = 0; for (CloudQueue queue : qClient.listQueues()) { - if (queue != null) { - initialCount++; - } + Assert.assertNotNull(queue); + initialCount++; } HashMap metadata1 = new HashMap(); @@ -84,9 +83,8 @@ public void testListQueuesSmallNumber() throws URISyntaxException, StorageExcept int count = 0; for (CloudQueue queue : qClient.listQueues()) { - if (queue != null) { - count++; - } + Assert.assertNotNull(queue); + count++; } Assert.assertEquals(count, initialCount + 25); @@ -103,9 +101,7 @@ public void testListQueuesSmallNumber() throws URISyntaxException, StorageExcept count = 0; for (CloudQueue queue : qClient.listQueues(perfix, QueueListingDetails.METADATA, null, null)) { - if (queue != null) { - count++; - } + count++; Assert.assertTrue(queue.getMetadata().size() == 1 && queue.getMetadata().get("tags").equals(queue.getName())); } @@ -117,9 +113,8 @@ public void testListQueuesSmallNumber() throws URISyntaxException, StorageExcept public void testListQueuesAndListQueuesSegmentedLargeNumber() throws URISyntaxException, StorageException { int count = 0; for (CloudQueue queue : qClient.listQueues()) { - if (queue != null) { - count++; - } + Assert.assertNotNull(queue); + count++; } int totalLimit = 5005; @@ -138,9 +133,8 @@ public void testListQueuesAndListQueuesSegmentedLargeNumber() throws URISyntaxEx count = 0; for (CloudQueue queue : qClient.listQueues()) { - if (queue != null) { - count++; - } + Assert.assertNotNull(queue); + count++; } } @@ -191,23 +185,20 @@ public void testListQueuesSegmented() throws URISyntaxException, StorageExceptio public void testListQueuesEqual() throws URISyntaxException, StorageException { int count1 = 0; for (CloudQueue queue : qClient.listQueues()) { - if (queue != null) { - count1++; - } + Assert.assertNotNull(queue); + count1++; } int count2 = 0; for (CloudQueue queue : qClient.listQueues("")) { - if (queue != null) { - count2++; - } + Assert.assertNotNull(queue); + count2++; } int count3 = 0; for (CloudQueue queue : qClient.listQueues(null)) { - if (queue != null) { - count3++; - } + Assert.assertNotNull(queue); + count3++; } Assert.assertEquals(count1, count2); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/CloudQueueTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/CloudQueueTests.java index 543b0b382cd3..699bbd128b10 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/CloudQueueTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/CloudQueueTests.java @@ -487,9 +487,8 @@ public void testClearMessages() throws URISyntaxException, StorageException, Uns int count = 0; for (CloudQueueMessage m : queue.peekMessages(32)) { - if (m != null) { - count++; - } + Assert.assertNotNull(m); + count++; } Assert.assertTrue(count == 2); @@ -500,9 +499,8 @@ public void testClearMessages() throws URISyntaxException, StorageException, Uns count = 0; for (CloudQueueMessage m : queue.peekMessages(32)) { - if (m != null) { - count++; - } + Assert.assertNotNull(m); + count++; } Assert.assertTrue(count == 0); From 269db3f312b47e10969aec4a3f84787a47a5721e Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" Date: Tue, 29 Jan 2013 11:11:16 -0800 Subject: [PATCH 13/17] Remove "catch (InterruptedException e)" that could obscure unexpected test failres. --- .../queue/client/CloudQueueTests.java | 40 +++++-------------- .../table/client/TableQueryTests.java | 11 ++--- 2 files changed, 14 insertions(+), 37 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/CloudQueueTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/CloudQueueTests.java index 699bbd128b10..9258e5931787 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/CloudQueueTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/CloudQueueTests.java @@ -676,7 +676,7 @@ public void testAddMessageLargeMessageInput() throws URISyntaxException, Storage @Test public void testAddMessageWithVisibilityTimeout() throws URISyntaxException, StorageException, - UnsupportedEncodingException { + UnsupportedEncodingException, InterruptedException { final String queueName = UUID.randomUUID().toString().toLowerCase(); final CloudQueue queue = qClient.getQueueReference(queueName); queue.create(); @@ -685,12 +685,7 @@ public void testAddMessageWithVisibilityTimeout() throws URISyntaxException, Sto Date d1 = m1.getExpirationTime(); queue.deleteMessage(m1); - try { - Thread.sleep(2000); - } - catch (InterruptedException e) { - e.printStackTrace(); - } + Thread.sleep(2000); queue.addMessage(new CloudQueueMessage("message"), 20, 0, null, null); CloudQueueMessage m2 = queue.retrieveMessage(); @@ -819,7 +814,8 @@ public void testDeleteMessageNullMessage() throws URISyntaxException, StorageExc } @Test - public void testRetrieveMessage() throws URISyntaxException, StorageException, UnsupportedEncodingException { + public void testRetrieveMessage() throws URISyntaxException, StorageException, UnsupportedEncodingException, + InterruptedException { String queueName = UUID.randomUUID().toString().toLowerCase(); CloudQueue newQueue = qClient.getQueueReference(queueName); newQueue.create(); @@ -834,12 +830,7 @@ public void testRetrieveMessage() throws URISyntaxException, StorageException, U newQueue.deleteMessage(message1); - try { - Thread.sleep(2000); - } - catch (InterruptedException e) { - e.printStackTrace(); - } + Thread.sleep(2000); newQueue.addMessage(new CloudQueueMessage("message"), 20, 0, null, null); CloudQueueMessage message2 = newQueue.retrieveMessage(); @@ -917,7 +908,8 @@ public void testRetrieveMessagesNonFound() throws URISyntaxException, StorageExc } @Test - public void testDequeueCountIncreases() throws URISyntaxException, StorageException, UnsupportedEncodingException { + public void testDequeueCountIncreases() throws URISyntaxException, StorageException, UnsupportedEncodingException, + InterruptedException { String queueName = UUID.randomUUID().toString().toLowerCase(); CloudQueue newQueue = qClient.getQueueReference(queueName); newQueue.create(); @@ -926,13 +918,7 @@ public void testDequeueCountIncreases() throws URISyntaxException, StorageExcept Assert.assertTrue(message1.getDequeueCount() == 1); for (int i = 2; i < 5; i++) { - try { - Thread.sleep(2000); - } - catch (InterruptedException e) { - e.printStackTrace(); - } - + Thread.sleep(2000); CloudQueueMessage message2 = newQueue.retrieveMessage(1, null, null); Assert.assertTrue(message2.getDequeueCount() == i); } @@ -1146,7 +1132,8 @@ public void testUpdateMessage() throws URISyntaxException, StorageException, Uns } @Test - public void testUpdateMessageFullPass() throws URISyntaxException, StorageException, UnsupportedEncodingException { + public void testUpdateMessageFullPass() throws URISyntaxException, StorageException, UnsupportedEncodingException, + InterruptedException { String queueName = UUID.randomUUID().toString().toLowerCase(); CloudQueue newQueue = qClient.getQueueReference(queueName); newQueue.create(); @@ -1161,12 +1148,7 @@ public void testUpdateMessageFullPass() throws URISyntaxException, StorageExcept Assert.assertTrue(popreceipt2 != popreceipt1); Assert.assertTrue(NextVisibleTim1.before(NextVisibleTim2)); - try { - Thread.sleep(2000); - } - catch (InterruptedException e) { - e.printStackTrace(); - } + Thread.sleep(2000); String newMesage = message.getMessageContentAsString() + "updated"; message.setMessageContent(newMesage); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableQueryTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableQueryTests.java index 8023517879ac..d8818dddc09c 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableQueryTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableQueryTests.java @@ -334,7 +334,7 @@ public void tableInvalidQuery() throws StorageException, IOException, URISyntaxE } @Test - public void testQueryOnSupportedTypes() throws StorageException { + public void testQueryOnSupportedTypes() throws StorageException, InterruptedException { // Setup TableBatchOperation batch = new TableBatchOperation(); String pk = UUID.randomUUID().toString(); @@ -359,13 +359,8 @@ public void testQueryOnSupportedTypes() throws StorageException { ent.setGuid(UUID.randomUUID()); ent.setString(String.format("%04d", j)); - try { - // Add delay to make times unique - Thread.sleep(100); - } - catch (InterruptedException e) { - e.printStackTrace(); - } + // Add delay to make times unique + Thread.sleep(100); batch.insert(ent); if (j == 50) { middleRef = ent; From 4bf887e76141a99e2f8d1ff00641315607a90d0e Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" Date: Tue, 29 Jan 2013 12:09:00 -0800 Subject: [PATCH 14/17] Remove hard-coded Fiddler code in tests --- .../windowsazure/services/blob/client/BlobTestBase.java | 7 ------- .../windowsazure/services/queue/client/QueueTestBase.java | 7 ------- .../windowsazure/services/table/client/TableTestBase.java | 6 ------ 3 files changed, 20 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/client/BlobTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/client/BlobTestBase.java index 81ac9334d8dc..cba0245c4270 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/client/BlobTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/client/BlobTestBase.java @@ -40,13 +40,6 @@ public class BlobTestBase { @BeforeClass public static void setup() throws URISyntaxException, StorageException, InvalidKeyException { - - // UNCOMMENT TO USE FIDDLER - System.setProperty("http.proxyHost", "localhost"); - System.setProperty("http.proxyPort", "8888"); - System.setProperty("https.proxyHost", "localhost"); - System.setProperty("https.proxyPort", "8888"); - if (USE_DEV_FABRIC) { httpAcc = CloudStorageAccount.getDevelopmentStorageAccount(); } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/QueueTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/QueueTestBase.java index ead279ce3dbd..e44acb2a2100 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/QueueTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/QueueTestBase.java @@ -41,13 +41,6 @@ public class QueueTestBase { @BeforeClass public static void setup() throws URISyntaxException, StorageException, InvalidKeyException { - - // UNCOMMENT TO USE FIDDLER - System.setProperty("http.proxyHost", "localhost"); - System.setProperty("http.proxyPort", "8888"); - System.setProperty("https.proxyHost", "localhost"); - System.setProperty("https.proxyPort", "8888"); - if (USE_DEV_FABRIC) { httpAcc = CloudStorageAccount.getDevelopmentStorageAccount(); } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableTestBase.java index b5c68c6df876..91d4398f760d 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableTestBase.java @@ -567,12 +567,6 @@ public static class1 generateRandomEnitity(String pk) { @BeforeClass public static void setup() throws URISyntaxException, StorageException, InvalidKeyException { - - //UNCOMMENT TO USE FIDDLER - System.setProperty("http.proxyHost", "localhost"); - System.setProperty("http.proxyPort", "8888"); - System.setProperty("https.proxyHost", "localhost"); - System.setProperty("https.proxyPort", "8888"); if (USE_DEV_FABRIC) { httpAcc = CloudStorageAccount.getDevelopmentStorageAccount(); } From 277921fa2444ce5a44a30f2ca5fb15ee308d87b3 Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" Date: Tue, 29 Jan 2013 12:17:22 -0800 Subject: [PATCH 15/17] Adding deltas to assertEquals for Date and Double, which are likely to experience slight rounding error and cause transient failures. --- .../services/table/client/TableTestBase.java | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableTestBase.java index 91d4398f760d..80c7ce30738a 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableTestBase.java @@ -176,12 +176,13 @@ public void assertEquality(ComplexEntity other) { Assert.assertEquals(this.getPartitionKey(), other.getPartitionKey()); Assert.assertEquals(this.getRowKey(), other.getRowKey()); - Assert.assertEquals(this.getDateTime(), other.getDateTime()); + assertDateApproxEquals(this.getDateTime(), other.getDateTime(), 100); + Assert.assertEquals(this.getGuid(), other.getGuid()); Assert.assertEquals(this.getString(), other.getString()); - Assert.assertEquals(this.getDouble(), other.getDouble()); - Assert.assertEquals(this.getDoublePrimitive(), other.getDoublePrimitive()); + Assert.assertEquals(this.getDouble(), other.getDouble(), 1.0e-10); + Assert.assertEquals(this.getDoublePrimitive(), other.getDoublePrimitive(), 1.0e-10); Assert.assertEquals(this.getInt32(), other.getInt32()); Assert.assertEquals(this.getIntegerPrimitive(), other.getIntegerPrimitive()); Assert.assertEquals(this.getBool(), other.getBool()); @@ -192,6 +193,18 @@ public void assertEquality(ComplexEntity other) { Assert.assertTrue(Arrays.equals(this.getBinaryPrimitive(), other.getBinaryPrimitive())); } + protected void assertDateApproxEquals(Date expected, Date actual, int deltaInMs) { + if (expected == null || actual == null) { + Assert.assertEquals(expected, actual); + } + else { + long diffInMilliseconds = Math.abs(expected.getTime() - actual.getTime()); + if (diffInMilliseconds > deltaInMs) { + Assert.assertEquals(expected, actual); + } + } + } + /** * @return the binary */ From 19ef20ccc634b93fbed4b60e38b3b6abd5e2d234 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Tue, 26 Feb 2013 13:11:12 -0800 Subject: [PATCH 16/17] fix the broken unit test due to nimbus server upgrade. --- .../services/media/AssetIntegrationTest.java | 2 +- .../media/ContentKeyIntegrationTest.java | 41 ++++++++++++++----- .../media/MediaProcessorIntegrationTest.java | 2 +- .../services/media/TaskIntegrationTest.java | 15 +++---- .../scenarios/MediaServiceWrapper.java | 2 +- 5 files changed, 41 insertions(+), 21 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java index 2c012d168f51..f262d415b8ea 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java @@ -288,7 +288,7 @@ public void deleteAssetFailedWithInvalidId() throws ServiceException { @Test public void linkAssetContentKeySuccess() throws ServiceException, URISyntaxException { // Arrange - String originalTestName = testAssetPrefix + "linkAssetContentKeyInvalidIdFailed"; + String originalTestName = testAssetPrefix + "linkAssetContentKeySuccess"; AssetInfo assetInfo = service.create(Asset.create().setName(originalTestName) .setOptions(AssetOption.StorageEncrypted)); String contentKeyId = String.format("nb:kid:UUID:%s", UUID.randomUUID()); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ContentKeyIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ContentKeyIntegrationTest.java index 3f479a6ea8b7..d7c6f40b96d7 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ContentKeyIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ContentKeyIntegrationTest.java @@ -27,6 +27,7 @@ import com.microsoft.windowsazure.services.media.models.ContentKey; import com.microsoft.windowsazure.services.media.models.ContentKeyInfo; import com.microsoft.windowsazure.services.media.models.ContentKeyType; +import com.microsoft.windowsazure.services.media.models.ProtectionKey; import com.microsoft.windowsazure.services.media.models.ProtectionKeyType; public class ContentKeyIntegrationTest extends IntegrationTestBase { @@ -65,15 +66,17 @@ public void canCreateContentKey() throws Exception { // Arrange String testCanCreateContentKeyId = createRandomContentKeyId(); String testCanCreateContentKeyName = "testCanCreateContentKey"; + String protectionKeyId = service.action(ProtectionKey.getProtectionKeyId(testContentKeyType)); // Act - ContentKeyInfo contentKeyInfo = service.create(ContentKey.create(testCanCreateContentKeyId, testContentKeyType, - testEncryptedContentKey).setName(testCanCreateContentKeyName)); + ContentKeyInfo contentKeyInfo = service.create(ContentKey + .create(testCanCreateContentKeyId, testContentKeyType, testEncryptedContentKey) + .setName(testCanCreateContentKeyName).setProtectionKeyId(protectionKeyId)); // Assert verifyContentKeyProperties("ContentKey", testCanCreateContentKeyId, testContentKeyType, - testEncryptedContentKey, testCanCreateContentKeyName, "", ProtectionKeyType.fromCode(0), "", - contentKeyInfo); + testEncryptedContentKey, testCanCreateContentKeyName, protectionKeyId, ProtectionKeyType.fromCode(0), + "", contentKeyInfo); } @Test @@ -81,8 +84,10 @@ public void canGetSingleContentKeyById() throws Exception { // Arrange String expectedName = testContentKeyPrefix + "GetOne"; String testGetSingleContentKeyByIdId = createRandomContentKeyId(); - ContentKeyInfo ContentKeyToGet = service.create(ContentKey.create(testGetSingleContentKeyByIdId, - testContentKeyType, testEncryptedContentKey).setName(expectedName)); + String protectionKeyId = service.action(ProtectionKey.getProtectionKeyId(testContentKeyType)); + ContentKeyInfo ContentKeyToGet = service.create(ContentKey + .create(testGetSingleContentKeyByIdId, testContentKeyType, testEncryptedContentKey) + .setName(expectedName).setProtectionKeyId(protectionKeyId)); // Act ContentKeyInfo retrievedContentKeyInfo = service.get(ContentKey.get(ContentKeyToGet.getId())); @@ -90,7 +95,8 @@ public void canGetSingleContentKeyById() throws Exception { // Assert assertEquals(ContentKeyToGet.getId(), retrievedContentKeyInfo.getId()); verifyContentKeyProperties("ContentKey", testGetSingleContentKeyByIdId, testContentKeyType, - testEncryptedContentKey, expectedName, "", ProtectionKeyType.fromCode(0), "", retrievedContentKeyInfo); + testEncryptedContentKey, expectedName, protectionKeyId, ProtectionKeyType.fromCode(0), "", + retrievedContentKeyInfo); } @Test @@ -102,18 +108,22 @@ public void cannotGetSingleContentKeyByInvalidId() throws Exception { @Test public void canRetrieveListOfContentKeys() throws Exception { + // Arrange String[] ContentKeyNames = new String[] { testContentKeyPrefix + "ListOne", testContentKeyPrefix + "ListTwo" }; + String protectionKeyId = service.action(ProtectionKey.getProtectionKeyId(testContentKeyType)); List expectedContentKeys = new ArrayList(); for (int i = 0; i < ContentKeyNames.length; i++) { String testCanRetrieveListOfContentKeysId = createRandomContentKeyId(); ContentKeyInfo contentKey = service.create(ContentKey.create(testCanRetrieveListOfContentKeysId, - testContentKeyType, testEncryptedContentKey)); + testContentKeyType, testEncryptedContentKey).setProtectionKeyId(protectionKeyId)); expectedContentKeys.add(contentKey); } + // Act List actualContentKeys = service.list(ContentKey.list()); + // Assert verifyListResultContains("listContentKeyss", expectedContentKeys, actualContentKeys, new ComponentDelegate() { @Override public void verifyEquals(String message, Object expected, Object actual) { @@ -124,32 +134,41 @@ public void verifyEquals(String message, Object expected, Object actual) { @Test public void canUseQueryParametersWhenListingContentKeys() throws Exception { + // Arrange String[] ContentKeyNames = new String[] { testContentKeyPrefix + "ListThree", testContentKeyPrefix + "ListFour", testContentKeyPrefix + "ListFive", testContentKeyPrefix + "ListSix", testContentKeyPrefix + "ListSeven" }; + String protectionKeyId = service.action(ProtectionKey.getProtectionKeyId(testContentKeyType)); List expectedContentKeys = new ArrayList(); for (int i = 0; i < ContentKeyNames.length; i++) { ContentKeyInfo contentKeyInfo = service.create(ContentKey.create(createRandomContentKeyId(), - testContentKeyType, testEncryptedContentKey)); + testContentKeyType, testEncryptedContentKey).setProtectionKeyId(protectionKeyId)); expectedContentKeys.add(contentKeyInfo); } + // Act List actualContentKeys = service.list(ContentKey.list().setTop(2)); + // Assert assertEquals(2, actualContentKeys.size()); } @Test public void canDeleteContentKeyById() throws Exception { + // Arrange + String protectionKeyId = service.action(ProtectionKey.getProtectionKeyId(testContentKeyType)); String contentKeyName = testContentKeyPrefix + "ToDelete"; - ContentKeyInfo contentKeyToDelete = service.create(ContentKey.create(createRandomContentKeyId(), - testContentKeyType, testEncryptedContentKey).setName(contentKeyName)); + ContentKeyInfo contentKeyToDelete = service.create(ContentKey + .create(createRandomContentKeyId(), testContentKeyType, testEncryptedContentKey) + .setName(contentKeyName).setProtectionKeyId(protectionKeyId)); List listContentKeysResult = service.list(ContentKey.list()); int ContentKeyCountBaseline = listContentKeysResult.size(); + // Act service.delete(ContentKey.delete(contentKeyToDelete.getId())); + // Assert listContentKeysResult = service.list(ContentKey.list()); assertEquals("listPoliciesResult.size", ContentKeyCountBaseline - 1, listContentKeysResult.size()); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaProcessorIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaProcessorIntegrationTest.java index 052fdc0811ef..176220765c00 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaProcessorIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaProcessorIntegrationTest.java @@ -73,6 +73,6 @@ public void listMediaProcessorWithOptionSuccess() throws ServiceException { assertEquals("listMediaProcessors size", 1, listMediaProcessorsResult.size()); MediaProcessorInfo mediaProcessorInfo = listMediaProcessorsResult.get(0); verifyMediaProcessorInfo("mediaProcessorInfo", "nb:mpid:UUID:aec03716-7c5e-4f68-b592-f4850eba9f10", - "Storage Decryption", "Storage Decryption", "", "Microsoft", "1.5.3", mediaProcessorInfo); + "Storage Decryption", "Storage Decryption", "", "Microsoft", "1.5.3.0", mediaProcessorInfo); } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/TaskIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/TaskIntegrationTest.java index ad9ca21b6750..2c576c8c193b 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/TaskIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/TaskIntegrationTest.java @@ -71,7 +71,7 @@ public void createTaskSuccess() throws ServiceException, UnsupportedEncodingExce // Optional parameters String configuration = new String(Base64.encode(commonConfiguration), "UTF8"); String name = "My encoding Task " + UUID.randomUUID().toString(); - int priority = 0; + int jobPriority = 3; TaskOption options = TaskOption.ProtectedConfiguration; // Use a fake id, to simulate real use. String encryptionKeyId = "nb:kid:UUID:" + UUID.randomUUID().toString(); @@ -81,7 +81,7 @@ public void createTaskSuccess() throws ServiceException, UnsupportedEncodingExce String initializationVector = new String(Base64.encode(new byte[16]), "UTF8"); CreateBatchOperation taskCreator = Task.create(mediaProcessorId, taskBody).setConfiguration(configuration) - .setName(name).setPriority(priority).setOptions(options).setEncryptionKeyId(encryptionKeyId) + .setName(name).setPriority(jobPriority).setOptions(options).setEncryptionKeyId(encryptionKeyId) .setEncryptionScheme(encryptionScheme).setEncryptionVersion(encryptionVersion) .setInitializationVector(initializationVector); jobCreator.addTaskCreator(taskCreator); @@ -92,8 +92,9 @@ public void createTaskSuccess() throws ServiceException, UnsupportedEncodingExce // Assert assertEquals("taskInfos count", 1, taskInfos.size()); - verifyTaskPropertiesJustStarted("taskInfo", mediaProcessorId, options, taskBody, configuration, name, priority, - encryptionKeyId, encryptionScheme, encryptionVersion, initializationVector, taskInfos.get(0)); + verifyTaskPropertiesJustStarted("taskInfo", mediaProcessorId, options, taskBody, configuration, name, + jobPriority, encryptionKeyId, encryptionScheme, encryptionVersion, initializationVector, + taskInfos.get(0)); } @Test @@ -108,7 +109,7 @@ public void createTwoTasksSuccess() throws ServiceException { String configuration = commonConfiguration; String baseName = "My encoding Task " + UUID.randomUUID().toString(); String[] suffixes = new String[] { " 1", " 2" }; - int priority = 0; + int jobPriority = 3; TaskOption options = TaskOption.None; List taskCreators = new ArrayList(); @@ -128,7 +129,7 @@ public void createTwoTasksSuccess() throws ServiceException { assertEquals("taskInfos count", taskCreators.size(), taskInfos.size()); for (int i = 0; i < taskCreators.size(); i++) { verifyTaskPropertiesJustStartedNoEncryption("taskInfo", mediaProcessorId, options, taskBodies[i], - configuration, baseName + suffixes[i], priority, taskInfos.get(i)); + configuration, baseName + suffixes[i], jobPriority, taskInfos.get(i)); } } @@ -184,7 +185,7 @@ public void cancelTaskSuccess() throws ServiceException, InterruptedException { List taskInfos = service.list(Task.list(cancellingJobInfo.getTasksLink())); for (TaskInfo taskInfo : taskInfos) { verifyTaskPropertiesNoEncryption("canceled task", mediaProcessorId, TaskOption.None, taskBody, - configuration, name, 0, new Date(), null, 0.0, 0.0, null, TaskState.Canceled, taskInfo); + configuration, name, 3, new Date(), null, 0.0, 0.0, null, TaskState.Canceled, taskInfo); } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java index 16ba0ddcdf92..19933421282f 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java @@ -278,7 +278,7 @@ public Task.CreateBatchOperation createTaskOptions(String taskName, int inputAss configuration = "VC1 Broadband SD 4x3"; break; case StorageDecryption: - processor = getMediaProcessorIdByName(MEDIA_PROCESSOR_STORAGE_DECRYPTION, "1.5.3"); + processor = getMediaProcessorIdByName(MEDIA_PROCESSOR_STORAGE_DECRYPTION, "1.5.3.0"); configuration = null; break; default: From 4f692bb39d8a9c4e9206190944c2dc33f16f4e10 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Tue, 26 Feb 2013 13:24:32 -0800 Subject: [PATCH 17/17] fix another unit test due to nimbus server upgrade. --- .../windowsazure/services/media/AssetIntegrationTest.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java index f262d415b8ea..b9bcbb3bfeef 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java @@ -47,6 +47,7 @@ import com.microsoft.windowsazure.services.media.models.Locator; import com.microsoft.windowsazure.services.media.models.LocatorInfo; import com.microsoft.windowsazure.services.media.models.LocatorType; +import com.microsoft.windowsazure.services.media.models.ProtectionKey; import com.microsoft.windowsazure.services.media.models.Task; import com.microsoft.windowsazure.services.media.models.Task.CreateBatchOperation; @@ -291,9 +292,12 @@ public void linkAssetContentKeySuccess() throws ServiceException, URISyntaxExcep String originalTestName = testAssetPrefix + "linkAssetContentKeySuccess"; AssetInfo assetInfo = service.create(Asset.create().setName(originalTestName) .setOptions(AssetOption.StorageEncrypted)); + + String protectionKeyId = service.action(ProtectionKey.getProtectionKeyId(ContentKeyType.StorageEncryption)); String contentKeyId = String.format("nb:kid:UUID:%s", UUID.randomUUID()); String encryptedContentKey = "dummyEncryptedContentKey"; - service.create(ContentKey.create(contentKeyId, ContentKeyType.StorageEncryption, encryptedContentKey)); + service.create(ContentKey.create(contentKeyId, ContentKeyType.StorageEncryption, encryptedContentKey) + .setProtectionKeyId(protectionKeyId)); // Act service.action(Asset.linkContentKey(assetInfo.getId(), contentKeyId));