use of org.apache.commons.httpclient.NameValuePair in project sling by apache.
the class PostServletDeleteTest method testDeleteAllChildrenByPath.
/**
* Test for SLING-2415 Ability to delete child nodes, without deleting the parent node
* Using :applyTo value of "/*"
*/
public void testDeleteAllChildrenByPath() throws IOException {
final String urlA = testClient.createNode(postUrl + SlingPostConstants.DEFAULT_CREATE_SUFFIX, null);
final String urlB = testClient.createNode(postUrl + SlingPostConstants.DEFAULT_CREATE_SUFFIX, null);
final String urlC = testClient.createNode(postUrl + SlingPostConstants.DEFAULT_CREATE_SUFFIX, null);
final String urlD = testClient.createNode(postUrl + "/specific-location/for-delete", null);
// initially all nodes must be found
assertHttpStatus(urlA + DEFAULT_EXT, HttpServletResponse.SC_OK, "A must initially exist");
assertHttpStatus(urlB + DEFAULT_EXT, HttpServletResponse.SC_OK, "B must initially exist");
assertHttpStatus(urlC + DEFAULT_EXT, HttpServletResponse.SC_OK, "C must initially exist");
assertHttpStatus(urlD + DEFAULT_EXT, HttpServletResponse.SC_OK, "D must initially exist");
// delete and check
final List<NameValuePair> params = new LinkedList<NameValuePair>();
params.add(new NameValuePair(SlingPostConstants.RP_OPERATION, SlingPostConstants.OPERATION_DELETE));
params.add(new NameValuePair(SlingPostConstants.RP_APPLY_TO, "/*"));
assertPostStatus(postUrl, HttpServletResponse.SC_OK, params, "Delete must return expected status");
assertHttpStatus(urlA + DEFAULT_EXT, HttpServletResponse.SC_NOT_FOUND, "A must be deleted");
assertHttpStatus(urlB + DEFAULT_EXT, HttpServletResponse.SC_NOT_FOUND, "B must be deleted");
assertHttpStatus(urlC + DEFAULT_EXT, HttpServletResponse.SC_NOT_FOUND, "C must be deleted");
assertHttpStatus(urlD + DEFAULT_EXT, HttpServletResponse.SC_NOT_FOUND, "D must be deleted");
}
use of org.apache.commons.httpclient.NameValuePair in project sling by apache.
the class PostServletDeleteTest method testDelete.
public void testDelete() throws IOException {
final String urlA = testClient.createNode(postUrl + SlingPostConstants.DEFAULT_CREATE_SUFFIX, null);
final String urlB = testClient.createNode(postUrl + SlingPostConstants.DEFAULT_CREATE_SUFFIX, null);
final String urlC = testClient.createNode(postUrl + SlingPostConstants.DEFAULT_CREATE_SUFFIX, null);
final String urlD = testClient.createNode(postUrl + "/specific-location/for-delete", null);
// initially all nodes must be found
assertHttpStatus(urlA + DEFAULT_EXT, HttpServletResponse.SC_OK, "A must initially exist");
assertHttpStatus(urlB + DEFAULT_EXT, HttpServletResponse.SC_OK, "B must initially exist");
assertHttpStatus(urlC + DEFAULT_EXT, HttpServletResponse.SC_OK, "C must initially exist");
assertHttpStatus(urlD + DEFAULT_EXT, HttpServletResponse.SC_OK, "D must initially exist");
// delete one and check
final List<NameValuePair> params = new LinkedList<NameValuePair>();
params.add(new NameValuePair(SlingPostConstants.RP_OPERATION, SlingPostConstants.OPERATION_DELETE));
assertPostStatus(urlA, HttpServletResponse.SC_OK, params, "Delete must return expected status (3)");
assertHttpStatus(urlA + DEFAULT_EXT, HttpServletResponse.SC_NOT_FOUND, "A must be deleted (1)");
assertHttpStatus(urlB + DEFAULT_EXT, HttpServletResponse.SC_OK, "B must still exist");
assertHttpStatus(urlC + DEFAULT_EXT, HttpServletResponse.SC_OK, "C must still exist");
assertHttpStatus(urlD + DEFAULT_EXT, HttpServletResponse.SC_OK, "D must still exist");
// delete the others with successive requests
assertPostStatus(urlB, HttpServletResponse.SC_OK, params, "Delete must return expected status (2)");
assertPostStatus(urlC, HttpServletResponse.SC_OK, params, "Delete must return expected status (2)");
assertPostStatus(urlD, HttpServletResponse.SC_OK, params, "Delete must return expected status (2)");
assertHttpStatus(urlA + DEFAULT_EXT, HttpServletResponse.SC_NOT_FOUND, "A must be deleted (2)");
assertHttpStatus(urlB + DEFAULT_EXT, HttpServletResponse.SC_NOT_FOUND, "B must be deleted (2)");
assertHttpStatus(urlC + DEFAULT_EXT, HttpServletResponse.SC_NOT_FOUND, "C must be deleted (2)");
assertHttpStatus(urlD + DEFAULT_EXT, HttpServletResponse.SC_NOT_FOUND, "D must be deleted (2)");
// attempting to delete non-existing nodes is ok
assertPostStatus(postUrl, HttpServletResponse.SC_OK, params, "Delete must return expected status (2)");
}
use of org.apache.commons.httpclient.NameValuePair in project sling by apache.
the class PostServletImportTest method testImportNodeWithAlreadyUsedExactName.
/**
* SLING-1091: test error reporting when attempting to import a node with an
* already used node name.
*/
public void testImportNodeWithAlreadyUsedExactName() throws IOException, JsonException {
String testNodeName = "alreadyUsedExactNodeName";
String location = importNodeWithExactName(testNodeName);
//try to create the same node again, since same name siblings are not allowed an error should be
// thrown
List<NameValuePair> postParams = new ArrayList<NameValuePair>();
postParams.add(new NameValuePair(SlingPostConstants.RP_NODE_NAME, testNodeName));
//expect a 500 status since the name is not unique
String postUrl = location.substring(0, location.lastIndexOf('/'));
assertPostStatus(postUrl + SlingPostConstants.DEFAULT_CREATE_SUFFIX, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, postParams, null);
}
use of org.apache.commons.httpclient.NameValuePair in project sling by apache.
the class PostServletCopyTest method testCopyAllChildrenByPath.
/**
* Test for SLING-2415 Ability to move all child nodes, without the parent node
* Using :applyTo value of "/*"
*/
public void testCopyAllChildrenByPath() throws IOException {
final String testPath = TEST_BASE_PATH + "/cpmultwc/" + System.currentTimeMillis();
final String testRoot = testClient.createNode(HTTP_BASE_URL + testPath, null);
// create multiple source nodes
Map<String, String> props = new HashMap<String, String>();
props.put("text", "Hello");
testClient.createNode(HTTP_BASE_URL + testPath + "/test/src1", props);
testClient.createNode(HTTP_BASE_URL + testPath + "/test/src2", props);
testClient.createNode(HTTP_BASE_URL + testPath + "/test/src3", props);
testClient.createNode(HTTP_BASE_URL + testPath + "/test/src4", props);
// create destination parent
testClient.createNode(HTTP_BASE_URL + testPath + "/dest", props);
// copy the src? nodes
List<NameValuePair> nvPairs = new ArrayList<NameValuePair>();
nvPairs.add(new NameValuePair(SlingPostConstants.RP_OPERATION, SlingPostConstants.OPERATION_COPY));
nvPairs.add(new NameValuePair(SlingPostConstants.RP_DEST, testPath + "/dest/"));
nvPairs.add(new NameValuePair(SlingPostConstants.RP_APPLY_TO, "/*"));
// we expect success
assertPostStatus(testRoot + "/test", HttpServletResponse.SC_OK, nvPairs, "Expecting Copy Success");
// assert existence of the src?/text properties
assertHttpStatus(HTTP_BASE_URL + testPath + "/dest/src1/text", HttpServletResponse.SC_OK);
assertHttpStatus(HTTP_BASE_URL + testPath + "/dest/src2/text", HttpServletResponse.SC_OK);
assertHttpStatus(HTTP_BASE_URL + testPath + "/dest/src3/text", HttpServletResponse.SC_OK);
assertHttpStatus(HTTP_BASE_URL + testPath + "/dest/src4/text", HttpServletResponse.SC_OK);
testClient.delete(testRoot);
}
use of org.apache.commons.httpclient.NameValuePair in project sling by apache.
the class PostServletCopyTest method testCopyAllChildrenOfSubNode.
/**
* Test for SLING-2415 Ability to copy all child nodes of a subnode, without the parent node
* Using :applyTo value of "subnode_path/*"
*/
public void testCopyAllChildrenOfSubNode() throws IOException {
final String testPath = TEST_BASE_PATH + "/cpmultwc/" + System.currentTimeMillis();
final String testRoot = testClient.createNode(HTTP_BASE_URL + testPath, null);
// create multiple source nodes
Map<String, String> props = new HashMap<String, String>();
props.put("text", "Hello");
testClient.createNode(HTTP_BASE_URL + testPath + "/test/src1", props);
testClient.createNode(HTTP_BASE_URL + testPath + "/test/src2", props);
testClient.createNode(HTTP_BASE_URL + testPath + "/test/src3", props);
testClient.createNode(HTTP_BASE_URL + testPath + "/test/src4", props);
// create destination parent
testClient.createNode(HTTP_BASE_URL + testPath + "/dest", props);
// copy the src? nodes
List<NameValuePair> nvPairs = new ArrayList<NameValuePair>();
nvPairs.add(new NameValuePair(SlingPostConstants.RP_OPERATION, SlingPostConstants.OPERATION_COPY));
nvPairs.add(new NameValuePair(SlingPostConstants.RP_DEST, testPath + "/dest/"));
nvPairs.add(new NameValuePair(SlingPostConstants.RP_APPLY_TO, "test/*"));
// we expect success
assertPostStatus(testRoot, HttpServletResponse.SC_OK, nvPairs, "Expecting Copy Success");
// assert existence of the src?/text properties
assertHttpStatus(HTTP_BASE_URL + testPath + "/dest/src1/text", HttpServletResponse.SC_OK);
assertHttpStatus(HTTP_BASE_URL + testPath + "/dest/src2/text", HttpServletResponse.SC_OK);
assertHttpStatus(HTTP_BASE_URL + testPath + "/dest/src3/text", HttpServletResponse.SC_OK);
assertHttpStatus(HTTP_BASE_URL + testPath + "/dest/src4/text", HttpServletResponse.SC_OK);
testClient.delete(testRoot);
}
Aggregations