Search in sources :

Example 6 with GetRequest

use of org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest in project alfresco-remote-api by Alfresco.

the class ReadOnlyTransactionInGetRestApiTest method testGetSiteBlog.

public void testGetSiteBlog() throws Exception {
    // TODO: Fixme - This REST API still requires a readwrite transaction to be successful
    // Also add tests for all other blog GET REST APIs
    Response response = sendRequest(new GetRequest(URL_GET_SITE_BLOG), 200);
    logResponse(response);
    assertEquals(Status.STATUS_OK, response.getStatus());
}
Also used : Response(org.springframework.extensions.webscripts.TestWebScriptServer.Response) GetRequest(org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest)

Example 7 with GetRequest

use of org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest in project alfresco-remote-api by Alfresco.

the class RepositoryContainerTest method testRunAsAdmin.

/**
 * Person should be current user irrespective of runas user.
 */
public void testRunAsAdmin() throws Exception {
    authenticationComponent.setCurrentUser(USER_ONE);
    // No runas specified within our webscript descriptor
    Response response = sendRequest(new GetRequest("/test/runas"), STATUS_OK);
    assertEquals(USER_ONE, response.getContentAsString());
    authenticationComponent.setCurrentUser(USER_TWO);
    // runas "Admin" specified within our webscript descriptor
    response = sendRequest(new GetRequest("/test/runasadmin"), STATUS_OK);
    assertEquals(USER_TWO, response.getContentAsString());
    authenticationComponent.setSystemUserAsCurrentUser();
}
Also used : Response(org.springframework.extensions.webscripts.TestWebScriptServer.Response) WebScriptResponse(org.springframework.extensions.webscripts.WebScriptResponse) HttpServletResponse(javax.servlet.http.HttpServletResponse) GetRequest(org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest)

Example 8 with GetRequest

use of org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest in project alfresco-remote-api by Alfresco.

the class RunningActionRestApiTest method testRunningActionsGet.

