You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by gr...@apache.org on 2016/01/13 21:18:56 UTC
usergrid git commit: Added test that verify that doing a get on an
asset will now return on 404 and added AmazonException throwing for reading.
Repository: usergrid
Updated Branches:
refs/heads/USERGRID-1047 [created] dae825429
Added test that verify that doing a get on an asset will now return on 404 and added AmazonException throwing for reading.
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/dae82542
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/dae82542
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/dae82542
Branch: refs/heads/USERGRID-1047
Commit: dae825429656871f97bba71b79a764e9c8976121
Parents: c080b02
Author: George Reyes <gr...@apache.org>
Authored: Wed Jan 13 12:18:53 2016 -0800
Committer: George Reyes <gr...@apache.org>
Committed: Wed Jan 13 12:18:53 2016 -0800
----------------------------------------------------------------------
.../rest/applications/ServiceResource.java | 9 ++++++++
.../applications/assets/AwsAssetResourceIT.java | 22 ++++++++++++++++++++
2 files changed, 31 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/usergrid/blob/dae82542/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ServiceResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ServiceResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ServiceResource.java
index 9956ff7..ba8a5a8 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ServiceResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ServiceResource.java
@@ -17,6 +17,8 @@
package org.apache.usergrid.rest.applications;
+import com.amazonaws.AmazonClientException;
+import com.amazonaws.AmazonServiceException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.jaxrs.json.annotation.JSONP;
import org.apache.commons.lang.StringUtils;
@@ -823,6 +825,13 @@ public class ServiceResource extends AbstractContextResource {
logger.error( "Amazon Property needed for this operation not found",apnfe );
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
}
+ catch(AmazonServiceException ase){
+ logger.error(ase.getMessage());
+ return Response.status(ase.getStatusCode()).build();
+ }
+ catch(AmazonClientException ace){
+ logger.error(ace.getMessage());
+ }
catch(RuntimeException re){
logger.error(re.getMessage());
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
http://git-wip-us.apache.org/repos/asf/usergrid/blob/dae82542/stack/rest/src/test/java/org/apache/usergrid/rest/applications/assets/AwsAssetResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/assets/AwsAssetResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/assets/AwsAssetResourceIT.java
index c1e87a6..4561199 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/assets/AwsAssetResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/assets/AwsAssetResourceIT.java
@@ -18,6 +18,8 @@ package org.apache.usergrid.rest.applications.assets;
import com.amazonaws.SDKGlobalConfiguration;
+import com.amazonaws.services.cognitoidentity.model.InternalErrorException;
+
import net.jcip.annotations.NotThreadSafe;
import org.apache.commons.io.IOUtils;
import org.apache.usergrid.rest.applications.assets.aws.NoAWSCredsRule;
@@ -32,6 +34,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.ws.rs.ClientErrorException;
+import javax.ws.rs.NotFoundException;
import javax.ws.rs.core.MediaType;
import java.io.IOException;
import java.io.InputStream;
@@ -71,6 +74,25 @@ public class AwsAssetResourceIT extends AbstractRestIT {
setTestProperties(originalProperties);
}
+
+ @Test
+ public void ensureMissingFileReturns404(){
+ Map<String, String> payload = hashMap( "name", "assettest" );
+ ApiResponse postResponse = pathResource( getOrgAppPath( "missingFile" ) ).post( payload );
+ UUID assetId = postResponse.getEntities().get( 0 ).getUuid();
+ assertNotNull( assetId );
+
+ try {
+ pathResource( getOrgAppPath( "missingFile/assettest" ) ).getAssetAsStream( true );
+ fail("Should fail as there isn't an asset to retrieve.");
+ }catch(NotFoundException nfe){
+ }
+ catch(Exception e){
+ fail("Shouldn't return any other kind of exception");
+ }
+
+ }
+
@Test
public void errorCheckingMissingProperties() throws Exception {
Map<String, Object> errorTestProperties;