incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jus...@apache.org
Subject svn commit: r1166232 - in /sling/trunk: bundles/extensions/groovy/ bundles/extensions/groovy/src/main/java/org/apache/sling/extensions/groovy/json/ bundles/extensions/groovy/src/main/java/org/apache/sling/extensions/groovy/json/internal/ bundles/extens...
Date Wed, 07 Sep 2011 15:39:41 GMT
Author: justin
Date: Wed Sep  7 15:39:40 2011
New Revision: 1166232

URL: http://svn.apache.org/viewvc?rev=1166232&view=rev
Log:
SLING-2059 - upgrading to groovy 1.8.2; removing custom JSON Builder and rewriting integration
tests to use standard groovy JSON Builder

Added:
    sling/trunk/bundles/extensions/groovy/src/main/java/org/apache/sling/extensions/groovy/json/internal/JsonBuilderBindingsValuesProvider.java
      - copied, changed from r1166199, sling/trunk/bundles/extensions/groovy/src/main/java/org/apache/sling/extensions/groovy/json/internal/JSONGroovyBuilderBindingsValuesProvider.java
    sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/GroovySlingResourceTypeRenderingTest.java
      - copied, changed from r1166199, sling/trunk/bundles/extensions/groovy/src/test/java/org/apache/sling/extensions/groovy/it/GroovySlingResourceTypeRenderingIT.java
    sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/JSONGroovyBuilderTest.java
      - copied, changed from r1166199, sling/trunk/bundles/extensions/groovy/src/test/java/org/apache/sling/extensions/groovy/it/JSONGroovyBuilderIT.java
    sling/trunk/launchpad/integration-tests/src/main/resources/integration-test/builder_array.groovy
      - copied, changed from r1166199, sling/trunk/bundles/extensions/groovy/src/test/resources/integration-test/builder.groovy
    sling/trunk/launchpad/integration-tests/src/main/resources/integration-test/builder_object.groovy
      - copied, changed from r1166199, sling/trunk/bundles/extensions/groovy/src/test/resources/integration-test/builder.groovy
    sling/trunk/launchpad/integration-tests/src/main/resources/integration-test/builder_rich_object.groovy
      - copied, changed from r1166199, sling/trunk/bundles/extensions/groovy/src/test/resources/integration-test/builder2.groovy
    sling/trunk/launchpad/integration-tests/src/main/resources/integration-test/rendering-test.gsp
      - copied, changed from r1166199, sling/trunk/bundles/extensions/groovy/src/test/resources/integration-test/rendering-test.gsp
Modified:
    sling/trunk/bundles/extensions/groovy/pom.xml
    sling/trunk/bundles/extensions/groovy/src/main/java/org/apache/sling/extensions/groovy/json/JSONGroovyBuilder.java
    sling/trunk/bundles/extensions/groovy/src/main/java/org/apache/sling/extensions/groovy/json/internal/JSONGroovyBuilderBindingsValuesProvider.java
    sling/trunk/bundles/extensions/groovy/src/test/groovy/org/apache/sling/extensions/groovy/json/JSONGroovyBuilderTest.groovy
    sling/trunk/bundles/extensions/groovy/src/test/java/json/JSONAssert.java
    sling/trunk/bundles/extensions/groovy/src/test/java/org/apache/sling/extensions/groovy/it/GroovySlingResourceTypeRenderingIT.java
    sling/trunk/bundles/extensions/groovy/src/test/java/org/apache/sling/extensions/groovy/it/JSONGroovyBuilderIT.java
    sling/trunk/bundles/extensions/groovy/src/test/resources/integration-test/builder.groovy
    sling/trunk/bundles/extensions/groovy/src/test/resources/integration-test/builder2.groovy
    sling/trunk/bundles/extensions/groovy/src/test/resources/integration-test/rendering-test.gsp
    sling/trunk/launchpad/builder/src/main/bundles/list.xml

Modified: sling/trunk/bundles/extensions/groovy/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/groovy/pom.xml?rev=1166232&r1=1166231&r2=1166232&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/groovy/pom.xml (original)
+++ sling/trunk/bundles/extensions/groovy/pom.xml Wed Sep  7 15:39:40 2011
@@ -54,18 +54,6 @@
                 <artifactId>maven-bundle-plugin</artifactId>
                 <extensions>true</extensions>
             </plugin>
-            <plugin>
-                <groupId>org.codehaus.groovy.maven</groupId>
-                <artifactId>gmaven-plugin</artifactId>
-                <executions>
-                    <execution>
-                        <goals>
-                            <goal>compile</goal>
-                            <goal>testCompile</goal>
-                        </goals>
-                    </execution>
-                </executions>
-            </plugin>
         </plugins>
     </build>
 
