mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Merged HEAD (5.2) to 5.2.N (5.2.1)
126536 jkaabimofrad: 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/BRANCHES/DEV/5.2.N/root@126880 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -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);
|
||||
|
@@ -47,6 +47,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;
|
||||
@@ -276,9 +277,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
|
||||
}
|
||||
@@ -353,9 +354,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
|
||||
}
|
||||
@@ -363,9 +364,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
|
||||
}
|
||||
@@ -383,9 +384,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
|
||||
}
|
||||
@@ -405,7 +406,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
|
||||
}
|
||||
@@ -416,7 +417,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
|
||||
}
|
||||
@@ -474,7 +475,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");
|
||||
|
Reference in New Issue
Block a user