public void testRunningActionsGet() throws Exception {
    Response response;
    // Not allowed if you're not an admin
    AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getGuestUserName());
    response = sendRequest(new GetRequest(URL_RUNNING_ACTIONS), Status.STATUS_UNAUTHORIZED);
    assertEquals(Status.STATUS_UNAUTHORIZED, response.getStatus());
    AuthenticationUtil.setFullyAuthenticatedUser(USER_NORMAL);
    response = sendRequest(new GetRequest(URL_RUNNING_ACTIONS), Status.STATUS_UNAUTHORIZED);
    assertEquals(Status.STATUS_UNAUTHORIZED, response.getStatus());
    // If nothing running, you don't get anything back
    AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
    response = sendRequest(new GetRequest(URL_RUNNING_ACTIONS), 200);
    assertEquals(Status.STATUS_OK, response.getStatus());
    String jsonStr = response.getContentAsString();
    JSONObject json = new JSONObject(jsonStr);
    JSONArray results = json.getJSONArray("data");
    assertNotNull(results);
    assertEquals(0, results.length());
    // Add a running action, it should show up
    ReplicationDefinition rd = replicationService.createReplicationDefinition("Test1", "Testing");
    replicationService.saveReplicationDefinition(rd);
    actionTrackingService.recordActionExecuting(rd);
    String id = rd.getId();
    String instance = Integer.toString(((ActionImpl) rd).getExecutionInstance());
    String startedAt = ISO8601DateFormat.format(rd.getExecutionStartDate());
    response = sendRequest(new GetRequest(URL_RUNNING_ACTIONS), 200);
    assertEquals(Status.STATUS_OK, response.getStatus());
    jsonStr = response.getContentAsString();
    json = new JSONObject(jsonStr);
    results = json.getJSONArray("data");
    assertNotNull(results);
    assertEquals(1, results.length());
    JSONObject jsonRD = (JSONObject) results.get(0);
    assertNotNull(jsonRD);
    assertEquals(id, jsonRD.get("actionId"));
    assertEquals(ReplicationDefinitionImpl.EXECUTOR_NAME, jsonRD.get("actionType"));
    assertEquals(instance, jsonRD.get("actionInstance"));
    assertEquals(rd.getNodeRef().toString(), jsonRD.get("actionNodeRef"));
    assertEquals(startedAt, jsonRD.get("startedAt"));
    assertEquals(false, jsonRD.getBoolean("cancelRequested"));
    assertEquals("/" + URL_RUNNING_ACTION + "replicationActionExecutor=" + id + "=" + instance, jsonRD.get("details"));
    // Ensure we didn't get any unexpected data back,
    // only the keys we should have done
    JSONArray keys = jsonRD.names();
    for (int i = 0; i < keys.length(); i++) {
        String key = keys.getString(0);
        if (key.equals("actionId") || key.equals("actionType") || key.equals("actionInstance") || key.equals("actionNodeRef") || key.equals("startedAt") || key.equals("cancelRequested") || key.equals("details")) {
        // All good
        } else {
            fail("Unexpected key '" + key + "' found in json, raw json is\n" + jsonStr);
        }
    }
    // Change the status to pending cancel, and re-check
    actionTrackingService.requestActionCancellation(rd);
    response = sendRequest(new GetRequest(URL_RUNNING_ACTIONS), 200);
    assertEquals(Status.STATUS_OK, response.getStatus());
    jsonStr = response.getContentAsString();
    json = new JSONObject(jsonStr);
    results = json.getJSONArray("data");
    assertNotNull(results);
    assertEquals(1, results.length());
    jsonRD = (JSONObject) results.get(0);
    assertNotNull(jsonRD);
    assertEquals(id, jsonRD.get("actionId"));
    assertEquals(ReplicationDefinitionImpl.EXECUTOR_NAME, jsonRD.get("actionType"));
    assertEquals(instance, jsonRD.get("actionInstance"));
    assertEquals(rd.getNodeRef().toString(), jsonRD.get("actionNodeRef"));
    assertEquals(startedAt, jsonRD.get("startedAt"));
    assertEquals(true, jsonRD.getBoolean("cancelRequested"));
    assertEquals("/" + URL_RUNNING_ACTION + "replicationActionExecutor=" + id + "=" + instance, jsonRD.get("details"));
    // Add a 2nd and 3rd - one pending, one running
    rd = replicationService.createReplicationDefinition("Test2", "2nd Testing");
    replicationService.saveReplicationDefinition(rd);
    actionTrackingService.recordActionExecuting(rd);
    String id2 = rd.getId();
    String instance2 = Integer.toString(((ActionImpl) rd).getExecutionInstance());
    String startedAt2 = ISO8601DateFormat.format(rd.getExecutionStartDate());
    rd = replicationService.createReplicationDefinition("AnotherTest", "3rd Testing");
    replicationService.saveReplicationDefinition(rd);
    actionTrackingService.recordActionPending(rd);
    String id3 = rd.getId();
    // Check we got all 3
    boolean has1 = false;
    boolean has2 = false;
    boolean has3 = false;
    response = sendRequest(new GetRequest(URL_RUNNING_ACTIONS), 200);
    assertEquals(Status.STATUS_OK, response.getStatus());
    jsonStr = response.getContentAsString();
    json = new JSONObject(jsonStr);
    results = json.getJSONArray("data");
    assertNotNull(results);
    assertEquals(3, results.length());
    for (int i = 0; i < 3; i++) {
        jsonRD = (JSONObject) results.get(i);
        if (jsonRD.get("actionId").equals(id)) {
            has1 = true;
        }
        if (jsonRD.get("actionId").equals(id2)) {
            has2 = true;
        }
        if (jsonRD.get("actionId").equals(id3)) {
            has3 = true;
        }
    }
    assertTrue(has1);
    assertTrue(has2);
    assertTrue(has3);
    // Remove one, check it goes
    UserTransaction txn = transactionService.getUserTransaction();
    txn.begin();
    actionTrackingService.recordActionComplete(rd);
    txn.commit();
    has1 = false;
    has2 = false;
    has3 = false;
    response = sendRequest(new GetRequest(URL_RUNNING_ACTIONS), 200);
    assertEquals(Status.STATUS_OK, response.getStatus());
    jsonStr = response.getContentAsString();
    json = new JSONObject(jsonStr);
    results = json.getJSONArray("data");
    assertNotNull(results);
    assertEquals(2, results.length());
    for (int i = 0; i < 2; i++) {
        jsonRD = (JSONObject) results.get(i);
        if (jsonRD.get("actionId").equals(id)) {
            has1 = true;
        }
        if (jsonRD.get("actionId").equals(id2)) {
            has2 = true;
        }
        if (jsonRD.get("actionId").equals(id3)) {
            has3 = true;
        }
    }
    assertTrue(has1);
    assertTrue(has2);
    assertFalse(has3);
    // Check we correctly filter by node ID
    rd = replicationService.loadReplicationDefinition("Test1");
    response = sendRequest(new GetRequest(URL_RUNNING_ACTIONS + "?nodeRef=" + rd.getNodeRef().toString()), 200);
    assertEquals(Status.STATUS_OK, response.getStatus());
    jsonStr = response.getContentAsString();
    json = new JSONObject(jsonStr);
    results = json.getJSONArray("data");
    assertNotNull(results);
    assertEquals(1, results.length());
    jsonRD = (JSONObject) results.get(0);
    assertNotNull(jsonRD);
    assertEquals(id, jsonRD.get("actionId"));
    assertEquals(ReplicationDefinitionImpl.EXECUTOR_NAME, jsonRD.get("actionType"));
    assertEquals(instance, jsonRD.get("actionInstance"));
    assertEquals(rd.getNodeRef().toString(), jsonRD.get("actionNodeRef"));
    assertEquals(startedAt, jsonRD.get("startedAt"));
    assertEquals(true, jsonRD.getBoolean("cancelRequested"));
    assertEquals("/" + URL_RUNNING_ACTION + "replicationActionExecutor=" + id + "=" + instance, jsonRD.get("details"));
    // Check the other one
    rd = replicationService.loadReplicationDefinition("Test2");
    response = sendRequest(new GetRequest(URL_RUNNING_ACTIONS + "?nodeRef=" + rd.getNodeRef().toString()), 200);
    assertEquals(Status.STATUS_OK, response.getStatus());
    jsonStr = response.getContentAsString();
    json = new JSONObject(jsonStr);
    results = json.getJSONArray("data");
    assertNotNull(results);
    assertEquals(1, results.length());
    jsonRD = (JSONObject) results.get(0);
    assertNotNull(jsonRD);
    assertEquals(id2, jsonRD.get("actionId"));
    assertEquals(ReplicationDefinitionImpl.EXECUTOR_NAME, jsonRD.get("actionType"));
    assertEquals(instance2, jsonRD.get("actionInstance"));
    assertEquals(rd.getNodeRef().toString(), jsonRD.get("actionNodeRef"));
    assertEquals(startedAt2, jsonRD.get("startedAt"));
    assertEquals(false, jsonRD.getBoolean("cancelRequested"));
    assertEquals("/" + URL_RUNNING_ACTION + "replicationActionExecutor=" + id2 + "=" + instance2, jsonRD.get("details"));
    // Check we correctly filter by type
    ActionImpl alt1 = new ActionImpl(null, "12345", "MadeUp1");
    ActionImpl alt2 = new ActionImpl(null, "54321", "MadeUp2");
    actionTrackingService.recordActionExecuting(alt1);
    actionTrackingService.recordActionExecuting(alt2);
    String startAtAlt2 = ISO8601DateFormat.format(alt2.getExecutionStartDate());
    String instanceAlt2 = Integer.toString(alt2.getExecutionInstance());
    // Goes up to 4 not by type
    response = sendRequest(new GetRequest(URL_RUNNING_ACTIONS), 200);
    assertEquals(Status.STATUS_OK, response.getStatus());
    jsonStr = response.getContentAsString();
    json = new JSONObject(jsonStr);
    results = json.getJSONArray("data");
    assertNotNull(results);
    assertEquals(4, results.length());
    // 2 replication actions
    response = sendRequest(new GetRequest(URL_RUNNING_ACTIONS + "?type=replicationActionExecutor"), 200);
    assertEquals(Status.STATUS_OK, response.getStatus());
    jsonStr = response.getContentAsString();
    json = new JSONObject(jsonStr);
    results = json.getJSONArray("data");
    assertNotNull(results);
    assertEquals(2, results.length());
    // 0 if doesn't exist
    response = sendRequest(new GetRequest(URL_RUNNING_ACTIONS + "?type=MadeUp4"), 200);
    assertEquals(Status.STATUS_OK, response.getStatus());
    jsonStr = response.getContentAsString();
    json = new JSONObject(jsonStr);
    results = json.getJSONArray("data");
    assertNotNull(results);
    assertEquals(0, results.length());
    // 1 each of the made up ones
    response = sendRequest(new GetRequest(URL_RUNNING_ACTIONS + "?type=MadeUp1"), 200);
    assertEquals(Status.STATUS_OK, response.getStatus());
    jsonStr = response.getContentAsString();
    json = new JSONObject(jsonStr);
    results = json.getJSONArray("data");
    assertNotNull(results);
    assertEquals(1, results.length());
    response = sendRequest(new GetRequest(URL_RUNNING_ACTIONS + "?type=MadeUp2"), 200);
    assertEquals(Status.STATUS_OK, response.getStatus());
    jsonStr = response.getContentAsString();
    json = new JSONObject(jsonStr);
    results = json.getJSONArray("data");
    assertNotNull(results);
    assertEquals(1, results.length());
    // Check the details of one of these
    jsonRD = (JSONObject) results.get(0);
    assertNotNull(jsonRD);
    assertEquals("54321", jsonRD.get("actionId"));
    assertEquals("MadeUp2", jsonRD.get("actionType"));
    assertEquals(instanceAlt2, jsonRD.get("actionInstance"));
    assertEquals(JSONObject.NULL, jsonRD.get("actionNodeRef"));
    assertEquals(startAtAlt2, jsonRD.get("startedAt"));
    assertEquals(false, jsonRD.getBoolean("cancelRequested"));
    assertEquals("/" + URL_RUNNING_ACTION + "MadeUp2=54321=" + instanceAlt2, jsonRD.get("details"));
}
Also used : Response(org.springframework.extensions.webscripts.TestWebScriptServer.Response) UserTransaction(javax.transaction.UserTransaction) JSONObject(org.json.JSONObject) ReplicationDefinition(org.alfresco.service.cmr.replication.ReplicationDefinition) GetRequest(org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest) JSONArray(org.json.JSONArray) ActionImpl(org.alfresco.repo.action.ActionImpl)

