Skip to content

Commit

Permalink
aXSCL 0.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
pemari-msft committed Aug 1, 2014
1 parent f8ef359 commit 0e5ffbb
Show file tree
Hide file tree
Showing 20 changed files with 474 additions and 24 deletions.
7 changes: 6 additions & 1 deletion ChangeLog.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
2014.08.01 Version 0.3.0
* Added the NameValidator class which contains helpers that check to see if resource names are valid.
* Fixed a bug where the RequestUrl of a LogRecord was not correctly HTML4 decoded.
* Made FileRange class and ListFilesAndDirectories method in the CloudFileDirectory class public.

2014.07.02 Version 0.2.0
* Added File Service support. The File Service and the associated SDK APIs are in preview.
* Added CloudAnalyticsClient and related methods to simplify Storage Analytics logging and metrics use case scenarios.
* Fixed a bug where an empty file would be left over during the downloadToFile error case.
* Updated StorageErrorCodeStrings class.
* Requests made using SAS credentials have the api-version query parameter appended to the URI.
* Fixed a null pointer exception that resulted when the first request was made with a blob created using the uri-only constructor (no sas creds appended).
* Fixed a null pointer exception that resulted when the first request was made with a blob created using the uri-only constructor (no sas creds appended).
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ 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:0.2.1@aar'
compile 'com.microsoft.azure.android:azure-storage-android:0.3.0@aar'
}

