Merge from SEAMIST3

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@10726 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
David Caruana
2008-09-04 10:56:47 +00:00
parent e22df58ebb
commit 86fa1c011f
80 changed files with 17833 additions and 2389 deletions

View File

@@ -25,14 +25,30 @@
package org.alfresco.repo.web.scripts;
import java.io.IOException;
import java.util.HashMap;
import java.io.UnsupportedEncodingException;
import java.util.Map;
import junit.framework.TestCase;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
import org.alfresco.web.scripts.TestWebScriptServer;
import org.springframework.mock.web.MockHttpServletResponse;
import org.alfresco.web.scripts.TestWebScriptServer.Request;
import org.alfresco.web.scripts.TestWebScriptServer.Response;
import org.apache.commons.httpclient.Header;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpMethod;
import org.apache.commons.httpclient.UsernamePasswordCredentials;
import org.apache.commons.httpclient.auth.AuthScope;
import org.apache.commons.httpclient.methods.ByteArrayRequestEntity;
import org.apache.commons.httpclient.methods.DeleteMethod;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.methods.PutMethod;
import org.apache.commons.httpclient.params.HttpClientParams;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* Base unit test class for web scripts.
@@ -41,11 +57,47 @@ import org.springframework.mock.web.MockHttpServletResponse;
*/
public abstract class BaseWebScriptTest extends TestCase
{
/** Standard HTTP method names */
protected static final String METHOD_POST = "post";
protected static final String METHOD_GET = "get";
protected static final String METHOD_PUT = "put";
protected static final String METHOD_DELETE = "delete";
// Logger
private static final Log logger = LogFactory.getLog(BaseWebScriptTest.class);
/** Local / Remote Server access */
private String defaultRunAs = null;
private RemoteServer remoteServer = null;
private HttpClient httpClient = null;
/**
* Set Remote Server context
*
* @param server remote server
*/
public void setRemoteServer(RemoteServer server)
{
remoteServer = server;
}
/**
* Set Local Run As User
*
* @param localRunAs
*/
public void setDefaultRunAs(String localRunAs)
{
this.defaultRunAs = localRunAs;
}
@Override
protected void setUp() throws Exception
{
super.setUp();
if (remoteServer != null)
{
httpClient = new HttpClient();
httpClient.getParams().setBooleanParameter(HttpClientParams.PREEMPTIVE_AUTHENTICATION, true);
httpClient.getState().setCredentials(new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT), new UsernamePasswordCredentials(remoteServer.username, remoteServer.password));
}
}
/** Test web script server */
private static TestWebScriptServer server = null;
@@ -59,160 +111,222 @@ public abstract class BaseWebScriptTest extends TestCase
return BaseWebScriptTest.server;
}
/**
* "GET" the url and check for the expected status code
* Send Request to Test Web Script Server (as admin)
*
* @param url
* @param req
* @param expectedStatus
* @return
* @return response
* @throws IOException
*/
protected MockHttpServletResponse getRequest(String url, int expectedStatus)
protected Response sendRequest(Request req, int expectedStatus)
throws IOException
{
return getRequest(url, expectedStatus, null);
}
/**
* "DELETE" the url and check for the expected status code
*
* @param url
* @param expectedStatus
* @return
* @throws IOException
*/
protected MockHttpServletResponse deleteRequest(String url, int expectedStatus)
throws IOException
{
return sendRequest(METHOD_DELETE, url, expectedStatus, null, null);
return sendRequest(req, expectedStatus, null);
}
/**
* "GET" the url and check for the expected status code
* Send Request
*
* @param url
* @param req
* @param expectedStatus
* @param asUser
* @return
* @return response
* @throws IOException
*/
protected MockHttpServletResponse getRequest(String url, int expectedStatus, String asUser)
protected Response sendRequest(Request req, int expectedStatus, String asUser)
throws IOException
{
return sendRequest(METHOD_GET, url, expectedStatus, null, null, asUser);
}
/**
* "POST" the url and check for the expected status code
*
* @param url
* @param expectedStatus
* @param body
* @param contentType
* @return
* @throws IOException
*/
protected MockHttpServletResponse postRequest(String url, int expectedStatus, String body, String contentType)
throws IOException
{
return postRequest(url, expectedStatus, body.getBytes(), contentType, null);
}
/**
* "POST" the url and check for the expected status code
*
* @param url
* @param expectedStatus
* @param asUser
* @return
* @throws IOException
*/
protected MockHttpServletResponse postRequest(String url, int expectedStatus, String body, String contentType, String asUser)
throws IOException
{
return postRequest(url, expectedStatus, body.getBytes(), contentType, asUser);
}
/**
* "POST" the url and check for the expected status code
*
* @param url
* @param expectedStatus
* @return
* @throws IOException
*/
protected MockHttpServletResponse postRequest(String url, int expectedStatus, byte[] body, String contentType)
throws IOException
{
return postRequest(url, expectedStatus, body, contentType, null);
}
/**
* "POST" the url and check for the expected status code
*
* @param url
* @param expectedStatus
* @param asUser
* @return
* @throws IOException
*/
protected MockHttpServletResponse postRequest(String url, int expectedStatus, byte[] body, String contentType, String asUser)
throws IOException
{
return sendRequest(METHOD_POST, url, expectedStatus, body, contentType, asUser);
}
/**
* Send request to Test Web Script Server
*
* @param url
* @param expectedStatus
* @param body
* @param contentType
* @return
* @throws IOException
*/
protected MockHttpServletResponse putRequest(String url, int expectedStatus, String body, String contentType)
throws IOException
{
return sendRequest(METHOD_PUT, url, expectedStatus, body, contentType);
}
/**
*
* @param method
* @param url
* @param expectedStatus
* @param body
* @param contentType
* @param asUser
* @return
* @throws IOException
*/
private MockHttpServletResponse sendRequest(final String method, final String url, final int expectedStatus, final byte[] body, final String contentType, String asUser)
throws IOException
{
// send request in context of specified user
String runAsUser = (asUser == null) ? AuthenticationUtil.getSystemUserName() : asUser;
MockHttpServletResponse response = AuthenticationUtil.runAs(new RunAsWork<MockHttpServletResponse>()
if (logger.isDebugEnabled())
{
@SuppressWarnings("synthetic-access")
public MockHttpServletResponse doWork() throws Exception
{
return BaseWebScriptTest.getServer().submitRequest(method, url, new HashMap<String, String>(), body, contentType);
}
}, runAsUser);
if (expectedStatus > 0 && expectedStatus != response.getStatus())
{
//if (response.getStatus() == 500)
//{
// System.out.println(response.getContentAsString());
//}
fail("Status code " + response.getStatus() + " returned, but expected " + expectedStatus + " for " + url + " (" + method + ")");
logger.debug("Request");
logger.debug(req.getBody() == null ? null : new String(req.getBody()));
}
return response;
Response res = null;
if (remoteServer == null)
{
res = sendLocalRequest(req, expectedStatus, asUser);
}
else
{
res = sendRemoteRequest(req, expectedStatus);
}
if (logger.isDebugEnabled())
{
logger.debug("Response:");
logger.debug(res.getContentAsString());
}
if (expectedStatus > 0 && expectedStatus != res.getStatus())
{
// if (res.getStatus() == 500)
// {
// System.out.println(res.getContentAsString());
// }
fail("Status code " + res.getStatus() + " returned, but expected " + expectedStatus + " for " + req.getFullUri() + " (" + req.getMethod() + ")");
}
return res;
}
/**
* Send Local Request to Test Web Script Server
*
* @param req
* @param expectedStatus
* @param asUser
* @return response
* @throws IOException
*/
protected Response sendLocalRequest(final Request req, final int expectedStatus, String asUser)
throws IOException
{
asUser = (asUser == null) ? defaultRunAs : asUser;
if (asUser == null)
{
return BaseWebScriptTest.getServer().submitRequest(req.getMethod(), req.getFullUri(), req.getHeaders(), req.getBody(), req.getType());
}
else
{
// send request in context of specified user
return AuthenticationUtil.runAs(new RunAsWork<Response>()
{
@SuppressWarnings("synthetic-access")
public Response doWork() throws Exception
{
return BaseWebScriptTest.getServer().submitRequest(req.getMethod(), req.getFullUri(), req.getHeaders(), req.getBody(), req.getType());
}
}, asUser);
}
}
/**
* Send Remote Request to stand-alone Web Script Server
*
* @param req
* @param expectedStatus
* @param asUser
* @return response
* @throws IOException
*/
protected Response sendRemoteRequest(Request req, int expectedStatus)
throws IOException
{
String uri = req.getFullUri();
if (!uri.startsWith("http"))
{
uri = remoteServer.baseAddress + uri;
}
// construct method
HttpMethod httpMethod = null;
String method = req.getMethod();
if (method.equalsIgnoreCase("GET"))
{
GetMethod get = new GetMethod(req.getFullUri());
httpMethod = get;
}
else if (method.equalsIgnoreCase("POST"))
{
PostMethod post = new PostMethod(req.getFullUri());
post.setRequestEntity(new ByteArrayRequestEntity(req.getBody(), req.getType()));
httpMethod = post;
}
else if (method.equalsIgnoreCase("PUT"))
{
PutMethod put = new PutMethod(req.getFullUri());
put.setRequestEntity(new ByteArrayRequestEntity(req.getBody(), req.getType()));
httpMethod = put;
}
else if (method.equalsIgnoreCase("DELETE"))
{
DeleteMethod del = new DeleteMethod(req.getFullUri());
httpMethod = del;
}
else
{
throw new AlfrescoRuntimeException("Http Method " + method + " not supported");
}
if (req.getHeaders() != null)
{
for (Map.Entry<String, String> header : req.getHeaders().entrySet())
{
httpMethod.setRequestHeader(header.getKey(), header.getValue());
}
}
// execute method
httpClient.executeMethod(httpMethod);
return new HttpMethodResponse(httpMethod);
}
/**
* Remote Context
*/
public static class RemoteServer
{
public String baseAddress;
public String username;
public String password;
}
/**
* HttpMethod wrapped as Web Script Test Response
*/
public static class HttpMethodResponse
implements Response
{
private HttpMethod method;
public HttpMethodResponse(HttpMethod method)
{
this.method = method;
}
public byte[] getContentAsByteArray()
{
try
{
return method.getResponseBody();
}
catch (IOException e)
{
return null;
}
}
public String getContentAsString() throws UnsupportedEncodingException
{
try
{
return method.getResponseBodyAsString();
}
catch (IOException e)
{
return null;
}
}
public String getContentType()
{
return getHeader("Content-Type");
}
public String getHeader(String name)
{
Header header = method.getResponseHeader(name);
return (header != null) ? header.getValue() : null;
}
public int getStatus()
{
return method.getStatusCode();
}
}
}

