Skip to content
This repository was archived by the owner on Jul 19, 2024. It is now read-only.

Commit 7b481e8

Browse files
author
jofriedm-msft
authored
Merge pull request #222 from Azure/master
6.0.0 Release
2 parents eb8198a + abfae32 commit 7b481e8

File tree

22 files changed

+913
-832
lines changed

22 files changed

+913
-832
lines changed

BreakingChanges.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
Changes in X.X.X
1+
Changes in 6.0.0
2+
3+
FILE
4+
* Many File service APIs can now throw a URISyntaxException.
5+
* Changed listShares() ShareListingDetails parameter to be an enum set like what is done for listing blobs.
6+
7+
OTHER
28
* DefaultEndpointsProtocol will now be explicitly included in generated connection strings.
39
* Connection string parsing has been substantially re-written and expanded. Please refer to current documentation about connection string formats.
410

ChangeLog.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
X.X.X
1+
2017.10.06 Version 6.0.0
2+
* Added support for taking a snapshot of a share.
3+
* IOExceptions wrapping StorageExceptions will now contain the StorageException message in the outer exception.
24
* Connection string support expanded to allow AccountName to be specified with SharedAccessSignature and DefaultEndpointsProtocol. In this case, SharedAccessSignature is used for credentials, while having both DefaultEndpointsProtocol and AccountName allows the library to infer a set of default endpoints. Additionally, we have added support for BlobSecondaryEndpoint, QueueSecondaryEndpoint, TableSecondaryEndpoint, and FileSecondaryEndpoint. Specifying a secondary endpoint requires the specification of the corresponding primary.
35
* All: The use of DefaultEndpointsProtocol in a connection string is now optional in the case where endpoints would be automatically generated; if missing, a value of https will be inferred. When the parsed account settings in such a case are used to generate a connection string, the value of DefaultEndpointsProtocol will be explicitly included.
46

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ To get the binaries of this library as distributed by Microsoft, ready for use w
3030
<dependency>
3131
<groupId>com.microsoft.azure</groupId>
3232
<artifactId>azure-storage</artifactId>
33-
<version>5.5.0</version>
33+
<version>6.0.0</version>
3434
</dependency>
3535
```
3636

microsoft-azure-storage-samples/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<dependency>
2727
<groupId>com.microsoft.azure</groupId>
2828
<artifactId>azure-storage</artifactId>
29-
<version>5.5.0</version>
29+
<version>6.0.0</version>
3030
</dependency>
3131
<dependency>
3232
<groupId>com.microsoft.azure</groupId>

microsoft-azure-storage-samples/src/com/microsoft/azure/storage/logging/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<dependency>
2727
<groupId>com.microsoft.azure</groupId>
2828
<artifactId>azure-storage</artifactId>
29-
<version>5.5.0</version>
29+
<version>6.0.0</version>
3030
</dependency>
3131
<dependency>
3232
<groupId>com.microsoft.azure</groupId>

microsoft-azure-storage-test/src/com/microsoft/azure/storage/EventFiringTests.java

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,10 @@
2020
import com.microsoft.azure.storage.TestRunners.DevFabricTests;
2121
import com.microsoft.azure.storage.TestRunners.DevStoreTests;
2222

23-
import org.apache.http.protocol.HTTP;
2423
import org.junit.Test;
2524
import org.junit.experimental.categories.Category;
2625

27-
import java.io.ByteArrayInputStream;
28-
import java.io.IOException;
2926
import java.net.HttpURLConnection;
30-
import java.net.SocketException;
3127
import java.net.URISyntaxException;
3228
import java.util.ArrayList;
3329

@@ -121,39 +117,46 @@ public void eventOccurred(ErrorReceivingResponseEvent eventArg) {
121117
}
122118
});
123119

124-
OperationContext.getGlobalErrorReceivingResponseEventHandler().addListener(new StorageEvent<ErrorReceivingResponseEvent>() {
120+
StorageEvent<ErrorReceivingResponseEvent> globalResponseReceivedListener = new StorageEvent<ErrorReceivingResponseEvent>() {
125121

126122
@Override
127123
public void eventOccurred(ErrorReceivingResponseEvent eventArg) {
128124
fail("This event should not trigger");
129125
}
130-
});
126+
};
131127

132-
assertEquals(0, callList.size());
133-
assertEquals(0, globalCallList.size());
128+
try {
129+
OperationContext.getGlobalErrorReceivingResponseEventHandler().addListener(globalResponseReceivedListener);
134130

135-
CloudBlobClient blobClient = TestHelper.createCloudBlobClient();
136-
CloudBlobContainer container = blobClient.getContainerReference("container1");
131+
assertEquals(0, callList.size());
132+
assertEquals(0, globalCallList.size());
137133

138-
// make sure both update
139-
container.exists(null, null, eventContext);
140-
assertEquals(1, callList.size());
141-
assertEquals(1, globalCallList.size());
134+
CloudBlobClient blobClient = TestHelper.createCloudBlobClient();
135+
CloudBlobContainer container = blobClient.getContainerReference("container1");
142136

143-
// make sure only global updates
144-
container.exists();
145-
assertEquals(1, callList.size());
146-
assertEquals(2, globalCallList.size());
137+
// make sure both update
138+
container.exists(null, null, eventContext);
139+
assertEquals(1, callList.size());
140+
assertEquals(1, globalCallList.size());
147141

148-
OperationContext
149-
.setGlobalResponseReceivedEventHandler(new StorageEventMultiCaster<ResponseReceivedEvent, StorageEvent<ResponseReceivedEvent>>());
150-
eventContext
151-
.setResponseReceivedEventHandler(new StorageEventMultiCaster<ResponseReceivedEvent, StorageEvent<ResponseReceivedEvent>>());
142+
// make sure only global updates
143+
container.exists();
144+
assertEquals(1, callList.size());
145+
assertEquals(2, globalCallList.size());
152146

153-
// make sure neither update
154-
container.exists(null, null, eventContext);
155-
assertEquals(1, callList.size());
156-
assertEquals(2, globalCallList.size());
147+
OperationContext
148+
.setGlobalResponseReceivedEventHandler(new StorageEventMultiCaster<ResponseReceivedEvent, StorageEvent<ResponseReceivedEvent>>());
149+
eventContext
150+
.setResponseReceivedEventHandler(new StorageEventMultiCaster<ResponseReceivedEvent, StorageEvent<ResponseReceivedEvent>>());
151+
152+
// make sure neither update
153+
container.exists(null, null, eventContext);
154+
assertEquals(1, callList.size());
155+
assertEquals(2, globalCallList.size());
156+
}
157+
finally {
158+
OperationContext.getGlobalErrorReceivingResponseEventHandler().removeListener(globalResponseReceivedListener);
159+
}
157160
}
158161

159162
@Test

microsoft-azure-storage-test/src/com/microsoft/azure/storage/file/CloudFileClientTests.java

Lines changed: 48 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public void testListSharesTest() throws StorageException, URISyntaxException {
6767
do {
6868

6969
ResultSegment<CloudFileShare> segment = fileClient.listSharesSegmented(prefix,
70-
ShareListingDetails.ALL, 15, token, null, null);
70+
EnumSet.allOf(ShareListingDetails.class), 15, token, null, null);
7171

7272
for (final CloudFileShare share : segment.getResults()) {
7373
share.downloadAttributes();
@@ -104,7 +104,7 @@ public void testListSharesMaxResultsValidationTest() throws StorageException, UR
104104
for (int i = 0; i >= -2; i--) {
105105
try{
106106
fileClient.listSharesSegmented(
107-
prefix, ShareListingDetails.ALL, i, null, null, null);
107+
prefix, EnumSet.allOf(ShareListingDetails.class), i, null, null, null);
108108
fail();
109109
}
110110
catch (IllegalArgumentException e) {
@@ -115,46 +115,50 @@ public void testListSharesMaxResultsValidationTest() throws StorageException, UR
115115
assertNotNull(fileClient.listSharesSegmented("thereshouldntbeanyshareswiththisprefix"));
116116
}
117117

118-
// @Test
119-
// public void testListSharesWithSnapshot() throws StorageException, URISyntaxException {
120-
// CloudFileClient fileClient = FileTestHelper.createCloudFileClient();
121-
// CloudFileShare share = fileClient.getShareReference(UUID.randomUUID().toString());
122-
// share.create();
123-
//
124-
// HashMap<String, String> shareMeta = new HashMap<String, String>();
125-
// shareMeta.put("key1", "value1");
126-
// share.setMetadata(shareMeta);
127-
// share.uploadMetadata();
128-
//
129-
// CloudFileShare snapshot = share.createSnapshot();
130-
// HashMap<String, String> meta2 = new HashMap<String, String>();
131-
// meta2.put("key2", "value2");
132-
// share.setMetadata(meta2);
133-
// share.uploadMetadata();
134-
//
135-
// CloudFileClient client = FileTestHelper.createCloudFileClient();
136-
// Iterable<CloudFileShare> listResult = client.listShares(share.name, ShareListingDetails.ALL, null, null);
137-
//
138-
// int count = 0;
139-
// boolean originalFound = false;
140-
// boolean snapshotFound = false;
141-
// for (CloudFileShare listShareItem : listResult) {
142-
// if (listShareItem.getName().equals(share.getName()) && !listShareItem.isSnapshot() && !originalFound)
143-
// {
144-
// count++;
145-
// originalFound = true;
146-
// assertEquals(share.getMetadata(), listShareItem.getMetadata());
147-
// assertEquals(share.getStorageUri(), listShareItem.getStorageUri());
148-
// }
149-
// else if (listShareItem.getName().equals(share.getName()) &&
150-
// listShareItem.isSnapshot() && !snapshotFound) {
151-
// count++;
152-
// snapshotFound = true;
153-
// assertEquals(snapshot.getMetadata(), listShareItem.getMetadata());
154-
// assertEquals(snapshot.getStorageUri(), listShareItem.getStorageUri());
155-
// }
156-
// }
157-
//
158-
// assertEquals(2, count);
159-
// }
118+
@Test
119+
public void testListSharesWithSnapshot() throws StorageException, URISyntaxException {
120+
CloudFileClient fileClient = FileTestHelper.createCloudFileClient();
121+
CloudFileShare share = fileClient.getShareReference(UUID.randomUUID().toString());
122+
try {
123+
share.create();
124+
125+
HashMap<String, String> shareMeta = new HashMap<String, String>();
126+
shareMeta.put("key1", "value1");
127+
share.setMetadata(shareMeta);
128+
share.uploadMetadata();
129+
130+
CloudFileShare snapshot = share.createSnapshot();
131+
HashMap<String, String> meta2 = new HashMap<String, String>();
132+
meta2.put("key2", "value2");
133+
share.setMetadata(meta2);
134+
share.uploadMetadata();
135+
136+
CloudFileClient client = FileTestHelper.createCloudFileClient();
137+
Iterable<CloudFileShare> listResult = client.listShares(share.name, EnumSet.allOf(ShareListingDetails.class), null, null);
138+
139+
int count = 0;
140+
boolean originalFound = false;
141+
boolean snapshotFound = false;
142+
for (CloudFileShare listShareItem : listResult) {
143+
if (listShareItem.getName().equals(share.getName()) && !listShareItem.isSnapshot() && !originalFound) {
144+
count++;
145+
originalFound = true;
146+
assertEquals(share.getMetadata(), listShareItem.getMetadata());
147+
assertEquals(share.getStorageUri(), listShareItem.getStorageUri());
148+
} else if (listShareItem.getName().equals(share.getName()) &&
149+
listShareItem.isSnapshot() && !snapshotFound) {
150+
count++;
151+
snapshotFound = true;
152+
assertEquals(snapshot.getMetadata(), listShareItem.getMetadata());
153+
assertEquals(snapshot.getStorageUri(), listShareItem.getStorageUri());
154+
}
155+
}
156+
157+
assertEquals(2, count);
158+
}
159+
finally
160+
{
161+
share.deleteIfExists(DeleteShareSnapshotsOption.INCLUDE_SNAPSHOTS, null, null, null);
162+
}
163+
}
160164
}

microsoft-azure-storage-test/src/com/microsoft/azure/storage/file/CloudFileDirectoryTests.java

Lines changed: 66 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public void cloudFileDirectorySetUp() throws URISyntaxException, StorageExceptio
6060

6161
@After
6262
public void cloudFileDirectoryTearDown() throws StorageException {
63-
this.share.deleteIfExists();
63+
this.share.deleteIfExists(DeleteShareSnapshotsOption.INCLUDE_SNAPSHOTS, null, null, null);
6464
}
6565

6666
/**
@@ -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

Comments
 (0)