###Option 4: aar via Maven
Expand All @@ -55,7 +55,7 @@ To get the binaries of this library as distributed by Microsoft, ready for use w
<dependency>
<groupId>com.microsoft.azure.android</groupId>
<artifactId>azure-storage-android</artifactId>
<version>0.2.1</version>
<version>0.3.0</version>
<type>aar</type>
</dependency>
```
Expand Down
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.android.sample"
android:versionCode="0"
android:versionName="0.2.1" >
android:versionName="0.3.0" >

<uses-sdk
android:minSdkVersion="15"
Expand Down
2 changes: 1 addition & 1 deletion 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="0.2.1" >
android:versionName="0.3.0" >

<uses-sdk
android:minSdkVersion="15"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ public void testCloudAnalyticsClientListLogsStartEndTime() throws URISyntaxExcep
*/
public void testCloudAnalyticsClientParseExLogs() throws ParseException, URISyntaxException, StorageException,
IOException {
String logText = "1.0;2011-08-09T18:52:40.9241789Z;GetBlob;AnonymousSuccess;200;18;10;anonymous;;myaccount;blob;\"https://myaccount.blob.core.windows.net/thumbnails/lake.jpg?timeout=30000\";\"/myaccount/thumbnails/lake.jpg\";a84aa705-8a85-48c5-b064-b43bd22979c3;0;123.100.2.10;2009-09-19;252;0;265;100;0;;;\"0x8CE1B6EA95033D5\";Tuesday, 09-Aug-11 18:52:40 GMT;;;;\"8/9/2011 6:52:40 PM ba98eb12-700b-4d53-9230-33a3330571fc\""
String logText = "1.0;2011-08-09T18:52:40.9241789Z;GetBlob;AnonymousSuccess;200;18;10;anonymous;;myaccount;blob;\"https://myaccount.blob.core.windows.net/thumb&amp;nails/lake.jpg?timeout=30000\";\"/myaccount/thumbnails/lake.jpg\";a84aa705-8a85-48c5-b064-b43bd22979c3;0;123.100.2.10;2009-09-19;252;0;265;100;0;;;\"0x8CE1B6EA95033D5\";Tuesday, 09-Aug-11 18:52:40 GMT;;;;\"8/9/2011 6:52:40 PM ba98eb12-700b-4d53-9230-33a3330571fc\""
+ '\n'
+ "1.0;2011-08-09T18:02:40.6271789Z;PutBlob;Success;201;28;21;authenticated;myaccount;myaccount;blob;\"https://myaccount.blob.core.windows.net/thumbnails/lake.jpg?timeout=30000\";\"/myaccount/thumbnails/lake.jpg\";fb658ee6-6123-41f5-81e2-4bfdc178fea3;0;201.9.10.20;2009-09-19;438;100;223;0;100;;\"66CbMXKirxDeTr82SXBKbg==\";\"0x8CE1B67AD25AA05\";Tuesday, 09-Aug-11 18:02:40 GMT;;;;\"8/9/2011 6:02:40 PM ab970a57-4a49-45c4-baa9-20b687941e32\""
+ '\n';
Expand All @@ -233,7 +233,7 @@ public void testCloudAnalyticsClientParseExLogs() throws ParseException, URISynt
expectedItemOne.setOwnerAccountName("myaccount");
expectedItemOne.setServiceType("blob");
expectedItemOne.setRequestUrl(new URI(
"https://myaccount.blob.core.windows.net/thumbnails/lake.jpg?timeout=30000"));
"https://myaccount.blob.core.windows.net/thumb&nails/lake.jpg?timeout=30000"));
expectedItemOne.setRequestedObjectKey("/myaccount/thumbnails/lake.jpg");
expectedItemOne.setRequestIdHeader(UUID.fromString("a84aa705-8a85-48c5-b064-b43bd22979c3"));
expectedItemOne.setOperationCount(0);
Expand Down Expand Up @@ -305,7 +305,7 @@ public void testCloudAnalyticsClientParseProdLogs() throws ParseException, URISy
IOException {

Calendar startTime = new GregorianCalendar();
startTime.add(GregorianCalendar.DAY_OF_MONTH, -3);
startTime.add(GregorianCalendar.HOUR_OF_DAY, -2);

Iterator<LogRecord> logRecordsIterator = (this.client.listLogRecords(StorageService.BLOB, startTime.getTime(),
null, null, null)).iterator();
Expand All @@ -314,6 +314,7 @@ public void testCloudAnalyticsClientParseProdLogs() throws ParseException, URISy
// Makes sure there's no exceptions thrown and that no records are null.
// Primarily a sanity check.
LogRecord rec = logRecordsIterator.next();
System.out.println(rec.getRequestUrl());
assertNotNull(rec);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import junit.framework.TestCase;

import com.microsoft.azure.storage.Constants;
import com.microsoft.azure.storage.NameValidator;
import com.microsoft.azure.storage.OperationContext;
import com.microsoft.azure.storage.ResultContinuation;
import com.microsoft.azure.storage.ResultSegment;
Expand All @@ -55,6 +56,42 @@ public void setUp() throws Exception {
public void tearDown() throws Exception {
this.container.deleteIfExists();
}

/**
* Test container name validation.
*/
public void testCloudBlobContainerNameValidation()
{
NameValidator.validateContainerName("alpha");
NameValidator.validateContainerName("4lphanum3r1c");
NameValidator.validateContainerName("middle-dash");
NameValidator.validateContainerName("$root");
NameValidator.validateContainerName("$logs");

invalidContainertTestHelper(null, "Null containers invalid.", "Invalid container name. The name may not be null, empty, or whitespace only.");
invalidContainertTestHelper("$ROOT", "Root container case sensitive.", "Invalid container name. Check MSDN for more information about valid naming.");
invalidContainertTestHelper("double--dash", "Double dashes not allowed.", "Invalid container name. Check MSDN for more information about valid naming.");
invalidContainertTestHelper("-start-dash", "Start dashes not allowed.", "Invalid container name. Check MSDN for more information about valid naming.");
invalidContainertTestHelper("CapsLock", "Lowercase only.", "Invalid container name. Check MSDN for more information about valid naming.");
invalidContainertTestHelper("illegal$char", "Only alphanumeric and hyphen characters.", "Invalid container name. Check MSDN for more information about valid naming.");
invalidContainertTestHelper("illegal!char", "Only alphanumeric and hyphen characters.", "Invalid container name. Check MSDN for more information about valid naming.");
invalidContainertTestHelper("white space", "Only alphanumeric and hyphen characters.", "Invalid container name. Check MSDN for more information about valid naming.");
invalidContainertTestHelper("2c", "Root container case sensitive.", "Invalid container name length. The name must be between 3 and 63 characters long.");
invalidContainertTestHelper(new String(new char[64]).replace("\0", "n"), "Between 3 and 64 characters.", "Invalid container name length. The name must be between 3 and 63 characters long.");
}

private void invalidContainertTestHelper(String containerName, String failMessage, String exceptionMessage)
{
try
{
NameValidator.validateContainerName(containerName);
fail(failMessage);
}
catch (IllegalArgumentException e)
{
assertEquals(exceptionMessage, e.getMessage());
}
}

/**
* Validate container references
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@

import com.microsoft.azure.storage.AccessCondition;
import com.microsoft.azure.storage.Constants;
import com.microsoft.azure.storage.NameValidator;
import com.microsoft.azure.storage.OperationContext;
import com.microsoft.azure.storage.RetryNoRetry;
import com.microsoft.azure.storage.SendingRequestEvent;
Expand Down Expand Up @@ -66,6 +67,37 @@ public void tearDown() throws StorageException {
this.container.deleteIfExists();
}

/**
* Test blob name validation.
*/
public void testCloudBlobNameValidation()
{
NameValidator.validateBlobName("alpha");
NameValidator.validateBlobName("4lphanum3r1c");
NameValidator.validateBlobName("CAPSLOCK");
NameValidator.validateBlobName("white space");
NameValidator.validateBlobName("ºth3r(h@racter$");
NameValidator.validateBlobName(new String(new char[253]).replace("\0", "a/a"));

invalidBlobTestHelper("", "No empty strings.", "Invalid blob name. The name may not be null, empty, or whitespace only.");
invalidBlobTestHelper(null, "No null strings.", "Invalid blob name. The name may not be null, empty, or whitespace only.");
invalidBlobTestHelper(new String(new char[1025]).replace("\0", "n"), "Maximum 1024 characters.", "Invalid blob name length. The name must be between 1 and 1024 characters long.");
invalidBlobTestHelper(new String(new char[254]).replace("\0", "a/a"), "Maximum 254 path segments.", "The count of URL path segments (strings between '/' characters) as part of the blob name cannot exceed 254.");
}

private void invalidBlobTestHelper(String blobName, String failMessage, String exceptionMessage)
{
try
{
NameValidator.validateBlobName(blobName);
fail(failMessage);
}
catch (IllegalArgumentException e)
{
assertEquals(exceptionMessage, e.getMessage());
}
}

public void testBlobUriOnlyConstructors() throws URISyntaxException, StorageException, InvalidKeyException {
URI blobURI = new URI(container.getUri().toString() + "/anonblob");
CloudBlockBlob blob = new CloudBlockBlob(blobURI);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import junit.framework.TestCase;

import com.microsoft.azure.storage.NameValidator;
import com.microsoft.azure.storage.OperationContext;
import com.microsoft.azure.storage.ResultSegment;
import com.microsoft.azure.storage.SendingRequestEvent;
Expand All @@ -47,6 +48,41 @@ public void setUp() throws URISyntaxException, StorageException {
public void tearDown() throws StorageException {
this.share.deleteIfExists();
}

/**
* Test directory name validation.
*/
public void testCloudFileDirectoryNameValidation()
{
NameValidator.validateDirectoryName("alpha");
NameValidator.validateDirectoryName("4lphanum3r1c");
NameValidator.validateDirectoryName("middle-dash");
NameValidator.validateDirectoryName("CAPS");
NameValidator.validateDirectoryName("$root");
NameValidator.validateDirectoryName("..");
NameValidator.validateDirectoryName("CLOCK$");
NameValidator.validateDirectoryName("endslash/");

invalidDirectoryTestHelper(null, "No null.", "Invalid directory name. The name may not be null, empty, or whitespace only.");
invalidDirectoryTestHelper("middle/slash", "Slashes only at the end.", "Invalid directory name. Check MSDN for more information about valid naming.");
invalidDirectoryTestHelper("illegal\"char", "Illegal character.", "Invalid directory name. Check MSDN for more information about valid naming.");
invalidDirectoryTestHelper("illegal:char?", "Illegal character.", "Invalid directory name. Check MSDN for more information about valid naming.");
invalidDirectoryTestHelper("", "Between 1 and 255 characters.", "Invalid directory name. The name may not be null, empty, or whitespace only.");
invalidDirectoryTestHelper(new String(new char[256]).replace("\0", "n"), "Between 1 and 255 characters.", "Invalid directory name length. The name must be between 1 and 255 characters long.");
}

private void invalidDirectoryTestHelper(String directoryName, String failMessage, String exceptionMessage)
{
try
{
NameValidator.validateDirectoryName(directoryName);
fail(failMessage);
}
catch (IllegalArgumentException e)
{
assertEquals(exceptionMessage, e.getMessage());
}
}

private boolean CloudFileDirectorySetup(CloudFileShare share) throws URISyntaxException, StorageException {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import junit.framework.TestCase;

import com.microsoft.azure.storage.NameValidator;
import com.microsoft.azure.storage.OperationContext;
import com.microsoft.azure.storage.SendingRequestEvent;
import com.microsoft.azure.storage.StorageErrorCodeStrings;
Expand All @@ -43,6 +44,39 @@ public void setUp() throws StorageException, URISyntaxException {
public void tearDown() throws StorageException {
this.share.deleteIfExists();
}

/**
* Test share name validation.
*/
public void testCloudShareNameValidation()
{
NameValidator.validateShareName("alpha");
NameValidator.validateShareName("4lphanum3r1c");
NameValidator.validateShareName("middle-dash");

invalidShareTestHelper(null, "Null not allowed.", "Invalid share name. The name may not be null, empty, or whitespace only.");
invalidShareTestHelper("$root", "Alphanumeric or dashes only.", "Invalid share name. Check MSDN for more information about valid naming.");
invalidShareTestHelper("double--dash", "No double dash.", "Invalid share name. Check MSDN for more information about valid naming.");
invalidShareTestHelper("CapsLock", "Lowercase only.", "Invalid share name. Check MSDN for more information about valid naming.");
invalidShareTestHelper("illegal$char", "Alphanumeric or dashes only.", "Invalid share name. Check MSDN for more information about valid naming.");
invalidShareTestHelper("illegal!char", "Alphanumeric or dashes only.", "Invalid share name. Check MSDN for more information about valid naming.");
invalidShareTestHelper("white space", "Alphanumeric or dashes only.", "Invalid share name. Check MSDN for more information about valid naming.");
invalidShareTestHelper("2c", "Between 3 and 63 characters.", "Invalid share name length. The name must be between 3 and 63 characters long.");
invalidShareTestHelper(new String(new char[64]).replace("\0", "n"), "Between 3 and 63 characters.", "Invalid share name length. The name must be between 3 and 63 characters long.");
}

private void invalidShareTestHelper(String shareName, String failMessage, String exceptionMessage)
{
try
{
NameValidator.validateShareName(shareName);
fail(failMessage);
}
catch (IllegalArgumentException e)
{
assertEquals(exceptionMessage, e.getMessage());
}
}

/**
* Validate share references
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

import junit.framework.TestCase;

import com.microsoft.azure.storage.NameValidator;
import com.microsoft.azure.storage.OperationContext;
import com.microsoft.azure.storage.RetryNoRetry;
import com.microsoft.azure.storage.SendingRequestEvent;
Expand All @@ -56,6 +57,41 @@ public void tearDown() throws StorageException {
this.share.deleteIfExists();
}

/**
* Test file name validation.
*/
public void CloudFileNameValidation()
{
NameValidator.validateFileName("alpha");
NameValidator.validateFileName("4lphanum3r1c");
NameValidator.validateFileName("middle-dash");
NameValidator.validateFileName("CAPS");
NameValidator.validateFileName("$root");

invalidFileTestHelper(null, "No null.", "Invalid file name. The name may not be null, empty, or whitespace only.");
invalidFileTestHelper("..", "Reserved.", "Invalid file name. This name is reserved.");
invalidFileTestHelper("Clock$", "Reserved.", "Invalid file name. This name is reserved.");
invalidFileTestHelper("endslash/", "No slashes.", "Invalid file name. Check MSDN for more information about valid naming.");
invalidFileTestHelper("middle/slash", "No slashes.", "Invalid file name. Check MSDN for more information about valid naming.");
invalidFileTestHelper("illegal\"char", "Illegal characters.", "Invalid file name. Check MSDN for more information about valid naming.");
invalidFileTestHelper("illegal:char?", "Illegal characters.", "Invalid file name. Check MSDN for more information about valid naming.");
invalidFileTestHelper("", "Between 1 and 255 characters.", "Invalid file name. The name may not be null, empty, or whitespace only.");
invalidFileTestHelper(new String(new char[256]).replace("\0", "n"), "Between 1 and 255 characters.", "Invalid file name length. The name must be between 1 and 255 characters long.");
}

private void invalidFileTestHelper(String fileName, String failMessage, String exceptionMessage)
{
try
{
NameValidator.validateFileName(fileName);
fail(failMessage);
}
catch (IllegalArgumentException e)
{
assertEquals(exceptionMessage, e.getMessage());
}
}

/**
* Test file creation and deletion.
*
Expand Down
Loading

0 comments on commit 0e5ffbb

Please sign in to comment.