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 21:34:48 UTC
svn commit: r1797272 - in
/sling/trunk/bundles/extensions/models/integration-tests: pom.xml
src/main/java/org/apache/sling/models/it/exporter/ExporterTest.java
Author: pauls
Date: Thu Jun 1 21:34:48 2017
New Revision: 1797272
URL: http://svn.apache.org/viewvc?rev=1797272&view=rev
Log:
SLING-6912: Remove commons.json from bundles/extensions/models/integration-tests
Modified:
sling/trunk/bundles/extensions/models/integration-tests/pom.xml
sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/exporter/ExporterTest.java
Modified: sling/trunk/bundles/extensions/models/integration-tests/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/models/integration-tests/pom.xml?rev=1797272&r1=1797271&r2=1797272&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/models/integration-tests/pom.xml (original)
+++ sling/trunk/bundles/extensions/models/integration-tests/pom.xml Thu Jun 1 21:34:48 2017
@@ -257,6 +257,7 @@
-->
<sling.additional.bundle.1>org.apache.sling.junit.core</sling.additional.bundle.1>
<sling.additional.bundle.2>geronimo-atinject_1.0_spec</sling.additional.bundle.2>
+ <sling.additional.bundle.3>org.apache.sling.commons.johnzon</sling.additional.bundle.3>
<sling.additional.bundle.10>org.apache.sling.models.api</sling.additional.bundle.10>
<sling.additional.bundle.11>org.apache.sling.models.impl</sling.additional.bundle.11>
<sling.additional.bundle.12>org.apache.sling.models.jacksonexporter</sling.additional.bundle.12>
@@ -285,19 +286,25 @@
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.junit.core</artifactId>
- <version>1.0.8</version>
+ <version>1.0.25-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.junit.remote</artifactId>
- <version>1.0.8</version>
+ <version>1.0.11-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.commons.johnzon</artifactId>
+ <version>1.0.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.testing.tools</artifactId>
- <version>1.0.12</version>
+ <version>1.0.17-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
@@ -389,11 +396,6 @@
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.commons.json</artifactId>
- <version>2.0.6</version>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.launchpad</artifactId>
<classifier>standalone</classifier>
<version>7</version>
Modified: sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/exporter/ExporterTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/exporter/ExporterTest.java?rev=1797272&r1=1797271&r2=1797272&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/exporter/ExporterTest.java (original)
+++ sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/exporter/ExporterTest.java Thu Jun 1 21:34:48 2017
@@ -17,6 +17,7 @@
package org.apache.sling.models.it.exporter;
import java.io.InputStream;
+import java.io.StringReader;
import java.io.ByteArrayInputStream;
import java.text.Format;
import java.util.Calendar;
@@ -25,6 +26,9 @@ import java.util.HashMap;
import java.util.Map;
import java.util.TimeZone;
+import javax.json.Json;
+import javax.json.JsonObject;
+
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.time.FastDateFormat;
import org.apache.sling.api.SlingConstants;
@@ -32,7 +36,6 @@ import org.apache.sling.api.resource.Res
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.api.resource.ResourceResolverFactory;
import org.apache.sling.api.resource.ResourceUtil;
-import org.apache.sling.commons.json.JSONObject;
import org.apache.sling.engine.SlingRequestProcessor;
import org.apache.sling.junit.annotations.SlingAnnotationsTestRunner;
import org.apache.sling.junit.annotations.TestReference;
@@ -151,15 +154,15 @@ public class ExporterTest {
Assert.assertTrue("JSON Data should contain the property value",
StringUtils.contains(jsonData, "baseTESTValue"));
- JSONObject parsed = new JSONObject(jsonData);
- JSONObject resource = parsed.getJSONObject("resource");
- Assert.assertEquals(3, resource.getJSONArray("sampleArray").length());
- Assert.assertEquals(1.0d, resource.getDouble("sampleDoubleValue"), .1);
- Assert.assertEquals(2, resource.getJSONArray(":sampleBinaryArray").length());
+ JsonObject parsed = Json.createReader(new StringReader(jsonData)).readObject();
+ JsonObject resource = parsed.getJsonObject("resource");
+ Assert.assertEquals(3, resource.getJsonArray("sampleArray").size());
+ Assert.assertEquals(1.0d, resource.getJsonNumber("sampleDoubleValue").doubleValue(), .1);
+ Assert.assertEquals(2, resource.getJsonArray(":sampleBinaryArray").size());
Assert.assertTrue(resource.getBoolean("sampleBooleanValue"));
- Assert.assertEquals(1, resource.getLong("sampleLongValue"));
- Assert.assertEquals(3, resource.getLong(":sampleBinary"));
- Assert.assertEquals(0, resource.getJSONArray("sampleEmptyArray").length());
+ Assert.assertEquals(1, resource.getInt("sampleLongValue"));
+ Assert.assertEquals(3, resource.getInt(":sampleBinary"));
+ Assert.assertEquals(0, resource.getJsonArray("sampleEmptyArray").size());
final Resource extendedComponentResource = resolver.getResource(extendedComponentPath);
Assert.assertNotNull(extendedComponentResource);
@@ -227,21 +230,21 @@ public class ExporterTest {
resolver = rrFactory.getAdministrativeResourceResolver(null);
FakeResponse response = new FakeResponse();
slingRequestProcessor.processRequest(new FakeRequest(baseComponentPath + ".model.json"), response, resolver);
- JSONObject obj = new JSONObject(response.getStringWriter().toString());
+ JsonObject obj = Json.createReader(new StringReader((response.getStringWriter().toString()))).readObject();
Assert.assertEquals("application/json", response.getContentType());
Assert.assertEquals("BASETESTVALUE", obj.getString("UPPER"));
Assert.assertEquals(baseComponentPath, obj.getString("id"));
response = new FakeResponse();
slingRequestProcessor.processRequest(new FakeRequest(extendedComponentPath + ".model.json"), response, resolver);
- obj = new JSONObject(response.getStringWriter().toString());
+ obj = Json.createReader(new StringReader((response.getStringWriter().toString()))).readObject();
Assert.assertEquals("application/json", response.getContentType());
Assert.assertEquals(extendedComponentPath, obj.getString("id"));
- Assert.assertEquals(testDate.getTimeInMillis(), obj.getLong("date"));
+ Assert.assertEquals(testDate.getTimeInMillis(), obj.getJsonNumber("date").longValue());
response = new FakeResponse();
slingRequestProcessor.processRequest(new FakeRequest(interfaceComponentPath + ".model.json"), response, resolver);
- obj = new JSONObject(response.getStringWriter().toString());
+ obj = Json.createReader(new StringReader((response.getStringWriter().toString()))).readObject();
Assert.assertEquals("application/json", response.getContentType());
Assert.assertEquals(interfaceComponentPath, obj.getString("id"));
Assert.assertEquals("interfaceTESTValue", obj.getString("sampleValue"));
@@ -263,27 +266,27 @@ public class ExporterTest {
Assert.assertTrue(stringOutput.startsWith("{\"UPPER\":"));
- JSONObject obj = new JSONObject(stringOutput);
+ JsonObject obj = Json.createReader(new StringReader(stringOutput)).readObject();
Assert.assertEquals("application/json", response.getContentType());
Assert.assertEquals("BASETESTVALUE", obj.getString("UPPER"));
- Assert.assertTrue(obj.has("testBindingsObject"));
- JSONObject testBindingsObject = obj.getJSONObject("testBindingsObject");
+ Assert.assertTrue(obj.containsKey("testBindingsObject"));
+ JsonObject testBindingsObject = obj.getJsonObject("testBindingsObject");
Assert.assertEquals("value", testBindingsObject.getString("name"));
- Assert.assertTrue(obj.has("testBindingsObject2"));
- JSONObject testBindingsObject2 = obj.getJSONObject("testBindingsObject2");
+ Assert.assertTrue(obj.containsKey("testBindingsObject2"));
+ JsonObject testBindingsObject2 = obj.getJsonObject("testBindingsObject2");
Assert.assertEquals("value2", testBindingsObject2.getString("name2"));
Assert.assertEquals(baseRequestComponentPath, obj.getString("id"));
response = new FakeResponse();
slingRequestProcessor.processRequest(new FakeRequest(extendedRequestComponentPath + ".model.json"), response, resolver);
- obj = new JSONObject(response.getStringWriter().toString());
+ obj = Json.createReader(new StringReader((response.getStringWriter().toString()))).readObject();
Assert.assertEquals("application/json", response.getContentType());
Assert.assertEquals(extendedRequestComponentPath, obj.getString("id"));
Assert.assertEquals(dateFormat.format(testDate), obj.getString("date"));
response = new FakeResponse();
slingRequestProcessor.processRequest(new FakeRequest(interfaceRequestComponentPath + ".model.json"), response, resolver);
- obj = new JSONObject(response.getStringWriter().toString());
+ obj = Json.createReader(new StringReader((response.getStringWriter().toString()))).readObject();
Assert.assertEquals("application/json", response.getContentType());
Assert.assertEquals(interfaceRequestComponentPath, obj.getString("id"));
Assert.assertEquals("interfaceTESTValue", obj.getString("sampleValue"));
@@ -302,13 +305,13 @@ public class ExporterTest {
FakeResponse response = new FakeResponse();
slingRequestProcessor.processRequest(new FakeRequest(doubledComponentPath + ".firstmodel.json"), response, resolver);
- JSONObject obj = new JSONObject(response.getStringWriter().toString());
+ JsonObject obj = Json.createReader(new StringReader((response.getStringWriter().toString()))).readObject();
Assert.assertEquals("application/json", response.getContentType());
Assert.assertEquals("first", obj.getString("value"));
response = new FakeResponse();
slingRequestProcessor.processRequest(new FakeRequest(doubledComponentPath + ".secondmodel.json"), response, resolver);
- obj = new JSONObject(response.getStringWriter().toString());
+ obj = Json.createReader(new StringReader((response.getStringWriter().toString()))).readObject();
Assert.assertEquals("application/json", response.getContentType());
Assert.assertEquals("second", obj.getString("value"));
} finally {