in src/main/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/post/PostServletImportTest.java [173:226]
public void testImportReplaceProperties() throws IOException, JsonException {
final String testPath = TEST_BASE_PATH;
Map<String, String> props = new HashMap<String, String>();
String testNode = testClient.createNode(HTTP_BASE_URL + testPath, props);
urlsToDelete.add(testNode);
//1. First import some initial content
props.clear();
props.put(SlingPostConstants.RP_OPERATION,
SlingPostConstants.OPERATION_IMPORT);
String testNodeName = "testNode_" + String.valueOf(random.nextInt());
props.put(SlingPostConstants.RP_NODE_NAME_HINT, testNodeName);
String jsonContent = getStreamAsString(getClass().getResourceAsStream("/integration-test/servlets/post/testimport.json"));
props.put(SlingPostConstants.RP_CONTENT, jsonContent);
props.put(SlingPostConstants.RP_CONTENT_TYPE, "json");
props.put(SlingPostConstants.RP_REDIRECT_TO, SERVLET_CONTEXT + testPath + "/*");
String importedNodeUrl = testClient.createNode(HTTP_BASE_URL + testPath, props);
// assert content at new location
String content = getContent(importedNodeUrl + ".3.json", CONTENT_TYPE_JSON);
JsonObject jsonObj = JsonUtil.parseObject(content);
assertNotNull(jsonObj);
//assert the imported content is there.
String expectedJsonContent = getStreamAsString(getClass().getResourceAsStream("/integration-test/servlets/post/importresults.json"));
assertExpectedJSON(JsonUtil.parseObject(expectedJsonContent), jsonObj);
//2. Second, import on top of the node from #1 to replace some properties.
props.clear();
props.put(SlingPostConstants.RP_OPERATION,
SlingPostConstants.OPERATION_IMPORT);
String jsonContent2 = getStreamAsString(getClass().getResourceAsStream("/integration-test/servlets/post/testimport_replaceProps.json"));
props.put(SlingPostConstants.RP_CONTENT, jsonContent2);
props.put(SlingPostConstants.RP_CONTENT_TYPE, "json");
props.put(SlingPostConstants.RP_REPLACE, "false");
props.put(SlingPostConstants.RP_REPLACE_PROPERTIES, "true");
testClient.createNode(importedNodeUrl, props);
// assert content at new location
String content2 = getContent(importedNodeUrl + ".3.json", CONTENT_TYPE_JSON);
JsonObject jsonObj2 = JsonUtil.parseObject(content2);
assertNotNull(jsonObj2);
//assert the imported content is there.
String expectedJsonContent2 = getStreamAsString(getClass().getResourceAsStream("/integration-test/servlets/post/testimport_replaceProps.json"));
assertExpectedJSON(JsonUtil.parseObject(expectedJsonContent2), jsonObj2);
}