Search in sources :

Example 91 with GetRequest

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

the class SubscriptionServiceRestApiTest method getFollowersCount.

protected int getFollowersCount(String user) throws Exception {
    String url = getUrl(URL_FOLLOWERS_COUNT, user);
    Response response = sendRequest(new GetRequest(url), Status.STATUS_OK);
    JSONObject resultObject = new JSONObject(response.getContentAsString());
    assertTrue(resultObject.has("count"));
    return resultObject.getInt("count");
}
Also used : Response(org.springframework.extensions.webscripts.TestWebScriptServer.Response) JSONObject(org.json.JSONObject) GetRequest(org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest)

Example 92 with GetRequest

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

the class TaggingServiceTest method testGetNodes.

public void testGetNodes() throws Exception {
    Response response = sendRequest(new GetRequest("/api/tags/" + StoreRef.PROTOCOL_WORKSPACE + "/SpacesStore/" + TAG_1 + "/nodes"), 200);
    JSONArray jsonArray = new JSONArray(response.getContentAsString());
    assertNotNull(jsonArray);
    assertEquals(1, jsonArray.length());
    System.out.println(response.getContentAsString());
    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 = sendRequest(new GetRequest("/api/tags/" + StoreRef.PROTOCOL_WORKSPACE + "/SpacesStore/jumk/nodes"), 200);
    jsonArray = new JSONArray(response.getContentAsString());
    assertNotNull(jsonArray);
    assertEquals(0, jsonArray.length());
}
Also used : Response(org.springframework.extensions.webscripts.TestWebScriptServer.Response) GetRequest(org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest) JSONArray(org.json.JSONArray)

Example 93 with GetRequest

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

the class TaggingServiceTest method testGetTags.

public void testGetTags() throws Exception {
    Response response = sendRequest(new GetRequest("/api/tags/" + StoreRef.PROTOCOL_WORKSPACE + "/SpacesStore"), 200);
    JSONArray jsonArray = new JSONArray(response.getContentAsString());
    // make sure there are results
    assertNotNull(jsonArray);
    assertTrue(jsonArray.length() > 0);
    response = sendRequest(new GetRequest("/api/tags/" + StoreRef.PROTOCOL_WORKSPACE + "/SpacesStore?tf=one"), 200);
    jsonArray = new JSONArray(response.getContentAsString());
    // make sure there are results
    assertNotNull(jsonArray);
    assertTrue(jsonArray.length() > 0);
    response = sendRequest(new GetRequest("/api/tags/" + StoreRef.PROTOCOL_WORKSPACE + "/SpacesStore?tf=none"), 200);
    jsonArray = new JSONArray(response.getContentAsString());
    // make sure there are no results
    assertNotNull(jsonArray);
    assertEquals(0, jsonArray.length());
}
Also used : Response(org.springframework.extensions.webscripts.TestWebScriptServer.Response) GetRequest(org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest) JSONArray(org.json.JSONArray)

Example 94 with GetRequest

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

the class ThumbnailServiceTest method getWait.

private void getWait(NodeRef node, String thumbnailName) throws Exception {
    String url = "/api/node/" + node.getStoreRef().getProtocol() + "/" + node.getStoreRef().getIdentifier() + "/" + node.getId() + "/content/thumbnails/" + thumbnailName;
    int retries = 50;
    int tries = 0;
    while (true) {
        if (tries >= retries) {
            fail("Thumbnail never gets created " + thumbnailName);
        }
        Response response = sendRequest(new GetRequest(url), 0);
        if (response.getStatus() == 200) {
            break;
        } else if (response.getStatus() == 500) {
            System.out.println("Error during getWait: " + response.getContentAsString());
            fail("A 500 status was found whilst waiting for the thumbnail to be processed");
        } else {
            Thread.sleep(100);
        }
        tries++;
    }
}
Also used : Response(org.springframework.extensions.webscripts.TestWebScriptServer.Response) GetRequest(org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest)

Example 95 with GetRequest

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

the class ThumbnailServiceTest method testCreateThumbnailInReadonlyMode.

public void testCreateThumbnailInReadonlyMode() throws Exception {
    createUser(USER_ALFRESCO);
    AuthenticationUtil.setFullyAuthenticatedUser(USER_ALFRESCO);
    this.transactionService.setAllowWrite(false);
    // do pdfToSWF transformation in read-only
    if (this.contentService.getTransformer(MimetypeMap.MIMETYPE_PDF, MimetypeMap.MIMETYPE_FLASH) != null) {
        // in share creation of thumbnail for webpreview is forced
        String url = "/api/node/" + pdfNode.getStoreRef().getProtocol() + "/" + pdfNode.getStoreRef().getIdentifier() + "/" + pdfNode.getId() + "/content/thumbnails/webpreview?c=force";
        JSONObject tn = new JSONObject();
        tn.put("thumbnailName", "webpreview");
        sendRequest(new GetRequest(url), 200, USER_ALFRESCO);
    }
    this.transactionService.setAllowWrite(true);
    // Check getAll whilst we are here
    Response getAllResp = sendRequest(new GetRequest(getThumbnailsURL(jpgNode)), 200);
    JSONArray getArr = new JSONArray(getAllResp.getContentAsString());
    assertNotNull(getArr);
    assertEquals(0, getArr.length());
}
Also used : Response(org.springframework.extensions.webscripts.TestWebScriptServer.Response) JSONObject(org.json.JSONObject) 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