Author: rombert
Date: Mon Sep 18 20:39:45 2017
New Revision: 1808775

URL: http://svn.apache.org/viewvc?rev=1808775&view=rev
Log:
SLING-7133 - Add minimal HTL tests to launchpad/testing

Add first batch of tests - simple HTL scripts with JS and Java use

Added:
    
sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/scripting/htl/
    
sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/scripting/htl/HtlTest.java
    
sling/trunk/launchpad/integration-tests/src/main/resources/integration-test/htl/
    
sling/trunk/launchpad/integration-tests/src/main/resources/integration-test/htl/Bean.java
    
sling/trunk/launchpad/integration-tests/src/main/resources/integration-test/htl/java.html
    
sling/trunk/launchpad/integration-tests/src/main/resources/integration-test/htl/js.html
    
sling/trunk/launchpad/integration-tests/src/main/resources/integration-test/htl/script.js

Added: 
sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/scripting/htl/HtlTest.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/scripting/htl/HtlTest.java?rev=1808775&view=auto
==============================================================================
--- 
sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/scripting/htl/HtlTest.java
 (added)
+++ 
sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/scripting/htl/HtlTest.java
 Mon Sep 18 20:39:45 2017
@@ -0,0 +1,58 @@
+/*
+ * 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.scripting.htl;
+
+import java.io.IOException;
+import java.util.Collections;
+
+import org.apache.sling.commons.testing.integration.HttpTestBase;
+
+public class HtlTest extends HttpTestBase {
+    
+    protected void tearDown() throws IOException {
+        testClient.delete(HTTP_BASE_URL + "/apps/sling/test/htl");
+        testClient.delete(HTTP_BASE_URL + "/content/htl");
+    }
+
+    public void testScriptWithJsUseBean() throws IOException {
+
+        testClient.mkdirs(HTTP_BASE_URL, "/apps/sling/test/htl/js");
+        testClient.upload(HTTP_BASE_URL + "/apps/sling/test/htl/js/js.html", 
getClass().getResourceAsStream("/integration-test/htl/js.html"));
+        testClient.upload(HTTP_BASE_URL + "/apps/sling/test/htl/js/script.js", 
getClass().getResourceAsStream("/integration-test/htl/script.js"));
+        
+        testClient.createNode(HTTP_BASE_URL + "/content/htl/js-use-bean", 
Collections.singletonMap("sling:resourceType", "sling/test/htl/js"));
+        
+        String content = getContent(HTTP_BASE_URL + 
"/content/htl/js-use-bean.html", CONTENT_TYPE_DONTCARE, null, 200);
+        
+        assertTrue("Expected content to contain 'from-js-use-script'", 
content.contains("from-js-use-script"));
+    }
+    
+    public void testScriptWithJavaUseBean() throws IOException {
+        
+        testClient.mkdirs(HTTP_BASE_URL, "/apps/sling/test/htl/java");
+        testClient.mkdirs(HTTP_BASE_URL, "/content/htl");
+        
+        testClient.upload(HTTP_BASE_URL + 
"/apps/sling/test/htl/java/java.html", 
getClass().getResourceAsStream("/integration-test/htl/java.html"));
+        testClient.upload(HTTP_BASE_URL + 
"/apps/sling/test/htl/java/Bean.java", 
getClass().getResourceAsStream("/integration-test/htl/Bean.java"));
+        
+        testClient.createNode(HTTP_BASE_URL + "/content/htl/java-use-bean", 
Collections.singletonMap("sling:resourceType", "sling/test/htl/java"));
+        
+        String content = getContent(HTTP_BASE_URL + 
"/content/htl/java-use-bean.html", CONTENT_TYPE_DONTCARE, null, 200);
+        
+        assertTrue("Expected content to contain 'from-js-use-script'", 
content.contains("from-java-use-bean"));
+    }
+}

Added: 
sling/trunk/launchpad/integration-tests/src/main/resources/integration-test/htl/Bean.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/launchpad/integration-tests/src/main/resources/integration-test/htl/Bean.java?rev=1808775&view=auto
==============================================================================
--- 
sling/trunk/launchpad/integration-tests/src/main/resources/integration-test/htl/Bean.java
 (added)
+++ 
sling/trunk/launchpad/integration-tests/src/main/resources/integration-test/htl/Bean.java
 Mon Sep 18 20:39:45 2017
@@ -0,0 +1,9 @@
+package apps.sling.test.htl.java;
+
+import java.util.Date;
+
+public class Bean {
+    public String getStatic() {
+        return "from-java-use-bean";
+    }
+}
\ No newline at end of file

Added: 
sling/trunk/launchpad/integration-tests/src/main/resources/integration-test/htl/java.html
URL: 
http://svn.apache.org/viewvc/sling/trunk/launchpad/integration-tests/src/main/resources/integration-test/htl/java.html?rev=1808775&view=auto
==============================================================================
--- 
sling/trunk/launchpad/integration-tests/src/main/resources/integration-test/htl/java.html
 (added)
+++ 
sling/trunk/launchpad/integration-tests/src/main/resources/integration-test/htl/java.html
 Mon Sep 18 20:39:45 2017
@@ -0,0 +1,29 @@
+<!--
+/*
+ * 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.
+ */
+-->
+<!DOCTYPE html!>
+<html>
+ <head>
+   <title>Page with Java use-bean</title>
+  </head>
+  <body>
+       <div data-sly-use.bean="Bean">
+               ${bean.static}
+       </div>
+  </body>
+</html>
\ No newline at end of file

Added: 
sling/trunk/launchpad/integration-tests/src/main/resources/integration-test/htl/js.html
URL: 
http://svn.apache.org/viewvc/sling/trunk/launchpad/integration-tests/src/main/resources/integration-test/htl/js.html?rev=1808775&view=auto
==============================================================================
--- 
sling/trunk/launchpad/integration-tests/src/main/resources/integration-test/htl/js.html
 (added)
+++ 
sling/trunk/launchpad/integration-tests/src/main/resources/integration-test/htl/js.html
 Mon Sep 18 20:39:45 2017
@@ -0,0 +1,29 @@
+<!--
+/*
+ * 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.
+ */
+-->
+<!DOCTYPE html!>
+<html>
+ <head>
+   <title>Page with JS use-script</title>
+  </head>
+  <body>
+       <div data-sly-use.scr="script.js">
+               ${scr.static}
+       </div>
+  </body>
+</html>
\ No newline at end of file

Added: 
sling/trunk/launchpad/integration-tests/src/main/resources/integration-test/htl/script.js
URL: 
http://svn.apache.org/viewvc/sling/trunk/launchpad/integration-tests/src/main/resources/integration-test/htl/script.js?rev=1808775&view=auto
==============================================================================
--- 
sling/trunk/launchpad/integration-tests/src/main/resources/integration-test/htl/script.js
 (added)
+++ 
sling/trunk/launchpad/integration-tests/src/main/resources/integration-test/htl/script.js
 Mon Sep 18 20:39:45 2017
@@ -0,0 +1,23 @@
+/*
+ * 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.
+ */
+
+"use strict";
+use(function() {
+    return {
+        "static": "from-js-use-script"
+    }
+});
\ No newline at end of file


Reply via email to