3535
3636import static org .junit .Assert .*;
3737
38- @ Category ({ SlowTests . class , DevFabricTests .class , DevStoreTests .class , CloudTests .class })
38+ @ Category ({ DevFabricTests .class , DevStoreTests .class , CloudTests .class })
3939public class ServicePropertiesTests {
4040
4141 /**
@@ -48,6 +48,7 @@ public class ServicePropertiesTests {
4848 public void testAnalyticsDisable () throws StorageException , InterruptedException {
4949 ServiceClient client = TestHelper .createCloudBlobClient ();
5050 ServiceProperties props = new ServiceProperties ();
51+ props .setDeleteRetentionPolicy (new DeleteRetentionPolicy ());
5152 props .setDefaultServiceVersion (Constants .HeaderConstants .TARGET_STORAGE_VERSION );
5253 testAnalyticsDisable (client , props );
5354
@@ -91,6 +92,7 @@ private void testAnalyticsDisable(ServiceClient client, ServiceProperties props)
9192 public void testAnalyticsDefaultServiceVersion () throws StorageException , InterruptedException {
9293 ServiceClient client = TestHelper .createCloudBlobClient ();
9394 ServiceProperties props = new ServiceProperties ();
95+ props .setDeleteRetentionPolicy (new DeleteRetentionPolicy ());
9496 props .setDefaultServiceVersion (Constants .HeaderConstants .TARGET_STORAGE_VERSION );
9597 testAnalyticsDefaultServiceVersion (client , props );
9698
@@ -151,6 +153,7 @@ private void testAnalyticsDefaultServiceVersion(ServiceClient client, ServicePro
151153 public void testAnalyticsLoggingOperations () throws StorageException , InterruptedException {
152154 ServiceClient client = TestHelper .createCloudBlobClient ();
153155 ServiceProperties props = new ServiceProperties ();
156+ props .setDeleteRetentionPolicy (new DeleteRetentionPolicy ());
154157 props .setDefaultServiceVersion (Constants .HeaderConstants .TARGET_STORAGE_VERSION );
155158 testAnalyticsLoggingOperations (client , props );
156159
@@ -191,6 +194,7 @@ private void testAnalyticsLoggingOperations(ServiceClient client, ServicePropert
191194 public void testAnalyticsHourMetricsLevel () throws StorageException , InterruptedException {
192195 ServiceClient client = TestHelper .createCloudBlobClient ();
193196 ServiceProperties props = new ServiceProperties ();
197+ props .setDeleteRetentionPolicy (new DeleteRetentionPolicy ());
194198 props .setDefaultServiceVersion (Constants .HeaderConstants .TARGET_STORAGE_VERSION );
195199 testAnalyticsHourMetricsLevel (client , props , null );
196200
@@ -259,6 +263,7 @@ private void testAnalyticsHourMetricsLevel(
259263 public void testAnalyticsMinuteMetricsLevel () throws StorageException , InterruptedException {
260264 ServiceClient client = TestHelper .createCloudBlobClient ();
261265 ServiceProperties props = new ServiceProperties ();
266+ props .setDeleteRetentionPolicy (new DeleteRetentionPolicy ());
262267 props .setDefaultServiceVersion (Constants .HeaderConstants .TARGET_STORAGE_VERSION );
263268 testAnalyticsMinuteMetricsLevel (client , props , null );
264269
@@ -327,6 +332,7 @@ private void testAnalyticsMinuteMetricsLevel(
327332 public void testAnalyticsRetentionPolicies () throws StorageException , InterruptedException {
328333 ServiceClient client = TestHelper .createCloudBlobClient ();
329334 ServiceProperties props = new ServiceProperties ();
335+ props .setDeleteRetentionPolicy (new DeleteRetentionPolicy ());
330336 props .setDefaultServiceVersion (Constants .HeaderConstants .TARGET_STORAGE_VERSION );
331337 testAnalyticsRetentionPolicies (client , props );
332338
@@ -426,6 +432,7 @@ private void testValidDeleteRetentionPolicy(ServiceClient client, boolean enable
426432
427433 try {
428434 ServiceProperties expectedServiceProperties = new ServiceProperties ();
435+ expectedServiceProperties .setDeleteRetentionPolicy (new DeleteRetentionPolicy ());
429436 expectedServiceProperties .setDefaultServiceVersion (Constants .HeaderConstants .TARGET_STORAGE_VERSION );
430437
431438 if (enabled ) {
@@ -435,7 +442,7 @@ private void testValidDeleteRetentionPolicy(ServiceClient client, boolean enable
435442 } else {
436443 // interval and retained versions per blob would both be ignored by the service in case the policy is not enabled
437444 ServiceProperties propertiesToUpload = new ServiceProperties ();
438- propertiesToUpload .getDeleteRetentionPolicy (). setEnabled ( false );
445+ propertiesToUpload .setDeleteRetentionPolicy ( new DeleteRetentionPolicy () );
439446 propertiesToUpload .getDeleteRetentionPolicy ().setRetentionIntervalInDays (interval );
440447
441448 expectedServiceProperties .getDeleteRetentionPolicy ().setEnabled (false );
@@ -448,7 +455,7 @@ private void testValidDeleteRetentionPolicy(ServiceClient client, boolean enable
448455 finally {
449456 // reset the delete retention policy
450457 ServiceProperties disabledDeleteRetentionPolicy = new ServiceProperties ();
451- disabledDeleteRetentionPolicy .getDeleteRetentionPolicy (). setEnabled ( false );
458+ disabledDeleteRetentionPolicy .setDeleteRetentionPolicy ( new DeleteRetentionPolicy () );
452459 callUploadServiceProps (client , disabledDeleteRetentionPolicy , null );
453460 }
454461 }
@@ -483,6 +490,7 @@ private void testInvalidDeleteRetentionPolicy(ServiceClient client, boolean enab
483490
484491 // Arrange
485492 ServiceProperties serviceProperties = new ServiceProperties ();
493+ serviceProperties .setDeleteRetentionPolicy (new DeleteRetentionPolicy ());
486494 serviceProperties .setDefaultServiceVersion (Constants .HeaderConstants .TARGET_STORAGE_VERSION );
487495
488496 if (enabled ) {
@@ -522,6 +530,7 @@ public void testEmptyDeleteRetentionPolicy() throws StorageException, Interrupte
522530 try {
523531 // set up initial delete retention policy
524532 ServiceProperties currentServiceProperties = new ServiceProperties ();
533+ currentServiceProperties .setDeleteRetentionPolicy (new DeleteRetentionPolicy ());
525534 currentServiceProperties .setDefaultServiceVersion (Constants .HeaderConstants .TARGET_STORAGE_VERSION );
526535 currentServiceProperties .getDeleteRetentionPolicy ().setEnabled (true );
527536 currentServiceProperties .getDeleteRetentionPolicy ().setRetentionIntervalInDays (5 );
@@ -540,7 +549,7 @@ public void testEmptyDeleteRetentionPolicy() throws StorageException, Interrupte
540549 finally {
541550 // reset the delete retention policy
542551 ServiceProperties disabledDeleteRetentionPolicy = new ServiceProperties ();
543- disabledDeleteRetentionPolicy .getDeleteRetentionPolicy (). setEnabled ( false );
552+ disabledDeleteRetentionPolicy .setDeleteRetentionPolicy ( new DeleteRetentionPolicy () );
544553 callUploadServiceProps (client , disabledDeleteRetentionPolicy , null );
545554 }
546555 }
@@ -555,6 +564,7 @@ public void testEmptyDeleteRetentionPolicy() throws StorageException, Interrupte
555564 public void testCloudValidCorsRules () throws StorageException , InterruptedException {
556565 ServiceClient client = TestHelper .createCloudBlobClient ();
557566 ServiceProperties props = new ServiceProperties ();
567+ props .setDeleteRetentionPolicy (new DeleteRetentionPolicy ());
558568 props .setDefaultServiceVersion (Constants .HeaderConstants .TARGET_STORAGE_VERSION );
559569 testCloudValidCorsRules (client , props , null );
560570
@@ -678,6 +688,7 @@ private void testCloudValidCorsRules(
678688 public void testCorsExpectedExceptions () throws StorageException {
679689 ServiceClient client = TestHelper .createCloudBlobClient ();
680690 ServiceProperties props = new ServiceProperties ();
691+ props .setDeleteRetentionPolicy (new DeleteRetentionPolicy ());
681692 props .setDefaultServiceVersion (Constants .HeaderConstants .TARGET_STORAGE_VERSION );
682693 testCorsExpectedExceptions (client , props , null );
683694
@@ -741,6 +752,7 @@ private void testCorsExpectedExceptions(
741752 public void testCorsMaxOrigins () throws StorageException , InterruptedException {
742753 ServiceClient client = TestHelper .createCloudBlobClient ();
743754 ServiceProperties props = new ServiceProperties ();
755+ props .setDeleteRetentionPolicy (new DeleteRetentionPolicy ());
744756 props .setDefaultServiceVersion (Constants .HeaderConstants .TARGET_STORAGE_VERSION );
745757 testCorsMaxOrigins (client , props , null );
746758
@@ -792,6 +804,7 @@ private void testCorsMaxOrigins(
792804 public void testCorsMaxHeaders () throws StorageException , InterruptedException {
793805 ServiceClient client = TestHelper .createCloudBlobClient ();
794806 ServiceProperties props = new ServiceProperties ();
807+ props .setDeleteRetentionPolicy (new DeleteRetentionPolicy ());
795808 props .setDefaultServiceVersion (Constants .HeaderConstants .TARGET_STORAGE_VERSION );
796809 testCorsMaxHeaders (client , props , null );
797810
@@ -895,6 +908,7 @@ private void testCorsMaxHeaders(
895908 public void testOptionalServiceProperties () throws StorageException , InterruptedException {
896909 ServiceClient client = TestHelper .createCloudBlobClient ();
897910 ServiceProperties props = new ServiceProperties ();
911+ props .setDeleteRetentionPolicy (new DeleteRetentionPolicy ());
898912 props .setDefaultServiceVersion (Constants .HeaderConstants .TARGET_STORAGE_VERSION );
899913 testOptionalServiceProperties (client , props );
900914
@@ -977,8 +991,9 @@ else if (client.getClass().equals(CloudFileClient.class)) {
977991 else {
978992 fail ();
979993 }
980-
981- Thread .sleep (30000 );
994+
995+ // It may take up to 30 seconds for the settings to take effect, but the new properties are immediately
996+ // visible when querying service properties.
982997 }
983998
984999 private ServiceProperties callDownloadServiceProperties (ServiceClient client ) throws StorageException {
@@ -1015,7 +1030,6 @@ private void testCorsRules(CorsRule rule, ServiceClient client, ServicePropertie
10151030 } else {
10161031 CloudFileClient fileClient = ((CloudFileClient ) client );
10171032 fileClient .uploadServiceProperties (fileServiceProperties );
1018- Thread .sleep (30000 );
10191033 assertFileServicePropertiesAreEqual (fileServiceProperties , fileClient .downloadServiceProperties ());
10201034 }
10211035 }
@@ -1039,7 +1053,6 @@ private void testCorsRules(List<CorsRule> corsRules, ServiceClient client, Servi
10391053 } else {
10401054 CloudFileClient fileClient = ((CloudFileClient ) client );
10411055 fileClient .uploadServiceProperties (fileServiceProperties );
1042- Thread .sleep (30000 );
10431056 assertFileServicePropertiesAreEqual (fileServiceProperties , fileClient .downloadServiceProperties ());
10441057 }
10451058 }
0 commit comments