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

Commit f9bd963

Browse files
authored
Merge pull request #100 from esummers-msft/master
Azure Storage Client Library 4.3.0 Release
2 parents 3b123f9 + 473472b commit f9bd963

23 files changed

+521
-32
lines changed

CONTRIBUTING.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
If you intend to contribute to the project, please make sure you've followed the instructions provided in the [Azure Projects Contribution Guidelines](http://azure.github.io/guidelines/).
2+
## Project Setup
3+
The Azure Storage development team uses Eclipse so instructions will be tailored to that preference. However, any preferred IDE or other toolset should be usable.
4+
5+
### Install
6+
* Java SE 6+
7+
* [Eclipse](https://eclipse.org/downloads/)
8+
* [Maven plugin for Eclipse](http://www.eclipse.org/m2e/index.html). Some Eclipse packages (ex Eclipse IDE for Java Developers) may come with this plugin already installed.
9+
* [Maven](https://maven.apache.org/install.html)
10+
* Clone the source code from GitHub
11+
12+
### Open Solution
13+
Open the project from Eclipse using File->Import->Maven->Existing Maven Projects and navigating to the azure-storage-java folder. Select the listed pom. This imports the source and the test files and downloads the required dependencies via Maven. If you'd like to import the samples, follow the same procedure but navigate to the azure-storage-java\microsoft-azure-storage-samples folder and select that pom. Both projects can be opened at the same time and will be shown in the Package Explorer.
14+
15+
## Tests
16+
17+
### Configuration
18+
The only step to configure testing is to setup a configuration file or connection string via environment variables. To use the connection string route, create an environment variable named "storageConnection". To use the configuration file route, create an environment variable named "storageTestConfiguration" with the path to a TestConfigurations.xml file with this [template](https://github.com/Azure/azure-storage-java/blob/master/microsoft-azure-storage-test/res/TestConfigurations.xml).
19+
20+
### Running
21+
To actually run tests, right click on the test class in the Package Explorer or the individual test in the Outline and select Run As->JUnitTest. All tests or tests grouped by service can be run using the test runners in the com.microsoft.azure.storage package TestRunners file. Running all tests from the top of the package explorer will result in each test being run multiple times as the package explorer will also run every test runner.
22+
23+
### Testing Features
24+
As you develop a feature, you'll need to write tests to ensure quality. You should also run existing tests related to your change to address any unexpected breaks.
25+
26+
## Pull Requests
27+
28+
### Guidelines
29+
The following are the minimum requirements for any pull request that must be met before contributions can be accepted.
30+
* Make sure you've signed the CLA before you start working on any change.
31+
* Discuss any proposed contribution with the team via a GitHub issue **before** starting development.
32+
* Code must be professional quality
33+
* No style issues
34+
* You should strive to mimic the style with which we have written the library
35+
* Clean, well-commented, well-designed code
36+
* Try to limit the number of commits for a feature to 1-2. If you end up having too many we may ask you to squash your changes into fewer commits.
37+
* [ChangeLog.md](ChangeLog.md) needs to be updated describing the new change
38+
* Thoroughly test your feature
39+
40+
### Branching Policy
41+
Changes should be based on the **dev** branch, not master as master is considered publicly released code. If after discussion with us breaking changes are considered for the library, we will create a **dev_breaking** branch based on dev which can be used to store these changes until the next breaking release. Each breaking change should be recorded in [BreakingChanges.md](BreakingChanges.md).
42+
43+
### Adding Features for Java 6+
44+
We strive to release each new feature in a backward compatible manner. Therefore, we ask that all contributions be written to work in Java 6, 7 and 8.
45+
46+
### Review Process
47+
We expect all guidelines to be met before accepting a pull request. As such, we will work with you to address issues we find by leaving comments in your code. Please understand that it may take a few iterations before the code is accepted as we maintain high standards on code quality. Once we feel comfortable with a contribution, we will validate the change and accept the pull request.
48+
49+
50+
Thank you for any contributions! Please let the team know if you have any questions or concerns about our contribution policy.

ChangeLog.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2016.07.06 Version 4.3.0
2+
* Added support for server-side encryption.
3+
* Added support for getBlobReferenceFromServer methods on CloudBlobContainer to support retrieving a blob without knowing its type.
4+
* Fixed a bug in the retry policies where 300 status codes were being retried when they shouldn't be.
5+
16
2016.04.07 Version 4.2.0
27
* Added support for setting a library-wide proxy. The default proxy can be set on OperationContext.
38
* Added support in Page Blob for getting a list of differing page ranges between snapshot versions.

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>4.2.0</version>
29+
<version>4.3.0</version>
3030
</dependency>
3131
<dependency>
3232
<groupId>com.microsoft.azure</groupId>

microsoft-azure-storage-test/res/TestConfigurations.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
<BlobServiceEndpoint>http://[ACCOUNT].blob.core.windows.net</BlobServiceEndpoint>
2222
<QueueServiceEndpoint>http://[ACCOUNT].queue.core.windows.net</QueueServiceEndpoint>
2323
<TableServiceEndpoint>http://[ACCOUNT].table.core.windows.net</TableServiceEndpoint>
24+
<FileServiceEndpoint>http://[ACCOUNT].file.core.windows.net</FileServiceEndpoint>
2425
<BlobServiceSecondaryEndpoint>http://[ACCOUNT]-secondary.blob.core.windows.net</BlobServiceSecondaryEndpoint>
2526
<QueueServiceSecondaryEndpoint>http://[ACCOUNT]-secondary.queue.core.windows.net</QueueServiceSecondaryEndpoint>
2627
<TableServiceSecondaryEndpoint>http://[ACCOUNT]-secondary.table.core.windows.net</TableServiceSecondaryEndpoint>

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

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
import static org.junit.Assert.*;
1818

19+
import java.io.ByteArrayOutputStream;
20+
import java.io.IOException;
1921
import java.net.HttpURLConnection;
2022
import java.net.URISyntaxException;
2123
import java.util.ArrayList;
@@ -30,6 +32,7 @@
3032
import com.microsoft.azure.storage.TestRunners.SlowTests;
3133
import com.microsoft.azure.storage.blob.BlobRequestOptions;
3234
import com.microsoft.azure.storage.blob.BlobTestHelper;
35+
import com.microsoft.azure.storage.blob.BlobType;
3336
import com.microsoft.azure.storage.blob.CloudBlobClient;
3437
import com.microsoft.azure.storage.blob.CloudBlobContainer;
3538
import com.microsoft.azure.storage.blob.CloudBlockBlob;
@@ -639,6 +642,32 @@ public void testMultiLocationRetriesTable() throws URISyntaxException, StorageEx
639642
testTableDownloadPermissions(null, LocationMode.SECONDARY_THEN_PRIMARY, StorageLocation.SECONDARY,
640643
retryContextList, retryInfoList);
641644
}
645+
646+
@Test
647+
public void testRetryOn304() throws StorageException, IOException, URISyntaxException {
648+
OperationContext operationContext = new OperationContext();
649+
operationContext.getRetryingEventHandler().addListener(new StorageEvent<RetryingEvent>() {
650+
@Override
651+
public void eventOccurred(RetryingEvent eventArg) {
652+
fail("Request should not be retried.");
653+
}
654+
});
655+
656+
CloudBlobContainer container = BlobTestHelper.getRandomContainerReference();
657+
try {
658+
container.create();
659+
CloudBlockBlob blockBlobRef = (CloudBlockBlob) BlobTestHelper.uploadNewBlob(container, BlobType.BLOCK_BLOB,
660+
"originalBlob", 1024, null);
661+
AccessCondition accessCondition = AccessCondition.generateIfNoneMatchCondition(blockBlobRef.getProperties().getEtag());
662+
blockBlobRef.download(new ByteArrayOutputStream(), accessCondition, null, operationContext);
663+
664+
fail("Download should fail with a 304.");
665+
} catch (StorageException ex) {
666+
assertEquals("The condition specified using HTTP conditional header(s) is not met.", ex.getMessage());
667+
} finally {
668+
container.deleteIfExists();
669+
}
670+
}
642671

643672
private static void AddUpdatedLocationModes(List<RetryContext> retryContextList, List<RetryInfo> retryInfoList) {
644673
retryInfoList

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
import com.microsoft.azure.storage.blob.CloudBlobClientTests;
1414
import com.microsoft.azure.storage.blob.CloudBlobContainerTests;
1515
import com.microsoft.azure.storage.blob.CloudBlobDirectoryTests;
16-
import com.microsoft.azure.storage.blob.CloudBlobEncryptionTests;
16+
import com.microsoft.azure.storage.blob.CloudBlobClientEncryptionTests;
17+
import com.microsoft.azure.storage.blob.CloudBlobServerEncryptionTests;
1718
import com.microsoft.azure.storage.blob.CloudBlockBlobTests;
1819
import com.microsoft.azure.storage.blob.CloudPageBlobTests;
1920
import com.microsoft.azure.storage.blob.LeaseTests;
@@ -100,8 +101,8 @@ public static class CoreTestSuite {
100101

101102
@RunWith(Suite.class)
102103
@SuiteClasses({ BlobOutputStreamTests.class, CloudBlobClientTests.class, CloudBlobContainerTests.class,
103-
CloudBlobDirectoryTests.class, CloudAppendBlobTests.class, CloudBlockBlobTests.class, CloudPageBlobTests.class,
104-
CloudBlobEncryptionTests.class, LeaseTests.class, SasTests.class })
104+
CloudBlobDirectoryTests.class, CloudAppendBlobTests.class, CloudBlockBlobTests.class, CloudPageBlobTests.class,
105+
CloudBlobClientEncryptionTests.class, CloudBlobServerEncryptionTests.class, LeaseTests.class, SasTests.class })
105106
public static class BlobTestSuite {
106107
}
107108

@@ -130,7 +131,8 @@ public static class AnalyticsTestSuite {
130131
}
131132

132133
@RunWith(Suite.class)
133-
@SuiteClasses({ CloudBlobEncryptionTests.class, CloudQueueEncryptionTests.class, TableEncryptionTests.class })
134+
@SuiteClasses({ CloudBlobClientEncryptionTests.class, CloudBlobServerEncryptionTests.class,
135+
CloudQueueEncryptionTests.class, TableEncryptionTests.class })
134136
public static class EncryptionTestSuite {
135137
}
136138

@@ -161,4 +163,4 @@ public static class DevFabricNoSecondarySuite {
161163
@SuiteClasses(AllTestSuite.class)
162164
public static class FastTestSuite {
163165
}
164-
}
166+
}

microsoft-azure-storage-test/src/com/microsoft/azure/storage/blob/BlobTestHelper.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,7 @@ public static void assertAreEqual(CloudBlob blob1, CloudBlob blob2) throws URISy
384384
}
385385
else {
386386
assertNotNull(blob2);
387+
assertEquals(blob1.getClass(), blob2.getClass());
387388
assertEquals(blob1.getUri(), blob2.getUri());
388389
assertEquals(blob1.getSnapshotID(), blob2.getSnapshotID());
389390
assertEquals(blob1.isSnapshot(), blob2.isSnapshot());
@@ -399,6 +400,7 @@ public static void assertAreEqual(BlobProperties prop1, BlobProperties prop2) {
399400
}
400401
else {
401402
assertNotNull(prop2);
403+
assertEquals(prop1.getBlobType(), prop2.getBlobType());
402404
assertEquals(prop1.getCacheControl(), prop2.getCacheControl());
403405
assertEquals(prop1.getContentDisposition(), prop2.getContentDisposition());
404406
assertEquals(prop1.getContentEncoding(), prop2.getContentEncoding());
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,18 +58,18 @@
5858
import com.microsoft.azure.storage.core.SR;
5959

6060
@Category({ CloudTests.class, DevFabricTests.class, DevStoreTests.class })
61-
public class CloudBlobEncryptionTests {
61+
public class CloudBlobClientEncryptionTests {
6262

6363
protected CloudBlobContainer container;
6464

6565
@Before
66-
public void blockBlobTestMethodSetup() throws URISyntaxException, StorageException {
66+
public void blobEncryptionTestMethodSetup() throws URISyntaxException, StorageException {
6767
this.container = BlobTestHelper.getRandomContainerReference();
6868
this.container.create();
6969
}
7070

7171
@After
72-
public void blockBlobTestMethodTearDown() throws StorageException {
72+
public void blobEncryptionTestMethodTearDown() throws StorageException {
7373
this.container.deleteIfExists();
7474
}
7575

@@ -1010,4 +1010,4 @@ public void eventOccurred(SendingRequestEvent eventArg) {
10101010
TestHelper.assertStreamsAreEqualAtIndex(stream, new ByteArrayInputStream(outputStream.toByteArray()), 0, 0,
10111011
size, 2 * 1024);
10121012
}
1013-
}
1013+
}

microsoft-azure-storage-test/src/com/microsoft/azure/storage/blob/CloudBlobContainerTests.java

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import java.io.IOException;
2020
import java.net.HttpURLConnection;
2121
import java.net.URISyntaxException;
22+
import java.security.InvalidKeyException;
2223
import java.util.Calendar;
2324
import java.util.Date;
2425
import java.util.EnumSet;
@@ -41,6 +42,7 @@
4142
import com.microsoft.azure.storage.ResultContinuation;
4243
import com.microsoft.azure.storage.ResultSegment;
4344
import com.microsoft.azure.storage.SendingRequestEvent;
45+
import com.microsoft.azure.storage.StorageCredentialsSharedAccessSignature;
4446
import com.microsoft.azure.storage.StorageErrorCodeStrings;
4547
import com.microsoft.azure.storage.StorageEvent;
4648
import com.microsoft.azure.storage.StorageException;
@@ -134,6 +136,86 @@ public void testCloudBlobContainerReference() throws StorageException, URISyntax
134136
.toString());
135137
}
136138

139+
@Test
140+
@Category({ DevFabricTests.class, DevStoreTests.class })
141+
public void testCloudBlobContainerReferenceFromServer() throws StorageException, URISyntaxException, IOException {
142+
this.container.create();
143+
144+
CloudBlob blob = BlobTestHelper.uploadNewBlob(this.container, BlobType.BLOCK_BLOB, null, 1024, null);
145+
blob.getProperties().setContentType("application/octet-stream");
146+
blob.getProperties().setLength(1024);
147+
148+
CloudBlob blobRef = this.container.getBlobReferenceFromServer(blob.getName());
149+
BlobTestHelper.assertAreEqual(blob, blobRef);
150+
151+
blob = BlobTestHelper.uploadNewBlob(this.container, BlobType.PAGE_BLOB, null, 1024, null);
152+
blob.getProperties().setContentType("application/octet-stream");
153+
blob.getProperties().setLength(1024);
154+
155+
blobRef = this.container.getBlobReferenceFromServer(blob.getName());
156+
BlobTestHelper.assertAreEqual(blob, blobRef);
157+
158+
blob = BlobTestHelper.uploadNewBlob(this.container, BlobType.APPEND_BLOB, null, 1024, null);
159+
blob.getProperties().setContentType("application/octet-stream");
160+
blob.getProperties().setLength(1024);
161+
162+
blobRef = this.container.getBlobReferenceFromServer(blob.getName());
163+
BlobTestHelper.assertAreEqual(blob, blobRef);
164+
}
165+
166+
@Test
167+
@Category({ DevFabricTests.class, DevStoreTests.class })
168+
public void testCloudBlobContainerReferenceFromServerSnapshot() throws StorageException, URISyntaxException,
169+
IOException {
170+
this.container.create();
171+
172+
CloudBlob blob = BlobTestHelper.uploadNewBlob(this.container, BlobType.BLOCK_BLOB, null, 1024, null);
173+
CloudBlob snapshot = blob.createSnapshot();
174+
snapshot.getProperties().setContentType("application/octet-stream");
175+
snapshot.getProperties().setLength(1024);
176+
177+
CloudBlob blobRef = this.container.getBlobReferenceFromServer(snapshot.getName(), snapshot.getSnapshotID(),
178+
null, null, null);
179+
BlobTestHelper.assertAreEqual(snapshot, blobRef);
180+
}
181+
182+
@Test
183+
@Category({ DevFabricTests.class, DevStoreTests.class })
184+
public void testCloudBlobContainerReferenceFromServerSAS() throws StorageException, URISyntaxException,
185+
IOException, InvalidKeyException {
186+
this.container.create();
187+
CloudBlob blob = BlobTestHelper.uploadNewBlob(this.container, BlobType.BLOCK_BLOB, null, 1024, null);
188+
189+
SharedAccessBlobPolicy policy = new SharedAccessBlobPolicy();
190+
Calendar now = Calendar.getInstance();
191+
now.add(Calendar.MINUTE, 10);
192+
policy.setSharedAccessExpiryTime(now.getTime());
193+
policy.setPermissions(EnumSet.of(SharedAccessBlobPermissions.READ));
194+
String token = this.container.generateSharedAccessSignature(policy, null);
195+
196+
CloudBlobContainer containerSAS = new CloudBlobContainer(this.container.getStorageUri(),
197+
new StorageCredentialsSharedAccessSignature(token));
198+
CloudBlob blobRef = containerSAS.getBlobReferenceFromServer(blob.getName());
199+
assertEquals(blob.getClass(), blobRef.getClass());
200+
assertEquals(blob.getUri(), blobRef.getUri());
201+
}
202+
203+
@Test
204+
@Category({ DevFabricTests.class, DevStoreTests.class })
205+
public void testCloudBlobContainerReferenceFromServerMissingBlob() throws StorageException, URISyntaxException,
206+
IOException {
207+
this.container.create();
208+
209+
String blobName = BlobTestHelper.generateRandomBlobNameWithPrefix("missing");
210+
211+
try {
212+
this.container.getBlobReferenceFromServer(blobName);
213+
fail("Get reference from server should fail.");
214+
} catch (StorageException ex) {
215+
assertEquals(404, ex.getHttpStatusCode());
216+
}
217+
}
218+
137219
/**
138220
* Create a container
139221
*

0 commit comments

Comments
 (0)