View File

@@ -30,11 +30,14 @@ import org.alfresco.repo.web.scripts.BaseWebScriptTest;
import org.alfresco.service.cmr.security.AuthenticationService;
import org.alfresco.service.cmr.security.PersonService;
import org.alfresco.util.PropertyMap;
import org.alfresco.web.scripts.TestWebScriptServer.DeleteRequest;
import org.alfresco.web.scripts.TestWebScriptServer.GetRequest;
import org.alfresco.web.scripts.TestWebScriptServer.PostRequest;
import org.alfresco.web.scripts.TestWebScriptServer.Response;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.mock.web.MockHttpServletResponse;
/**
* Unit test the Activity Service's User Feed Control Web Script API
@@ -116,7 +119,7 @@ public class FeedControlTest extends BaseWebScriptTest
feedControl.put("appToolId", appToolId);
int expectedStatus = 200;
MockHttpServletResponse response = postRequest(URL_CONTROL, expectedStatus, feedControl.toString(), "application/json");
Response response = sendRequest(new PostRequest(URL_CONTROL, feedControl.toString(), "application/json"), expectedStatus);
if (logger.isDebugEnabled())
{
@@ -128,7 +131,7 @@ public class FeedControlTest extends BaseWebScriptTest
{
// Get (retrieve) feed controls
int expectedStatus = 200;
MockHttpServletResponse response = getRequest(URL_CONTROLS, expectedStatus);
Response response = sendRequest(new GetRequest(URL_CONTROLS), expectedStatus);
JSONArray result = new JSONArray(response.getContentAsString());
if (logger.isDebugEnabled())
@@ -151,7 +154,7 @@ public class FeedControlTest extends BaseWebScriptTest
{
// Unset (delete) feed control
int expectedStatus = 200;
MockHttpServletResponse response = deleteRequest(URL_CONTROL + "?s=" + TEST_SITE_ID + "&a=" + TEST_APP_TOOL_ID, expectedStatus);
Response response = sendRequest(new DeleteRequest(URL_CONTROL + "?s=" + TEST_SITE_ID + "&a=" + TEST_APP_TOOL_ID), expectedStatus);
if (logger.isDebugEnabled())
{

View File

@@ -37,11 +37,15 @@ import org.alfresco.repo.web.scripts.BaseWebScriptTest;
import org.alfresco.service.cmr.security.AuthenticationService;
import org.alfresco.service.cmr.security.PersonService;
import org.alfresco.util.PropertyMap;
import org.alfresco.web.scripts.TestWebScriptServer.DeleteRequest;
import org.alfresco.web.scripts.TestWebScriptServer.GetRequest;
import org.alfresco.web.scripts.TestWebScriptServer.PostRequest;
import org.alfresco.web.scripts.TestWebScriptServer.PutRequest;
import org.alfresco.web.scripts.TestWebScriptServer.Response;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.mock.web.MockHttpServletResponse;
/**
* Unit Test to test Blog Web Script API
@@ -178,7 +182,7 @@ public class BlogServiceTest extends BaseWebScriptTest
throws Exception
{
JSONObject post = getRequestObject(title, content, tags, isDraft);
MockHttpServletResponse response = postRequest(URL_BLOG_POSTS, expectedStatus, post.toString(), "application/json");
Response response = sendRequest(new PostRequest(URL_BLOG_POSTS, post.toString(), "application/json"), expectedStatus);
if (expectedStatus != 200)
{
@@ -203,7 +207,7 @@ public class BlogServiceTest extends BaseWebScriptTest
throws Exception
{
JSONObject post = getRequestObject(title, content, tags, isDraft);
MockHttpServletResponse response = putRequest(URL_BLOG_POST + name, expectedStatus, post.toString(), "application/json");
Response response = sendRequest(new PutRequest(URL_BLOG_POST + name, post.toString(), "application/json"), expectedStatus);
if (expectedStatus != 200)
{
@@ -217,7 +221,7 @@ public class BlogServiceTest extends BaseWebScriptTest
private JSONObject getPost(String name, int expectedStatus)
throws Exception
{
MockHttpServletResponse response = getRequest(URL_BLOG_POST + name, expectedStatus);
Response response = sendRequest(new GetRequest(URL_BLOG_POST + name), expectedStatus);
if (expectedStatus == 200)
{
JSONObject result = new JSONObject(response.getContentAsString());
@@ -245,7 +249,7 @@ public class BlogServiceTest extends BaseWebScriptTest
JSONObject comment = new JSONObject();
comment.put("title", title);
comment.put("content", content);
MockHttpServletResponse response = postRequest(getCommentsUrl(nodeRef), expectedStatus, comment.toString(), "application/json");
Response response = sendRequest(new PostRequest(getCommentsUrl(nodeRef), comment.toString(), "application/json"), expectedStatus);
if (expectedStatus != 200)
{
@@ -263,7 +267,7 @@ public class BlogServiceTest extends BaseWebScriptTest
JSONObject comment = new JSONObject();
comment.put("title", title);
comment.put("content", content);
MockHttpServletResponse response = putRequest(getCommentUrl(nodeRef), expectedStatus, comment.toString(), "application/json");
Response response = sendRequest(new PutRequest(getCommentUrl(nodeRef), comment.toString(), "application/json"), expectedStatus);
if (expectedStatus != 200)
{
@@ -385,7 +389,7 @@ public class BlogServiceTest extends BaseWebScriptTest
public void testGetAll() throws Exception
{
String url = URL_BLOG_POSTS;
MockHttpServletResponse response = getRequest(url, 200);
Response response = sendRequest(new GetRequest(url), 200);
JSONObject result = new JSONObject(response.getContentAsString());
// we should have posts.size + drafts.size together
@@ -395,7 +399,7 @@ public class BlogServiceTest extends BaseWebScriptTest
public void testGetNew() throws Exception
{
String url = URL_BLOG_POSTS + "/new";
MockHttpServletResponse response = getRequest(url, 200);
Response response = sendRequest(new GetRequest(url), 200);
JSONObject result = new JSONObject(response.getContentAsString());
// we should have posts.size
@@ -405,7 +409,7 @@ public class BlogServiceTest extends BaseWebScriptTest
public void _testGetDrafts() throws Exception
{
String url = URL_BLOG_POSTS + "/mydrafts";
MockHttpServletResponse response = getRequest(URL_BLOG_POSTS, 200);
Response response = sendRequest(new GetRequest(URL_BLOG_POSTS), 200);
JSONObject result = new JSONObject(response.getContentAsString());
// we should have drafts.size resultss
@@ -413,7 +417,7 @@ public class BlogServiceTest extends BaseWebScriptTest
// the second user should have zero
this.authenticationComponent.setCurrentUser(USER_TWO);
response = getRequest(url, 200);
response = sendRequest(new GetRequest(url), 200);
result = new JSONObject(response.getContentAsString());
assertEquals(0, result.getInt("total"));
this.authenticationComponent.setCurrentUser(USER_ONE);
@@ -423,7 +427,7 @@ public class BlogServiceTest extends BaseWebScriptTest
public void _testMyPublished() throws Exception
{
String url = URL_BLOG_POSTS + "/mypublished";
MockHttpServletResponse response = getRequest(url, 200);
Response response = sendRequest(new GetRequest(url), 200);
JSONObject result = new JSONObject(response.getContentAsString());
// we should have posts.size results
@@ -431,7 +435,7 @@ public class BlogServiceTest extends BaseWebScriptTest
// the second user should have zero
this.authenticationComponent.setCurrentUser(USER_TWO);
response = getRequest(url, 200);
response = sendRequest(new GetRequest(url), 200);
result = new JSONObject(response.getContentAsString());
assertEquals(0, result.getInt("total"));
this.authenticationComponent.setCurrentUser(USER_ONE);
@@ -447,21 +451,21 @@ public class BlogServiceTest extends BaseWebScriptTest
JSONObject commentTwo = createComment(nodeRef, "comment", "content", 200);
// fetch the comments
MockHttpServletResponse response = getRequest(getCommentsUrl(nodeRef), 200);
Response response = sendRequest(new GetRequest(getCommentsUrl(nodeRef)), 200);
JSONObject result = new JSONObject(response.getContentAsString());
assertEquals(2, result.getInt("total"));
// add another one
JSONObject commentThree = createComment(nodeRef, "comment", "content", 200);
response = getRequest(getCommentsUrl(nodeRef), 200);
response = sendRequest(new GetRequest(getCommentsUrl(nodeRef)), 200);
result = new JSONObject(response.getContentAsString());
assertEquals(3, result.getInt("total"));
// delete the last comment
response = deleteRequest(getCommentUrl(commentThree.getString("nodeRef")), 200);
response = sendRequest(new DeleteRequest(getCommentUrl(commentThree.getString("nodeRef"))), 200);
response = getRequest(getCommentsUrl(nodeRef), 200);
response = sendRequest(new GetRequest(getCommentsUrl(nodeRef)), 200);
result = new JSONObject(response.getContentAsString());
assertEquals(2, result.getInt("total"));

View File

@@ -36,10 +36,14 @@ import org.alfresco.repo.web.scripts.BaseWebScriptTest;
import org.alfresco.service.cmr.security.AuthenticationService;
import org.alfresco.service.cmr.security.PersonService;
import org.alfresco.util.PropertyMap;
import org.alfresco.web.scripts.TestWebScriptServer.DeleteRequest;
import org.alfresco.web.scripts.TestWebScriptServer.GetRequest;
import org.alfresco.web.scripts.TestWebScriptServer.PostRequest;
import org.alfresco.web.scripts.TestWebScriptServer.PutRequest;
import org.alfresco.web.scripts.TestWebScriptServer.Response;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.json.JSONObject;
import org.springframework.mock.web.MockHttpServletResponse;
/**
* Unit Test to test Discussions Web Script API
@@ -151,7 +155,7 @@ public class DiscussionServiceTest extends BaseWebScriptTest
JSONObject post = new JSONObject();
post.put("title", title);
post.put("content", content);
MockHttpServletResponse response = postRequest(URL_FORUM_POSTS, expectedStatus, post.toString(), "application/json");
Response response = sendRequest(new PostRequest(URL_FORUM_POSTS, post.toString(), "application/json"), expectedStatus);
if (expectedStatus != 200)
{
@@ -171,7 +175,7 @@ public class DiscussionServiceTest extends BaseWebScriptTest
JSONObject post = new JSONObject();
post.put("title", title);
post.put("content", content);
MockHttpServletResponse response = putRequest(getPostUrl(nodeRef), expectedStatus, post.toString(), "application/json");
Response response = sendRequest(new PutRequest(URL_FORUM_POST + name, post.toString(), "application/json"), expectedStatus);
if (expectedStatus != 200)
{
@@ -185,7 +189,7 @@ public class DiscussionServiceTest extends BaseWebScriptTest
private JSONObject getPost(String name, int expectedStatus)
throws Exception
{
MockHttpServletResponse response = getRequest(URL_FORUM_POST + name, expectedStatus);
Response response = sendRequest(new GetRequest(URL_FORUM_POST + name), expectedStatus);
if (expectedStatus == 200)
{
JSONObject result = new JSONObject(response.getContentAsString());
@@ -213,7 +217,7 @@ public class DiscussionServiceTest extends BaseWebScriptTest
JSONObject reply = new JSONObject();
reply.put("title", title);
reply.put("content", content);
MockHttpServletResponse response = postRequest(getRepliesUrl(nodeRef), expectedStatus, reply.toString(), "application/json");
Response response = sendRequest(new PostRequest(getRepliesUrl(nodeRef), reply.toString(), "application/json"), expectedStatus);
if (expectedStatus != 200)
{
@@ -224,6 +228,23 @@ public class DiscussionServiceTest extends BaseWebScriptTest
return result.getJSONObject("item");
}
private JSONObject updateComment(String nodeRef, String title, String content, int expectedStatus)
throws Exception
{
JSONObject comment = new JSONObject();
comment.put("title", title);
comment.put("content", content);
Response response = sendRequest(new PutRequest(getPostUrl(nodeRef), comment.toString(), "application/json"), expectedStatus);
if (expectedStatus != 200)
{
return null;
}
//logger.debug("Comment updated: " + response.getContentAsString());
JSONObject result = new JSONObject(response.getContentAsString());
return result.getJSONObject("item");
}
// Tests
@@ -268,7 +289,7 @@ public class DiscussionServiceTest extends BaseWebScriptTest
public void testGetAll() throws Exception
{
String url = URL_FORUM_POSTS;
MockHttpServletResponse response = getRequest(url, 200);
Response response = sendRequest(new GetRequest(url), 200);
JSONObject result = new JSONObject(response.getContentAsString());
// we should have posts.size + drafts.size together
@@ -282,10 +303,10 @@ public class DiscussionServiceTest extends BaseWebScriptTest
String name = item.getString("name");
// delete the post
MockHttpServletResponse response = deleteRequest(URL_FORUM_POST + name, 200);
Response response = sendRequest(new DeleteRequest(URL_FORUM_POST + name), 200);
// try to fetch it again
getRequest(URL_FORUM_POST + name, 404);
sendRequest(new GetRequest(URL_FORUM_POST + name), 404);
}
public void testAddReply() throws Exception
@@ -307,7 +328,7 @@ public class DiscussionServiceTest extends BaseWebScriptTest
assertEquals("test2", reply2.getString("content"));
// fetch all replies for the post
MockHttpServletResponse response = getRequest(getRepliesUrl(postNodeRef), 200);
Response response = sendRequest(new GetRequest(getRepliesUrl(postNodeRef)), 200);
logger.debug(response.getContentAsString());
JSONObject result = new JSONObject(response.getContentAsString());
// check the number of replies

View File

@@ -50,9 +50,13 @@ import org.alfresco.service.cmr.workflow.WorkflowService;
import org.alfresco.util.PropertyMap;
import org.alfresco.util.URLEncoder;
import org.alfresco.web.scripts.Status;
<<<<<<< .working
import org.apache.commons.lang.RandomStringUtils;
=======
import org.alfresco.web.scripts.TestWebScriptServer.GetRequest;
import org.alfresco.web.scripts.TestWebScriptServer.Response;
>>>>>>> .merge-right.r9819
import org.json.JSONObject;
import org.springframework.mock.web.MockHttpServletResponse;
/**
* Unit Test to test Invite Web Script API
@@ -279,11 +283,18 @@ public class InviteServiceTest extends BaseWebScriptTest
private void deletePersonByUserName(String userName)
{
<<<<<<< .working
// delete authentication if authentication exists for given user name
if (this.authenticationService.authenticationExists(userName))
{
this.authenticationService.deleteAuthentication(userName);
}
=======
// Inviter sends invitation to Invitee to join a Site
String startInviteUrl = URL_INVITE_SERVICE + "/" + INVITE_ACTION_START + "?inviteeEmail=" + inviteeEmail
+ "&siteShortName=" + siteShortName;
Response response = sendRequest(new GetRequest(startInviteUrl), expectedStatus);
>>>>>>> .merge-right.r9819
// delete user account
if (this.mutableAuthenticationDao.userExists(userName))
@@ -480,10 +491,15 @@ public class InviteServiceTest extends BaseWebScriptTest
String inviteId = result.getString("inviteId");
// Inviter cancels pending invitation
<<<<<<< .working
String cancelInviteUrl = URL_INVITE_SERVICE + "/"
+ INVITE_ACTION_CANCEL + "?inviteId=" + inviteId;
MockHttpServletResponse response = getRequest(cancelInviteUrl,
Status.STATUS_OK);
=======
String cancelInviteUrl = URL_INVITE_SERVICE + "/" + INVITE_ACTION_CANCEL + "?workflowId=" + workflowId;
Response response = sendRequest(new GetRequest(cancelInviteUrl), Status.STATUS_OK);
>>>>>>> .merge-right.r9819
}
public void testAcceptInvite() throws Exception
@@ -501,6 +517,7 @@ public class InviteServiceTest extends BaseWebScriptTest
String inviteeUserName = result.getString("inviteeUserName");
// Invitee accepts invitation to a Site from Inviter
<<<<<<< .working
String acceptInviteUrl = URL_INVITE_SERVICE + "/" + inviteId + "/" + inviteTicket + "/accept";
MockHttpServletResponse response = putRequest(acceptInviteUrl,
Status.STATUS_OK, null, null);
@@ -518,6 +535,11 @@ public class InviteServiceTest extends BaseWebScriptTest
// there should no longer be any invites identified by invite ID pending
assertEquals(getInvitesResult.getJSONArray("invites").length(), 0);
=======
String acceptInviteUrl = URL_INVITERSP_SERVICE + "/" + INVITE_RSP_ACCEPT + "?workflowId=" + workflowId
+ "&inviteeUserName=" + inviteeUserName + "&siteShortName=" + SITE_SHORT_NAME_INVITE;
Response response = sendRequest(new GetRequest(acceptInviteUrl), Status.STATUS_OK);
>>>>>>> .merge-right.r9819
}
public void testRejectInvite() throws Exception
@@ -570,11 +592,21 @@ public class InviteServiceTest extends BaseWebScriptTest
JSONObject getInvitesResult = getInvitesByInviteId(inviteId,
Status.STATUS_OK);
<<<<<<< .working
assertEquals(getInvitesResult.getJSONArray("invites").length(), 1);
JSONObject inviteJSONObj = getInvitesResult.getJSONArray("invites").getJSONObject(0);
assertEquals(inviteId, inviteJSONObj.get("inviteId"));
=======
// get hold of invitee user name that was generated as part of starting the invite
String inviteeUserName = result.getString("inviteeUserName");
// Invitee rejects invitation to a Site from Inviter
String rejectInviteUrl = URL_INVITERSP_SERVICE + "/" + INVITE_RSP_REJECT + "?workflowId=" + workflowId
+ "&inviteeUserName=" + inviteeUserName + "&siteShortName=" + SITE_SHORT_NAME_INVITE;
Response response = sendRequest(new GetRequest(rejectInviteUrl), Status.STATUS_OK);
>>>>>>> .merge-right.r9819
}
public void testGetInvitesByInviterUserName() throws Exception

View File

@@ -33,10 +33,11 @@ import org.alfresco.repo.web.scripts.BaseWebScriptTest;
import org.alfresco.service.cmr.security.AuthenticationService;
import org.alfresco.service.cmr.security.PersonService;
import org.alfresco.util.PropertyMap;
import org.alfresco.web.scripts.Status;
import org.alfresco.web.scripts.TestWebScriptServer.GetRequest;
import org.alfresco.web.scripts.TestWebScriptServer.PostRequest;
import org.alfresco.web.scripts.TestWebScriptServer.Response;
import org.apache.commons.lang.RandomStringUtils;
import org.json.JSONObject;
import org.springframework.mock.web.MockHttpServletResponse;
/**
* Unit test to test person Web Script API
@@ -168,7 +169,8 @@ public class PersonServiceTest extends BaseWebScriptTest
person.put("jobtitle", jobTitle);
person.put("email", email);
MockHttpServletResponse response = postRequest(URL_PEOPLE, expectedStatus, person.toString(), "application/json");
Response response = sendRequest(new PostRequest(URL_PEOPLE, person.toString(), "application/json"), expectedStatus);
this.createdPeople.add(userName);
if ((userName != null) && (userName.length() != 0))
{
@@ -202,22 +204,20 @@ public class PersonServiceTest extends BaseWebScriptTest
{
// Test basic GET people with no filters ==
MockHttpServletResponse response = getRequest(URL_PEOPLE, Status.STATUS_OK);
Response response = sendRequest(new GetRequest(URL_PEOPLE), 200);
System.out.println(response.getContentAsString());
}
public void testGetPerson() throws Exception
{
// Get a person that doesn't exist
MockHttpServletResponse response = getRequest(URL_PEOPLE + "/" + "nonExistantUser", 404);
Response response = sendRequest(new GetRequest(URL_PEOPLE + "/" + "nonExistantUser"), 404);
// Create a person and get him/her
String userName = RandomStringUtils.randomNumeric(6);
JSONObject result = createPerson(userName, "myTitle", "myFirstName", "myLastName", "myOrganisation",
"myJobTitle", "myEmailAddress", "myBio", "images/avatar.jpg", Status.STATUS_OK);
response = getRequest(URL_PEOPLE + "/" + userName, Status.STATUS_OK);
"myJobTitle", "myEmailAddress", "myBio", "images/avatar.jpg", 200);
response = sendRequest(new GetRequest(URL_PEOPLE + "/" + userName), 200);
}
public void testUpdatePerson() throws Exception

View File

@@ -24,21 +24,17 @@
*/
package org.alfresco.repo.web.scripts.preference;
import java.util.ArrayList;
import java.util.List;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.security.authentication.AuthenticationComponent;
import org.alfresco.repo.site.SiteModel;
import org.alfresco.repo.web.scripts.BaseWebScriptTest;
import org.alfresco.service.cmr.security.AuthenticationService;
import org.alfresco.service.cmr.security.PersonService;
import org.alfresco.util.GUID;
import org.alfresco.util.PropertyMap;
import org.json.JSONArray;
import org.alfresco.web.scripts.TestWebScriptServer.GetRequest;
import org.alfresco.web.scripts.TestWebScriptServer.PostRequest;
import org.alfresco.web.scripts.TestWebScriptServer.Response;
import org.json.JSONException;
import org.json.JSONObject;
import org.springframework.mock.web.MockHttpServletResponse;
/**
* Unit test to test preference Web Script API
@@ -102,7 +98,7 @@ public class PreferenceServiceTest extends BaseWebScriptTest
{
// Get the preferences before they have been set
MockHttpServletResponse resp = getRequest(URL, 200);
Response resp = sendRequest(new GetRequest(URL), 200);
JSONObject jsonResult = new JSONObject(resp.getContentAsString());
assertNotNull(jsonResult);
@@ -113,12 +109,12 @@ public class PreferenceServiceTest extends BaseWebScriptTest
JSONObject jsonObject = getPreferenceObj();
jsonObject.put("comp1", getPreferenceObj());
resp = postRequest(URL, 200, jsonObject.toString(), "application/json");
assertEquals(0, resp.getContentLength());
resp = sendRequest(new PostRequest(URL, jsonObject.toString(), "application/json"), 200);
assertEquals(0, resp.getContentAsByteArray().length);
// Get the preferences
resp = getRequest(URL, 200);
resp = sendRequest(new GetRequest(URL), 200);
jsonResult = new JSONObject(resp.getContentAsString());
assertNotNull(jsonResult);
assertTrue(jsonResult.keys().hasNext());
@@ -131,12 +127,12 @@ public class PreferenceServiceTest extends BaseWebScriptTest
jsonObject.put("stringValue", "updated");
jsonObject.put("comp2", getPreferenceObj());
resp = postRequest(URL, 200, jsonObject.toString(), "application/json");
assertEquals(0, resp.getContentLength());
resp = sendRequest(new PostRequest(URL, jsonObject.toString(), "application/json"), 200);
assertEquals(0, resp.getContentAsByteArray().length);
// Get the preferences
resp = getRequest(URL, 200);
resp = sendRequest(new GetRequest(URL), 200);
jsonResult = new JSONObject(resp.getContentAsString());
assertNotNull(jsonResult);
assertTrue(jsonResult.keys().hasNext());
@@ -149,7 +145,7 @@ public class PreferenceServiceTest extends BaseWebScriptTest
// Filter the preferences retrieved
resp = getRequest(URL + "?pf=comp2", 200);
resp = sendRequest(new GetRequest(URL + "?pf=comp2"), 200);
jsonResult = new JSONObject(resp.getContentAsString());
assertNotNull(jsonResult);
assertTrue(jsonResult.keys().hasNext());
@@ -163,10 +159,10 @@ public class PreferenceServiceTest extends BaseWebScriptTest
// Clear all the preferences
// Test trying to update another user's permissions
postRequest("/api/people/" + USER_BAD + "/preferences", 500, jsonObject.toString(), "application/json");
sendRequest(new PostRequest("/api/people/" + USER_BAD + "/preferences", jsonObject.toString(), "application/json"), 500);
// Test error conditions
getRequest("/api/people/noExistUser/preferences", 404);
sendRequest(new GetRequest("/api/people/noExistUser/preferences"), 404);
}
private JSONObject getPreferenceObj()

View File

@@ -35,9 +35,13 @@ import org.alfresco.service.cmr.security.AuthenticationService;
import org.alfresco.service.cmr.security.PersonService;
import org.alfresco.util.GUID;
import org.alfresco.util.PropertyMap;
import org.alfresco.web.scripts.TestWebScriptServer.DeleteRequest;
import org.alfresco.web.scripts.TestWebScriptServer.GetRequest;
import org.alfresco.web.scripts.TestWebScriptServer.PostRequest;
import org.alfresco.web.scripts.TestWebScriptServer.PutRequest;
import org.alfresco.web.scripts.TestWebScriptServer.Response;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.mock.web.MockHttpServletResponse;
/**
* Unit test to test site Web Script API
@@ -103,7 +107,7 @@ public class SiteServiceTest extends BaseWebScriptTest
// Tidy-up any site's create during the execution of the test
for (String shortName : this.createdSites)
{
deleteRequest(URL_SITES + "/" + shortName, 0);
sendRequest(new DeleteRequest(URL_SITES + "/" + shortName), 0);
}
// Clear the list
@@ -137,14 +141,14 @@ public class SiteServiceTest extends BaseWebScriptTest
site.put("title", title);
site.put("description", description);
site.put("isPublic", isPublic);
MockHttpServletResponse response = postRequest(URL_SITES, expectedStatus, site.toString(), "application/json");
Response response = sendRequest(new PostRequest(URL_SITES, site.toString(), "application/json"), expectedStatus);
this.createdSites.add(shortName);
return new JSONObject(response.getContentAsString());
}
public void testGetSites() throws Exception
{
MockHttpServletResponse response = getRequest(URL_SITES, 200);
Response response = sendRequest(new GetRequest(URL_SITES), 200);
JSONArray result = new JSONArray(response.getContentAsString());
assertNotNull(result);
assertEquals(0, result.length());
@@ -174,12 +178,12 @@ public class SiteServiceTest extends BaseWebScriptTest
public void testGetSite() throws Exception
{
// Get a site that doesn't exist
MockHttpServletResponse response = getRequest(URL_SITES + "/" + "somerandomshortname", 404);
Response response = sendRequest(new GetRequest(URL_SITES + "/" + "somerandomshortname"), 404);
// Create a site and get it
String shortName = GUID.generate();
JSONObject result = createSite("myPreset", shortName, "myTitle", "myDescription", true, 200);
response = getRequest(URL_SITES + "/" + shortName, 200);
response = sendRequest(new GetRequest(URL_SITES + "/" + shortName), 200);
}
@@ -193,14 +197,14 @@ public class SiteServiceTest extends BaseWebScriptTest
result.put("title", "abs123abc");
result.put("description", "123abc123");
result.put("isPublic", false);
MockHttpServletResponse response = putRequest(URL_SITES + "/" + shortName, 200, result.toString(), "application/json");
Response response = sendRequest(new PutRequest(URL_SITES + "/" + shortName, result.toString(), "application/json"), 200);
result = new JSONObject(response.getContentAsString());
assertEquals("abs123abc", result.get("title"));
assertEquals("123abc123", result.get("description"));
assertFalse(result.getBoolean("isPublic"));
// Try and get the site and double check it's changed
response = getRequest(URL_SITES + "/" + shortName, 200);
response = sendRequest(new GetRequest(URL_SITES + "/" + shortName), 200);
result = new JSONObject(response.getContentAsString());
assertEquals("abs123abc", result.get("title"));
assertEquals("123abc123", result.get("description"));
@@ -210,20 +214,20 @@ public class SiteServiceTest extends BaseWebScriptTest
public void testDeleteSite() throws Exception
{
// Delete non-existant site
MockHttpServletResponse response = deleteRequest(URL_SITES + "/" + "somerandomshortname", 404);
Response response = sendRequest(new DeleteRequest(URL_SITES + "/" + "somerandomshortname"), 404);
// Create a site
String shortName = GUID.generate();
JSONObject result = createSite("myPreset", shortName, "myTitle", "myDescription", true, 200);
// Get the site
response = getRequest(URL_SITES + "/" + shortName, 200);
response = sendRequest(new GetRequest(URL_SITES + "/" + shortName), 200);
// Delete the site
response = deleteRequest(URL_SITES + "/" + shortName, 200);
response = sendRequest(new DeleteRequest(URL_SITES + "/" + shortName), 200);
// Get the site
response = getRequest(URL_SITES + "/" + shortName, 404);
response = sendRequest(new GetRequest(URL_SITES + "/" + shortName), 404);
}
public void testGetMemeberships() throws Exception
@@ -233,7 +237,7 @@ public class SiteServiceTest extends BaseWebScriptTest
createSite("myPreset", shortName, "myTitle", "myDescription", true, 200);
// Check the memberships
MockHttpServletResponse response = getRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS, 200);
Response response = sendRequest(new GetRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS), 200);
JSONArray result = new JSONArray(response.getContentAsString());
assertNotNull(result);
assertEquals(1, result.length());
@@ -256,7 +260,7 @@ public class SiteServiceTest extends BaseWebScriptTest
membership.put("person", person);
// Post the memebership
MockHttpServletResponse response = postRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS, 200, membership.toString(), "application/json");
Response response = sendRequest(new PostRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS, membership.toString(), "application/json"), 200);
JSONObject result = new JSONObject(response.getContentAsString());
// Check the result
@@ -264,7 +268,7 @@ public class SiteServiceTest extends BaseWebScriptTest
assertEquals(USER_TWO, membership.getJSONObject("person").get("userName"));
// Get the membership list
response = getRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS, 200);
response = sendRequest(new GetRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS), 200);
JSONArray result2 = new JSONArray(response.getContentAsString());
assertNotNull(result2);
assertEquals(2, result2.length());
@@ -277,11 +281,11 @@ public class SiteServiceTest extends BaseWebScriptTest
createSite("myPreset", shortName, "myTitle", "myDescription", true, 200);
// Test error conditions
getRequest(URL_SITES + "/badsite" + URL_MEMBERSHIPS + "/" + USER_ONE, 404);
getRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS + "/baduser", 404);
getRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS + "/" + USER_TWO, 404);
sendRequest(new GetRequest(URL_SITES + "/badsite" + URL_MEMBERSHIPS + "/" + USER_ONE), 404);
sendRequest(new GetRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS + "/baduser"), 404);
sendRequest(new GetRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS + "/" + USER_TWO), 404);
MockHttpServletResponse response = getRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS + "/" + USER_ONE, 200);
Response response = sendRequest(new GetRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS + "/" + USER_ONE), 200);
JSONObject result = new JSONObject(response.getContentAsString());
// Check the result
@@ -306,12 +310,12 @@ public class SiteServiceTest extends BaseWebScriptTest
membership.put("person", person);
// Post the memebership
MockHttpServletResponse response = postRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS, 200, membership.toString(), "application/json");
Response response = sendRequest(new PostRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS, membership.toString(), "application/json"), 200);
JSONObject newMember = new JSONObject(response.getContentAsString());
// Update the role
newMember.put("role", SiteModel.SITE_COLLABORATOR);
response = putRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS + "/" + USER_TWO, 200, newMember.toString(), "application/json");
response = sendRequest(new PutRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS + "/" + USER_TWO, newMember.toString(), "application/json"), 200);
JSONObject result = new JSONObject(response.getContentAsString());
// Check the result
@@ -319,7 +323,7 @@ public class SiteServiceTest extends BaseWebScriptTest
assertEquals(USER_TWO, result.getJSONObject("person").get("userName"));
// Double check and get the membership for user two
response = getRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS + "/" + USER_TWO, 200);
response = sendRequest(new GetRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS + "/" + USER_TWO), 200);
result = new JSONObject(response.getContentAsString());
assertEquals(SiteModel.SITE_COLLABORATOR, result.get("role"));
assertEquals(USER_TWO, result.getJSONObject("person").get("userName"));
@@ -339,13 +343,13 @@ public class SiteServiceTest extends BaseWebScriptTest
membership.put("person", person);
// Post the membership
postRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS, 200, membership.toString(), "application/json");
sendRequest(new PostRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS, membership.toString(), "application/json"), 200);
// Delete the membership
deleteRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS + "/" + USER_TWO, 200);
sendRequest(new DeleteRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS + "/" + USER_TWO), 200);
// Check that the membership has been deleted
getRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS + "/" + USER_TWO, 404);
sendRequest(new GetRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS + "/" + USER_TWO), 404);
}

View File

@@ -37,9 +37,11 @@ import org.alfresco.service.cmr.repository.ContentWriter;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.util.GUID;
import org.alfresco.web.scripts.TestWebScriptServer.GetRequest;
import org.alfresco.web.scripts.TestWebScriptServer.PostRequest;
import org.alfresco.web.scripts.TestWebScriptServer.Response;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.mock.web.MockHttpServletResponse;
/**
* Unit test to test thumbnail web script API
@@ -110,13 +112,13 @@ public class ThumbnailServiceTest extends BaseWebScriptTest
JSONObject tn = new JSONObject();
tn.put("thumbnailName", "webpreview");
MockHttpServletResponse response = this.postRequest(url, 200, tn.toString(), "application/json");
Response response = sendRequest(new PostRequest(url, tn.toString(), "application/json"), 200);
System.out.println(response.getContentAsString());
}
// Check getAll whilst we are here
MockHttpServletResponse getAllResp = this.getRequest(getThumbnailsURL(jpgNode), 200);
Response getAllResp = sendRequest(new GetRequest(getThumbnailsURL(jpgNode)), 200);
JSONArray getArr = new JSONArray(getAllResp.getContentAsString());
assertNotNull(getArr);
assertEquals(0, getArr.length());
@@ -125,16 +127,16 @@ public class ThumbnailServiceTest extends BaseWebScriptTest
String url = "/api/node/" + jpgNode.getStoreRef().getProtocol() + "/" + jpgNode.getStoreRef().getIdentifier() + "/" + jpgNode.getId() + "/content/thumbnails";
JSONObject tn = new JSONObject();
tn.put("thumbnailName", "medium");
MockHttpServletResponse response = this.postRequest(url, 200, tn.toString(), "application/json");
Response response = sendRequest(new PostRequest(url, tn.toString(), "application/json"), 200);
System.out.println(response.getContentAsString());
JSONObject result = new JSONObject(response.getContentAsString());
String thumbnailUrl = result.getString("url").substring(17);
System.out.println(thumbnailUrl);
response = getRequest(thumbnailUrl, 200);
response = sendRequest(new GetRequest(thumbnailUrl), 200);
// Check getAll whilst we are here
getAllResp = this.getRequest(getThumbnailsURL(jpgNode), 200);
getAllResp = sendRequest(new GetRequest(getThumbnailsURL(jpgNode)), 200);
getArr = new JSONArray(getAllResp.getContentAsString());
assertNotNull(getArr);
assertEquals(1, getArr.length());
@@ -203,7 +205,7 @@ public class ThumbnailServiceTest extends BaseWebScriptTest
JSONObject tn = new JSONObject();
tn.put("thumbnailName", "webpreview");
MockHttpServletResponse response = this.postRequest(url, 200, tn.toString(), "application/json");
Response response = sendRequest(new PostRequest(url, tn.toString(), "application/json"), 200);
assertEquals("", response.getContentAsString().trim());
getWait(pdfNode, "webpreview");
}
@@ -212,7 +214,7 @@ public class ThumbnailServiceTest extends BaseWebScriptTest
String url = "/api/node/" + jpgNode.getStoreRef().getProtocol() + "/" + jpgNode.getStoreRef().getIdentifier() + "/" + jpgNode.getId() + "/content/thumbnails?as=true";
JSONObject tn = new JSONObject();
tn.put("thumbnailName", "medium");
MockHttpServletResponse response = this.postRequest(url, 200, tn.toString(), "application/json");
Response response = sendRequest(new PostRequest(url, tn.toString(), "application/json"), 200);
assertEquals("", response.getContentAsString().trim());
getWait(jpgNode, "medium");
@@ -232,7 +234,7 @@ public class ThumbnailServiceTest extends BaseWebScriptTest
fail("Thumbnail never gets created " + thumbnailName);
}
MockHttpServletResponse response = getRequest(url, 0);
Response response = sendRequest(new GetRequest(url), 0);
if (response.getStatus() == 200)
{
break;
@@ -257,13 +259,13 @@ public class ThumbnailServiceTest extends BaseWebScriptTest
if (this.contentService.getTransformer(MimetypeMap.MIMETYPE_PDF, MimetypeMap.MIMETYPE_FLASH) != null)
{
// Check that there is no place holder set for webpreview
this.getRequest(getThumbnailsURL(pdfNode) + "/webpreview", 404);
this.getRequest(getThumbnailsURL(pdfNode) + "/webpreview?ph=true", 404);
sendRequest(new GetRequest(getThumbnailsURL(pdfNode) + "/webpreview"), 404);
sendRequest(new GetRequest(getThumbnailsURL(pdfNode) + "/webpreview?ph=true"), 404);
}
// Check that here is a place holder for medium
this.getRequest(getThumbnailsURL(jpgNode) + "/medium", 404);
this.getRequest(getThumbnailsURL(jpgNode) + "/medium?ph=true", 200);
sendRequest(new GetRequest(getThumbnailsURL(jpgNode) + "/medium"), 404);
sendRequest(new GetRequest(getThumbnailsURL(jpgNode) + "/medium?ph=true"), 200);
System.out.println(getThumbnailsURL(jpgNode) + "/medium?ph=true");
}