Example 9 with GetRequest

use of org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest in project alfresco-remote-api by Alfresco.

the class RunningActionRestApiTest method testRunningReplicationActionsGet.

public void testRunningReplicationActionsGet() throws Exception {
    Response response;
    // Not allowed if you're not an admin
    AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getGuestUserName());
    response = sendRequest(new GetRequest(URL_RUNNING_REPLICATION_ACTIONS), Status.STATUS_UNAUTHORIZED);
    assertEquals(Status.STATUS_UNAUTHORIZED, response.getStatus());
    AuthenticationUtil.setFullyAuthenticatedUser(USER_NORMAL);
    response = sendRequest(new GetRequest(URL_RUNNING_REPLICATION_ACTIONS), Status.STATUS_UNAUTHORIZED);
    assertEquals(Status.STATUS_UNAUTHORIZED, response.getStatus());
    // If nothing running, you don't get anything back
    AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
    response = sendRequest(new GetRequest(URL_RUNNING_REPLICATION_ACTIONS), 200);
    assertEquals(Status.STATUS_OK, response.getStatus());
    String jsonStr = response.getContentAsString();
    JSONObject json = new JSONObject(jsonStr);
    JSONArray results = json.getJSONArray("data");
    assertNotNull(results);
    assertEquals(0, results.length());
    // Add a running action, it should show up
    ReplicationDefinition rd = replicationService.createReplicationDefinition("Test1", "Testing");
    replicationService.saveReplicationDefinition(rd);
    actionTrackingService.recordActionExecuting(rd);
    String id = rd.getId();
    String instance = Integer.toString(((ActionImpl) rd).getExecutionInstance());
    String startedAt = ISO8601DateFormat.format(rd.getExecutionStartDate());
    response = sendRequest(new GetRequest(URL_RUNNING_REPLICATION_ACTIONS), 200);
    assertEquals(Status.STATUS_OK, response.getStatus());
    jsonStr = response.getContentAsString();
    json = new JSONObject(jsonStr);
    results = json.getJSONArray("data");
    assertNotNull(results);
    assertEquals(1, results.length());
    JSONObject jsonRD = (JSONObject) results.get(0);
    assertNotNull(jsonRD);
    assertEquals(id, jsonRD.get("actionId"));
    assertEquals(ReplicationDefinitionImpl.EXECUTOR_NAME, jsonRD.get("actionType"));
    assertEquals(instance, jsonRD.get("actionInstance"));
    assertEquals(rd.getNodeRef().toString(), jsonRD.get("actionNodeRef"));
    assertEquals(startedAt, jsonRD.get("startedAt"));
    assertEquals(false, jsonRD.getBoolean("cancelRequested"));
    assertEquals("/" + URL_RUNNING_ACTION + "replicationActionExecutor=" + id + "=" + instance, jsonRD.get("details"));
    // Ensure we didn't get any unexpected data back,
    // only the keys we should have done
    JSONArray keys = jsonRD.names();
    for (int i = 0; i < keys.length(); i++) {
        String key = keys.getString(0);
        if (key.equals("actionId") || key.equals("actionType") || key.equals("actionInstance") || key.equals("actionNodeRef") || key.equals("startedAt") || key.equals("cancelRequested") || key.equals("details")) {
        // All good
        } else {
            fail("Unexpected key '" + key + "' found in json, raw json is\n" + jsonStr);
        }
    }
    // Change the status to pending cancel, and re-check
    actionTrackingService.requestActionCancellation(rd);
    response = sendRequest(new GetRequest(URL_RUNNING_REPLICATION_ACTIONS), 200);
    assertEquals(Status.STATUS_OK, response.getStatus());
    jsonStr = response.getContentAsString();
    json = new JSONObject(jsonStr);
    results = json.getJSONArray("data");
    assertNotNull(results);
    assertEquals(1, results.length());
    jsonRD = (JSONObject) results.get(0);
    assertNotNull(jsonRD);
    assertEquals(id, jsonRD.get("actionId"));
    assertEquals(ReplicationDefinitionImpl.EXECUTOR_NAME, jsonRD.get("actionType"));
    assertEquals(instance, jsonRD.get("actionInstance"));
    assertEquals(rd.getNodeRef().toString(), jsonRD.get("actionNodeRef"));
    assertEquals(startedAt, jsonRD.get("startedAt"));
    assertEquals(true, jsonRD.getBoolean("cancelRequested"));
    assertEquals("/" + URL_RUNNING_ACTION + "replicationActionExecutor=" + id + "=" + instance, jsonRD.get("details"));
    // Add a 2nd and 3rd, one running and one pending
    rd = replicationService.createReplicationDefinition("Test2", "2nd Testing");
    replicationService.saveReplicationDefinition(rd);
    actionTrackingService.recordActionExecuting(rd);
    String id2 = rd.getId();
    @SuppressWarnings("unused") String instance2 = Integer.toString(((ActionImpl) rd).getExecutionInstance());
    @SuppressWarnings("unused") String startedAt2 = ISO8601DateFormat.format(rd.getExecutionStartDate());
    rd = replicationService.createReplicationDefinition("AnotherTest", "3rd Testing");
    replicationService.saveReplicationDefinition(rd);
    actionTrackingService.recordActionPending(rd);
    String id3 = rd.getId();
    // Check we got all 3
    boolean has1 = false;
    boolean has2 = false;
    boolean has3 = false;
    response = sendRequest(new GetRequest(URL_RUNNING_REPLICATION_ACTIONS), 200);
    assertEquals(Status.STATUS_OK, response.getStatus());
    jsonStr = response.getContentAsString();
    json = new JSONObject(jsonStr);
    results = json.getJSONArray("data");
    assertNotNull(results);
    assertEquals(3, results.length());
    for (int i = 0; i < 3; i++) {
        jsonRD = (JSONObject) results.get(i);
        if (jsonRD.get("actionId").equals(id)) {
            has1 = true;
        }
        if (jsonRD.get("actionId").equals(id2)) {
            has2 = true;
        }
        if (jsonRD.get("actionId").equals(id3)) {
            has3 = true;
        }
    }
    assertTrue(has1);
    assertTrue(has2);
    assertTrue(has3);
    // Remove one, check it goes
    UserTransaction txn = transactionService.getUserTransaction();
    txn.begin();
    actionTrackingService.recordActionComplete(rd);
    txn.commit();
    has1 = false;
    has2 = false;
    has3 = false;
    response = sendRequest(new GetRequest(URL_RUNNING_REPLICATION_ACTIONS), 200);
    assertEquals(Status.STATUS_OK, response.getStatus());
    jsonStr = response.getContentAsString();
    json = new JSONObject(jsonStr);
    results = json.getJSONArray("data");
    assertNotNull(results);
    assertEquals(2, results.length());
    for (int i = 0; i < 2; i++) {
        jsonRD = (JSONObject) results.get(i);
        if (jsonRD.get("actionId").equals(id)) {
            has1 = true;
        }
        if (jsonRD.get("actionId").equals(id2)) {
            has2 = true;
        }
        if (jsonRD.get("actionId").equals(id3)) {
            has3 = true;
        }
    }
    assertTrue(has1);
    assertTrue(has2);
    assertFalse(has3);
    // Check we correctly filter by name
    rd = replicationService.loadReplicationDefinition("Test1");
    response = sendRequest(new GetRequest(URL_RUNNING_REPLICATION_ACTIONS + "?name=Test1"), 200);
    assertEquals(Status.STATUS_OK, response.getStatus());
    jsonStr = response.getContentAsString();
    json = new JSONObject(jsonStr);
    results = json.getJSONArray("data");
    assertNotNull(results);
    assertEquals(1, results.length());
    jsonRD = (JSONObject) results.get(0);
    assertNotNull(jsonRD);
    assertEquals(id, jsonRD.get("actionId"));
    assertEquals(ReplicationDefinitionImpl.EXECUTOR_NAME, jsonRD.get("actionType"));
    assertEquals(instance, jsonRD.get("actionInstance"));
    assertEquals(rd.getNodeRef().toString(), jsonRD.get("actionNodeRef"));
    assertEquals(startedAt, jsonRD.get("startedAt"));
    assertEquals(true, jsonRD.getBoolean("cancelRequested"));
    assertEquals("/" + URL_RUNNING_ACTION + "replicationActionExecutor=" + id + "=" + instance, jsonRD.get("details"));
    // Check we correctly filter by type
    ActionImpl alt1 = new ActionImpl(null, "12345", "MadeUp1");
    ActionImpl alt2 = new ActionImpl(null, "54321", "MadeUp2");
    actionTrackingService.recordActionExecuting(alt1);
    actionTrackingService.recordActionExecuting(alt2);
    @SuppressWarnings("unused") String startAtAlt2 = ISO8601DateFormat.format(alt2.getExecutionStartDate());
    @SuppressWarnings("unused") String instanceAlt2 = Integer.toString(alt2.getExecutionInstance());
    // 2 replication actions
    response = sendRequest(new GetRequest(URL_RUNNING_REPLICATION_ACTIONS), 200);
    assertEquals(Status.STATUS_OK, response.getStatus());
    jsonStr = response.getContentAsString();
    json = new JSONObject(jsonStr);
    results = json.getJSONArray("data");
    assertNotNull(results);
    assertEquals(2, results.length());
}
Also used : Response(org.springframework.extensions.webscripts.TestWebScriptServer.Response) UserTransaction(javax.transaction.UserTransaction) JSONObject(org.json.JSONObject) ReplicationDefinition(org.alfresco.service.cmr.replication.ReplicationDefinition) GetRequest(org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest) JSONArray(org.json.JSONArray) ActionImpl(org.alfresco.repo.action.ActionImpl)

