Merged HEAD (5.2) to 5.2.N (5.2.1)

126543 jkaabimofrad: Merged FILE-FOLDER-API (5.2.0) to HEAD (5.2)
      123868 jkaabimofrad: RA-856: Added support for REST APIs “/content” endpoints to optionally set their own cache. (Currently, only the Renditions API is setting its own cache)
          - Removed the http attachment header setting from the AbstractResourceWebScript, as the ContentStreamer already has this feature
          - Reformatted ContentStreamer according to Alfresco code standards 


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@126888 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Ancuta Morarasu
2016-05-11 12:06:18 +00:00
parent 7925bca309
commit ae11fef3de
9 changed files with 378 additions and 189 deletions

View File

@@ -2739,7 +2739,10 @@ public class NodeApiTest extends AbstractBaseApiTest
Map<String, String> responseHeaders = response.getHeaders();
assertNotNull(responseHeaders);
assertEquals("attachment; filename=\"quick-1.txt\"; filename*=UTF-8''quick-1.txt", responseHeaders.get("Content-Disposition"));
assertNotNull(responseHeaders.get("Cache-Control"));
String cacheControl = responseHeaders.get("Cache-Control");
assertNotNull(cacheControl);
assertTrue(cacheControl.contains("must-revalidate"));
assertTrue(cacheControl.contains("max-age=0"));
assertNotNull(responseHeaders.get("Expires"));
String lastModifiedHeader = responseHeaders.get(LAST_MODIFIED_HEADER);
assertNotNull(lastModifiedHeader);

View File

@@ -21,6 +21,7 @@ package org.alfresco.rest.api.tests;
import static org.alfresco.rest.api.tests.util.RestApiUtil.toJsonAsString;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
@@ -489,6 +490,9 @@ public class RenditionsTest extends AbstractBaseApiTest
assertNotNull(response.getResponseAsBytes());
responseHeaders = response.getHeaders();
assertNotNull(responseHeaders);
String cacheControl = responseHeaders.get("Cache-Control");
assertNotNull(cacheControl);
assertTrue(cacheControl.contains("must-revalidate"));
assertNull(responseHeaders.get("Content-Disposition"));
contentType = responseHeaders.get("Content-Type");
assertNotNull(contentType);
@@ -536,6 +540,11 @@ public class RenditionsTest extends AbstractBaseApiTest
assertNotNull(response.getResponseAsBytes());
responseHeaders = response.getHeaders();
assertNotNull(responseHeaders);
// Check the cache settings which have been set in the RenditionsImpl#getContent()
cacheControl = responseHeaders.get("Cache-Control");
assertNotNull(cacheControl);
assertFalse(cacheControl.contains("must-revalidate"));
assertTrue(cacheControl.contains("max-age=31536000"));
contentDisposition = responseHeaders.get("Content-Disposition");
assertNotNull(contentDisposition);
assertTrue(contentDisposition.contains("filename=\"doclib\""));