@@ -73,7 +61,7 @@
         <dependency>
             <groupId>org.codehaus.groovy</groupId>
             <artifactId>groovy-all</artifactId>
-            <version>1.6.0</version>
+            <version>1.8.0</version>
             <scope>provided</scope>
         </dependency>
         <dependency>
@@ -81,12 +69,6 @@
             <artifactId>slf4j-api</artifactId>
         </dependency>
         <dependency>
-            <groupId>org.apache.sling</groupId>
-            <artifactId>org.apache.sling.commons.json</artifactId>
-            <version>2.0.4-incubator</version>
-            <scope>provided</scope>
-        </dependency>
-        <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
         </dependency>
@@ -110,11 +92,5 @@
             <version>1.0.0</version>
             <scope>provided</scope>
         </dependency>
-        <dependency>
-            <groupId>org.apache.sling</groupId>
-            <artifactId>org.apache.sling.launchpad.integration-tests</artifactId>
-            <version>1.0.1-SNAPSHOT</version>
-            <scope>test</scope>
-        </dependency>
     </dependencies>
 </project>
\ No newline at end of file

Copied: sling/trunk/bundles/extensions/groovy/src/main/java/org/apache/sling/extensions/groovy/json/internal/JsonBuilderBindingsValuesProvider.java
(from r1166199, sling/trunk/bundles/extensions/groovy/src/main/java/org/apache/sling/extensions/groovy/json/internal/JSONGroovyBuilderBindingsValuesProvider.java)
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/groovy/src/main/java/org/apache/sling/extensions/groovy/json/internal/JsonBuilderBindingsValuesProvider.java?p2=sling/trunk/bundles/extensions/groovy/src/main/java/org/apache/sling/extensions/groovy/json/internal/JsonBuilderBindingsValuesProvider.java&p1=sling/trunk/bundles/extensions/groovy/src/main/java/org/apache/sling/extensions/groovy/json/internal/JSONGroovyBuilderBindingsValuesProvider.java&r1=1166199&r2=1166232&rev=1166232&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/groovy/src/main/java/org/apache/sling/extensions/groovy/json/internal/JSONGroovyBuilderBindingsValuesProvider.java
(original)
+++ sling/trunk/bundles/extensions/groovy/src/main/java/org/apache/sling/extensions/groovy/json/internal/JsonBuilderBindingsValuesProvider.java
Wed Sep  7 15:39:40 2011
@@ -16,17 +16,19 @@
  */
 package org.apache.sling.extensions.groovy.json.internal;
 
+import groovy.json.JsonBuilder;
+
 import java.util.HashMap;
 
 import org.apache.felix.scr.annotations.Component;
 import org.apache.felix.scr.annotations.Properties;
 import org.apache.felix.scr.annotations.Property;
 import org.apache.felix.scr.annotations.Service;
-import org.apache.sling.extensions.groovy.json.JSONGroovyBuilder;
 
 /**
- * BindingsValuesProvider which binds an instance of JSONGroovyBuilder.
+ * BindingsValuesProvider which binds an instance of JsonBuilder.
  */
+@SuppressWarnings("serial")
 @Component(immediate=true, metatype=false)
 @Service
 @Properties({
@@ -34,11 +36,11 @@ import org.apache.sling.extensions.groov
     @Property(name="service.vendor", value="The Apache Software Foundation"),
     @Property(name="javax.script.name", value="groovy")
 })
