Author: bdelacretaz
Date: Wed Jun 18 07:25:55 2008
New Revision: 669182
URL: http://svn.apache.org/viewvc?rev=669182&view=rev
Log:
SLING-466 - unit tests added
Added:
incubator/sling/trunk/scripting/jst/src/test/java/org/apache/sling/scripting/jst/BodyOnlyScriptFilteredCopyTest.java
(with props)
incubator/sling/trunk/scripting/jst/src/test/java/org/apache/sling/scripting/jst/HtmlCodeGeneratorTest.java
(with props)
incubator/sling/trunk/scripting/jst/src/test/java/org/apache/sling/scripting/jst/JsCodeGeneratorTest.java
(with props)
incubator/sling/trunk/scripting/jst/src/test/java/org/apache/sling/scripting/jst/StringUtil.java
(with props)
incubator/sling/trunk/scripting/jst/src/test/resources/
incubator/sling/trunk/scripting/jst/src/test/resources/htmlcode/
incubator/sling/trunk/scripting/jst/src/test/resources/htmlcode/htmlcode1.expected.html
(with props)
incubator/sling/trunk/scripting/jst/src/test/resources/htmlcode/htmlcode1.input.jst
incubator/sling/trunk/scripting/jst/src/test/resources/jscode/
incubator/sling/trunk/scripting/jst/src/test/resources/jscode/jscode1.expected.js
(with props)
incubator/sling/trunk/scripting/jst/src/test/resources/jscode/jscode1.input.jst
incubator/sling/trunk/scripting/jst/src/test/resources/jscode/jscode2.expected.js
(with props)
incubator/sling/trunk/scripting/jst/src/test/resources/jscode/jscode2.input.jst
Modified:
incubator/sling/trunk/scripting/jst/pom.xml
incubator/sling/trunk/scripting/jst/src/main/resources/xslt/script-transform.xsl
incubator/sling/trunk/scripting/jst/src/test/java/org/apache/sling/scripting/jst/ScriptFilteredCopyTest.java
Modified: incubator/sling/trunk/scripting/jst/pom.xml
URL:
http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/jst/pom.xml?rev=669182&r1=669181&r2=669182&view=diff
==============================================================================
--- incubator/sling/trunk/scripting/jst/pom.xml (original)
+++ incubator/sling/trunk/scripting/jst/pom.xml Wed Jun 18 07:25:55 2008
@@ -28,7 +28,7 @@
</parent>
<artifactId>org.apache.sling.scripting.jst</artifactId>
- <version>2.0.0-incubator-SNAPSHOT</version>
+ <version>2.0.3-incubator-SNAPSHOT</version>
<packaging>bundle</packaging>
<name>Sling - Scripting - JST Support</name>
@@ -157,9 +157,24 @@
<scope>provided</scope>
</dependency>
<dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+ <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.commons.testing</artifactId>
+ <version>${pom.version}</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
Modified:
incubator/sling/trunk/scripting/jst/src/main/resources/xslt/script-transform.xsl
URL:
http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/jst/src/main/resources/xslt/script-transform.xsl?rev=669182&r1=669181&r2=669182&view=diff
==============================================================================
---
incubator/sling/trunk/scripting/jst/src/main/resources/xslt/script-transform.xsl
(original)
+++
incubator/sling/trunk/scripting/jst/src/main/resources/xslt/script-transform.xsl
Wed Jun 18 07:25:55 2008
@@ -68,19 +68,27 @@
<!-- replace body with default rendering + script reference -->
<xsl:template match="body|BODY" mode="inner">
<div id="JstDefaultRendering">
- <xsl:value-of select="$defaultRendering" disable-output-escaping="yes" />
+ <xsl:text>
+ </xsl:text>
+ <xsl:value-of select="$defaultRendering" disable-output-escaping="yes" />
+ <xsl:text>
+ </xsl:text>
</div>
<script language="javascript">
var e = document.getElementById("JstDefaultRendering");
e.parentNode.removeChild(e);
</script>
+ <xsl:text>
+ </xsl:text>
<script src="{$jstScriptPath}"/>
</xsl:template>
<!-- add reference to sling.js in head, and currentNode data -->
<xsl:template match="head|HEAD" mode="inner">
<xsl:apply-templates/>
- <script src="{$slingScriptPath}"/>
+ <script src="{$slingScriptPath}"></script>
+ <xsl:text>
+ </xsl:text>
<script language="javascript">
<xsl:value-of select="$jsonData"/>
</script>
Added:
incubator/sling/trunk/scripting/jst/src/test/java/org/apache/sling/scripting/jst/BodyOnlyScriptFilteredCopyTest.java
URL:
http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/jst/src/test/java/org/apache/sling/scripting/jst/BodyOnlyScriptFilteredCopyTest.java?rev=669182&view=auto
==============================================================================
---
incubator/sling/trunk/scripting/jst/src/test/java/org/apache/sling/scripting/jst/BodyOnlyScriptFilteredCopyTest.java
(added)
+++
incubator/sling/trunk/scripting/jst/src/test/java/org/apache/sling/scripting/jst/BodyOnlyScriptFilteredCopyTest.java
Wed Jun 18 07:25:55 2008
@@ -0,0 +1,75 @@
+/*
+ * 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.scripting.jst;
+
+import java.io.IOException;
+import java.io.StringReader;
+import java.io.StringWriter;
+
+import junit.framework.TestCase;
+
+/** Test the BodyOnlyScriptFilteredCopy */
+public class BodyOnlyScriptFilteredCopyTest extends TestCase {
+
+ private final BodyOnlyScriptFilteredCopy bfc = new
BodyOnlyScriptFilteredCopy();
+
+ private void runTest(String input, String expected) throws IOException {
+ final StringWriter sw = new StringWriter();
+ bfc.copy(new StringReader(input), sw);
+ assertEquals(StringUtil.flatten(expected),
StringUtil.flatten(sw.toString()));
+ }
+
+ public void testNoChanges() throws IOException {
+ final String input = "No out.write statements on their own lines";
+ final String expected = "";
+ runTest(input,expected);
+ }
+
+ public void testBasicTemplate() throws IOException {
+ final String input =
+ "out.write('Something before body');\n"
+ + "out.write('<body class='foo'>');\n"
+ + "out.write(\"some template code\");\n"
+ + "out.write('</body>');\n"
+ + "out.write('Something after body');\n"
+ ;
+
+ final String expected =
+ "out.write(\"some template code\");\n"
+ ;
+
+ runTest(input,expected);
+ }
+
+ public void testOpenClose() throws IOException {
+ final String input =
+ "A\n"
+ + "out.write(' <body class='foo'>');\n"
+ + "out.write(\"some <script> here </script>\");\n"
+ + "out.write('</body>');\n"
+ + "B\n";
+
+ final String expected =
+ "out.write(\"some <\");\n"
+ + "out.write(\"script> here </\");\n"
+ + "out.write(\"script>\");\n";
+
+ runTest(input,expected);
+ }
+}
Propchange:
incubator/sling/trunk/scripting/jst/src/test/java/org/apache/sling/scripting/jst/BodyOnlyScriptFilteredCopyTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/sling/trunk/scripting/jst/src/test/java/org/apache/sling/scripting/jst/BodyOnlyScriptFilteredCopyTest.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision Rev URL
Added:
incubator/sling/trunk/scripting/jst/src/test/java/org/apache/sling/scripting/jst/HtmlCodeGeneratorTest.java
URL:
http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/jst/src/test/java/org/apache/sling/scripting/jst/HtmlCodeGeneratorTest.java?rev=669182&view=auto
==============================================================================
---
incubator/sling/trunk/scripting/jst/src/test/java/org/apache/sling/scripting/jst/HtmlCodeGeneratorTest.java
(added)
+++
incubator/sling/trunk/scripting/jst/src/test/java/org/apache/sling/scripting/jst/HtmlCodeGeneratorTest.java
Wed Jun 18 07:25:55 2008
@@ -0,0 +1,186 @@
+/*
+ * 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.scripting.jst;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.PrintWriter;
+import java.io.StringReader;
+import java.io.StringWriter;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+
+import junit.framework.TestCase;
+
+import org.apache.sling.api.SlingHttpServletRequest;
+import org.apache.sling.commons.testing.jcr.MockNode;
+import org.apache.sling.commons.testing.sling.MockResource;
+import org.apache.sling.commons.testing.sling.MockSlingHttpServletRequest;
+
+/** Test the JsCodeGenerator */
+public class HtmlCodeGeneratorTest extends TestCase {
+
+ public static final String ENCODING = "UTF-8";
+ public static final String TEST_RESOURCES_PATH = "/htmlcode";
+ private final HtmlCodeGenerator generator = new HtmlCodeGenerator();
+
+ /** Pass a .input.jst test file through the HtmlCodeGenerator,
+ * and verify that the result matches the corresponding
+ * .expected.html file.
+ */
+ protected boolean runTest(int index) throws Exception {
+ final String scriptPath = TEST_RESOURCES_PATH + "/htmlcode" + index +
".input.jst";
+ final InputStream scriptStream =
getClass().getResourceAsStream(scriptPath);
+ if(scriptStream == null) {
+ // no more test files
+ return false;
+ }
+ assertNotNull(scriptPath + " must be found", scriptStream);
+
+ final String expectedCode = StringUtil.readClassResource(
+ getClass(), TEST_RESOURCES_PATH + "/htmlcode" + index +
".expected.html", ENCODING);
+ final StringWriter result = new StringWriter();
+ final SlingHttpServletRequest request = getMockRequest();
+ generator.generateHtml(request, scriptPath, scriptStream, new
PrintWriter(result));
+ compareLineByLine(expectedCode.toString(), result.toString());
+
+ return true;
+ }
+
+ /** Read until a non-blank line is found */
+ protected String readLine(BufferedReader br) throws IOException {
+ String result = null;
+ while(true) {
+ result = br.readLine();
+ if(result == null) {
+ break;
+ }
+ result = result.trim();
+ if(result.indexOf("<!-- TODO TEST") >= 0) {
+ continue;
+ }
+ if(result.length() > 0) {
+ break;
+ }
+ }
+ return result;
+ }
+
+ protected void compareLineByLine(String expected, String actual) throws
IOException {
+ final BufferedReader ex = new BufferedReader(new
StringReader(expected.trim()));
+ final BufferedReader ac = new BufferedReader(new
StringReader(actual.trim()));
+ boolean ok = false;
+
+ try {
+ for(int line=1; true; line++) {
+ final String exLine = readLine(ex);
+ final String acLine = readLine(ac);
+
+ if(exLine == null && acLine==null) {
+ ok = true;
+ break;
+ } else if(exLine == null && acLine != null) {
+ fail("At line " + line + ", actual code has more lines
than expected");
+ } else {
+ assertEquals("Line " + line + " must match", exLine,
acLine);
+ }
+ }
+
+ } finally {
+ if(!ok) {
+ System.err.println("Expected code:\n" + expected);
+ System.err.println("Actual code:\n" + actual);
+ }
+ }
+ }
+
+ protected SlingHttpServletRequest getMockRequest() {
+ final String resourcePath = "foo";
+ final MockSlingHttpServletRequest r = new
MockSlingHttpServletRequest(resourcePath,null,null,null,null) {
+ @Override
+ public String getContextPath() {
+ return "/CONTEXT";
+ }
+
+ @Override
+ public String getServletPath() {
+ return "/SERVLET";
+ }
+ };
+
+ final String path = "/foo/node";
+
+ final MockNode mn = new MockNode(path);
+ try {
+ mn.setProperty("title", "test.title");
+ mn.setProperty("desc", "test.desc");
+ } catch(RepositoryException ignored) {
+ // ignore, cannot happen with this mock class
+ }
+
+ final MockResource mr = new MockResource(null, path, null) {
+ @SuppressWarnings("unchecked")
+ public <Type> Type adaptTo(Class<Type> type) {
+ if(type.equals(Node.class)) {
+ return (Type)mn;
+ } else {
+ return null;
+ }
+ }
+ };
+
+ r.setResource(mr);
+
+ return r;
+ }
+
+ public void testHtmlcodeTestFiles() throws Exception {
+ int maxTestFiles = 999;
+ int expectedTests = 1;
+ int counter = 0;
+
+ for(int i=1 ; i <= maxTestFiles; i++) {
+ if(!runTest(i)) {
+ break;
+ }
+ counter++;
+ }
+
+ assertTrue("At least " + expectedTests + " have been run", counter >=
expectedTests);
+ }
+
+ public void testTitleBuilding() throws RepositoryException {
+ final String path = "/foo/title";
+ final MockNode n = new MockNode(path);
+ final MockResource r = new MockResource(null, path, null);
+
+ assertEquals("foo/title", generator.getTitle(r, n));
+
+ n.setProperty("description", "the description");
+ assertEquals("the description", generator.getTitle(r, n));
+
+ n.setProperty("name", "the name");
+ assertEquals("the name", generator.getTitle(r, n));
+
+ n.setProperty("title", "the title");
+ assertEquals("the title", generator.getTitle(r, n));
+ }
+}
\ No newline at end of file
Propchange:
incubator/sling/trunk/scripting/jst/src/test/java/org/apache/sling/scripting/jst/HtmlCodeGeneratorTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/sling/trunk/scripting/jst/src/test/java/org/apache/sling/scripting/jst/HtmlCodeGeneratorTest.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision Rev URL
Added:
incubator/sling/trunk/scripting/jst/src/test/java/org/apache/sling/scripting/jst/JsCodeGeneratorTest.java
URL:
http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/jst/src/test/java/org/apache/sling/scripting/jst/JsCodeGeneratorTest.java?rev=669182&view=auto
==============================================================================
---
incubator/sling/trunk/scripting/jst/src/test/java/org/apache/sling/scripting/jst/JsCodeGeneratorTest.java
(added)
+++
incubator/sling/trunk/scripting/jst/src/test/java/org/apache/sling/scripting/jst/JsCodeGeneratorTest.java
Wed Jun 18 07:25:55 2008
@@ -0,0 +1,77 @@
+/*
+ * 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.scripting.jst;
+
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.PrintWriter;
+import java.io.Reader;
+import java.io.StringWriter;
+
+import junit.framework.TestCase;
+
+/** Test the JsCodeGenerator */
+public class JsCodeGeneratorTest extends TestCase {
+
+ public static final String ENCODING = "UTF-8";
+ public static final String TEST_RESOURCES_PATH = "/jscode";
+ private final JsCodeGenerator generator = new JsCodeGenerator();
+
+ /** Pass a .input.jst test file through the JsCodeGenerator,
+ * and verify that the result matches the corresponding
+ * .expected.js file.
+ */
+ protected boolean runTest(int index) throws Exception {
+ final String input = TEST_RESOURCES_PATH + "/jscode" + index +
".input.jst";
+ final InputStream scriptStream = getClass().getResourceAsStream(input);
+ if(scriptStream == null) {
+ // no more test files
+ return false;
+ }
+ assertNotNull(input + " must be found", scriptStream);
+ final Reader r = new InputStreamReader(scriptStream, ENCODING);
+
+ final String expectedCode = StringUtil.readClassResource(
+ getClass(), TEST_RESOURCES_PATH + "/jscode" + index +
".expected.js", ENCODING);
+ final StringWriter result = new StringWriter();
+ generator.generateCode(r, new PrintWriter(result));
+
+ assertEquals("Generated code matches expected code",
+ StringUtil.flatten(expectedCode.toString().trim()),
+ StringUtil.flatten(result.toString().trim())
+ );
+
+ return true;
+ }
+
+ public void testJscodeTestFiles() throws Exception {
+ int maxTestFiles = 999;
+ int expectedTests = 2;
+ int counter = 0;
+
+ for(int i=1 ; i <= maxTestFiles; i++) {
+ if(!runTest(i)) {
+ break;
+ }
+ counter++;
+ }
+
+ assertTrue("At least " + expectedTests + " have been run", counter >=
expectedTests);
+ }
+}
Propchange:
incubator/sling/trunk/scripting/jst/src/test/java/org/apache/sling/scripting/jst/JsCodeGeneratorTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/sling/trunk/scripting/jst/src/test/java/org/apache/sling/scripting/jst/JsCodeGeneratorTest.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision Rev URL
Modified:
incubator/sling/trunk/scripting/jst/src/test/java/org/apache/sling/scripting/jst/ScriptFilteredCopyTest.java
URL:
http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/jst/src/test/java/org/apache/sling/scripting/jst/ScriptFilteredCopyTest.java?rev=669182&r1=669181&r2=669182&view=diff
==============================================================================
---
incubator/sling/trunk/scripting/jst/src/test/java/org/apache/sling/scripting/jst/ScriptFilteredCopyTest.java
(original)
+++
incubator/sling/trunk/scripting/jst/src/test/java/org/apache/sling/scripting/jst/ScriptFilteredCopyTest.java
Wed Jun 18 07:25:55 2008
@@ -32,7 +32,7 @@
private void runTest(String input, String expected) throws IOException {
final StringWriter sw = new StringWriter();
sfc.copy(new StringReader(input), sw);
- assertEquals(flatten(expected), flatten(sw.toString()));
+ assertEquals(StringUtil.flatten(expected),
StringUtil.flatten(sw.toString()));
}
public void testNoChanges() throws IOException {
@@ -75,9 +75,4 @@
;
runTest(input,expected);
}
-
- /** Replace \n with . in strings to make it easier to compare visually for
testing */
- private static String flatten(String str) {
- return str.replace('\n', '.');
- }
}
Added:
incubator/sling/trunk/scripting/jst/src/test/java/org/apache/sling/scripting/jst/StringUtil.java
URL:
http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/jst/src/test/java/org/apache/sling/scripting/jst/StringUtil.java?rev=669182&view=auto
==============================================================================
---
incubator/sling/trunk/scripting/jst/src/test/java/org/apache/sling/scripting/jst/StringUtil.java
(added)
+++
incubator/sling/trunk/scripting/jst/src/test/java/org/apache/sling/scripting/jst/StringUtil.java
Wed Jun 18 07:25:55 2008
@@ -0,0 +1,46 @@
+/*
+ * 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.scripting.jst;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+/** Test utilities */
+class StringUtil {
+ /** Replace \n with . in strings to make it easier to compare visually for
testing */
+ static String flatten(String str) {
+ return str.replace('\n', '.');
+ }
+
+ /** Read given Class resource */
+ static String readClassResource(Class<?> clazz, String path, String
encoding) throws IOException {
+ final InputStream s = clazz.getResourceAsStream(path);
+ if(s == null) {
+ throw new IOException("Class resource " + path + " not found");
+ }
+ final byte [] buffer = new byte[4096];
+ final StringBuffer result = new StringBuffer();
+ int bytesRead = 0;
+ while( (bytesRead = s.read(buffer, 0, buffer.length)) > 0) {
+ final String str = new String(buffer, 0, bytesRead, encoding);
+ result.append(str);
+ }
+ return result.toString();
+ }
+}
Propchange:
incubator/sling/trunk/scripting/jst/src/test/java/org/apache/sling/scripting/jst/StringUtil.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/sling/trunk/scripting/jst/src/test/java/org/apache/sling/scripting/jst/StringUtil.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision Rev URL
Added:
incubator/sling/trunk/scripting/jst/src/test/resources/htmlcode/htmlcode1.expected.html
URL:
http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/jst/src/test/resources/htmlcode/htmlcode1.expected.html?rev=669182&view=auto
==============================================================================
---
incubator/sling/trunk/scripting/jst/src/test/resources/htmlcode/htmlcode1.expected.html
(added)
+++
incubator/sling/trunk/scripting/jst/src/test/resources/htmlcode/htmlcode1.expected.html
Wed Jun 18 07:25:55 2008
@@ -0,0 +1,24 @@
+<html>
+ <head>
+ <!-- TODO TEST why is the meta doubled? -->
+ <META http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
+ <title>test.title</title>
+ <script src="/CONTEXT/SERVLET/system/sling.js"></script>
+ <script language="javascript">var
currentNode={"title":"test.title","desc":"test.desc"};</script>
+ </head>
+ <body>
+ <div id="JstDefaultRendering">
+ <h1>Node dumped by HtmlRendererServlet</h1>
+ <p>Node path: <b>/foo/node</b></p>
+ <p>Resource metadata: <b>{sling.resolutionPath=/foo/node}</b></p>
+ <h2>Node properties</h2>
+ title: <b>test.title</b><br/>desc: <b>test.desc</b><br/>
+ </div>
+ <script language="javascript">
+ var e = document.getElementById("JstDefaultRendering");
+ e.parentNode.removeChild(e);
+ </script>
+ <script src="/CONTEXT/SERVLET/htmlcode/htmlcode1.input.jst.jst.js"></script>
+ </body>
+</html>
\ No newline at end of file
Propchange:
incubator/sling/trunk/scripting/jst/src/test/resources/htmlcode/htmlcode1.expected.html
------------------------------------------------------------------------------
svn:eol-style = native
Added:
incubator/sling/trunk/scripting/jst/src/test/resources/htmlcode/htmlcode1.input.jst
URL:
http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/jst/src/test/resources/htmlcode/htmlcode1.input.jst?rev=669182&view=auto
==============================================================================
---
incubator/sling/trunk/scripting/jst/src/test/resources/htmlcode/htmlcode1.input.jst
(added)
+++
incubator/sling/trunk/scripting/jst/src/test/resources/htmlcode/htmlcode1.input.jst
Wed Jun 18 07:25:55 2008
@@ -0,0 +1,9 @@
+<html>
+ <head>
+ <META http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>Ignored, this should be replaced by the node path</title>
+ </head>
+ <body>
+ <%= currentNode.title %>
+ </body>
+</html>
\ No newline at end of file
Added:
incubator/sling/trunk/scripting/jst/src/test/resources/jscode/jscode1.expected.js
URL:
http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/jst/src/test/resources/jscode/jscode1.expected.js?rev=669182&view=auto
==============================================================================
---
incubator/sling/trunk/scripting/jst/src/test/resources/jscode/jscode1.expected.js
(added)
+++
incubator/sling/trunk/scripting/jst/src/test/resources/jscode/jscode1.expected.js
Wed Jun 18 07:25:55 2008
@@ -0,0 +1,2 @@
+out=document;
+out.write(" ");out.write( currentNode.title );out.write("\n");
\ No newline at end of file
Propchange:
incubator/sling/trunk/scripting/jst/src/test/resources/jscode/jscode1.expected.js
------------------------------------------------------------------------------
svn:eol-style = native
Added:
incubator/sling/trunk/scripting/jst/src/test/resources/jscode/jscode1.input.jst
URL:
http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/jst/src/test/resources/jscode/jscode1.input.jst?rev=669182&view=auto
==============================================================================
---
incubator/sling/trunk/scripting/jst/src/test/resources/jscode/jscode1.input.jst
(added)
+++
incubator/sling/trunk/scripting/jst/src/test/resources/jscode/jscode1.input.jst
Wed Jun 18 07:25:55 2008
@@ -0,0 +1,11 @@
+<html>
+ <!--
+ The currentNode.whatever code must not be output,
+ JST considers only what's inside <body>
+ for javascript generation
+ -->
+ <%= currentNode.whatever %>
+ <body>
+ <%= currentNode.title %>
+ </body>
+</html>
\ No newline at end of file
Added:
incubator/sling/trunk/scripting/jst/src/test/resources/jscode/jscode2.expected.js
URL:
http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/jst/src/test/resources/jscode/jscode2.expected.js?rev=669182&view=auto
==============================================================================
---
incubator/sling/trunk/scripting/jst/src/test/resources/jscode/jscode2.expected.js
(added)
+++
incubator/sling/trunk/scripting/jst/src/test/resources/jscode/jscode2.expected.js
Wed Jun 18 07:25:55 2008
@@ -0,0 +1 @@
+out=document;
\ No newline at end of file
Propchange:
incubator/sling/trunk/scripting/jst/src/test/resources/jscode/jscode2.expected.js
------------------------------------------------------------------------------
svn:eol-style = native
Added:
incubator/sling/trunk/scripting/jst/src/test/resources/jscode/jscode2.input.jst
URL:
http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/jst/src/test/resources/jscode/jscode2.input.jst?rev=669182&view=auto
==============================================================================
---
incubator/sling/trunk/scripting/jst/src/test/resources/jscode/jscode2.input.jst
(added)
+++
incubator/sling/trunk/scripting/jst/src/test/resources/jscode/jscode2.input.jst
Wed Jun 18 07:25:55 2008
@@ -0,0 +1,7 @@
+<html>
+ <!--
+ Missing <body> tag, nothing must be output
+ -->
+ <%= currentNode.whatever %>
+ <b>This will not generate javascript code</b>
+</html>
\ No newline at end of file