From eadf37cf16f616684f02bf40854958e40dfe6ca2 Mon Sep 17 00:00:00 2001 From: Chris Tavares Date: Fri, 14 Dec 2012 12:17:30 -0800 Subject: [PATCH] Removing setExpirationTime from locator update, and removing verification since we have no control over it any more --- .../services/media/models/Locator.java | 18 +-------- .../media/LocatorIntegrationTests.java | 39 +++++++------------ .../media/models/LocatorEntityTest.java | 7 +--- 3 files changed, 16 insertions(+), 48 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java index 69c346e6fd88e..5d68ec9b6e305 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java @@ -230,9 +230,6 @@ public static class Updater extends EntityOperationBase implements EntityUpdateO /** The start date time. */ private Date startDateTime; - /** The expiration date time. */ - private Date expirationDateTime; - /** * Instantiates a new updater. * @@ -248,7 +245,7 @@ public Updater(String locatorId) { */ @Override public Object getRequestContents() { - return new LocatorRestType().setStartTime(startDateTime).setExpirationDateTime(expirationDateTime); + return new LocatorRestType().setStartTime(startDateTime); } /* (non-Javadoc) @@ -270,19 +267,6 @@ public Updater setStartDateTime(Date startDateTime) { this.startDateTime = startDateTime; return this; } - - /** - * Set when the locator will expire. - * - * @param expirationDateTime - * the expiration date & time - * @return Updater instance - */ - public Updater setExpirationDateTime(Date expirationDateTime) { - this.expirationDateTime = expirationDateTime; - return this; - } - } /** diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java index 8b3a6094f63d5..7faea174f2464 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java @@ -46,33 +46,24 @@ public class LocatorIntegrationTests extends IntegrationTestBase { private static int minuteInMS = 60 * 1000; private static int tenMinutesInMS = 10 * 60 * 1000; - private Date calculateDefaultExpectedExpDate(AccessPolicyInfo accessPolicy, AssetInfo asset) { - return new Date(asset.getLastModified().getTime() + (long) accessPolicy.getDurationInMinutes() * minuteInMS); - } - private void verifyLocatorInfosEqual(String message, LocatorInfo expected, LocatorInfo actual) { verifyLocatorProperties(message, expected.getAccessPolicyId(), expected.getAssetId(), - expected.getLocatorType(), expected.getStartTime(), expected.getExpirationDateTime(), expected.getId(), - expected.getPath(), actual); + expected.getLocatorType(), expected.getStartTime(), expected.getId(), expected.getPath(), actual); } private void verifyLocatorProperties(String message, String accessPolicyId, String assetId, - LocatorType locatorType, Date startTime, Date expirationDateTime, LocatorInfo actualLocator) { - verifyLocatorProperties(message, accessPolicyId, assetId, locatorType, startTime, expirationDateTime, null, - null, actualLocator); + LocatorType locatorType, Date startTime, LocatorInfo actualLocator) { + verifyLocatorProperties(message, accessPolicyId, assetId, locatorType, startTime, null, null, actualLocator); } private void verifyLocatorProperties(String message, String accessPolicyId, String assetId, - LocatorType locatorType, Date startTime, Date expirationDateTime, String id, String path, - LocatorInfo actualLocator) { + LocatorType locatorType, Date startTime, String id, String path, LocatorInfo actualLocator) { assertNotNull(message, actualLocator); assertEquals(message + " accessPolicyId", accessPolicyId, actualLocator.getAccessPolicyId()); assertEquals(message + " assetId", assetId, actualLocator.getAssetId()); assertEquals(message + " locatorType", locatorType, actualLocator.getLocatorType()); assertDateApproxEquals(message + " startTime", startTime, actualLocator.getStartTime()); - assertDateApproxEquals(message + " expirationDateTime", expirationDateTime, - actualLocator.getExpirationDateTime()); if (id == null) { assertNotNull(message + " Id", actualLocator.getId()); @@ -106,7 +97,6 @@ public void instanceSetup() throws Exception { public void createLocatorSuccess() throws ServiceException { // Arrange LocatorType locatorType = LocatorType.SAS; - Date expectedExpirationDateTime = calculateDefaultExpectedExpDate(accessPolicyInfoRead, assetInfo); // Act LocatorInfo locatorInfo = service.create(Locator.create(accessPolicyInfoRead.getId(), assetInfo.getId(), @@ -114,14 +104,13 @@ public void createLocatorSuccess() throws ServiceException { // Assert verifyLocatorProperties("locatorInfo", accessPolicyInfoRead.getId(), assetInfo.getId(), locatorType, null, - expectedExpirationDateTime, locatorInfo); + locatorInfo); } @Test public void createLocatorWithSpecifiedIdSuccess() throws ServiceException { // Arrange LocatorType locatorType = LocatorType.SAS; - Date expectedExpirationDateTime = calculateDefaultExpectedExpDate(accessPolicyInfoRead, assetInfo); // Act LocatorInfo locatorInfo = service.create(Locator.create(accessPolicyInfoRead.getId(), assetInfo.getId(), @@ -129,7 +118,7 @@ public void createLocatorWithSpecifiedIdSuccess() throws ServiceException { // Assert verifyLocatorProperties("locatorInfo", accessPolicyInfoRead.getId(), assetInfo.getId(), locatorType, null, - expectedExpirationDateTime, locatorInfo); + locatorInfo); } @Test @@ -138,8 +127,6 @@ public void createLocatorOptionsSetStartTimeSuccess() throws ServiceException { Date expectedStartDateTime = new Date(); expectedStartDateTime.setTime(expectedStartDateTime.getTime() + tenMinutesInMS); LocatorType locatorType = LocatorType.SAS; - Date expectedExpirationDateTime = new Date(expectedStartDateTime.getTime() - + (long) accessPolicyInfo.getDurationInMinutes() * minuteInMS); // Act LocatorInfo locatorInfo = service.create(Locator.create(accessPolicyInfo.getId(), assetInfo.getId(), @@ -147,7 +134,7 @@ public void createLocatorOptionsSetStartTimeSuccess() throws ServiceException { // Assert verifyLocatorProperties("locatorInfo", accessPolicyInfo.getId(), assetInfo.getId(), locatorType, - expectedStartDateTime, expectedExpirationDateTime, locatorInfo); + expectedStartDateTime, locatorInfo); } @Test @@ -229,20 +216,20 @@ public void updateLocatorSuccess() throws ServiceException { LocatorInfo locatorInfo = service.create(Locator.create(accessPolicyInfoRead.getId(), assetInfo.getId(), locatorType)); - Date expirationDateTime = new Date(); - expirationDateTime.setTime(expirationDateTime.getTime() + tenMinutesInMS); Date startTime = new Date(); startTime.setTime(startTime.getTime() - tenMinutesInMS); // Act - service.update(Locator.update(locatorInfo.getId()).setExpirationDateTime(expirationDateTime) - .setStartDateTime(startTime)); + service.update(Locator.update(locatorInfo.getId()).setStartDateTime(startTime)); LocatorInfo updatedLocatorInfo = service.get(Locator.get(locatorInfo.getId())); // Assert + Date expectedExpiration = new Date(); + expectedExpiration.setTime(startTime.getTime() + (long) accessPolicyInfoRead.getDurationInMinutes() + * minuteInMS); + verifyLocatorProperties("updatedLocatorInfo", locatorInfo.getAccessPolicyId(), locatorInfo.getAssetId(), - locatorInfo.getLocatorType(), startTime, expirationDateTime, locatorInfo.getId(), - locatorInfo.getPath(), updatedLocatorInfo); + locatorInfo.getLocatorType(), startTime, locatorInfo.getId(), locatorInfo.getPath(), updatedLocatorInfo); } @Test diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorEntityTest.java index 6008fcd16371f..699ba22876597 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorEntityTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorEntityTest.java @@ -157,19 +157,16 @@ public void locatorUpdateReturnsExpectedUri() throws Exception { } @Test - public void locatorUpdateCanStartAndExpirationTime() throws Exception { + public void locatorUpdateCanSetStarTime() throws Exception { Date now = new Date(); Date tenMinutesAgo = new Date(now.getTime() - 10 * 60 * 1000); - Date twoHoursFromNow = new Date(now.getTime() + 2 * 60 * 60 * 1000); - EntityUpdateOperation updater = Locator.update(exampleLocatorId).setStartDateTime(tenMinutesAgo) - .setExpirationDateTime(twoHoursFromNow); + EntityUpdateOperation updater = Locator.update(exampleLocatorId).setStartDateTime(tenMinutesAgo); LocatorRestType payload = (LocatorRestType) updater.getRequestContents(); assertEquals(tenMinutesAgo, payload.getStartTime()); - assertEquals(twoHoursFromNow, payload.getExpirationDateTime()); } @Test