-public class JSONGroovyBuilderBindingsValuesProvider extends HashMap<String, Object>
{
+public class JsonBuilderBindingsValuesProvider extends HashMap<String, Object> {
 
-    public JSONGroovyBuilderBindingsValuesProvider() {
+    public JsonBuilderBindingsValuesProvider() {
         super();
-        put("jsonBuilder", new JSONGroovyBuilder());
+        put("jsonBuilder", new JsonBuilder());
     }
 
 }

Modified: sling/trunk/launchpad/builder/src/main/bundles/list.xml
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/builder/src/main/bundles/list.xml?rev=1166232&r1=1166231&r2=1166232&view=diff
==============================================================================
--- sling/trunk/launchpad/builder/src/main/bundles/list.xml (original)
+++ sling/trunk/launchpad/builder/src/main/bundles/list.xml Wed Sep  7 15:39:40 2011
@@ -180,7 +180,7 @@
         <bundle>
             <groupId>org.codehaus.groovy</groupId>
             <artifactId>groovy-all</artifactId>
-            <version>1.7.4</version>
+            <version>1.8.2</version>
         </bundle>
 
         <!-- felix httpservice whiteboard -->
@@ -308,7 +308,12 @@
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.extensions.explorer</artifactId>
             <version>1.0.2</version>
-        </bundle> 
+        </bundle>
+        <bundle>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.extensions.groovy</artifactId>
+            <version>1.0.0-SNAPSHOT</version>
+        </bundle>
     </startLevel>
 
     <startLevel level="10">

Copied: sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/GroovySlingResourceTypeRenderingTest.java
(from r1166199, sling/trunk/bundles/extensions/groovy/src/test/java/org/apache/sling/extensions/groovy/it/GroovySlingResourceTypeRenderingIT.java)
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/GroovySlingResourceTypeRenderingTest.java?p2=sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/GroovySlingResourceTypeRenderingTest.java&p1=sling/trunk/bundles/extensions/groovy/src/test/java/org/apache/sling/extensions/groovy/it/GroovySlingResourceTypeRenderingIT.java&r1=1166199&r2=1166232&rev=1166232&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/groovy/src/test/java/org/apache/sling/extensions/groovy/it/GroovySlingResourceTypeRenderingIT.java
(original)
+++ sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/GroovySlingResourceTypeRenderingTest.java
Wed Sep  7 15:39:40 2011
@@ -1,10 +1,26 @@
-package org.apache.sling.extensions.groovy.it;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.sling.launchpad.webapp.integrationtest;
 
 import java.io.IOException;
 
 import org.apache.sling.launchpad.webapp.integrationtest.AbstractSlingResourceTypeRenderingTest;
 
-public class GroovySlingResourceTypeRenderingIT extends AbstractSlingResourceTypeRenderingTest
{
+public class GroovySlingResourceTypeRenderingTest extends AbstractSlingResourceTypeRenderingTest
{
 
     public void testGspJavaCode() throws IOException {
         final String toDelete = uploadTestScript("rendering-test.gsp","html.gsp");

Copied: sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/JSONGroovyBuilderTest.java
(from r1166199, sling/trunk/bundles/extensions/groovy/src/test/java/org/apache/sling/extensions/groovy/it/JSONGroovyBuilderIT.java)
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/JSONGroovyBuilderTest.java?p2=sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/JSONGroovyBuilderTest.java&p1=sling/trunk/bundles/extensions/groovy/src/test/java/org/apache/sling/extensions/groovy/it/JSONGroovyBuilderIT.java&r1=1166199&r2=1166232&rev=1166232&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/groovy/src/test/java/org/apache/sling/extensions/groovy/it/JSONGroovyBuilderIT.java
(original)
+++ sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/JSONGroovyBuilderTest.java
Wed Sep  7 15:39:40 2011
@@ -1,15 +1,32 @@
-package org.apache.sling.extensions.groovy.it;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.sling.launchpad.webapp.integrationtest;
 
 import java.io.IOException;
 import java.util.HashMap;
 import java.util.Map;
 
+import org.apache.sling.commons.json.JSONArray;
 import org.apache.sling.commons.json.JSONException;
 import org.apache.sling.commons.json.JSONObject;
 import org.apache.sling.launchpad.webapp.integrationtest.RenderingTestBase;
 import org.apache.sling.servlets.post.SlingPostConstants;
 
-public class JSONGroovyBuilderIT extends RenderingTestBase {
+public class JSONGroovyBuilderTest extends RenderingTestBase {
     private String slingResourceType;
 
     @Override
@@ -32,8 +49,8 @@ public class JSONGroovyBuilderIT extends
         testClient.mkdirs(WEBDAV_BASE_URL, scriptPath);
     }
 
-    public void testJSONGroovyBuilder() throws IOException, JSONException {
-        final String toDelete = uploadTestScript("builder.groovy","json.groovy");
+    public void testObject() throws IOException, JSONException {
+        final String toDelete = uploadTestScript("builder_object.groovy","json.groovy");
         try {
             final String content = getContent(displayUrl + ".json", CONTENT_TYPE_JSON);
             JSONObject jo = new JSONObject(content);
@@ -44,15 +61,28 @@ public class JSONGroovyBuilderIT extends
             testClient.delete(toDelete);
         }
     }
-
-    public void testJSONGroovyBuilder2() throws IOException, JSONException {
-        final String toDelete = uploadTestScript("builder2.groovy","json.groovy");
+    
+    public void testRichObject() throws IOException, JSONException {
+        final String toDelete = uploadTestScript("builder_rich_object.groovy","json.groovy");
         try {
             final String content = getContent(displayUrl + ".json", CONTENT_TYPE_JSON);
+            System.out.println(content);
             JSONObject jo = new JSONObject(content);
-            assertEquals("Content contained wrong number of items", 1, jo.length());
-            assertEquals("Content contained wrong key", "text", jo.keys().next());
+            assertEquals("Content contained wrong number of items", 2, jo.length());
             assertEquals("Content contained wrong data", testText, jo.get("text"));
+            assertEquals("Content contained wrong data", "bar", ((JSONObject) jo.get("obj")).get("foo"));
+        } finally {
+            testClient.delete(toDelete);
+        }
+    }
+
+    public void testArray() throws IOException, JSONException {
+        final String toDelete = uploadTestScript("builder_array.groovy","json.groovy");
+        try {
+            final String content = getContent(displayUrl + ".json", CONTENT_TYPE_JSON);
+            JSONArray jo = new JSONArray(content);
+            assertEquals("Content contained wrong number of items", 1, jo.length());
+            assertEquals("Content contained wrong data", testText, jo.get(0));
         } finally {
             testClient.delete(toDelete);
         }

Copied: sling/trunk/launchpad/integration-tests/src/main/resources/integration-test/builder_array.groovy
(from r1166199, sling/trunk/bundles/extensions/groovy/src/test/resources/integration-test/builder.groovy)
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/integration-tests/src/main/resources/integration-test/builder_array.groovy?p2=sling/trunk/launchpad/integration-tests/src/main/resources/integration-test/builder_array.groovy&p1=sling/trunk/bundles/extensions/groovy/src/test/resources/integration-test/builder.groovy&r1=1166199&r2=1166232&rev=1166232&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/groovy/src/test/resources/integration-test/builder.groovy
(original)
+++ sling/trunk/launchpad/integration-tests/src/main/resources/integration-test/builder_array.groovy
Wed Sep  7 15:39:40 2011
@@ -17,6 +17,6 @@
  * under the License.
  */
 
-out.write jsonBuilder.json {
-	text currentNode.getProperty("text").string
-} as String
+jsonBuilder(currentNode.getProperty("text").string)
+
+jsonBuilder.writeTo(out) // or out.write jsonBuilder
\ No newline at end of file

Copied: sling/trunk/launchpad/integration-tests/src/main/resources/integration-test/builder_object.groovy
(from r1166199, sling/trunk/bundles/extensions/groovy/src/test/resources/integration-test/builder.groovy)
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/integration-tests/src/main/resources/integration-test/builder_object.groovy?p2=sling/trunk/launchpad/integration-tests/src/main/resources/integration-test/builder_object.groovy&p1=sling/trunk/bundles/extensions/groovy/src/test/resources/integration-test/builder.groovy&r1=1166199&r2=1166232&rev=1166232&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/groovy/src/test/resources/integration-test/builder.groovy
(original)
+++ sling/trunk/launchpad/integration-tests/src/main/resources/integration-test/builder_object.groovy
Wed Sep  7 15:39:40 2011
@@ -16,7 +16,6 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+jsonBuilder text: currentNode.getProperty("text").string
 
-out.write jsonBuilder.json {
-	text currentNode.getProperty("text").string
-} as String
+out.write jsonBuilder // or jsonBuilder.writeTo(out)
\ No newline at end of file

Copied: sling/trunk/launchpad/integration-tests/src/main/resources/integration-test/builder_rich_object.groovy
(from r1166199, sling/trunk/bundles/extensions/groovy/src/test/resources/integration-test/builder2.groovy)
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/integration-tests/src/main/resources/integration-test/builder_rich_object.groovy?p2=sling/trunk/launchpad/integration-tests/src/main/resources/integration-test/builder_rich_object.groovy&p1=sling/trunk/bundles/extensions/groovy/src/test/resources/integration-test/builder2.groovy&r1=1166199&r2=1166232&rev=1166232&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/groovy/src/test/resources/integration-test/builder2.groovy
(original)
+++ sling/trunk/launchpad/integration-tests/src/main/resources/integration-test/builder_rich_object.groovy
Wed Sep  7 15:39:40 2011
@@ -16,7 +16,11 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-
-jsonBuilder.write(out).json {
+jsonBuilder {
     text currentNode.getProperty("text").string
-}
\ No newline at end of file
+    obj {
+        foo "bar"
+    }
+}
+
+out.write jsonBuilder // or jsonBuilder.writeTo(out)
\ No newline at end of file

Copied: sling/trunk/launchpad/integration-tests/src/main/resources/integration-test/rendering-test.gsp
(from r1166199, sling/trunk/bundles/extensions/groovy/src/test/resources/integration-test/rendering-test.gsp)
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/integration-tests/src/main/resources/integration-test/rendering-test.gsp?p2=sling/trunk/launchpad/integration-tests/src/main/resources/integration-test/rendering-test.gsp&p1=sling/trunk/bundles/extensions/groovy/src/test/resources/integration-test/rendering-test.gsp&r1=1166199&r2=1166232&rev=1166232&view=diff
==============================================================================
    (empty)



Mime
View raw message