use of org.springframework.extensions.webscripts.TestWebScriptServer.Response in project alfresco-remote-api by Alfresco.
the class PersonServiceTest method deletePerson.
private JSONObject deletePerson(String userName, int expectedStatus) throws Exception {
// switch to admin user to delete a person
String currentUser = this.authenticationComponent.getCurrentUserName();
String adminUser = this.authenticationComponent.getSystemUserName();
this.authenticationComponent.setCurrentUser(adminUser);
Response response = sendRequest(new DeleteRequest(URL_PEOPLE + "/" + userName), expectedStatus);
this.createdPeople.remove(userName);
// switch back to non-admin user
this.authenticationComponent.setCurrentUser(currentUser);
return new JSONObject(response.getContentAsString());
}
use of org.springframework.extensions.webscripts.TestWebScriptServer.Response in project alfresco-remote-api by Alfresco.
the class PersonServiceTest method testGetPerson.
@SuppressWarnings("unused")
public void testGetPerson() throws Exception {
// Get a person that doesn't exist
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", 0, 200);
response = sendRequest(new GetRequest(URL_PEOPLE + "/" + userName), 200);
}
use of org.springframework.extensions.webscripts.TestWebScriptServer.Response in project alfresco-remote-api by Alfresco.
the class QuickShareRestApiTest method testSanityCheckUrls.
public void testSanityCheckUrls() throws Exception {
checkTransformer();
final int expectedStatusOK = 200;
final int expectedStatusNotFound = 404;
// currently mapped from AccessDenied (should it be 403, 404 or does it depend on use-case)
final int expectedStatusServerError = 500;
final int expectedStatusForbidden = 403;
String testNodeRef_3 = testNode.toString().replace("://", "/");
// As user one ...
// get metadata for node (authenticated)
Response rsp = sendRequest(new GetRequest(AUTH_METADATA_URL.replace("{node_ref_3}", testNodeRef_3)), expectedStatusOK, USER_ONE);
JSONObject jsonRsp = new JSONObject(new JSONTokener(rsp.getContentAsString()));
String name = jsonRsp.getString("name");
assertEquals(TEST_NAME, name);
String mimetype = jsonRsp.getString("mimetype");
assertEquals(TEST_MIMETYPE_JPEG, mimetype);
// get content for node (authenticated)
// Commented out when removing original CMIS impl
// rsp = sendRequest(new GetRequest(AUTH_CONTENT_URL.replace("{node_ref_3}", testNodeRef_3)), expectedStatusOK, USER_ONE);
// byte[] content = rsp.getContentAsByteArray();
// checkBytes(TEST_CONTENT, content);
// get content thumbnail for node (authenticated)
rsp = sendRequest(new GetRequest(AUTH_CONTENT_THUMBNAIL_URL.replace("{node_ref_3}", testNodeRef_3).replace("{thumbnailname}", "doclib")), expectedStatusOK, USER_ONE);
String type = rsp.getContentType();
assertEquals(TEST_MIMETYPE_PNG, type);
// As user two ...
rsp = sendRequest(new GetRequest(AUTH_METADATA_URL.replace("{node_ref_3}", testNodeRef_3)), expectedStatusServerError, USER_TWO);
// Commented out when removing original CMIS impl
// rsp = sendRequest(new GetRequest(AUTH_CONTENT_URL.replace("{node_ref_3}", testNodeRef_3)), expectedStatusForbidden, USER_TWO);
rsp = sendRequest(new GetRequest(AUTH_CONTENT_THUMBNAIL_URL.replace("{node_ref_3}", testNodeRef_3).replace("{thumbnailname}", "doclib")), expectedStatusServerError, USER_TWO);
// As user one ...
// share
rsp = sendRequest(new PostRequest(SHARE_URL.replace("{node_ref_3}", testNodeRef_3), "", APPLICATION_JSON), expectedStatusOK, USER_ONE);
jsonRsp = new JSONObject(new JSONTokener(rsp.getContentAsString()));
String sharedId = jsonRsp.getString("sharedId");
assertNotNull(sharedId);
// note: we may have to adjust/remove this check if we change length of id (or it becomes variable length)
assertEquals(22, sharedId.length());
// As user two ...
// get metadata for share (note: can be unauthenticated)
rsp = sendRequest(new GetRequest(SHARE_METADATA_URL.replace("{shared_id}", sharedId)), expectedStatusOK, USER_TWO);
jsonRsp = new JSONObject(new JSONTokener(rsp.getContentAsString()));
name = jsonRsp.getString("name");
assertEquals(TEST_NAME, name);
mimetype = jsonRsp.getString("mimetype");
assertEquals(TEST_MIMETYPE_JPEG, mimetype);
// get content for share (note: can be unauthenticated)
rsp = sendRequest(new GetRequest(SHARE_CONTENT_URL.replace("{shared_id}", sharedId)), expectedStatusOK, USER_TWO);
byte[] content = rsp.getContentAsByteArray();
checkBytes(TEST_CONTENT, content);
// get content thumbnail for share (note: can be unauthenticated)
rsp = sendRequest(new GetRequest(SHARE_CONTENT_THUMBNAIL_URL.replace("{shared_id}", sharedId).replace("{thumbnailname}", "doclib")), expectedStatusOK, USER_TWO);
type = rsp.getContentType();
assertEquals(TEST_MIMETYPE_PNG, type);
// As user one ...
// unshare
rsp = sendRequest(new DeleteRequest(UNSHARE_URL.replace("{shared_id}", sharedId)), expectedStatusOK, USER_ONE);
// As user two ...
// -ve test (should not be able to get metadata or content via sharedId) - whether authenticated or not
rsp = sendRequest(new GetRequest(SHARE_METADATA_URL.replace("{shared_id}", sharedId)), expectedStatusNotFound, USER_TWO);
rsp = sendRequest(new GetRequest(SHARE_CONTENT_URL.replace("{shared_id}", sharedId)), expectedStatusNotFound, USER_TWO);
rsp = sendRequest(new GetRequest(SHARE_CONTENT_THUMBNAIL_URL.replace("{shared_id}", sharedId).replace("{thumbnailname}", "doclib")), expectedStatusNotFound, USER_TWO);
}
use of org.springframework.extensions.webscripts.TestWebScriptServer.Response in project alfresco-remote-api by Alfresco.
the class ReplicationRestApiTest method testReplicationDefinitionGet.
public void testReplicationDefinitionGet() throws Exception {
Response response;
// Not allowed if you're not an admin
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getGuestUserName());
response = sendRequest(new GetRequest(URL_DEFINITION + "madeup"), Status.STATUS_UNAUTHORIZED);
assertEquals(Status.STATUS_UNAUTHORIZED, response.getStatus());
AuthenticationUtil.setFullyAuthenticatedUser(USER_NORMAL);
response = sendRequest(new GetRequest(URL_DEFINITION + "madeup"), Status.STATUS_UNAUTHORIZED);
assertEquals(Status.STATUS_UNAUTHORIZED, response.getStatus());
// If an invalid name is given, you get a 404
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
response = sendRequest(new GetRequest(URL_DEFINITION + "madeup"), 404);
assertEquals(Status.STATUS_NOT_FOUND, response.getStatus());
// Add a definition, it should show up
ReplicationDefinition rd = replicationService.createReplicationDefinition("Test1", "Testing");
replicationService.saveReplicationDefinition(rd);
response = sendRequest(new GetRequest(URL_DEFINITION + "Test1"), 200);
assertEquals(Status.STATUS_OK, response.getStatus());
String jsonStr = response.getContentAsString();
JSONObject json = new JSONObject(jsonStr).getJSONObject("data");
assertNotNull(json);
// Check
assertEquals("Test1", json.get("name"));
assertEquals("Testing", json.get("description"));
assertEquals("New", json.get("status"));
assertEquals(JSONObject.NULL, json.get("startedAt"));
assertEquals(JSONObject.NULL, json.get("endedAt"));
assertEquals(JSONObject.NULL, json.get("failureMessage"));
assertEquals(JSONObject.NULL, json.get("executionDetails"));
assertEquals(JSONObject.NULL, json.get("transferLocalReport"));
assertEquals(JSONObject.NULL, json.get("transferRemoteReport"));
assertEquals(true, json.get("enabled"));
assertEquals(JSONObject.NULL, json.get("targetName"));
// Payload is empty
assertEquals(0, json.getJSONArray("payload").length());
// Ensure we didn't get any unexpected data back
JSONArray keys = json.names();
for (int i = 0; i < keys.length(); i++) {
String key = keys.getString(0);
if (key.equals("name") || key.equals("description") || key.equals("status") || key.equals("startedAt") || key.equals("endedAt") || key.equals("failureMessage") || key.equals("executionDetails") || key.equals("payload") || key.equals("transferLocalReport") || key.equals("transferRemoteReport") || key.equals("enabled") || key.equals("targetName") || key.equals("schedule")) {
// All good
} else {
fail("Unexpected key '" + key + "' found in json, raw json is\n" + jsonStr);
}
}
// Mark it as pending, and check
actionTrackingService.recordActionPending(rd);
String actionId = rd.getId();
int instanceId = ((ActionImpl) rd).getExecutionInstance();
response = sendRequest(new GetRequest(URL_DEFINITION + "Test1"), 200);
assertEquals(Status.STATUS_OK, response.getStatus());
jsonStr = response.getContentAsString();
json = new JSONObject(jsonStr).getJSONObject("data");
assertEquals("Test1", json.get("name"));
assertEquals("Testing", json.get("description"));
assertEquals("Pending", json.get("status"));
assertEquals(JSONObject.NULL, json.get("startedAt"));
assertEquals(JSONObject.NULL, json.get("endedAt"));
assertEquals(JSONObject.NULL, json.get("failureMessage"));
assertEquals("/" + URL_RUNNING_ACTION + "replicationActionExecutor=" + actionId + "=" + instanceId, json.get("executionDetails"));
assertEquals(JSONObject.NULL, json.get("transferLocalReport"));
assertEquals(JSONObject.NULL, json.get("transferRemoteReport"));
assertEquals(true, json.get("enabled"));
assertEquals(JSONObject.NULL, json.get("targetName"));
// Payload is empty
assertEquals(0, json.getJSONArray("payload").length());
// Change the status to running, and re-check
actionTrackingService.recordActionExecuting(rd);
assertEquals(actionId, rd.getId());
assertEquals(instanceId, ((ActionImpl) rd).getExecutionInstance());
String startedAt = ISO8601DateFormat.format(rd.getExecutionStartDate());
response = sendRequest(new GetRequest(URL_DEFINITION + "Test1"), 200);
assertEquals(Status.STATUS_OK, response.getStatus());
jsonStr = response.getContentAsString();
json = new JSONObject(jsonStr).getJSONObject("data");
assertEquals("Test1", json.get("name"));
assertEquals("Testing", json.get("description"));
assertEquals("Running", json.get("status"));
assertEquals(startedAt, json.getJSONObject("startedAt").get("iso8601"));
assertEquals(JSONObject.NULL, json.get("endedAt"));
assertEquals(JSONObject.NULL, json.get("failureMessage"));
assertEquals("/" + URL_RUNNING_ACTION + "replicationActionExecutor=" + actionId + "=" + instanceId, json.get("executionDetails"));
assertEquals(JSONObject.NULL, json.get("transferLocalReport"));
assertEquals(JSONObject.NULL, json.get("transferRemoteReport"));
assertEquals(true, json.get("enabled"));
assertEquals(JSONObject.NULL, json.get("targetName"));
// Payload is empty
assertEquals(0, json.getJSONArray("payload").length());
// Cancel it
actionTrackingService.requestActionCancellation(rd);
response = sendRequest(new GetRequest(URL_DEFINITION + "Test1"), 200);
assertEquals(Status.STATUS_OK, response.getStatus());
jsonStr = response.getContentAsString();
json = new JSONObject(jsonStr).getJSONObject("data");
assertEquals("Test1", json.get("name"));
assertEquals("Testing", json.get("description"));
assertEquals("CancelRequested", json.get("status"));
assertEquals(startedAt, json.getJSONObject("startedAt").get("iso8601"));
assertEquals(JSONObject.NULL, json.get("endedAt"));
assertEquals(JSONObject.NULL, json.get("failureMessage"));
assertEquals("/" + URL_RUNNING_ACTION + "replicationActionExecutor=" + actionId + "=" + instanceId, json.get("executionDetails"));
assertEquals(JSONObject.NULL, json.get("transferLocalReport"));
assertEquals(JSONObject.NULL, json.get("transferRemoteReport"));
assertEquals(true, json.get("enabled"));
assertEquals(JSONObject.NULL, json.get("targetName"));
// Payload is empty
assertEquals(0, json.getJSONArray("payload").length());
// Add some payload details, ensure that they get expanded
// as they should be
rd.getPayload().add(repositoryHelper.getCompanyHome());
rd.getPayload().add(dataDictionary);
replicationService.saveReplicationDefinition(rd);
response = sendRequest(new GetRequest(URL_DEFINITION + "Test1"), 200);
assertEquals(Status.STATUS_OK, response.getStatus());
jsonStr = response.getContentAsString();
json = new JSONObject(jsonStr).getJSONObject("data");
assertEquals("Test1", json.get("name"));
assertEquals("Testing", json.get("description"));
assertEquals("CancelRequested", json.get("status"));
assertEquals(startedAt, json.getJSONObject("startedAt").get("iso8601"));
assertEquals(JSONObject.NULL, json.get("endedAt"));
assertEquals(JSONObject.NULL, json.get("failureMessage"));
assertEquals("/" + URL_RUNNING_ACTION + "replicationActionExecutor=" + actionId + "=" + instanceId, json.get("executionDetails"));
assertEquals(JSONObject.NULL, json.get("transferLocalReport"));
assertEquals(JSONObject.NULL, json.get("transferRemoteReport"));
assertEquals(true, json.get("enabled"));
assertEquals(JSONObject.NULL, json.get("targetName"));
// Check Payload
assertEquals(2, json.getJSONArray("payload").length());
JSONObject payload = json.getJSONArray("payload").getJSONObject(0);
assertEquals(repositoryHelper.getCompanyHome().toString(), payload.get("nodeRef"));
assertEquals(true, payload.get("isFolder"));
assertEquals("Company Home", payload.get("name"));
assertEquals("/Company Home", payload.get("path"));
payload = json.getJSONArray("payload").getJSONObject(1);
assertEquals(dataDictionary.toString(), payload.get("nodeRef"));
assertEquals(true, payload.get("isFolder"));
assertEquals("Data Dictionary", payload.get("name"));
assertEquals("/Company Home/Data Dictionary", payload.get("path"));
// Add a deleted NodeRef too, will be silently ignored
// by the webscript layer
UserTransaction txn = transactionService.getUserTransaction();
txn.begin();
NodeRef deleted = nodeService.createNode(dataDictionary, ContentModel.ASSOC_CONTAINS, QName.createQName("IwillBEdeleted"), ContentModel.TYPE_CONTENT).getChildRef();
nodeService.deleteNode(deleted);
txn.commit();
rd.getPayload().add(deleted);
replicationService.saveReplicationDefinition(rd);
response = sendRequest(new GetRequest(URL_DEFINITION + "Test1"), 200);
assertEquals(Status.STATUS_OK, response.getStatus());
jsonStr = response.getContentAsString();
json = new JSONObject(jsonStr).getJSONObject("data");
assertEquals("Test1", json.get("name"));
assertEquals("Testing", json.get("description"));
assertEquals("CancelRequested", json.get("status"));
assertEquals(startedAt, json.getJSONObject("startedAt").get("iso8601"));
assertEquals(JSONObject.NULL, json.get("endedAt"));
assertEquals(JSONObject.NULL, json.get("failureMessage"));
assertEquals("/" + URL_RUNNING_ACTION + "replicationActionExecutor=" + actionId + "=" + instanceId, json.get("executionDetails"));
assertEquals(JSONObject.NULL, json.get("transferLocalReport"));
assertEquals(JSONObject.NULL, json.get("transferRemoteReport"));
assertEquals(true, json.get("enabled"));
assertEquals(JSONObject.NULL, json.get("targetName"));
// Check Payload
assertEquals(2, json.getJSONArray("payload").length());
payload = json.getJSONArray("payload").getJSONObject(0);
assertEquals("Company Home", payload.get("name"));
payload = json.getJSONArray("payload").getJSONObject(1);
assertEquals("Data Dictionary", payload.get("name"));
// Add a 2nd and 3rd definition
rd = replicationService.createReplicationDefinition("Test2", "2nd Testing");
replicationService.saveReplicationDefinition(rd);
rd = replicationService.createReplicationDefinition("Test3", "3rd Testing");
rd.setLocalTransferReport(repositoryHelper.getRootHome());
rd.setRemoteTransferReport(repositoryHelper.getCompanyHome());
rd.setEnabled(false);
// Have the 3rd one flagged as having failed
txn = transactionService.getUserTransaction();
txn.begin();
replicationService.saveReplicationDefinition(rd);
actionTrackingService.recordActionExecuting(rd);
actionTrackingService.recordActionFailure(rd, new Exception("Test Failure"));
txn.commit();
Thread.sleep(50);
replicationService.saveReplicationDefinition(rd);
// Original one comes back unchanged
response = sendRequest(new GetRequest(URL_DEFINITION + "Test1"), 200);
assertEquals(Status.STATUS_OK, response.getStatus());
jsonStr = response.getContentAsString();
json = new JSONObject(jsonStr).getJSONObject("data");
assertEquals("Test1", json.get("name"));
assertEquals("Testing", json.get("description"));
assertEquals("CancelRequested", json.get("status"));
assertEquals(startedAt, json.getJSONObject("startedAt").get("iso8601"));
assertEquals(JSONObject.NULL, json.get("endedAt"));
assertEquals(JSONObject.NULL, json.get("failureMessage"));
assertEquals("/" + URL_RUNNING_ACTION + "replicationActionExecutor=" + actionId + "=" + instanceId, json.get("executionDetails"));
assertEquals(JSONObject.NULL, json.get("transferLocalReport"));
assertEquals(JSONObject.NULL, json.get("transferRemoteReport"));
assertEquals(true, json.get("enabled"));
assertEquals(JSONObject.NULL, json.get("targetName"));
// Check Payload
assertEquals(2, json.getJSONArray("payload").length());
payload = json.getJSONArray("payload").getJSONObject(0);
assertEquals(repositoryHelper.getCompanyHome().toString(), payload.get("nodeRef"));
assertEquals(true, payload.get("isFolder"));
assertEquals("Company Home", payload.get("name"));
assertEquals("/Company Home", payload.get("path"));
payload = json.getJSONArray("payload").getJSONObject(1);
assertEquals(dataDictionary.toString(), payload.get("nodeRef"));
assertEquals(true, payload.get("isFolder"));
assertEquals("Data Dictionary", payload.get("name"));
assertEquals("/Company Home/Data Dictionary", payload.get("path"));
// They show up things as expected
response = sendRequest(new GetRequest(URL_DEFINITION + "Test2"), 200);
assertEquals(Status.STATUS_OK, response.getStatus());
jsonStr = response.getContentAsString();
json = new JSONObject(jsonStr).getJSONObject("data");
assertEquals("Test2", json.get("name"));
assertEquals("2nd Testing", json.get("description"));
assertEquals("New", json.get("status"));
assertEquals(JSONObject.NULL, json.get("startedAt"));
assertEquals(JSONObject.NULL, json.get("endedAt"));
assertEquals(JSONObject.NULL, json.get("failureMessage"));
assertEquals(JSONObject.NULL, json.get("executionDetails"));
assertEquals(JSONObject.NULL, json.get("transferLocalReport"));
assertEquals(JSONObject.NULL, json.get("transferRemoteReport"));
assertEquals(true, json.get("enabled"));
assertEquals(JSONObject.NULL, json.get("targetName"));
assertEquals(0, json.getJSONArray("payload").length());
// And the 3rd one, which is failed
response = sendRequest(new GetRequest(URL_DEFINITION + "Test3"), 200);
assertEquals(Status.STATUS_OK, response.getStatus());
jsonStr = response.getContentAsString();
json = new JSONObject(jsonStr).getJSONObject("data");
startedAt = ISO8601DateFormat.format(rd.getExecutionStartDate());
String endedAt = ISO8601DateFormat.format(rd.getExecutionEndDate());
assertEquals("Test3", json.get("name"));
assertEquals("3rd Testing", json.get("description"));
assertEquals("Failed", json.get("status"));
assertEquals(startedAt, json.getJSONObject("startedAt").get("iso8601"));
assertEquals(endedAt, json.getJSONObject("endedAt").get("iso8601"));
assertEquals("Test Failure", json.get("failureMessage"));
assertEquals(JSONObject.NULL, json.get("executionDetails"));
assertEquals(repositoryHelper.getRootHome().toString(), json.get("transferLocalReport"));
assertEquals(repositoryHelper.getCompanyHome().toString(), json.get("transferRemoteReport"));
assertEquals(false, json.get("enabled"));
assertEquals(JSONObject.NULL, json.get("targetName"));
assertEquals(0, json.getJSONArray("payload").length());
// When pending/running, the previous end time, transfer reports and
// failure details are hidden
rd = replicationService.loadReplicationDefinition("Test3");
assertEquals(0, actionTrackingService.getExecutingActions(rd).size());
actionTrackingService.recordActionPending(rd);
assertEquals(1, actionTrackingService.getExecutingActions(rd).size());
instanceId = ((ActionImpl) rd).getExecutionInstance();
actionId = rd.getId();
response = sendRequest(new GetRequest(URL_DEFINITION + "Test3"), 200);
assertEquals(Status.STATUS_OK, response.getStatus());
jsonStr = response.getContentAsString();
json = new JSONObject(jsonStr).getJSONObject("data");
assertEquals("Test3", json.get("name"));
assertEquals("3rd Testing", json.get("description"));
assertEquals("Pending", json.get("status"));
assertEquals(JSONObject.NULL, json.get("startedAt"));
assertEquals(JSONObject.NULL, json.get("endedAt"));
assertEquals(JSONObject.NULL, json.get("failureMessage"));
assertEquals("/" + URL_RUNNING_ACTION + "replicationActionExecutor=" + actionId + "=" + instanceId, json.get("executionDetails"));
assertEquals(JSONObject.NULL, json.get("transferLocalReport"));
assertEquals(JSONObject.NULL, json.get("transferRemoteReport"));
assertEquals(false, json.get("enabled"));
assertEquals(JSONObject.NULL, json.get("targetName"));
assertEquals(0, json.getJSONArray("payload").length());
actionTrackingService.recordActionExecuting(rd);
response = sendRequest(new GetRequest(URL_DEFINITION + "Test3"), 200);
assertEquals(Status.STATUS_OK, response.getStatus());
jsonStr = response.getContentAsString();
json = new JSONObject(jsonStr).getJSONObject("data");
startedAt = ISO8601DateFormat.format(rd.getExecutionStartDate());
assertEquals("Test3", json.get("name"));
assertEquals("3rd Testing", json.get("description"));
assertEquals("Running", json.get("status"));
assertEquals(startedAt, json.getJSONObject("startedAt").get("iso8601"));
assertEquals(JSONObject.NULL, json.get("endedAt"));
assertEquals(JSONObject.NULL, json.get("failureMessage"));
assertEquals("/" + URL_RUNNING_ACTION + "replicationActionExecutor=" + actionId + "=" + instanceId, json.get("executionDetails"));
assertEquals(JSONObject.NULL, json.get("transferLocalReport"));
assertEquals(JSONObject.NULL, json.get("transferRemoteReport"));
assertEquals(false, json.get("enabled"));
assertEquals(JSONObject.NULL, json.get("targetName"));
assertEquals(0, json.getJSONArray("payload").length());
actionTrackingService.requestActionCancellation(rd);
response = sendRequest(new GetRequest(URL_DEFINITION + "Test3"), 200);
assertEquals(Status.STATUS_OK, response.getStatus());
jsonStr = response.getContentAsString();
json = new JSONObject(jsonStr).getJSONObject("data");
startedAt = ISO8601DateFormat.format(rd.getExecutionStartDate());
assertEquals("Test3", json.get("name"));
assertEquals("3rd Testing", json.get("description"));
assertEquals("CancelRequested", json.get("status"));
assertEquals(startedAt, json.getJSONObject("startedAt").get("iso8601"));
assertEquals(JSONObject.NULL, json.get("endedAt"));
assertEquals(JSONObject.NULL, json.get("failureMessage"));
assertEquals("/" + URL_RUNNING_ACTION + "replicationActionExecutor=" + actionId + "=" + instanceId, json.get("executionDetails"));
assertEquals(JSONObject.NULL, json.get("transferLocalReport"));
assertEquals(JSONObject.NULL, json.get("transferRemoteReport"));
assertEquals(false, json.get("enabled"));
assertEquals(JSONObject.NULL, json.get("targetName"));
assertEquals(0, json.getJSONArray("payload").length());
// These show up again when no longer running
txn = transactionService.getUserTransaction();
txn.begin();
actionTrackingService.recordActionComplete(rd);
txn.commit();
response = sendRequest(new GetRequest(URL_DEFINITION + "Test3"), 200);
assertEquals(Status.STATUS_OK, response.getStatus());
jsonStr = response.getContentAsString();
json = new JSONObject(jsonStr).getJSONObject("data");
startedAt = ISO8601DateFormat.format(rd.getExecutionStartDate());
endedAt = ISO8601DateFormat.format(rd.getExecutionEndDate());
assertEquals("Test3", json.get("name"));
assertEquals("3rd Testing", json.get("description"));
assertEquals("Completed", json.get("status"));
assertEquals(startedAt, json.getJSONObject("startedAt").get("iso8601"));
assertEquals(endedAt, json.getJSONObject("endedAt").get("iso8601"));
assertEquals(JSONObject.NULL, json.get("failureMessage"));
assertEquals(JSONObject.NULL, json.get("executionDetails"));
assertEquals(repositoryHelper.getRootHome().toString(), json.get("transferLocalReport"));
assertEquals(repositoryHelper.getCompanyHome().toString(), json.get("transferRemoteReport"));
assertEquals(false, json.get("enabled"));
assertEquals(JSONObject.NULL, json.get("targetName"));
assertEquals(0, json.getJSONArray("payload").length());
}
use of org.springframework.extensions.webscripts.TestWebScriptServer.Response in project alfresco-remote-api by Alfresco.
the class ReplicationRestApiTest method testReplicationServiceIsEnabled.
/**
* @since 3.5
*/
public void testReplicationServiceIsEnabled() throws Exception {
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
Response response = sendRequest(new GetRequest(URL_REPLICATION_SERVICE_STATUS), 200);
assertEquals(Status.STATUS_OK, response.getStatus());
String jsonStr = response.getContentAsString();
JSONObject json = new JSONObject(jsonStr);
JSONObject data = json.getJSONObject("data");
assertNotNull(data);
assertTrue("ReplicationService was unexpectedly disabled.", data.getBoolean(ReplicationServiceStatusGet.ENABLED));
}
Aggregations