Example 10 with GetRequest

use of org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest in project alfresco-remote-api by Alfresco.

the class FeedControlTest method testRetrieveFeedControls.

public void testRetrieveFeedControls() throws Exception {
    // Get (retrieve) feed controls
    int expectedStatus = 200;
    Response response = sendRequest(new GetRequest(URL_CONTROLS), expectedStatus);
    JSONArray result = new JSONArray(response.getContentAsString());
    if (logger.isDebugEnabled()) {
        logger.debug(result);
    }
    assertNotNull(result);
    assertEquals(3, result.length());
}
Also used : Response(org.springframework.extensions.webscripts.TestWebScriptServer.Response) GetRequest(org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest) JSONArray(org.json.JSONArray)

Aggregations

GetRequest (org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest)182 Response (org.springframework.extensions.webscripts.TestWebScriptServer.Response)171 JSONObject (org.json.JSONObject)141 JSONArray (org.json.JSONArray)89 PostRequest (org.springframework.extensions.webscripts.TestWebScriptServer.PostRequest)25 HashMap (java.util.HashMap)23 JSONTokener (org.json.JSONTokener)23 DeleteRequest (org.springframework.extensions.webscripts.TestWebScriptServer.DeleteRequest)21 PutRequest (org.springframework.extensions.webscripts.TestWebScriptServer.PutRequest)17 NodeRef (org.alfresco.service.cmr.repository.NodeRef)14 Serializable (java.io.Serializable)13 WorkflowDefinition (org.alfresco.service.cmr.workflow.WorkflowDefinition)13 QName (org.alfresco.service.namespace.QName)13 ArrayList (java.util.ArrayList)12 WorkflowPath (org.alfresco.service.cmr.workflow.WorkflowPath)12 Date (java.util.Date)11 WorkflowTask (org.alfresco.service.cmr.workflow.WorkflowTask)11 JSONStringer (org.json.JSONStringer)7 Calendar (java.util.Calendar)6 UserTransaction (javax.transaction.UserTransaction)6