@@ -480,70 +480,70 @@ private static void testMetadataFailures(CloudFileDirectory directory, String ke
480480 directory .getMetadata ().remove (key );
481481 }
482482
483- // @Test
484- // public void testUnsupportedDirectoryApisWithinShareSnapshot() throws StorageException, URISyntaxException {
485- // CloudFileShare snapshot = this.share.createSnapshot();
486- // CloudFileDirectory rootDir = snapshot.getRootDirectoryReference();
487- // try {
488- // rootDir.create();
489- // fail("Shouldn't get here");
490- // }
491- // catch (IllegalArgumentException e) {
492- // assertEquals(SR.INVALID_OPERATION_FOR_A_SHARE_SNAPSHOT, e.getMessage());
493- // }
494- // try {
495- // rootDir.delete();
496- // fail("Shouldn't get here");
497- // }
498- // catch (IllegalArgumentException e) {
499- // assertEquals(SR.INVALID_OPERATION_FOR_A_SHARE_SNAPSHOT, e.getMessage());
500- // }
501- // try {
502- // rootDir.uploadMetadata();
503- // fail("Shouldn't get here");
504- // }
505- // catch (IllegalArgumentException e) {
506- // assertEquals(SR.INVALID_OPERATION_FOR_A_SHARE_SNAPSHOT, e.getMessage());
507- // }
508- //
509- // snapshot.delete();
510- // }
511-
512- // @Test
513- // public void testSupportedDirectoryApisInShareSnapshot() throws StorageException, URISyntaxException {
514- // CloudFileDirectory dir = this.share.getRootDirectoryReference().getDirectoryReference("dir1");
515- // dir.deleteIfExists();
516- // dir.create();
517- // HashMap<String, String> meta = new HashMap<String, String>();
518- // meta.put("key1", "value1");
519- // dir.setMetadata(meta);
520- // dir.uploadMetadata();
521- // CloudFileShare snapshot = this.share.createSnapshot();
522- // CloudFileDirectory snapshotDir = snapshot.getRootDirectoryReference().getDirectoryReference("dir1");
523- //
524- // HashMap<String, String> meta2 = new HashMap<String, String>();
525- // meta2.put("key2", "value2");
526- // dir.setMetadata(meta2);
527- // dir.uploadMetadata();
528- // snapshotDir.downloadAttributes();
529- //
530- // assertTrue(snapshotDir.getMetadata().size() == 1 && snapshotDir.getMetadata().get("key1").equals("value1"));
531- // assertNotNull(snapshotDir.getProperties().getEtag());
532- //
533- // dir.downloadAttributes();
534- // assertTrue(dir.getMetadata().size() == 1 && dir.getMetadata().get("key2").equals("value2"));
535- // assertNotNull(dir.getProperties().getEtag());
536- // assertNotEquals(dir.getProperties().getEtag(), snapshotDir.getProperties().getEtag());
537- //
538- // final UriQueryBuilder uriBuilder = new UriQueryBuilder();
539- // uriBuilder.add("sharesnapshot", snapshot.snapshotID);
540- // uriBuilder.add("restype", "directory");
541- // CloudFileDirectory snapshotDir2 = new CloudFileDirectory(uriBuilder.addToURI(dir.getUri()), this.share.getServiceClient().getCredentials());
542- // assertEquals(snapshot.snapshotID, snapshotDir2.getShare().snapshotID);
543- // assertTrue(snapshotDir2.exists());
544- //
545- // snapshot.delete();
546- // }
483+ // @Test
484+ public void testUnsupportedDirectoryApisWithinShareSnapshot () throws StorageException , URISyntaxException {
485+ CloudFileShare snapshot = this .share .createSnapshot ();
486+ CloudFileDirectory rootDir = snapshot .getRootDirectoryReference ();
487+ try {
488+ rootDir .create ();
489+ fail ("Shouldn't get here" );
490+ }
491+ catch (IllegalArgumentException e ) {
492+ assertEquals (SR .INVALID_OPERATION_FOR_A_SHARE_SNAPSHOT , e .getMessage ());
493+ }
494+ try {
495+ rootDir .delete ();
496+ fail ("Shouldn't get here" );
497+ }
498+ catch (IllegalArgumentException e ) {
499+ assertEquals (SR .INVALID_OPERATION_FOR_A_SHARE_SNAPSHOT , e .getMessage ());
500+ }
501+ try {
502+ rootDir .uploadMetadata ();
503+ fail ("Shouldn't get here" );
504+ }
505+ catch (IllegalArgumentException e ) {
506+ assertEquals (SR .INVALID_OPERATION_FOR_A_SHARE_SNAPSHOT , e .getMessage ());
507+ }
508+
509+ snapshot .delete ();
510+ }
511+
512+ // @Test
513+ public void testSupportedDirectoryApisInShareSnapshot () throws StorageException , URISyntaxException {
514+ CloudFileDirectory dir = this .share .getRootDirectoryReference ().getDirectoryReference ("dir1" );
515+ dir .deleteIfExists ();
516+ dir .create ();
517+ HashMap <String , String > meta = new HashMap <String , String >();
518+ meta .put ("key1" , "value1" );
519+ dir .setMetadata (meta );
520+ dir .uploadMetadata ();
521+ CloudFileShare snapshot = this .share .createSnapshot ();
522+ CloudFileDirectory snapshotDir = snapshot .getRootDirectoryReference ().getDirectoryReference ("dir1" );
523+
524+ HashMap <String , String > meta2 = new HashMap <String , String >();
525+ meta2 .put ("key2" , "value2" );
526+ dir .setMetadata (meta2 );
527+ dir .uploadMetadata ();
528+ snapshotDir .downloadAttributes ();
529+
530+ assertTrue (snapshotDir .getMetadata ().size () == 1 && snapshotDir .getMetadata ().get ("key1" ).equals ("value1" ));
531+ assertNotNull (snapshotDir .getProperties ().getEtag ());
532+
533+ dir .downloadAttributes ();
534+ assertTrue (dir .getMetadata ().size () == 1 && dir .getMetadata ().get ("key2" ).equals ("value2" ));
535+ assertNotNull (dir .getProperties ().getEtag ());
536+ assertNotEquals (dir .getProperties ().getEtag (), snapshotDir .getProperties ().getEtag ());
537+
538+ final UriQueryBuilder uriBuilder = new UriQueryBuilder ();
539+ uriBuilder .add ("sharesnapshot" , snapshot .snapshotID );
540+ uriBuilder .add ("restype" , "directory" );
541+ CloudFileDirectory snapshotDir2 = new CloudFileDirectory (uriBuilder .addToURI (dir .getUri ()), this .share .getServiceClient ().getCredentials ());
542+ assertEquals (snapshot .snapshotID , snapshotDir2 .getShare ().snapshotID );
543+ assertTrue (snapshotDir2 .exists ());
544+
545+ snapshot .delete ();
546+ }
547547
548548 /*
549549 [TestMethod]
@@ -872,7 +872,7 @@ public void eventOccurred(SendingRequestEvent eventArg) {
872872 directory .delete ();
873873 assertFalse (directory .exists ());
874874 }
875- catch (StorageException e ) {
875+ catch (Exception e ) {
876876 fail ("Delete should succeed." );
877877 }
878878 }
0 commit comments