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

Commit 50ee225

Browse files
committed
Merge pull request #20 from pemari-msft/master
JXSCL 1.2.0
2 parents f88731a + 19da1b4 commit 50ee225

File tree

18 files changed

+475
-11
lines changed

18 files changed

+475
-11
lines changed

ChangeLog.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2014.08.01 Version 1.2.0
2+
* Added the NameValidator class which contains helpers that check to see if resource names are valid.
3+
* Fixed a bug where the RequestUrl of a LogRecord was not correctly HTML4 decoded. Added a dependency on Apache Commons Lang3.
4+
* Made FileRange class and ListFilesAndDirectories method in the CloudFileDirectory class public.
5+
16
2014.07.01 Version 1.1.0
27
* Changed the maven group id and artifact id. The new group id is com.microsoft.azure and the new artifact id is azure-storage.
38
* Added File Service support. The File Service and the associated SDK APIs are in preview.

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ To get the binaries of this library as distributed by Microsoft, ready for use w
2828
<dependency>
2929
<groupId>com.microsoft.azure</groupId>
3030
<artifactId>azure-storage</artifactId>
31-
<version>1.1.0</version>
31+
<version>1.2.0</version>
3232
</dependency>
3333
```
3434

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

3939
git clone git://github.com/Azure/azure-storage-java.git
40+
cd ./azure-storage-java/microsoft-azure-storage
41+
mvn compile
4042

4143
###Option 3: Source Zip
4244

@@ -128,4 +130,4 @@ If you encounter any bugs with the library please file an issue in the [Issues](
128130
* [Azure Developer Center](http://azure.microsoft.com/en-us/develop/java/)
129131
* [Azure Storage Service](http://azure.microsoft.com/en-us/documentation/services/storage/)
130132
* [Azure Storage Team Blog](http://blogs.msdn.com/b/windowsazurestorage/)
131-
* [JavaDocs](http://dl.windowsazure.com/storage/javadoc)
133+
* [JavaDocs](http://dl.windowsazure.com/storage/javadoc)

microsoft-azure-storage-samples/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<dependency>
2626
<groupId>com.microsoft.azure</groupId>
2727
<artifactId>azure-storage</artifactId>
28-
<version>1.1.0</version>
28+
<version>1.2.0</version>
2929
</dependency>
3030
</dependencies>
3131
</project>

microsoft-azure-storage-test/src/com/microsoft/azure/storage/analytics/CloudAnalyticsClientTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ public void testCloudAnalyticsClientListLogsStartEndTime() throws URISyntaxExcep
220220
@Test
221221
public void testCloudAnalyticsClientParseExLogs() throws ParseException, URISyntaxException, StorageException,
222222
IOException {
223-
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\""
223+
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\""
224224
+ '\n'
225225
+ "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\""
226226
+ '\n';
@@ -247,7 +247,7 @@ public void testCloudAnalyticsClientParseExLogs() throws ParseException, URISynt
247247
expectedItemOne.setOwnerAccountName("myaccount");
248248
expectedItemOne.setServiceType("blob");
249249
expectedItemOne.setRequestUrl(new URI(
250-
"https://myaccount.blob.core.windows.net/thumbnails/lake.jpg?timeout=30000"));
250+
"https://myaccount.blob.core.windows.net/thumb&nails/lake.jpg?timeout=30000"));
251251
expectedItemOne.setRequestedObjectKey("/myaccount/thumbnails/lake.jpg");
252252
expectedItemOne.setRequestIdHeader(UUID.fromString("a84aa705-8a85-48c5-b064-b43bd22979c3"));
253253
expectedItemOne.setOperationCount(0);

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

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import org.junit.experimental.categories.Category;
3636

3737
import com.microsoft.azure.storage.Constants;
38+
import com.microsoft.azure.storage.NameValidator;
3839
import com.microsoft.azure.storage.OperationContext;
3940
import com.microsoft.azure.storage.ResultContinuation;
4041
import com.microsoft.azure.storage.ResultSegment;
@@ -66,6 +67,43 @@ public void blobContainerTestMethodSetUp() throws StorageException, URISyntaxExc
6667
public void blobContainerTestMethodTearDown() throws StorageException {
6768
this.container.deleteIfExists();
6869
}
70+
71+
/**
72+
* Test container name validation.
73+
*/
74+
@Test
75+
public void testCloudBlobContainerNameValidation()
76+
{
77+
NameValidator.validateContainerName("alpha");
78+
NameValidator.validateContainerName("4lphanum3r1c");
79+
NameValidator.validateContainerName("middle-dash");
80+
NameValidator.validateContainerName("$root");
81+
NameValidator.validateContainerName("$logs");
82+
83+
invalidContainertTestHelper(null, "Null containers invalid.", "Invalid container name. The name may not be null, empty, or whitespace only.");
84+
invalidContainertTestHelper("$ROOT", "Root container case sensitive.", "Invalid container name. Check MSDN for more information about valid naming.");
85+
invalidContainertTestHelper("double--dash", "Double dashes not allowed.", "Invalid container name. Check MSDN for more information about valid naming.");
86+
invalidContainertTestHelper("-start-dash", "Start dashes not allowed.", "Invalid container name. Check MSDN for more information about valid naming.");
87+
invalidContainertTestHelper("CapsLock", "Lowercase only.", "Invalid container name. Check MSDN for more information about valid naming.");
88+
invalidContainertTestHelper("illegal$char", "Only alphanumeric and hyphen characters.", "Invalid container name. Check MSDN for more information about valid naming.");
89+
invalidContainertTestHelper("illegal!char", "Only alphanumeric and hyphen characters.", "Invalid container name. Check MSDN for more information about valid naming.");
90+
invalidContainertTestHelper("white space", "Only alphanumeric and hyphen characters.", "Invalid container name. Check MSDN for more information about valid naming.");
91+
invalidContainertTestHelper("2c", "Root container case sensitive.", "Invalid container name length. The name must be between 3 and 63 characters long.");
92+
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.");
93+
}
94+
95+
private void invalidContainertTestHelper(String containerName, String failMessage, String exceptionMessage)
96+
{
97+
try
98+
{
99+
NameValidator.validateContainerName(containerName);
100+
fail(failMessage);
101+
}
102+
catch (IllegalArgumentException e)
103+
{
104+
assertEquals(exceptionMessage, e.getMessage());
105+
}
106+
}
69107

70108
/**
71109
* Validate container references

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

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545

4646
import com.microsoft.azure.storage.AccessCondition;
4747
import com.microsoft.azure.storage.Constants;
48+
import com.microsoft.azure.storage.NameValidator;
4849
import com.microsoft.azure.storage.OperationContext;
4950
import com.microsoft.azure.storage.RetryNoRetry;
5051
import com.microsoft.azure.storage.SendingRequestEvent;
@@ -77,6 +78,38 @@ public void blockBlobTestMethodTearDown() throws StorageException {
7778
this.container.deleteIfExists();
7879
}
7980

81+
/**
82+
* Test blob name validation.
83+
*/
84+
@Test
85+
public void testCloudBlobNameValidation()
86+
{
87+
NameValidator.validateBlobName("alpha");
88+
NameValidator.validateBlobName("4lphanum3r1c");
89+
NameValidator.validateBlobName("CAPSLOCK");
90+
NameValidator.validateBlobName("white space");
91+
NameValidator.validateBlobName("ºth3r(h@racter$");
92+
NameValidator.validateBlobName(new String(new char[253]).replace("\0", "a/a"));
93+
94+
invalidBlobTestHelper("", "No empty strings.", "Invalid blob name. The name may not be null, empty, or whitespace only.");
95+
invalidBlobTestHelper(null, "No null strings.", "Invalid blob name. The name may not be null, empty, or whitespace only.");
96+
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.");
97+
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.");
98+
}
99+
100+
private void invalidBlobTestHelper(String blobName, String failMessage, String exceptionMessage)
101+
{
102+
try
103+
{
104+
NameValidator.validateBlobName(blobName);
105+
fail(failMessage);
106+
}
107+
catch (IllegalArgumentException e)
108+
{
109+
assertEquals(exceptionMessage, e.getMessage());
110+
}
111+
}
112+
80113
@Test
81114
public void testBlobUriOnlyConstructors() throws URISyntaxException, StorageException, InvalidKeyException {
82115
URI blobURI = new URI(this.container.getUri().toString() + "/anonblob");

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

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.junit.Test;
2828
import org.junit.experimental.categories.Category;
2929

30+
import com.microsoft.azure.storage.NameValidator;
3031
import com.microsoft.azure.storage.OperationContext;
3132
import com.microsoft.azure.storage.ResultSegment;
3233
import com.microsoft.azure.storage.SendingRequestEvent;
@@ -56,6 +57,42 @@ public void fileTestMethodSetup() throws URISyntaxException, StorageException {
5657
public void fileTestMethodTearDown() throws StorageException {
5758
this.share.deleteIfExists();
5859
}
60+
61+
/**
62+
* Test directory name validation.
63+
*/
64+
@Test
65+
public void testCloudFileDirectoryNameValidation()
66+
{
67+
NameValidator.validateDirectoryName("alpha");
68+
NameValidator.validateDirectoryName("4lphanum3r1c");
69+
NameValidator.validateDirectoryName("middle-dash");
70+
NameValidator.validateDirectoryName("CAPS");
71+
NameValidator.validateDirectoryName("$root");
72+
NameValidator.validateDirectoryName("..");
73+
NameValidator.validateDirectoryName("CLOCK$");
74+
NameValidator.validateDirectoryName("endslash/");
75+
76+
invalidDirectoryTestHelper(null, "No null.", "Invalid directory name. The name may not be null, empty, or whitespace only.");
77+
invalidDirectoryTestHelper("middle/slash", "Slashes only at the end.", "Invalid directory name. Check MSDN for more information about valid naming.");
78+
invalidDirectoryTestHelper("illegal\"char", "Illegal character.", "Invalid directory name. Check MSDN for more information about valid naming.");
79+
invalidDirectoryTestHelper("illegal:char?", "Illegal character.", "Invalid directory name. Check MSDN for more information about valid naming.");
80+
invalidDirectoryTestHelper("", "Between 1 and 255 characters.", "Invalid directory name. The name may not be null, empty, or whitespace only.");
81+
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.");
82+
}
83+
84+
private void invalidDirectoryTestHelper(String directoryName, String failMessage, String exceptionMessage)
85+
{
86+
try
87+
{
88+
NameValidator.validateDirectoryName(directoryName);
89+
fail(failMessage);
90+
}
91+
catch (IllegalArgumentException e)
92+
{
93+
assertEquals(exceptionMessage, e.getMessage());
94+
}
95+
}
5996

6097
private boolean CloudFileDirectorySetup(CloudFileShare share) throws URISyntaxException, StorageException {
6198
try {

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

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.junit.Test;
2626
import org.junit.experimental.categories.Category;
2727

28+
import com.microsoft.azure.storage.NameValidator;
2829
import com.microsoft.azure.storage.OperationContext;
2930
import com.microsoft.azure.storage.SendingRequestEvent;
3031
import com.microsoft.azure.storage.StorageErrorCodeStrings;
@@ -53,6 +54,40 @@ public void fileShareTestMethodSetUp() throws StorageException, URISyntaxExcepti
5354
public void fileShareTestMethodTearDown() throws StorageException {
5455
this.share.deleteIfExists();
5556
}
57+
58+
/**
59+
* Test share name validation.
60+
*/
61+
@Test
62+
public void testCloudShareNameValidation()
63+
{
64+
NameValidator.validateShareName("alpha");
65+
NameValidator.validateShareName("4lphanum3r1c");
66+
NameValidator.validateShareName("middle-dash");
67+
68+
invalidShareTestHelper(null, "Null not allowed.", "Invalid share name. The name may not be null, empty, or whitespace only.");
69+
invalidShareTestHelper("$root", "Alphanumeric or dashes only.", "Invalid share name. Check MSDN for more information about valid naming.");
70+
invalidShareTestHelper("double--dash", "No double dash.", "Invalid share name. Check MSDN for more information about valid naming.");
71+
invalidShareTestHelper("CapsLock", "Lowercase only.", "Invalid share name. Check MSDN for more information about valid naming.");
72+
invalidShareTestHelper("illegal$char", "Alphanumeric or dashes only.", "Invalid share name. Check MSDN for more information about valid naming.");
73+
invalidShareTestHelper("illegal!char", "Alphanumeric or dashes only.", "Invalid share name. Check MSDN for more information about valid naming.");
74+
invalidShareTestHelper("white space", "Alphanumeric or dashes only.", "Invalid share name. Check MSDN for more information about valid naming.");
75+
invalidShareTestHelper("2c", "Between 3 and 63 characters.", "Invalid share name length. The name must be between 3 and 63 characters long.");
76+
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.");
77+
}
78+
79+
private void invalidShareTestHelper(String shareName, String failMessage, String exceptionMessage)
80+
{
81+
try
82+
{
83+
NameValidator.validateShareName(shareName);
84+
fail(failMessage);
85+
}
86+
catch (IllegalArgumentException e)
87+
{
88+
assertEquals(exceptionMessage, e.getMessage());
89+
}
90+
}
5691

5792
/**
5893
* Validate share references

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

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import org.junit.Test;
3737
import org.junit.experimental.categories.Category;
3838

39+
import com.microsoft.azure.storage.NameValidator;
3940
import com.microsoft.azure.storage.OperationContext;
4041
import com.microsoft.azure.storage.RetryNoRetry;
4142
import com.microsoft.azure.storage.SendingRequestEvent;
@@ -65,6 +66,42 @@ public void fileTestMethodTearDown() throws StorageException {
6566
this.share.deleteIfExists();
6667
}
6768

69+
/**
70+
* Test file name validation.
71+
*/
72+
@Test
73+
public void CloudFileNameValidation()
74+
{
75+
NameValidator.validateFileName("alpha");
76+
NameValidator.validateFileName("4lphanum3r1c");
77+
NameValidator.validateFileName("middle-dash");
78+
NameValidator.validateFileName("CAPS");
79+
NameValidator.validateFileName("$root");
80+
81+
invalidFileTestHelper(null, "No null.", "Invalid file name. The name may not be null, empty, or whitespace only.");
82+
invalidFileTestHelper("..", "Reserved.", "Invalid file name. This name is reserved.");
83+
invalidFileTestHelper("Clock$", "Reserved.", "Invalid file name. This name is reserved.");
84+
invalidFileTestHelper("endslash/", "No slashes.", "Invalid file name. Check MSDN for more information about valid naming.");
85+
invalidFileTestHelper("middle/slash", "No slashes.", "Invalid file name. Check MSDN for more information about valid naming.");
86+
invalidFileTestHelper("illegal\"char", "Illegal characters.", "Invalid file name. Check MSDN for more information about valid naming.");
87+
invalidFileTestHelper("illegal:char?", "Illegal characters.", "Invalid file name. Check MSDN for more information about valid naming.");
88+
invalidFileTestHelper("", "Between 1 and 255 characters.", "Invalid file name. The name may not be null, empty, or whitespace only.");
89+
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.");
90+
}
91+
92+
private void invalidFileTestHelper(String fileName, String failMessage, String exceptionMessage)
93+
{
94+
try
95+
{
96+
NameValidator.validateFileName(fileName);
97+
fail(failMessage);
98+
}
99+
catch (IllegalArgumentException e)
100+
{
101+
assertEquals(exceptionMessage, e.getMessage());
102+
}
103+
}
104+
68105
/**
69106
* Test file creation and deletion.
70107
*

microsoft-azure-storage-test/src/com/microsoft/azure/storage/queue/CloudQueueTests.java

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737

3838
import com.microsoft.azure.storage.AuthenticationScheme;
3939
import com.microsoft.azure.storage.LocationMode;
40+
import com.microsoft.azure.storage.NameValidator;
4041
import com.microsoft.azure.storage.OperationContext;
4142
import com.microsoft.azure.storage.RetryNoRetry;
4243
import com.microsoft.azure.storage.SendingRequestEvent;
@@ -70,6 +71,40 @@ public void queueTestMethodTearDown() throws StorageException {
7071
this.queue.deleteIfExists();
7172
}
7273

74+
/**
75+
* Tests queue name validation.
76+
*/
77+
@Test
78+
public void testCloudQueueNameValidation()
79+
{
80+
NameValidator.validateQueueName("alpha");
81+
NameValidator.validateQueueName("4lphanum3r1c");
82+
NameValidator.validateQueueName("middle-dash");
83+
84+
invalidQueueTestHelper(null, "Null not allowed.", "Invalid queue name. The name may not be null, empty, or whitespace only.");
85+
invalidQueueTestHelper("$root", "Alphanumeric or dashes only.", "Invalid queue name. Check MSDN for more information about valid naming.");
86+
invalidQueueTestHelper("double--dash", "No double dash.", "Invalid queue name. Check MSDN for more information about valid naming.");
87+
invalidQueueTestHelper("CapsLock", "Lowercase only.", "Invalid queue name. Check MSDN for more information about valid naming.");
88+
invalidQueueTestHelper("illegal$char", "Alphanumeric or dashes only.", "Invalid queue name. Check MSDN for more information about valid naming.");
89+
invalidQueueTestHelper("illegal!char", "Alphanumeric or dashes only.", "Invalid queue name. Check MSDN for more information about valid naming.");
90+
invalidQueueTestHelper("white space", "Alphanumeric or dashes only.", "Invalid queue name. Check MSDN for more information about valid naming.");
91+
invalidQueueTestHelper("2c", "Between 3 and 63 characters.", "Invalid queue name length. The name must be between 3 and 63 characters long.");
92+
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.");
93+
}
94+
95+
private void invalidQueueTestHelper(String queueName, String failMessage, String exceptionMessage)
96+
{
97+
try
98+
{
99+
NameValidator.validateQueueName(queueName);
100+
fail(failMessage);
101+
}
102+
catch (IllegalArgumentException e)
103+
{
104+
assertEquals(exceptionMessage, e.getMessage());
105+
}
106+
}
107+
73108
/**
74109
* Get permissions from string
75110
*/

0 commit comments

Comments
 (0)