Skip to content

Commit

Permalink
Merge pull request #53 from Azure/dev
Browse files Browse the repository at this point in the history
1.1.0
  • Loading branch information
jofriedm-msft authored Jul 31, 2017
2 parents 24bf897 + 6f17612 commit e4f4cd0
Show file tree
Hide file tree
Showing 47 changed files with 1,665 additions and 176 deletions.
10 changes: 10 additions & 0 deletions ChangeLog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
2017.07.31 Version 1.1.0
* Support for 2017-04-17 REST version. Please see our REST API documentation and blogs for information about the related added features.
* For Premium Accounts only, added support for getting and setting the tier on a page blob. The tier can also be set when creating or copying from an existing page blob.
* Fixed a bug where the transactional MD5 check would fail when downloading a range of blob or file and the recovery action is performed on a subsection of the range.
* Added support for server side encryption for File Service.
* Fixed a bug that prevented setting content MD5 to true when creating a new file.
* Fixed a bug where access conditions, options, and operation context were not being passed when calling openWriteExisting() on a page blob or a file.
* Fixed a bug where an exception was being thrown on a range get of a blob or file when the options disableContentMD5Validation is set to false and useTransactionalContentMD5 is set to true and there is no overall MD5.
* Fixed a bug where retries were happening immediately if a sock exception was thrown.

2017.01.30 Version 1.0.0
* Android Studio support via Gradle build system.
* Updated tests from JUnit 3 to Android Junit 4.
Expand Down
32 changes: 16 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#Microsoft Azure Storage SDK for Android
# Microsoft Azure Storage SDK for Android

