Merged FILE-FOLDER-API (5.2.0) to HEAD (5.2)

123214 gjames: RA-812: Changed http 400 to 404


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@126536 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Jamal Kaabi-Mofrad
2016-05-10 11:23:22 +00:00
parent 4b07325b44
commit d9144eb712
3 changed files with 38 additions and 19 deletions

View File

@@ -259,6 +259,25 @@ public class ExecutionTests extends AbstractContextTest
}
@Test
public void testInvalidUrls() throws IOException
{
AbstractResourceWebScript executor = (AbstractResourceWebScript) applicationContext.getBean("executorOfGets");
executor.setLocator(locator);
executor.setResolver(simpleMappingExceptionResolver);
executor.setJsonHelper(jsonHelper);
Map<String, String> templateVars = new HashMap();
templateVars.put("apiScope", "private");
templateVars.put("apiVersion", "1");
templateVars.put("apiName", "alfrescomock");
WebScriptResponse response = mockResponse();
templateVars.put(ResourceLocator.COLLECTION_RESOURCE, "blah:");
executor.execute(api, mockRequest(templateVars, new HashMap<String, List<String>>(1)), response);
//Can't find it so a 404
verify(response, times(1)).setStatus(HttpServletResponse.SC_NOT_FOUND);
}
private WebScriptResponse mockResponse() throws IOException
{
WebScriptResponse res = mock(WebScriptResponse.class);

View File

@@ -22,6 +22,7 @@ import org.alfresco.rest.framework.core.ResourceMetadata;
import org.alfresco.rest.framework.core.ResourceOperation;
import org.alfresco.rest.framework.core.ResourceWithMetadata;
import org.alfresco.rest.framework.core.exceptions.InvalidArgumentException;
import org.alfresco.rest.framework.core.exceptions.NotFoundException;
import org.alfresco.rest.framework.core.exceptions.UnsupportedResourceOperationException;
import org.alfresco.rest.framework.resource.EntityResource;
import org.alfresco.rest.framework.resource.RelationshipResource;
@@ -251,9 +252,9 @@ public class ResourceLocatorTests
{
//Tests by passing invalid propery
collResource = locator.locateResource(api, templateVars, HttpMethod.GET);
fail("Should throw an InvalidArgumentException");
fail("Should throw an NotFoundException");
}
catch (InvalidArgumentException error)
catch (NotFoundException error)
{
//this is correct
}
@@ -328,9 +329,9 @@ public class ResourceLocatorTests
try
{
entityResource = locator.locateEntityResource(Api.valueOf("alfrescomock", "public", "1"),"sheep", HttpMethod.GET);
fail("Should throw an InvalidArgumentException");
fail("Should throw an NotFoundException");
}
catch (InvalidArgumentException error)
catch (NotFoundException error)
{
//this is correct
}
@@ -338,9 +339,9 @@ public class ResourceLocatorTests
try
{
entityResource = locator.locateEntityResource(Api.valueOf("alfrescomock", "public", "999"),"sheep", HttpMethod.GET);
fail("Should throw an InvalidArgumentException");
fail("Should throw an NotFoundException");
}
catch (InvalidArgumentException error)
catch (NotFoundException error)
{
//this is correct
}
@@ -358,9 +359,9 @@ public class ResourceLocatorTests
try
{
aResource = locator.locateEntityResource(api, "sheepnoaction", HttpMethod.GET);
fail("Should throw an InvalidArgumentException");
fail("Should throw an NotFoundException");
}
catch (InvalidArgumentException error)
catch (NotFoundException error)
{
//this is correct
}
@@ -380,7 +381,7 @@ public class ResourceLocatorTests
aResource = locator.locateRelationResource(api, "sheepnoaction","v3isaresource", HttpMethod.GET);
fail("Only available in v3");
}
catch (InvalidArgumentException error)
catch (NotFoundException error)
{
//this is correct
}
@@ -391,7 +392,7 @@ public class ResourceLocatorTests
aResource = locator.locateRelationResource(v2, "sheepnoaction","v3isaresource", HttpMethod.GET);
fail("Only available in v3");
}
catch (InvalidArgumentException error)
catch (NotFoundException error)
{
//this is correct
}
@@ -449,7 +450,7 @@ public class ResourceLocatorTests
assertEquals ("sheepnoaction", name);
}
@Test(expected=org.alfresco.rest.framework.core.exceptions.InvalidArgumentException.class)
@Test(expected=org.alfresco.rest.framework.core.exceptions.NotFoundException.class)
public void testLocateRelationResource()
{
Collection<String> relKeys = Arrays.asList("blacksheep","baaahh");