Merge from SEAMIST3

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@10728 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
David Caruana
2008-09-04 10:59:40 +00:00
parent 7e0b3f5453
commit bf504cba8c
6 changed files with 38 additions and 75 deletions

View File

@@ -175,7 +175,7 @@ public class DiscussionServiceTest extends BaseWebScriptTest
JSONObject post = new JSONObject();
post.put("title", title);
post.put("content", content);
Response response = sendRequest(new PutRequest(URL_FORUM_POST + name, post.toString(), "application/json"), expectedStatus);
Response response = sendRequest(new PutRequest(URL_FORUM_POST + nodeRef, post.toString(), "application/json"), expectedStatus);
if (expectedStatus != 200)
{

View File

@@ -50,12 +50,10 @@ 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.PutRequest;
import org.alfresco.web.scripts.TestWebScriptServer.Response;
>>>>>>> .merge-right.r9819
import org.apache.commons.lang.RandomStringUtils;
import org.json.JSONObject;
/**
@@ -283,18 +281,11 @@ 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))
@@ -326,8 +317,7 @@ public class InviteServiceTest extends BaseWebScriptTest
+ "&acceptUrl=" + "page/accept-invite"
+ "&rejectUrl=" + "page/reject-invite";
MockHttpServletResponse response = getRequest(startInviteUrl,
expectedStatus);
Response response = sendRequest(new GetRequest(startInviteUrl), expectedStatus);
JSONObject result = new JSONObject(response.getContentAsString());
@@ -354,8 +344,7 @@ public class InviteServiceTest extends BaseWebScriptTest
String getInvitesUrl = URL_INVITES_SERVICE + "?inviteId=" + inviteId;
// invoke get invites web script
MockHttpServletResponse response = getRequest(getInvitesUrl,
expectedStatus);
Response response = sendRequest(new GetRequest(getInvitesUrl), expectedStatus);
JSONObject result = new JSONObject(response.getContentAsString());
@@ -370,8 +359,7 @@ public class InviteServiceTest extends BaseWebScriptTest
+ inviterUserName;
// invoke get invites web script
MockHttpServletResponse response = getRequest(getInvitesUrl,
expectedStatus);
Response response = sendRequest(new GetRequest(getInvitesUrl), expectedStatus);
JSONObject result = new JSONObject(response.getContentAsString());
@@ -386,8 +374,7 @@ public class InviteServiceTest extends BaseWebScriptTest
+ inviteeUserName;
// invoke get invites web script
MockHttpServletResponse response = getRequest(getInvitesUrl,
expectedStatus);
Response response = sendRequest(new GetRequest(getInvitesUrl), expectedStatus);
JSONObject result = new JSONObject(response.getContentAsString());
@@ -402,8 +389,7 @@ public class InviteServiceTest extends BaseWebScriptTest
+ siteShortName;
// invoke get invites web script
MockHttpServletResponse response = getRequest(getInvitesUrl,
expectedStatus);
Response response = sendRequest(new GetRequest(getInvitesUrl), expectedStatus);
JSONObject result = new JSONObject(response.getContentAsString());
@@ -491,15 +477,8 @@ 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;
String cancelInviteUrl = URL_INVITE_SERVICE + "/" + INVITE_ACTION_CANCEL + "?inviteId=" + inviteId;
Response response = sendRequest(new GetRequest(cancelInviteUrl), Status.STATUS_OK);
>>>>>>> .merge-right.r9819
}
public void testAcceptInvite() throws Exception
@@ -517,10 +496,8 @@ 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);
Response response = sendRequest(new PutRequest(acceptInviteUrl, (byte[])null, null), Status.STATUS_OK);
//
// test that invitation represented by invite ID (of invitation started
@@ -535,11 +512,6 @@ 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
@@ -558,8 +530,7 @@ public class InviteServiceTest extends BaseWebScriptTest
// Invitee rejects invitation to a Site from Inviter
String rejectInviteUrl = URL_INVITE_SERVICE + "/" + inviteId + "/" + inviteTicket + "/reject";
MockHttpServletResponse response = putRequest(rejectInviteUrl,
Status.STATUS_OK, null, null);
Response response = sendRequest(new PutRequest(rejectInviteUrl, (byte[])null, null), Status.STATUS_OK);
//
// test that invite represented by invite ID (of invitation started
@@ -569,8 +540,7 @@ public class InviteServiceTest extends BaseWebScriptTest
//
// get pending invite matching inviteId from invite started above
JSONObject getInvitesResult = getInvitesByInviteId(inviteId,
Status.STATUS_OK);
JSONObject getInvitesResult = getInvitesByInviteId(inviteId, Status.STATUS_OK);
// there should no longer be any invites identified by invite ID pending
assertEquals(getInvitesResult.getJSONArray("invites").length(), 0);
@@ -592,21 +562,11 @@ 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,8 +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.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.lang.RandomStringUtils;
import org.json.JSONObject;
@@ -142,8 +145,7 @@ public class PersonServiceTest extends BaseWebScriptTest
person.put("jobtitle", jobTitle);
person.put("email", email);
MockHttpServletResponse response = putRequest(
URL_PEOPLE + "/" + userName, expectedStatus, person.toString(), "application/json");
Response response = sendRequest(new PutRequest(URL_PEOPLE + "/" + userName, person.toString(), "application/json"), expectedStatus);
// switch back to non-admin user
this.authenticationComponent.setCurrentUser(currentUser);
@@ -191,7 +193,7 @@ public class PersonServiceTest extends BaseWebScriptTest
String adminUser = this.authenticationComponent.getSystemUserName();
this.authenticationComponent.setCurrentUser(adminUser);
MockHttpServletResponse response = deleteRequest(URL_PEOPLE + "/" + userName, expectedStatus);
Response response = sendRequest(new DeleteRequest(URL_PEOPLE + "/" + userName), expectedStatus);
this.createdPeople.remove(userName);
// switch back to non-admin user

View File

@@ -159,17 +159,17 @@ public class SiteServiceTest extends BaseWebScriptTest
createSite("myPreset", GUID.generate(), "myTitle", "myDescription", true, 200);
createSite("myPreset", GUID.generate(), "myTitle", "myDescription", true, 200);
response = getRequest(URL_SITES, 200);
response = sendRequest(new GetRequest(URL_SITES), 200);
result = new JSONArray(response.getContentAsString());
assertNotNull(result);
assertEquals(5, result.length());
response = getRequest(URL_SITES + "?size=3", 200);
response = sendRequest(new GetRequest(URL_SITES + "?size=3"), 200);
result = new JSONArray(response.getContentAsString());
assertNotNull(result);
assertEquals(3, result.length());
response = getRequest(URL_SITES + "?size=13", 200);
response = sendRequest(new GetRequest(URL_SITES + "?size=13"), 200);
result = new JSONArray(response.getContentAsString());
assertNotNull(result);
assertEquals(5, result.length());
@@ -361,7 +361,7 @@ public class SiteServiceTest extends BaseWebScriptTest
String shortName2 = GUID.generate();
createSite("myPreset", shortName2, "myTitle", "myDescription", true, 200);
MockHttpServletResponse response = getRequest("/api/people/" + USER_TWO + "/sites", 200);
Response response = sendRequest(new GetRequest("/api/people/" + USER_TWO + "/sites"), 200);
JSONArray result = new JSONArray(response.getContentAsString());
assertNotNull(result);
@@ -373,39 +373,39 @@ public class SiteServiceTest extends BaseWebScriptTest
JSONObject person = new JSONObject();
person.put("userName", USER_TWO);
membership.put("person", person);
postRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS, 200, membership.toString(), "application/json");
sendRequest(new PostRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS, membership.toString(), "application/json"), 200);
membership = new JSONObject();
membership.put("role", SiteModel.SITE_CONSUMER);
person = new JSONObject();
person.put("userName", USER_TWO);
membership.put("person", person);
postRequest(URL_SITES + "/" + shortName2 + URL_MEMBERSHIPS, 200, membership.toString(), "application/json");
sendRequest(new PostRequest(URL_SITES + "/" + shortName2 + URL_MEMBERSHIPS, membership.toString(), "application/json"), 200);
response = getRequest("/api/people/" + USER_TWO + "/sites", 200);
response = sendRequest(new GetRequest("/api/people/" + USER_TWO + "/sites"), 200);
result = new JSONArray(response.getContentAsString());
assertNotNull(result);
assertEquals(2, result.length());
response = getRequest("/api/people/" + USER_ONE + "/sites", 200);
response = sendRequest(new GetRequest("/api/people/" + USER_ONE + "/sites"), 200);
result = new JSONArray(response.getContentAsString());
assertNotNull(result);
assertEquals(2, result.length());
response = getRequest("/api/people/" + USER_THREE + "/sites", 200);
response = sendRequest(new GetRequest("/api/people/" + USER_THREE + "/sites"), 200);
result = new JSONArray(response.getContentAsString());
assertNotNull(result);
assertEquals(0, result.length());
response = getRequest("/api/people/" + USER_ONE + "/sites?size=1", 200);
response = sendRequest(new GetRequest("/api/people/" + USER_ONE + "/sites?size=1"), 200);
result = new JSONArray(response.getContentAsString());
assertNotNull(result);
assertEquals(1, result.length());
response = getRequest("/api/people/" + USER_ONE + "/sites?size=5", 200);
response = sendRequest(new GetRequest("/api/people/" + USER_ONE + "/sites?size=5"), 200);
result = new JSONArray(response.getContentAsString());
assertNotNull(result);

View File

@@ -37,8 +37,9 @@ import org.alfresco.service.cmr.security.PersonService;
import org.alfresco.service.cmr.tagging.TaggingService;
import org.alfresco.util.GUID;
import org.alfresco.util.PropertyMap;
import org.alfresco.web.scripts.TestWebScriptServer.GetRequest;
import org.alfresco.web.scripts.TestWebScriptServer.Response;
import org.json.JSONArray;
import org.springframework.mock.web.MockHttpServletResponse;
/**
* Unit test to test tagging Web Script API
@@ -140,19 +141,19 @@ public class TaggingServiceTest extends BaseWebScriptTest
public void testGetTags()
throws Exception
{
MockHttpServletResponse response = getRequest("/api/tags/" + StoreRef.PROTOCOL_WORKSPACE + "/SpacesStore", 200);
Response response = sendRequest(new GetRequest("/api/tags/" + StoreRef.PROTOCOL_WORKSPACE + "/SpacesStore"), 200);
JSONArray jsonArray = new JSONArray(response.getContentAsString());
assertNotNull(jsonArray);
//assertEquals(5, jsonArray.length());
response = getRequest("/api/tags/" + StoreRef.PROTOCOL_WORKSPACE + "/SpacesStore?tf=one", 200);
response = sendRequest(new GetRequest("/api/tags/" + StoreRef.PROTOCOL_WORKSPACE + "/SpacesStore?tf=one"), 200);
jsonArray = new JSONArray(response.getContentAsString());
assertNotNull(jsonArray);
assertEquals(1, jsonArray.length());
response = getRequest("/api/tags/" + StoreRef.PROTOCOL_WORKSPACE + "/SpacesStore?tf=none", 200);
response = sendRequest(new GetRequest("/api/tags/" + StoreRef.PROTOCOL_WORKSPACE + "/SpacesStore?tf=none"), 200);
jsonArray = new JSONArray(response.getContentAsString());
assertNotNull(jsonArray);
@@ -162,7 +163,7 @@ public class TaggingServiceTest extends BaseWebScriptTest
public void testGetNodes()
throws Exception
{
MockHttpServletResponse response = getRequest("/api/tags/" + StoreRef.PROTOCOL_WORKSPACE + "/SpacesStore/" + TAG_1 + "/nodes", 200);
Response response = sendRequest(new GetRequest("/api/tags/" + StoreRef.PROTOCOL_WORKSPACE + "/SpacesStore/" + TAG_1 + "/nodes"), 200);
JSONArray jsonArray = new JSONArray(response.getContentAsString());
assertNotNull(jsonArray);
@@ -170,13 +171,13 @@ public class TaggingServiceTest extends BaseWebScriptTest
System.out.println(response.getContentAsString());
response = getRequest("/api/tags/" + StoreRef.PROTOCOL_WORKSPACE + "/SpacesStore/" + TAG_2 + "/nodes", 200);
response = sendRequest(new GetRequest("/api/tags/" + StoreRef.PROTOCOL_WORKSPACE + "/SpacesStore/" + TAG_2 + "/nodes"), 200);
jsonArray = new JSONArray(response.getContentAsString());
assertNotNull(jsonArray);
assertEquals(2, jsonArray.length());
response = getRequest("/api/tags/" + StoreRef.PROTOCOL_WORKSPACE + "/SpacesStore/jumk/nodes", 200);
response = sendRequest(new GetRequest("/api/tags/" + StoreRef.PROTOCOL_WORKSPACE + "/SpacesStore/jumk/nodes"), 200);
jsonArray = new JSONArray(response.getContentAsString());
assertNotNull(jsonArray);

View File

@@ -150,7 +150,7 @@ public class ThumbnailServiceTest extends BaseWebScriptTest
if (this.contentService.getTransformer(MimetypeMap.MIMETYPE_PDF, MimetypeMap.MIMETYPE_FLASH) != null)
{
String url = "/api/node/" + pdfNode.getStoreRef().getProtocol() + "/" + pdfNode.getStoreRef().getIdentifier() + "/" + pdfNode.getId() + "/content/thumbnaildefinitions";
MockHttpServletResponse response = this.getRequest(url, 200);
Response response = sendRequest(new GetRequest(url), 200);
JSONArray array = new JSONArray(response.getContentAsString());
assertNotNull(array);
@@ -173,7 +173,7 @@ public class ThumbnailServiceTest extends BaseWebScriptTest
}
String url = "/api/node/" + jpgNode.getStoreRef().getProtocol() + "/" + jpgNode.getStoreRef().getIdentifier() + "/" + jpgNode.getId() + "/content/thumbnaildefinitions";
MockHttpServletResponse response = this.getRequest(url, 200);
Response response = sendRequest(new GetRequest(url), 200);
JSONArray array = new JSONArray(response.getContentAsString());
assertNotNull(array);