Merged API-STRIKES-BACK (5.2.0) to HEAD (5.2)

126242 gjames: RA-878:All api errors should return the standard error object


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@127571 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Jamal Kaabi-Mofrad
2016-06-02 21:40:03 +00:00
parent 00c3315166
commit f17a4d19cf
24 changed files with 382 additions and 236 deletions

View File

@@ -29,11 +29,14 @@ import static org.junit.Assert.assertTrue;
import org.alfresco.rest.api.model.ModulePackage;
import org.alfresco.rest.api.tests.client.HttpResponse;
import org.alfresco.rest.api.tests.client.PublicApiClient;
import org.alfresco.rest.api.tests.client.RequestContext;
import org.alfresco.rest.api.tests.util.RestApiUtil;
import org.apache.commons.httpclient.HttpStatus;
import org.junit.Before;
import org.junit.Test;
import java.util.List;
import java.util.Map;
/**
* Basic modulepackages api calls
@@ -82,6 +85,26 @@ public class ModulePackagesApiTest extends AbstractBaseApiTest
assertTrue("Simple module must be the correct version","1.0.0-SNAPSHOT".equals(simpleModule.getVersion().toString()));
}
@Test
public void testErrorUrls() throws Exception
{
publicApiClient.setRequestContext(new RequestContext(null));
Map<String, String> params = createParams(null, null);
//Call an endpoint that doesn't exist
HttpResponse response = publicApiClient.get(getScope(), MODULEPACKAGES+"/fred/blogs/king/kong/got/if/wrong", null, null, null, params);
assertNotNull(response);
assertEquals(HttpStatus.SC_NOT_FOUND, response.getStatusCode());
assertEquals("no-cache", response.getHeaders().get("Cache-Control"));
assertEquals("application/json;charset=UTF-8", response.getHeaders().get("Content-Type"));
PublicApiClient.ExpectedErrorResponse errorResponse = RestApiUtil.parseErrorResponse(response.getJsonResponse());
assertNotNull(errorResponse);
assertNotNull(errorResponse.getErrorKey());
assertNotNull(errorResponse.getBriefSummary());
}
@Override
public String getScope()
{