Author: olli Date: Thu Aug 18 09:23:29 2016 New Revision: 1756747 URL: http://svn.apache.org/viewvc?rev=1756747&view=rev Log: SLING-5973 HTMLSerializer not handling some unicode characters (emoji, etc.)
add test Added: sling/trunk/contrib/extensions/rewriter/src/test/java/org/apache/sling/rewriter/it/ sling/trunk/contrib/extensions/rewriter/src/test/java/org/apache/sling/rewriter/it/tests/ sling/trunk/contrib/extensions/rewriter/src/test/java/org/apache/sling/rewriter/it/tests/EmojiIT.java sling/trunk/contrib/extensions/rewriter/src/test/java/org/apache/sling/rewriter/it/tests/RewriterTestSupport.java sling/trunk/contrib/extensions/rewriter/src/test/resources/ sling/trunk/contrib/extensions/rewriter/src/test/resources/apps/ sling/trunk/contrib/extensions/rewriter/src/test/resources/apps/esp/ sling/trunk/contrib/extensions/rewriter/src/test/resources/apps/esp/page/ sling/trunk/contrib/extensions/rewriter/src/test/resources/apps/esp/page/emoji/ sling/trunk/contrib/extensions/rewriter/src/test/resources/apps/esp/page/emoji/html.esp sling/trunk/contrib/extensions/rewriter/src/test/resources/content/ sling/trunk/contrib/extensions/rewriter/src/test/resources/content/rewriter.json Modified: sling/trunk/contrib/extensions/rewriter/pom.xml Modified: sling/trunk/contrib/extensions/rewriter/pom.xml URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/rewriter/pom.xml?rev=1756747&r1=1756746&r2=1756747&view=diff ============================================================================== --- sling/trunk/contrib/extensions/rewriter/pom.xml (original) +++ sling/trunk/contrib/extensions/rewriter/pom.xml Thu Aug 18 09:23:29 2016 @@ -7,9 +7,9 @@ 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 @@ -23,7 +23,7 @@ <parent> <groupId>org.apache.sling</groupId> <artifactId>sling</artifactId> - <version>26</version> + <version>28</version> <relativePath /> </parent> @@ -44,6 +44,11 @@ <url>http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/rewriter</url> </scm> + <properties> + <sling.java.version>7</sling.java.version> + <org.ops4j.pax.exam.version>4.9.1</org.ops4j.pax.exam.version> + </properties> + <build> <plugins> <plugin> @@ -83,6 +88,39 @@ </instructions> </configuration> </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-failsafe-plugin</artifactId> + <version>2.18.1</version> + <executions> + <execution> + <goals> + <goal>integration-test</goal> + <goal>verify</goal> + </goals> + </execution> + </executions> + <configuration> + <systemProperties> + <property> + <name>bundle.filename</name> + <value>${basedir}/target/${project.build.finalName}.jar</value> + </property> + </systemProperties> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.servicemix.tooling</groupId> + <artifactId>depends-maven-plugin</artifactId> + <version>1.2</version> + <executions> + <execution> + <goals> + <goal>generate-depends-file</goal> + </goals> + </execution> + </executions> + </plugin> </plugins> </build> @@ -128,16 +166,26 @@ <scope>provided</scope> </dependency> <dependency> + <groupId>org.apache.sling</groupId> + <artifactId>org.apache.sling.testing.paxexam</artifactId> + <version>0.0.2</version> + <scope>provided</scope> + </dependency> + <dependency> <groupId>javax.servlet</groupId> - <artifactId>servlet-api</artifactId> + <artifactId>javax.servlet-api</artifactId> + <scope>provided</scope> </dependency> + <!-- OSGi --> <dependency> <groupId>org.osgi</groupId> - <artifactId>org.osgi.core</artifactId> + <artifactId>osgi.cmpn</artifactId> + <scope>provided</scope> </dependency> <dependency> <groupId>org.osgi</groupId> - <artifactId>org.osgi.compendium</artifactId> + <artifactId>osgi.core</artifactId> + <scope>provided</scope> </dependency> <dependency> <groupId>org.slf4j</groupId> @@ -168,5 +216,56 @@ <version>1.9.5</version> <scope>test</scope> </dependency> + <!-- Apache Felix --> + <dependency> + <groupId>org.apache.felix</groupId> + <artifactId>org.apache.felix.framework</artifactId> + <version>5.4.0</version> + <scope>test</scope> + </dependency> + <!-- jsoup --> + <dependency> + <groupId>org.jsoup</groupId> + <artifactId>jsoup</artifactId> + <version>1.9.1</version> + <scope>test</scope> + </dependency> + <!-- testing --> + <dependency> + <groupId>org.apache.servicemix.bundles</groupId> + <artifactId>org.apache.servicemix.bundles.hamcrest</artifactId> + <version>1.3_1</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.ops4j.pax.exam</groupId> + <artifactId>pax-exam</artifactId> + <version>${org.ops4j.pax.exam.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.ops4j.pax.exam</groupId> + <artifactId>pax-exam-cm</artifactId> + <version>${org.ops4j.pax.exam.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.ops4j.pax.exam</groupId> + <artifactId>pax-exam-container-forked</artifactId> + <version>${org.ops4j.pax.exam.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.ops4j.pax.exam</groupId> + <artifactId>pax-exam-junit4</artifactId> + <version>${org.ops4j.pax.exam.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.ops4j.pax.exam</groupId> + <artifactId>pax-exam-link-mvn</artifactId> + <version>${org.ops4j.pax.exam.version}</version> + <scope>test</scope> + </dependency> </dependencies> </project> Added: sling/trunk/contrib/extensions/rewriter/src/test/java/org/apache/sling/rewriter/it/tests/EmojiIT.java URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/rewriter/src/test/java/org/apache/sling/rewriter/it/tests/EmojiIT.java?rev=1756747&view=auto ============================================================================== --- sling/trunk/contrib/extensions/rewriter/src/test/java/org/apache/sling/rewriter/it/tests/EmojiIT.java (added) +++ sling/trunk/contrib/extensions/rewriter/src/test/java/org/apache/sling/rewriter/it/tests/EmojiIT.java Thu Aug 18 09:23:29 2016 @@ -0,0 +1,60 @@ +/* + * 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.rewriter.it.tests; + +import java.io.IOException; + +import org.jsoup.Jsoup; +import org.jsoup.nodes.Document; +import org.jsoup.nodes.Element; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.ops4j.pax.exam.junit.PaxExam; +import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy; +import org.ops4j.pax.exam.spi.reactors.PerClass; + +import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertThat; + +@RunWith(PaxExam.class) +@ExamReactorStrategy(PerClass.class) +public class EmojiIT extends RewriterTestSupport { + + private Document document; + + @Before + public void setup() throws IOException { + final String url = String.format("http://localhost:%s/rewriter/emoji.html", httpPort()); + document = Jsoup.connect(url).get(); + } + + @Test + public void testTitle() throws IOException { + final String title = document.title(); + assertThat(title, is("emoji test")); + } + + @Test + public void testContent() throws IOException { + final Element content = document.getElementById("content"); + assertThat(content.text(), is("âð ð ð ð ð ðð")); + } + +} Added: sling/trunk/contrib/extensions/rewriter/src/test/java/org/apache/sling/rewriter/it/tests/RewriterTestSupport.java URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/rewriter/src/test/java/org/apache/sling/rewriter/it/tests/RewriterTestSupport.java?rev=1756747&view=auto ============================================================================== --- sling/trunk/contrib/extensions/rewriter/src/test/java/org/apache/sling/rewriter/it/tests/RewriterTestSupport.java (added) +++ sling/trunk/contrib/extensions/rewriter/src/test/java/org/apache/sling/rewriter/it/tests/RewriterTestSupport.java Thu Aug 18 09:23:29 2016 @@ -0,0 +1,69 @@ +/* + * 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.rewriter.it.tests; + +import org.apache.sling.testing.paxexam.TestSupport; +import org.ops4j.pax.exam.Configuration; +import org.ops4j.pax.exam.Option; +import org.ops4j.pax.exam.ProbeBuilder; +import org.ops4j.pax.exam.TestProbeBuilder; + +import static org.apache.sling.testing.paxexam.SlingOptions.slingCommonsHtml; +import static org.apache.sling.testing.paxexam.SlingOptions.slingLaunchpadOakTar; +import static org.apache.sling.testing.paxexam.SlingOptions.slingScriptingJavascript; +import static org.ops4j.pax.exam.CoreOptions.composite; +import static org.ops4j.pax.exam.CoreOptions.junitBundles; +import static org.ops4j.pax.exam.CoreOptions.mavenBundle; + +public abstract class RewriterTestSupport extends TestSupport { + + @Configuration + public Option[] configuration() { + return new Option[]{ + baseConfiguration(), + launchpad(), + // Sling Rewriter + testBundle("bundle.filename"), + // testing + mavenBundle().groupId("org.jsoup").artifactId("jsoup").versionAsInProject(), + mavenBundle().groupId("org.apache.servicemix.bundles").artifactId("org.apache.servicemix.bundles.hamcrest").versionAsInProject(), + junitBundles() + }; + } + + @ProbeBuilder + public TestProbeBuilder probeConfiguration(final TestProbeBuilder testProbeBuilder) { + testProbeBuilder.setHeader("Sling-Initial-Content", String.join(",", + "apps/esp;path:=/apps/esp;overwrite:=true;uninstall:=true", + "content;path:=/content;overwrite:=true;uninstall:=true" + )); + return testProbeBuilder; + } + + protected Option launchpad() { + final int httpPort = findFreePort(); + final String workingDirectory = workingDirectory(); + return composite( + slingLaunchpadOakTar(workingDirectory, httpPort), + slingCommonsHtml(), + slingScriptingJavascript() + ); + } + +} Added: sling/trunk/contrib/extensions/rewriter/src/test/resources/apps/esp/page/emoji/html.esp URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/rewriter/src/test/resources/apps/esp/page/emoji/html.esp?rev=1756747&view=auto ============================================================================== --- sling/trunk/contrib/extensions/rewriter/src/test/resources/apps/esp/page/emoji/html.esp (added) +++ sling/trunk/contrib/extensions/rewriter/src/test/resources/apps/esp/page/emoji/html.esp Thu Aug 18 09:23:29 2016 @@ -0,0 +1,28 @@ +<!DOCTYPE html> +<!-- + 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. +--> +<html> +<head> + <title><%= currentNode.title %></title> +</head> +<body> + <h1><%= currentNode.title %></h1> + <p id="content"><%= currentNode.content %></p> +</body> +</html> Added: sling/trunk/contrib/extensions/rewriter/src/test/resources/content/rewriter.json URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/rewriter/src/test/resources/content/rewriter.json?rev=1756747&view=auto ============================================================================== --- sling/trunk/contrib/extensions/rewriter/src/test/resources/content/rewriter.json (added) +++ sling/trunk/contrib/extensions/rewriter/src/test/resources/content/rewriter.json Thu Aug 18 09:23:29 2016 @@ -0,0 +1,11 @@ +{ + "jcr:primaryType": "nt:unstructured", + "sling:resourceType": "sling/servlet/default", + "title": "Apache Sling Rewriter", + "emoji": { + "jcr:primaryType": "nt:unstructured", + "sling:resourceType": "esp/page/emoji", + "title": "emoji test", + "content" : "âð ð ð ð ð ð\ud83c\udf40" + } +}