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)
126517 jkaabimofrad: Merged FILE-FOLDER-API (5.2.0) to HEAD (5.2) 122952 gjames: RA-211: test for custom caching git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@126861 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package org.alfresco.rest.framework.tests.api.mocks;
|
||||
|
||||
import org.alfresco.rest.framework.BinaryProperties;
|
||||
import org.alfresco.rest.framework.WebApiParam;
|
||||
import org.alfresco.rest.framework.core.exceptions.EntityNotFoundException;
|
||||
import org.alfresco.rest.framework.resource.EntityResource;
|
||||
import org.alfresco.rest.framework.resource.actions.interfaces.BinaryResourceAction;
|
||||
@@ -10,6 +11,8 @@ import org.alfresco.rest.framework.resource.content.BinaryResource;
|
||||
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
|
||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||
import org.alfresco.rest.framework.webscripts.WithResponse;
|
||||
import org.springframework.extensions.webscripts.Cache;
|
||||
import org.springframework.extensions.webscripts.Description;
|
||||
import org.springframework.extensions.webscripts.Status;
|
||||
|
||||
import java.io.InputStream;
|
||||
@@ -26,10 +29,31 @@ public class CowEntityResource implements EntityResourceAction.ReadByIdWithRespo
|
||||
BinaryResourceAction.DeleteWithResponse,
|
||||
BinaryResourceAction.UpdateWithResponse<Goat>
|
||||
{
|
||||
public final static Cache CACHE_COW = new Cache(new Description.RequiredCache()
|
||||
{
|
||||
@Override
|
||||
public boolean getNeverCache()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsPublic()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getMustRevalidate()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
@Override
|
||||
public Goat readById(String id, Parameters parameters, WithResponse withResponse)
|
||||
{
|
||||
withResponse.setCache(CACHE_COW);
|
||||
return new Goat("Goat"+id);
|
||||
}
|
||||
|
||||
|
@@ -3,6 +3,7 @@ package org.alfresco.rest.framework.tests.core;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.anyInt;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.times;
|
||||
@@ -17,15 +18,18 @@ import org.alfresco.rest.framework.resource.actions.ActionExecutor;
|
||||
import org.alfresco.rest.framework.resource.content.ContentInfo;
|
||||
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
|
||||
import org.alfresco.rest.framework.resource.parameters.Params;
|
||||
import org.alfresco.rest.framework.tests.api.mocks.CowEntityResource;
|
||||
import org.alfresco.rest.framework.tests.api.mocks.Goat;
|
||||
import org.alfresco.rest.framework.tests.api.mocks.Grass;
|
||||
import org.alfresco.rest.framework.tests.api.mocks.Sheep;
|
||||
import org.alfresco.rest.framework.tests.api.mocks3.FlockEntityResource;
|
||||
import org.alfresco.rest.framework.webscripts.AbstractResourceWebScript;
|
||||
import org.alfresco.rest.framework.webscripts.ApiWebScript;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.extensions.webscripts.Cache;
|
||||
import org.springframework.extensions.webscripts.Status;
|
||||
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||
import org.springframework.extensions.webscripts.WebScriptResponse;
|
||||
@@ -54,12 +58,16 @@ public class ExecutionTests extends AbstractContextTest
|
||||
Object result = executor.execute(entityResource, Params.valueOf((String)null, null, mock(WebScriptRequest.class)), mock(WebScriptResponse.class), true);
|
||||
assertNotNull(result);
|
||||
|
||||
WebScriptResponse response = mock(WebScriptResponse.class);
|
||||
entityResource = locator.locateEntityResource(api,"cow", HttpMethod.GET);
|
||||
result = executor.execute(entityResource, Params.valueOf((String)null, null, mock(WebScriptRequest.class)), mock(WebScriptResponse.class), true);
|
||||
result = executor.execute(entityResource, Params.valueOf((String)null, null, mock(WebScriptRequest.class)), response, true);
|
||||
assertNotNull(result);
|
||||
verify(response, times(1)).setCache((Cache) ApiWebScript.CACHE_NEVER);
|
||||
|
||||
result = executor.execute(entityResource, Params.valueOf("543", null, mock(WebScriptRequest.class)), mock(WebScriptResponse.class), true);
|
||||
response = mock(WebScriptResponse.class);
|
||||
result = executor.execute(entityResource, Params.valueOf("543", null, mock(WebScriptRequest.class)), response, true);
|
||||
assertNotNull(result);
|
||||
verify(response, times(1)).setCache((Cache) CowEntityResource.CACHE_COW);
|
||||
|
||||
ResourceWithMetadata baa = locator.locateRelationResource(api,"sheep", "baaahh", HttpMethod.GET);
|
||||
result = executor.execute(baa, Params.valueOf("4", null, mock(WebScriptRequest.class)), mock(WebScriptResponse.class), true);
|
||||
|
Reference in New Issue
Block a user