You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by pa...@apache.org on 2017/06/01 19:28:23 UTC
svn commit: r1797248 [3/3] - in /sling/trunk/launchpad/integration-tests: ./
src/main/java/org/apache/sling/launchpad/webapp/integrationtest/
src/main/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/
src/main/java/org/apache/sling/...
Modified: sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/UserPrivilegesInfoTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/UserPrivilegesInfoTest.java?rev=1797248&r1=1797247&r2=1797248&view=diff
==============================================================================
--- sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/UserPrivilegesInfoTest.java (original)
+++ sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/UserPrivilegesInfoTest.java Thu Jun 1 19:28:22 2017
@@ -24,14 +24,15 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
+import javax.json.JsonException;
+import javax.json.JsonObject;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.httpclient.Credentials;
import org.apache.commons.httpclient.NameValuePair;
import org.apache.commons.httpclient.UsernamePasswordCredentials;
-import org.apache.sling.commons.json.JSONException;
-import org.apache.sling.commons.json.JSONObject;
import org.apache.sling.commons.testing.integration.HttpTest;
+import org.apache.sling.launchpad.webapp.integrationtest.util.JsonUtil;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -101,7 +102,7 @@ public class UserPrivilegesInfoTest {
* to add a new user.
*/
@Test
- public void testCanAddUser() throws JSONException, IOException {
+ public void testCanAddUser() throws JsonException, IOException {
testUserId = H.createTestUser();
String getUrl = HttpTest.HTTP_BASE_URL + "/system/userManager/user/" + testUserId + ".privileges-info.json";
@@ -111,7 +112,7 @@ public class UserPrivilegesInfoTest {
String json = H.getAuthenticatedContent(testUserCreds, getUrl, HttpTest.CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK);
assertNotNull(json);
- JSONObject jsonObj = new JSONObject(json);
+ JsonObject jsonObj = JsonUtil.parseObject(json);
assertEquals(false, jsonObj.getBoolean("canAddUser"));
}
@@ -121,7 +122,7 @@ public class UserPrivilegesInfoTest {
* to add a new group.
*/
@Test
- public void testCanAddGroup() throws IOException, JSONException {
+ public void testCanAddGroup() throws IOException, JsonException {
testUserId = H.createTestUser();
String getUrl = HttpTest.HTTP_BASE_URL + "/system/userManager/user/" + testUserId + ".privileges-info.json";
@@ -131,7 +132,7 @@ public class UserPrivilegesInfoTest {
String json = H.getAuthenticatedContent(testUserCreds, getUrl, HttpTest.CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK);
assertNotNull(json);
- JSONObject jsonObj = new JSONObject(json);
+ JsonObject jsonObj = JsonUtil.parseObject(json);
assertEquals(false, jsonObj.getBoolean("canAddGroup"));
}
@@ -141,7 +142,7 @@ public class UserPrivilegesInfoTest {
* to update the properties of the specified user.
*/
@Test
- public void testCanUpdateUserProperties() throws IOException, JSONException {
+ public void testCanUpdateUserProperties() throws IOException, JsonException {
testUserId = H.createTestUser();
//1. verify user can update thier own properties
@@ -152,7 +153,7 @@ public class UserPrivilegesInfoTest {
String json = H.getAuthenticatedContent(testUserCreds, getUrl, HttpTest.CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK);
assertNotNull(json);
- JSONObject jsonObj = new JSONObject(json);
+ JsonObject jsonObj = JsonUtil.parseObject(json);
//user can update their own properties
assertEquals(true, jsonObj.getBoolean("canUpdateProperties"));
@@ -166,7 +167,7 @@ public class UserPrivilegesInfoTest {
String json2 = H.getAuthenticatedContent(testUser2Creds, getUrl, HttpTest.CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK);
assertNotNull(json2);
- JSONObject jsonObj2 = new JSONObject(json2);
+ JsonObject jsonObj2 = JsonUtil.parseObject(json2);
//user can not update other users properties
assertEquals(false, jsonObj2.getBoolean("canUpdateProperties"));
@@ -177,7 +178,7 @@ public class UserPrivilegesInfoTest {
* to update the properties of the specified group.
*/
@Test
- public void testCanUpdateGroupProperties() throws IOException, JSONException {
+ public void testCanUpdateGroupProperties() throws IOException, JsonException {
testGroupId = H.createTestGroup();
testUserId = H.createTestUser();
@@ -189,7 +190,7 @@ public class UserPrivilegesInfoTest {
String json = H.getAuthenticatedContent(testUserCreds, getUrl, HttpTest.CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK);
assertNotNull(json);
- JSONObject jsonObj = new JSONObject(json);
+ JsonObject jsonObj = JsonUtil.parseObject(json);
//normal user can not update group properties
assertEquals(false, jsonObj.getBoolean("canUpdateProperties"));
@@ -200,7 +201,7 @@ public class UserPrivilegesInfoTest {
* to remove the specified user.
*/
@Test
- public void testCanRemoveUser() throws IOException, JSONException {
+ public void testCanRemoveUser() throws IOException, JsonException {
testUserId = H.createTestUser();
//1. verify user can not remove themselves
@@ -211,7 +212,7 @@ public class UserPrivilegesInfoTest {
String json = H.getAuthenticatedContent(testUserCreds, getUrl, HttpTest.CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK);
assertNotNull(json);
- JSONObject jsonObj = new JSONObject(json);
+ JsonObject jsonObj = JsonUtil.parseObject(json);
//user can not remove themselves
assertEquals(false, jsonObj.getBoolean("canRemove"));
@@ -225,7 +226,7 @@ public class UserPrivilegesInfoTest {
String json2 = H.getAuthenticatedContent(testUser2Creds, getUrl, HttpTest.CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK);
assertNotNull(json2);
- JSONObject jsonObj2 = new JSONObject(json2);
+ JsonObject jsonObj2 = JsonUtil.parseObject(json2);
//user can not delete other users
assertEquals(false, jsonObj2.getBoolean("canRemove"));
@@ -236,7 +237,7 @@ public class UserPrivilegesInfoTest {
* to remove the specified group.
*/
@Test
- public void testCanRemoveGroup() throws IOException, JSONException {
+ public void testCanRemoveGroup() throws IOException, JsonException {
testGroupId = H.createTestGroup();
testUserId = H.createTestUser();
@@ -248,7 +249,7 @@ public class UserPrivilegesInfoTest {
String json = H.getAuthenticatedContent(testUserCreds, getUrl, HttpTest.CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK);
assertNotNull(json);
- JSONObject jsonObj = new JSONObject(json);
+ JsonObject jsonObj = JsonUtil.parseObject(json);
//normal user can not remove group
assertEquals(false, jsonObj.getBoolean("canRemove"));
@@ -259,7 +260,7 @@ public class UserPrivilegesInfoTest {
* to update the membership of the specified group.
*/
@Test
- public void testCanUpdateGroupMembers() throws IOException, JSONException {
+ public void testCanUpdateGroupMembers() throws IOException, JsonException {
testGroupId = H.createTestGroup();
testUserId = H.createTestUser();
@@ -271,7 +272,7 @@ public class UserPrivilegesInfoTest {
String json = H.getAuthenticatedContent(testUserCreds, getUrl, HttpTest.CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK);
assertNotNull(json);
- JSONObject jsonObj = new JSONObject(json);
+ JsonObject jsonObj = JsonUtil.parseObject(json);
//normal user can not remove group
assertEquals(false, jsonObj.getBoolean("canUpdateGroupMembers"));
Modified: sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/util/EventsCounterUtil.java
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/util/EventsCounterUtil.java?rev=1797248&r1=1797247&r2=1797248&view=diff
==============================================================================
--- sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/util/EventsCounterUtil.java (original)
+++ sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/util/EventsCounterUtil.java Thu Jun 1 19:28:22 2017
@@ -20,8 +20,9 @@ package org.apache.sling.launchpad.webap
import java.io.IOException;
-import org.apache.sling.commons.json.JSONException;
-import org.apache.sling.commons.json.JSONObject;
+import javax.json.JsonException;
+import javax.json.JsonObject;
+
import org.apache.sling.commons.testing.integration.HttpTest;
import org.apache.sling.commons.testing.integration.HttpTestBase;
import org.apache.sling.testing.tools.retry.RetryLoop;
@@ -29,9 +30,9 @@ import org.apache.sling.testing.tools.re
/** Give access to info provided by the test-services EventsCounterServlet */
public class EventsCounterUtil {
- public static int getEventsCount(HttpTestBase b, String topic) throws JSONException, IOException {
- final JSONObject json = new JSONObject(b.getContent(HttpTest.HTTP_BASE_URL + "/testing/EventsCounter.json", HttpTest.CONTENT_TYPE_JSON));
- return json.has(topic) ? json.getInt(topic) : 0;
+ public static int getEventsCount(HttpTestBase b, String topic) throws JsonException, IOException {
+ final JsonObject json = JsonUtil.parseObject(b.getContent(HttpTest.HTTP_BASE_URL + "/testing/EventsCounter.json", HttpTest.CONTENT_TYPE_JSON));
+ return json.containsKey(topic) ? json.getInt(topic) : 0;
}
public static void waitForEvent(final HttpTestBase b, final String topic, int timeoutSeconds, final int previousCount) {
Modified: sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/util/RepositoryTestUtil.java
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/util/RepositoryTestUtil.java?rev=1797248&r1=1797247&r2=1797248&view=diff
==============================================================================
--- sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/util/RepositoryTestUtil.java (original)
+++ sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/util/RepositoryTestUtil.java Thu Jun 1 19:28:22 2017
@@ -20,8 +20,9 @@ package org.apache.sling.launchpad.webap
import java.io.IOException;
-import org.apache.sling.commons.json.JSONException;
-import org.apache.sling.commons.json.JSONObject;
+import javax.json.JsonException;
+import javax.json.JsonObject;
+
import org.apache.sling.commons.testing.integration.HttpTest;
import org.apache.sling.commons.testing.integration.HttpTestBase;
import org.slf4j.Logger;
@@ -33,13 +34,13 @@ public class RepositoryTestUtil {
public static final String DESCRIPTORS_KEY = "descriptors";
- public static String getDescriptor(HttpTestBase H, String descriptorName) throws JSONException, IOException {
+ public static String getDescriptor(HttpTestBase H, String descriptorName) throws JsonException, IOException {
final String path = "/testing/RepositoryDescriptors.json";
- final JSONObject json = new JSONObject(H.getContent(HttpTest.HTTP_BASE_URL + path, HttpTest.CONTENT_TYPE_JSON));
- return json.getJSONObject("descriptors").getString(descriptorName);
+ final JsonObject json = JsonUtil.parseObject(H.getContent(HttpTest.HTTP_BASE_URL + path, HttpTest.CONTENT_TYPE_JSON));
+ return json.getJsonObject("descriptors").getString(descriptorName);
}
- public static void logDescriptors(HttpTestBase H, String ... names) throws JSONException, IOException {
+ public static void logDescriptors(HttpTestBase H, String ... names) throws JsonException, IOException {
for(String name : names) {
log.info("Repository descriptor {}={}", name, getDescriptor(H, name));
}
Modified: sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/util/ServerSideTestClient.java
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/util/ServerSideTestClient.java?rev=1797248&r1=1797247&r2=1797248&view=diff
==============================================================================
--- sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/util/ServerSideTestClient.java (original)
+++ sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/util/ServerSideTestClient.java Thu Jun 1 19:28:22 2017
@@ -27,9 +27,9 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.apache.sling.commons.json.JSONArray;
-import org.apache.sling.commons.json.JSONObject;
-import org.apache.sling.commons.json.JSONTokener;
+import javax.json.JsonArray;
+import javax.json.JsonObject;
+
import org.apache.sling.junit.remote.httpclient.RemoteTestHttpClient;
import org.apache.sling.testing.tools.http.RequestExecutor;
import org.apache.sling.testing.tools.jarexec.JarExecutor;
@@ -76,14 +76,16 @@ public class ServerSideTestClient extend
final RequestExecutor executor = testClient.runTests(testPackageOrClassName, null, "json", options);
executor.assertContentType("application/json");
String content = executor.getContent();
- final JSONArray json = new JSONArray(new JSONTokener(content));
-
- for(int i = 0 ; i < json.length(); i++) {
- final JSONObject obj = json.getJSONObject(i);
- if("test".equals(obj.getString("INFO_TYPE"))) {
- r.testCount++;
- if(obj.has("failure")) {
- r.failures.add(obj.get("failure").toString());
+ if (!content.trim().isEmpty()) {
+ final JsonArray json = JsonUtil.parseArray(content);
+
+ for(int i = 0 ; i < json.size(); i++) {
+ final JsonObject obj = json.getJsonObject(i);
+ if("test".equals(obj.getString("INFO_TYPE"))) {
+ r.testCount++;
+ if(obj.containsKey("failure")) {
+ r.failures.add(JsonUtil.toString(obj.get("failure")));
+ }
}
}
}