Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge week 1's work into WindowsAzure/dev #139

Merged
merged 4 commits into from
Jul 27, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions microsoft-azure-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,16 @@
</lifecycleMappingMetadata>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.4.3</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12</version>
</plugin>
</plugins>
</pluginManagement>
</build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ void setContainerMetadata(String container, HashMap<String, String> metadata, Se
* @throws ServiceException
* if an error occurs accessing the storage service.
*/
void createPageBlob(String container, String blob, int length) throws ServiceException;
void createPageBlob(String container, String blob, long length) throws ServiceException;

/**
* Creates a page blob of the specified maximum length, using the specified options.
Expand Down Expand Up @@ -457,7 +457,7 @@ void setContainerMetadata(String container, HashMap<String, String> metadata, Se
* @throws ServiceException
* if an error occurs accessing the storage service.
*/
void createPageBlob(String container, String blob, int length, CreateBlobOptions options) throws ServiceException;
void createPageBlob(String container, String blob, long length, CreateBlobOptions options) throws ServiceException;

/**
* Creates a block blob from a content stream.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
* Copyright 2011 Microsoft Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.microsoft.windowsazure.services.blob.implementation;

Expand Down Expand Up @@ -383,7 +383,7 @@ public ListBlobsResult listBlobs(String container, ListBlobsOptions options) thr
}

@Override
public void createPageBlob(String container, String blob, int length) throws ServiceException {
public void createPageBlob(String container, String blob, long length) throws ServiceException {
try {
service.createPageBlob(container, blob, length);
}
Expand All @@ -396,7 +396,7 @@ public void createPageBlob(String container, String blob, int length) throws Ser
}

@Override
public void createPageBlob(String container, String blob, int length, CreateBlobOptions options)
public void createPageBlob(String container, String blob, long length, CreateBlobOptions options)
throws ServiceException {
try {
service.createPageBlob(container, blob, length, options);
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
public class DeleteBlobOptions extends BlobServiceOptions {
private String snapshot;
private String leaseId;
private boolean deleteSnaphotsOnly;
private Boolean deleteSnaphotsOnly;
private AccessCondition accessCondition;

/**
Expand Down Expand Up @@ -111,9 +111,10 @@ public DeleteBlobOptions setLeaseId(String leaseId) {
*
* @return
* A value of <code>true</code> to delete only the snapshots, or <code>false</code> to delete both snapshots
* and the blob.
* and the blob. When the value <code>null</code> is set, x-ms-delete-snapshots in the header will not be
* set.
*/
public boolean getDeleteSnaphotsOnly() {
public Boolean getDeleteSnaphotsOnly() {
return deleteSnaphotsOnly;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
* Copyright 2011 Microsoft Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.microsoft.windowsazure.services.serviceBus.implementation;

Expand Down Expand Up @@ -39,10 +39,12 @@ public EntryModelProvider(@Context MessageBodyWorkers workers) {
this.workers = workers;
}

@Override
public boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
return EntryModel.class.isAssignableFrom(type);
}

@Override
public EntryModel<?> readFrom(Class<EntryModel<?>> type, Type genericType, Annotation[] annotations,
MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream)
throws IOException, WebApplicationException {
Expand Down Expand Up @@ -71,10 +73,12 @@ public EntryModel<?> readFrom(Class<EntryModel<?>> type, Type genericType, Annot
}
}

@Override
public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
return EntryModel.class.isAssignableFrom(type);
}

@Override
public void writeTo(EntryModel<?> t, Class<?> type, Type genericType, Annotation[] annotations,
MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream)
throws IOException, WebApplicationException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,20 @@
* Copyright 2011 Microsoft Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.microsoft.windowsazure.services.serviceBus.implementation;

import javax.inject.Inject;
import javax.ws.rs.WebApplicationException;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Expand Down Expand Up @@ -213,6 +214,9 @@ public GetQueueResult getQueue(String queuePath) throws ServiceException {
try {
return next.getQueue(queuePath);
}
catch (WebApplicationException e) {
throw processCatch(new ServiceException(e));
}
catch (UniformInterfaceException e) {
throw processCatch(new ServiceException(e));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
* Copyright 2011 Microsoft Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.microsoft.windowsazure.services.serviceBus.implementation;

Expand All @@ -22,6 +22,7 @@

import javax.inject.Inject;
import javax.inject.Named;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.MediaType;

import org.apache.commons.logging.Log;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
* Copyright 2011 Microsoft Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.microsoft.windowsazure.services.blob;

Expand All @@ -30,6 +30,7 @@
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import junit.framework.Assert;
Expand All @@ -48,6 +49,7 @@
import com.microsoft.windowsazure.services.blob.models.CreateBlobSnapshotOptions;
import com.microsoft.windowsazure.services.blob.models.CreateBlobSnapshotResult;
import com.microsoft.windowsazure.services.blob.models.CreateContainerOptions;
import com.microsoft.windowsazure.services.blob.models.DeleteBlobOptions;
import com.microsoft.windowsazure.services.blob.models.GetBlobMetadataResult;
import com.microsoft.windowsazure.services.blob.models.GetBlobOptions;
import com.microsoft.windowsazure.services.blob.models.GetBlobPropertiesOptions;
Expand All @@ -59,6 +61,7 @@
import com.microsoft.windowsazure.services.blob.models.ListBlobRegionsResult;
import com.microsoft.windowsazure.services.blob.models.ListBlobsOptions;
import com.microsoft.windowsazure.services.blob.models.ListBlobsResult;
import com.microsoft.windowsazure.services.blob.models.ListBlobsResult.BlobEntry;
import com.microsoft.windowsazure.services.blob.models.ListContainersOptions;
import com.microsoft.windowsazure.services.blob.models.ListContainersResult;
import com.microsoft.windowsazure.services.blob.models.ListContainersResult.Container;
Expand Down Expand Up @@ -219,6 +222,19 @@ public void createContainerWorks() throws Exception {
// Assert
}

@Test(expected = IllegalArgumentException.class)
public void createNullContainerFail() throws Exception {
// Arrange
Configuration config = createConfiguration();
BlobContract service = BlobService.create(config);

// Act
service.createContainer(null);

// Assert
assertTrue(false);
}

@Test
public void createContainerWithMetadataWorks() throws Exception {
// Arrange
Expand Down Expand Up @@ -270,6 +286,40 @@ public void createContainerWithMetadataWorks() throws Exception {

}

@Test
public void deleteContainerWorks() throws Exception {
// Arrange
Configuration config = createConfiguration();
BlobContract service = BlobService.create(config);
String containerName = "deletecontainerworks";
service.createContainer(
containerName,
new CreateContainerOptions().setPublicAccess("blob").addMetadata("test", "bar")
.addMetadata("blah", "bleah"));

// Act
service.deleteContainer(containerName);
ListContainersResult listContainerResult = service.listContainers();

// Assert
for (Container container : listContainerResult.getContainers()) {
assertTrue(!container.getName().equals(container));
}
}

@Test(expected = IllegalArgumentException.class)
public void deleteNullContainerFail() throws Exception {
// Arrange
Configuration config = createConfiguration();
BlobContract service = BlobService.create(config);

// Act
service.deleteContainer(null);

// Assert
assertTrue(false);
}

@Test
public void setContainerMetadataWorks() throws Exception {
// Arrange
Expand Down Expand Up @@ -885,6 +935,30 @@ public void createBlobBlockWorks() throws Exception {
// Assert
}

@Test
public void createBlobBlockNullContainerWorks() throws Exception {
// Arrange
Configuration config = createConfiguration();
BlobContract service = BlobService.create(config);

// Act
String container = null;
String blob = "createblobblocknullcontainerworks";
String content = new String(new char[512]);
service.createBlockBlob(container, blob, new ByteArrayInputStream(content.getBytes("UTF-8")));
GetBlobPropertiesResult result = service.getBlobProperties(null, blob);
GetBlobResult getBlobResult = service.getBlob(null, blob);

// Assert
assertNotNull(result);
assertNotNull(result.getMetadata());
assertEquals(0, result.getMetadata().size());
BlobProperties props = result.getProperties();
assertNotNull(props);

assertEquals(content, inputStreamToString(getBlobResult.getContentStream(), "UTF-8"));
}

@Test
public void createBlockBlobWorks() throws Exception {
// Arrange
Expand Down Expand Up @@ -1298,6 +1372,30 @@ public void deleteBlobWorks() throws Exception {
// Assert
}

@Test
public void deleteBlobSnapshotSuccess() throws Exception {
// Arrange
Configuration config = createConfiguration();
BlobContract service = BlobService.create(config);
String blobName = "deleteBlobSnapshotSuccess";
// Act
service.createPageBlob(TEST_CONTAINER_FOR_BLOBS, blobName, 512);
CreateBlobSnapshotResult createBlobSnapshotResult = service.createBlobSnapshot(TEST_CONTAINER_FOR_BLOBS,
blobName);
DeleteBlobOptions deleteBlobOptions = new DeleteBlobOptions();
String snapshot = createBlobSnapshotResult.getSnapshot();
deleteBlobOptions.setSnapshot(snapshot);
service.deleteBlob(TEST_CONTAINER_FOR_BLOBS, blobName, deleteBlobOptions);

// Assert
ListBlobsResult listBlobsResult = service.listBlobs(TEST_CONTAINER_FOR_BLOBS);
List<BlobEntry> blobEntry = listBlobsResult.getBlobs();
for (BlobEntry blobEntryItem : blobEntry) {
assertTrue(blobEntryItem.getSnapshot() != snapshot);
}
assertTrue(true);
}

@Test
public void copyBlobWorks() throws Exception {
// Arrange
Expand Down
Loading