use of org.springframework.extensions.webscripts.TestWebScriptServer.Response in project alfresco-remote-api by Alfresco.
the class SOLRWebScriptTest method DISABLED_testGetContent.
public void DISABLED_testGetContent() throws Exception {
long nodeId = -1l;
String propertyName = ContentModel.PROP_CONTENT.toString();
buildTransactions3();
String url = "/api/solr/content?nodeId=" + nodeId + "&propertyName=" + propertyName;
TestWebScriptServer.GetRequest req = new TestWebScriptServer.GetRequest(url);
Response response = sendRequest(req, Status.STATUS_OK, admin);
if (logger.isDebugEnabled()) {
logger.debug("content1 = " + response.getContentAsString());
}
assertEquals("Content length is incorrect", "test content".length(), response.getContentLength());
}
use of org.springframework.extensions.webscripts.TestWebScriptServer.Response in project alfresco-remote-api by Alfresco.
the class SOLRWebScriptTest method getNodesMetaData.
private JSONArray getNodesMetaData(List<Long> nodeIds, int maxResults, int numMetaDataNodes) throws Exception {
StringBuilder url = new StringBuilder("/api/solr/metadata");
JSONObject json = new JSONObject();
if (nodeIds != null && nodeIds.size() > 0) {
JSONArray array = new JSONArray();
for (Long nodeId : nodeIds) {
array.put(nodeId);
}
json.put("nodeIds", array);
}
json.put("maxResults", maxResults);
TestWebScriptServer.PostRequest req = new TestWebScriptServer.PostRequest(url.toString(), json.toString(), "application/json");
long startTime = System.currentTimeMillis();
Response response = sendRequest(req, Status.STATUS_OK, admin);
long endTime = System.currentTimeMillis();
String content = response.getContentAsString();
if (logger.isDebugEnabled()) {
logger.debug("nodesMetaData = " + content);
}
JSONObject jsonResponse = null;
try {
jsonResponse = new JSONObject(content);
} catch (JSONException e) {
fail(e.getMessage());
}
JSONArray nodes = jsonResponse.getJSONArray("nodes");
logger.debug("Got metadata for " + nodes.length() + " nodes in " + (endTime - startTime) + " ms");
assertEquals("Number of returned nodes is incorrect", numMetaDataNodes, nodes.length());
return nodes;
}
use of org.springframework.extensions.webscripts.TestWebScriptServer.Response in project alfresco-remote-api by Alfresco.
the class SOLRWebScriptTest method getTransactions.
private JSONArray getTransactions(long fromCommitTime) throws Exception {
String url = "/api/solr/transactions?fromCommitTime=" + fromCommitTime;
TestWebScriptServer.GetRequest req = new TestWebScriptServer.GetRequest(url);
long startTime = System.currentTimeMillis();
Response response = sendRequest(req, Status.STATUS_OK, admin);
long endTime = System.currentTimeMillis();
if (logger.isDebugEnabled()) {
logger.debug(response.getContentAsString());
}
JSONObject json = new JSONObject(response.getContentAsString());
JSONArray transactions = json.getJSONArray("transactions");
logger.debug("Got " + transactions.length() + " txns in " + (endTime - startTime) + " ms");
return transactions;
}
use of org.springframework.extensions.webscripts.TestWebScriptServer.Response in project alfresco-remote-api by Alfresco.
the class CustomModelImportTest method testValidUpload_ExtModuleOnly.
public void testValidUpload_ExtModuleOnly() throws Exception {
File zipFile = getResourceFile("validExtModule.zip");
PostRequest postRequest = buildMultipartPostRequest(zipFile);
AuthenticationUtil.setFullyAuthenticatedUser(NON_ADMIN_USER);
Response response = sendRequest(postRequest, 403);
AuthenticationUtil.setFullyAuthenticatedUser(CUSTOM_MODEL_ADMIN);
response = sendRequest(postRequest, 200);
JSONObject json = new JSONObject(new JSONTokener(response.getContentAsString()));
assertFalse(json.has("modelName"));
String extModule = json.getString("shareExtModule");
Document document = XMLUtil.parse(extModule);
NodeList nodes = document.getElementsByTagName("id");
assertEquals(1, nodes.getLength());
assertNotNull(nodes.item(0).getTextContent());
}
use of org.springframework.extensions.webscripts.TestWebScriptServer.Response in project alfresco-remote-api by Alfresco.
the class CustomModelImportTest method testValidUpload_ModelAndExtModule.
public void testValidUpload_ModelAndExtModule() throws Exception {
File zipFile = getResourceFile("validModelAndExtModule.zip");
PostRequest postRequest = buildMultipartPostRequest(zipFile);
AuthenticationUtil.setFullyAuthenticatedUser(NON_ADMIN_USER);
Response response = sendRequest(postRequest, 403);
AuthenticationUtil.setFullyAuthenticatedUser(CUSTOM_MODEL_ADMIN);
response = sendRequest(postRequest, 200);
JSONObject json = new JSONObject(new JSONTokener(response.getContentAsString()));
String importedModelName = json.getString("modelName");
importedModels.add(importedModelName);
String extModule = json.getString("shareExtModule");
Document document = XMLUtil.parse(extModule);
NodeList nodes = document.getElementsByTagName("id");
assertEquals(1, nodes.getLength());
assertNotNull(nodes.item(0).getTextContent());
}
Aggregations