Skip to content

Commit

Permalink
JXSCL 1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
pemari-msft committed Aug 1, 2014
1 parent f88731a commit 19da1b4
Show file tree
Hide file tree
Showing 18 changed files with 475 additions and 11 deletions.
5 changes: 5 additions & 0 deletions ChangeLog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2014.08.01 Version 1.2.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. Added a dependency on Apache Commons Lang3.
* Made FileRange class and ListFilesAndDirectories method in the CloudFileDirectory class public.

2014.07.01 Version 1.1.0
* Changed the maven group id and artifact id. The new group id is com.microsoft.azure and the new artifact id is azure-storage.
* Added File Service support. The File Service and the associated SDK APIs are in preview.
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ To get the binaries of this library as distributed by Microsoft, ready for use w
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-storage</artifactId>
<version>1.1.0</version>
<version>1.2.0</version>
</dependency>
```

Expand All @@ -37,6 +37,8 @@ To get the binaries of this library as distributed by Microsoft, ready for use w
To get the source code of the SDK via git just type:

git clone git://github.com/Azure/azure-storage-java.git
cd ./azure-storage-java/microsoft-azure-storage
mvn compile

###Option 3: Source Zip

Expand Down Expand Up @@ -128,4 +130,4 @@ If you encounter any bugs with the library please file an issue in the [Issues](
* [Azure Developer Center](http://azure.microsoft.com/en-us/develop/java/)
* [Azure Storage Service](http://azure.microsoft.com/en-us/documentation/services/storage/)
* [Azure Storage Team Blog](http://blogs.msdn.com/b/windowsazurestorage/)
* [JavaDocs](http://dl.windowsazure.com/storage/javadoc)
* [JavaDocs](http://dl.windowsazure.com/storage/javadoc)
2 changes: 1 addition & 1 deletion microsoft-azure-storage-samples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-storage</artifactId>
<version>1.1.0</version>
<version>1.2.0</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ public void testCloudAnalyticsClientListLogsStartEndTime() throws URISyntaxExcep
@Test
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 @@ -247,7 +247,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
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.junit.experimental.categories.Category;

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 Down Expand Up @@ -66,6 +67,43 @@ public void blobContainerTestMethodSetUp() throws StorageException, URISyntaxExc
public void blobContainerTestMethodTearDown() throws StorageException {
this.container.deleteIfExists();
}

/**
* Test container name validation.
*/
@Test
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 @@ -45,6 +45,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 @@ -77,6 +78,38 @@ public void blockBlobTestMethodTearDown() throws StorageException {
this.container.deleteIfExists();
}

/**
* Test blob name validation.
*/
@Test
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());
}
}

@Test
public void testBlobUriOnlyConstructors() throws URISyntaxException, StorageException, InvalidKeyException {
URI blobURI = new URI(this.container.getUri().toString() + "/anonblob");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.junit.Test;
import org.junit.experimental.categories.Category;

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 Down Expand Up @@ -56,6 +57,42 @@ public void fileTestMethodSetup() throws URISyntaxException, StorageException {
public void fileTestMethodTearDown() throws StorageException {
this.share.deleteIfExists();
}

/**
* Test directory name validation.
*/
@Test
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 @@ -25,6 +25,7 @@
import org.junit.Test;
import org.junit.experimental.categories.Category;

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 Down Expand Up @@ -53,6 +54,40 @@ public void fileShareTestMethodSetUp() throws StorageException, URISyntaxExcepti
public void fileShareTestMethodTearDown() throws StorageException {
this.share.deleteIfExists();
}

/**
* Test share name validation.
*/
@Test
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 @@ -36,6 +36,7 @@
import org.junit.Test;
import org.junit.experimental.categories.Category;

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 @@ -65,6 +66,42 @@ public void fileTestMethodTearDown() throws StorageException {
this.share.deleteIfExists();
}

/**
* Test file name validation.
*/
@Test
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
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@

import com.microsoft.azure.storage.AuthenticationScheme;
import com.microsoft.azure.storage.LocationMode;
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 @@ -70,6 +71,40 @@ public void queueTestMethodTearDown() throws StorageException {
this.queue.deleteIfExists();
}

/**
* Tests queue name validation.
*/
@Test
public void testCloudQueueNameValidation()
{
NameValidator.validateQueueName("alpha");
NameValidator.validateQueueName("4lphanum3r1c");
NameValidator.validateQueueName("middle-dash");

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

private void invalidQueueTestHelper(String queueName, String failMessage, String exceptionMessage)
{
try
{
NameValidator.validateQueueName(queueName);
fail(failMessage);
}
catch (IllegalArgumentException e)
{
assertEquals(exceptionMessage, e.getMessage());
}
}

/**
* Get permissions from string
*/
Expand Down
Loading

0 comments on commit 19da1b4

Please sign in to comment.