This project provides a client library for Android that makes it easy to consume Microsoft Azure Storage services. For documentation please see the [AndroidDocs](http://azure.github.io/azure-storage-android/).

> If you are looking for the Azure Storage Java SDK, please visit [https://github.com/Azure/azure-storage-java](https://github.com/Azure/azure-storage-java).
#Features
# Features
* Blob
* Create/Read/Update/Delete containers
* Create/Read/Update/Delete blobs
Expand All @@ -19,21 +19,21 @@ This project provides a client library for Android that makes it easy to consume
* Batch operations
* Advanced Table Operations

#Getting Started
# Getting Started

##Download
###Option 1: Source Zip
## Download
### Option 1: Source Zip

To download a copy of the source code, click "Download ZIP" on the right side of the page or click [here](https://github.com/Azure/azure-storage-android/archive/master.zip). Unzip and navigate to the microsoft-azure-storage folder.

###Option 2: Source via Git
### Option 2: Source Via Git

To get the source code of the SDK via git just type:

git clone git://github.com/Azure/azure-storage-android.git
cd ./azure-storage-android/microsoft-azure-storage

###Option 3: aar via Gradle
### Option 3: aar via Gradle

To get the binaries of this library as distributed by Microsoft, ready for use within your project, you can use Gradle.

Expand All @@ -46,30 +46,30 @@ First, add mavenCentral to your repositories by adding the following to your gra
Then, add a dependency by adding the following to your gradle build file:

dependencies {
compile 'com.microsoft.azure.android:azure-storage-android:1.0.0@aar'
compile 'com.microsoft.azure.android:azure-storage-android:1.1.0@aar'
}

###Option 4: aar via Maven
### Option 4: aar via Maven

To get the binaries of this library as distributed by Microsoft, ready for use within your project, you can use Maven.

```xml
<dependency>
<groupId>com.microsoft.azure.android</groupId>
<artifactId>azure-storage-android</artifactId>
<version>1.0.0</version>
<version>1.1.0</version>
<type>aar</type>
</dependency>
```

##Minimum Requirements and Setup
## Minimum Requirements and Setup
* [Jackson-Core](https://github.com/FasterXML/jackson-core) is used for JSON parsing.
* Android 4.0/15+
* (Optional) Gradle or Maven

This library is currently tested to work on Android versions 4.0+. Compatibility with older versions is not guaranteed.

##Usage
## Usage

To use this SDK to call Microsoft Azure storage services, you need to first [create an account](https://account.windowsazure.com/signup).

Expand All @@ -79,21 +79,21 @@ Make sure the storage client library is added as a project dependency. From Andr

If using Maven or Gradle, Jackson-Core should be automatically added to the build path. Otherwise, please download the jar and add it to your build path. Also, please make sure that the jar will be added to your project's apk. To do this in Android Studio, go to File -> Project Structure -> Modules. Click the Dependencies tab. Click the '+' sign and click 'File Dependency'. Navigate the .jar.

##Code Samples
## Code Samples

Runnable samples for blob, queue, and table may be found in the microsoft-azure-storage-samples directory. To run these samples, specify a connection string in the MainActivity class and add a dependency on the Android client library. For additional information on using the Android client library, the Java [general documentation](http://azure.microsoft.com/en-us/develop/java/) and Java How To guides for [blobs](http://azure.microsoft.com/en-us/documentation/articles/storage-java-how-to-use-blob-storage/), [queues](http://azure.microsoft.com/en-us/documentation/articles/storage-java-how-to-use-queue-storage/), [tables](http://azure.microsoft.com/en-us/documentation/articles/storage-java-how-to-use-table-storage/) may be helpful.

#Need Help?
# Need Help?

Be sure to check out the Azure [Developer Forums on MSDN](http://social.msdn.microsoft.com/Forums/windowsazure/en-US/home?forum=windowsazuredata) or the [Developer Forums on Stack Overflow](http://stackoverflow.com/questions/tagged/azure+windows-azure-storage) if you have trouble with the provided code.

#Contribute Code or Provide Feedback
# Contribute Code or Provide Feedback

If you would like to become an active contributor to this project please follow the instructions provided in [Azure Projects Contribution Guidelines](http://azure.github.io/guidelines/).

If you encounter any bugs with the library please file an issue in the [Issues](https://github.com/Azure/azure-storage-android/issues) section of the project.

#Learn More
# Learn More
* [Azure Storage Service](http://azure.microsoft.com/en-us/documentation/services/storage/)
* [Azure Storage Team Blog](http://blogs.msdn.com/b/windowsazurestorage/)
* [AndroidDocs](http://azure.github.io/azure-storage-android/)
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'com.android.tools.build:gradle:2.3.3'
}
}

Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Nov 30 14:47:51 PST 2016
#Sun May 28 10:18:41 PDT 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
2 changes: 1 addition & 1 deletion microsoft-azure-storage-samples/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.microsoft.azure.storage.samples"
android:versionCode="0"
android:versionName="1.0.0" >
android:versionName="1.1.0" >

<uses-sdk
android:minSdkVersion="15"
Expand Down
2 changes: 1 addition & 1 deletion microsoft-azure-storage-samples/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ dependencies {

android {
compileSdkVersion 19
buildToolsVersion "24.0.1"
buildToolsVersion '25.0.0'

sourceSets {
main {
Expand Down
4 changes: 2 additions & 2 deletions microsoft-azure-storage-test/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.microsoft.azure.android.test"
android:versionCode="0"
android:versionName="1.0.0" >
android:versionName="1.1.0" >

<uses-sdk
android:minSdkVersion="15"
Expand All @@ -20,7 +20,7 @@
<uses-permission android:name="android.permission.INTERNET" />

<instrumentation
android:name="android.test.InstrumentationTestRunner"
android:name="android.support.test.runner.AndroidJUnitRunner"
android:targetPackage="com.microsoft.azure.android.test" />

<application
Expand Down
2 changes: 1 addition & 1 deletion microsoft-azure-storage-test/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ repositories {

android {
compileSdkVersion 19
buildToolsVersion "24.0.1"
buildToolsVersion '25.0.0'

defaultConfig {
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,17 @@
import com.microsoft.azure.storage.TestRunners.CloudTests;
import com.microsoft.azure.storage.TestRunners.DevFabricTests;
import com.microsoft.azure.storage.TestRunners.DevStoreTests;
import com.microsoft.azure.storage.blob.BlobRequestOptions;
import com.microsoft.azure.storage.blob.CloudBlobClient;
import com.microsoft.azure.storage.blob.CloudBlobContainer;
import com.microsoft.azure.storage.blob.*;
import com.microsoft.azure.storage.core.SR;

import org.apache.http.protocol.HTTP;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.SocketException;
import java.net.URISyntaxException;
import java.util.ArrayList;

Expand Down Expand Up @@ -111,6 +113,22 @@ public void eventOccurred(ResponseReceivedEvent eventArg) {
}
});

eventContext.getErrorReceivingResponseEventHandler().addListener(new StorageEvent<ErrorReceivingResponseEvent>() {

@Override
public void eventOccurred(ErrorReceivingResponseEvent eventArg) {
fail("This event should not trigger");
}
});

OperationContext.getGlobalErrorReceivingResponseEventHandler().addListener(new StorageEvent<ErrorReceivingResponseEvent>() {

@Override
public void eventOccurred(ErrorReceivingResponseEvent eventArg) {
fail("This event should not trigger");
}
});

assertEquals(0, callList.size());
assertEquals(0, globalCallList.size());

Expand Down Expand Up @@ -138,6 +156,85 @@ public void eventOccurred(ResponseReceivedEvent eventArg) {
assertEquals(2, globalCallList.size());
}

@Test
public void testErrorReceivingResponseEvent() throws URISyntaxException, StorageException {
final ArrayList<Boolean> callList = new ArrayList<Boolean>();
final ArrayList<Boolean> globalCallList = new ArrayList<Boolean>();

OperationContext eventContext = new OperationContext();
BlobRequestOptions options = new BlobRequestOptions();
options.setRetryPolicyFactory(new RetryNoRetry());

// setting the sending request event handler to trigger an exception.
// this is a retryable exception
eventContext.getSendingRequestEventHandler().addListener(new StorageEvent<SendingRequestEvent>() {
@Override
public void eventOccurred(SendingRequestEvent eventArg) {
HttpURLConnection connection = (HttpURLConnection) eventArg.getConnectionObject();
connection.setFixedLengthStreamingMode(0);
}
});

eventContext.getErrorReceivingResponseEventHandler().addListener(new StorageEvent<ErrorReceivingResponseEvent>() {
@Override
public void eventOccurred(ErrorReceivingResponseEvent eventArg) {
assertEquals(eventArg.getRequestResult(), eventArg.getOpContext().getLastResult());
callList.add(true);
}
});

OperationContext.getGlobalErrorReceivingResponseEventHandler().addListener(new StorageEvent<ErrorReceivingResponseEvent>() {
@Override
public void eventOccurred(ErrorReceivingResponseEvent eventArg) {
assertEquals(eventArg.getRequestResult(), eventArg.getOpContext().getLastResult());
globalCallList.add(true);
}
});

CloudBlobClient blobClient = TestHelper.createCloudBlobClient();
CloudBlobContainer container = blobClient.getContainerReference("container1");
container.createIfNotExists();

try {
CloudBlockBlob blob1 = container.getBlockBlobReference("blob1");
try {
String blockID = String.format("%08d", 1);
blob1.uploadBlock(blockID, BlobTestHelper.getRandomDataStream(10), 10, null, options, eventContext);
} catch (Exception e) { }

// make sure both the local and globab context update
assertEquals(1, callList.size());
assertEquals(1, globalCallList.size());

// make sure only global updates by replacing the local with a no-op event
eventContext
.setErrorReceivingResponseEventHandler(new StorageEventMultiCaster<ErrorReceivingResponseEvent, StorageEvent<ErrorReceivingResponseEvent>>());
try {
String blockID2 = String.format("%08d", 2);
blob1.uploadBlock(blockID2, BlobTestHelper.getRandomDataStream(10), 10, null, options, eventContext);
} catch (Exception e) { }

assertEquals(1, callList.size());
assertEquals(2, globalCallList.size());

// make sure global does not update by replacing the global with a no-op
OperationContext
.setGlobalErrorReceivingResponseEventHandler(new StorageEventMultiCaster<ErrorReceivingResponseEvent, StorageEvent<ErrorReceivingResponseEvent>>());

// make sure neither update
try {
String blockID3 = String.format("%08d", 3);
blob1.uploadBlock(blockID3, BlobTestHelper.getRandomDataStream(10), 10, null, options, eventContext);
} catch (Exception e) { }

assertEquals(1, callList.size());
assertEquals(2, globalCallList.size());
}
finally {
container.deleteIfExists();
}
}

@Test
public void testRequestCompletedEvents() throws URISyntaxException, StorageException {
final ArrayList<Boolean> callList = new ArrayList<Boolean>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,9 @@ public void testMaximumExecutionTimeBlobWrites() throws URISyntaxException, Stor
BlobRequestOptions options = new BlobRequestOptions();
options.setMaximumExecutionTimeInMs(5000);

// set a lower put blob threshold so that we perform multiple put block requests that timeout
options.setSingleBlobPutThresholdInBytes(32 * Constants.MB);

CloudBlobClient blobClient = TestHelper.createCloudBlobClient();
CloudBlobContainer container = blobClient.getContainerReference(generateRandomName("container"));

Expand Down
Loading

0 comments on commit e4f4cd0

Please sign in to comment.