You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ju...@apache.org on 2010/02/23 20:00:59 UTC
svn commit: r915490 -
/sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/post/ReferenceTypeHintTest.java
Author: justin
Date: Tue Feb 23 19:00:58 2010
New Revision: 915490
URL: http://svn.apache.org/viewvc?rev=915490&view=rev
Log:
SLING-1333 - adding multi-valued test post SLING-1407 addition
Modified:
sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/post/ReferenceTypeHintTest.java
Modified: sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/post/ReferenceTypeHintTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/post/ReferenceTypeHintTest.java?rev=915490&r1=915489&r2=915490&view=diff
==============================================================================
--- sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/post/ReferenceTypeHintTest.java (original)
+++ sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/post/ReferenceTypeHintTest.java Tue Feb 23 19:00:58 2010
@@ -19,7 +19,10 @@
import java.util.HashMap;
import java.util.Map;
+import org.apache.sling.commons.json.JSONArray;
+import org.apache.sling.commons.json.JSONObject;
import org.apache.sling.commons.testing.integration.HttpTestBase;
+import org.apache.sling.commons.testing.integration.NameValuePairList;
import org.apache.sling.servlets.post.SlingPostConstants;
/**
@@ -36,35 +39,44 @@
}
public void testReferenceTypes() throws Exception {
- final Map<String, String> props = new HashMap<String, String>();
- props.put("a", "");
- props.put("jcr:mixinTypes", "mix:referenceable");
+ final NameValuePairList props = new NameValuePairList();
+ props.add("a", "");
+ props.add("jcr:mixinTypes", "mix:referenceable");
- final String firstCreatedNodeUrl = testClient.createNode(postUrl + SlingPostConstants.DEFAULT_CREATE_SUFFIX, props);
+ final String firstCreatedNodeUrl = testClient.createNode(postUrl + SlingPostConstants.DEFAULT_CREATE_SUFFIX, props, null, false);
final String firstUuid = getProperty(firstCreatedNodeUrl, "jcr:uuid");
final String firstPath = getPath(firstCreatedNodeUrl);
- final String secondCreatedNodeUrl = testClient.createNode(postUrl + SlingPostConstants.DEFAULT_CREATE_SUFFIX, props);
- final String secondUuid = getProperty(firstCreatedNodeUrl, "jcr:uuid");
- final String secondPath = getPath(firstCreatedNodeUrl);
+ final String secondCreatedNodeUrl = testClient.createNode(postUrl + SlingPostConstants.DEFAULT_CREATE_SUFFIX, props, null, false);
+ final String secondUuid = getProperty(secondCreatedNodeUrl, "jcr:uuid");
+ final String secondPath = getPath(secondCreatedNodeUrl);
props.clear();
- props.put("a", firstPath);
- props.put("a@TypeHint", "Reference");
- props.put("b", firstPath);
- props.put("b@TypeHint", "WeakReference");
- props.put("as", firstPath);
- props.put("as@TypeHint", "Reference");
- props.put("bs", firstPath);
- props.put("bs@TypeHint", "WeakReference");
+ props.add("r", firstPath);
+ props.add("r@TypeHint", "Reference");
+ props.add("w", firstPath);
+ props.add("w@TypeHint", "WeakReference");
+ props.add("rs", firstPath);
+ props.add("rs", secondPath);
+ props.add("rs@TypeHint", "Reference");
+ props.add("ws", firstPath);
+ props.add("ws", secondPath);
+ props.add("ws@TypeHint", "WeakReference");
final String referencingNodeUrl = testClient.createNode(postUrl + SlingPostConstants.DEFAULT_CREATE_SUFFIX,
- props);
+ props, null, false);
- String refCreatedValue = getProperty(referencingNodeUrl, "a");
- String weakrefCreatedValue = getProperty(referencingNodeUrl, "b");
+ String refCreatedValue = getProperty(referencingNodeUrl, "r");
+ String weakrefCreatedValue = getProperty(referencingNodeUrl, "w");
+
+ String[] refCreatedValues = getPropertyArray(referencingNodeUrl, "rs");
+ String[] weakrefCreatedValues = getPropertyArray(referencingNodeUrl, "ws");
assertEquals(firstUuid, refCreatedValue);
assertEquals(firstUuid, weakrefCreatedValue);
+ assertEquals(firstUuid, refCreatedValues[0]);
+ assertEquals(firstUuid, weakrefCreatedValues[0]);
+ assertEquals(secondUuid, refCreatedValues[1]);
+ assertEquals(secondUuid, weakrefCreatedValues[1]);
}
private String getPath(String url) {
@@ -74,4 +86,14 @@
private String getProperty(String url, String name) throws Exception {
return getContent(url + "/" + name + ".txt", CONTENT_TYPE_PLAIN);
}
+
+ private String[] getPropertyArray(String url, String name) throws Exception {
+ JSONObject jo = new JSONObject(getContent(url + "/" + name + ".json", CONTENT_TYPE_JSON));
+ JSONArray arr = jo.getJSONArray(name);
+ String[] result = new String[arr.length()];
+ for (int i = 0; i < arr.length(); i++) {
+ result[i] = arr.getString(i);
+ }
+ return result;
+ }
}