SLING-1341 - adding builder.write() method

git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@904258 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/JSONGroovyBuilderIntegrationTest.java b/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/JSONGroovyBuilderIntegrationTest.java
index 1f68186..159af84 100644
--- a/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/JSONGroovyBuilderIntegrationTest.java
+++ b/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/JSONGroovyBuilderIntegrationTest.java
@@ -60,4 +60,17 @@
             testClient.delete(toDelete);
         }
     }
+
+    public void testJSONGroovyBuilder2() throws IOException, JSONException {
+        final String toDelete = uploadTestScript("builder2.groovy","json.groovy");
+        try {
+            final String content = getContent(displayUrl + ".json", CONTENT_TYPE_JSON);
+            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 data", testText, jo.get("text"));
+        } finally {
+            testClient.delete(toDelete);
+        }
+    }
 }
diff --git a/src/test/resources/integration-test/builder.groovy b/src/test/resources/integration-test/builder.groovy
index df1342a..62f2fa0 100644
--- a/src/test/resources/integration-test/builder.groovy
+++ b/src/test/resources/integration-test/builder.groovy
@@ -18,5 +18,5 @@
  */
 
 out.write jsonBuilder.json {
-    text currentNode.getProperty("text").string
+	text currentNode.getProperty("text").string
 } as String
diff --git a/src/test/resources/integration-test/builder2.groovy b/src/test/resources/integration-test/builder2.groovy
new file mode 100644
index 0000000..2f826eb
--- /dev/null
+++ b/src/test/resources/integration-test/builder2.groovy
@@ -0,0 +1,22 @@
+/*
+ * 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.
+ */
+
+jsonBuilder.write(out).json {
+    text currentNode.getProperty("text").string
+}
\ No newline at end of file