You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/09/18 20:39:57 UTC

svn commit: r1808776 - in /sling/trunk/launchpad: integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/scripting/htl/ integration-tests/src/main/resources/integration-test/htl/ test-services/ test-services/src/main/java/org...

Author: rombert
Date: Mon Sep 18 20:39:57 2017
New Revision: 1808776

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

Add a test which uses a Sling Model bean - passes with Java 8 but fails
with Java 9.

Added:
    sling/trunk/launchpad/integration-tests/src/main/resources/integration-test/htl/model.html
    sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/models/
    sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/models/DummyModel.java
Modified:
    sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/scripting/htl/HtlTest.java
    sling/trunk/launchpad/test-services/pom.xml

Modified: 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=1808776&r1=1808775&r2=1808776&view=diff
==============================================================================
--- sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/scripting/htl/HtlTest.java (original)
+++ sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/scripting/htl/HtlTest.java Mon Sep 18 20:39:57 2017
@@ -53,6 +53,20 @@ public class HtlTest extends HttpTestBas
         
         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"));
+        assertTrue("Expected content to contain 'from-java-use-script'", content.contains("from-java-use-bean"));
+    }
+    
+    public void testScriptWithModelUseBean() throws IOException {
+        
+        testClient.mkdirs(HTTP_BASE_URL, "/apps/sling/test/htl/model");
+        testClient.mkdirs(HTTP_BASE_URL, "/content/htl");
+        
+        testClient.upload(HTTP_BASE_URL + "/apps/sling/test/htl/model/model.html", getClass().getResourceAsStream("/integration-test/htl/model.html"));
+        
+        testClient.createNode(HTTP_BASE_URL + "/content/htl/model-use-bean", Collections.singletonMap("sling:resourceType", "sling/test/htl/model"));
+        
+        String content = getContent(HTTP_BASE_URL + "/content/htl/model-use-bean.html", CONTENT_TYPE_DONTCARE, null, 200);
+        
+        assertTrue("Expected content to contain 'from-sling-model'", content.contains("from-sling-model"));
     }
 }

Added: sling/trunk/launchpad/integration-tests/src/main/resources/integration-test/htl/model.html
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/integration-tests/src/main/resources/integration-test/htl/model.html?rev=1808776&view=auto
==============================================================================
--- sling/trunk/launchpad/integration-tests/src/main/resources/integration-test/htl/model.html (added)
+++ sling/trunk/launchpad/integration-tests/src/main/resources/integration-test/htl/model.html Mon Sep 18 20:39:57 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 Model use-bean</title>
+  </head>
+  <body>
+  	<div data-sly-use.model="org.apache.sling.launchpad.testservices.models.DummyModel">
+  		${model.message}
+  	</div>
+  </body>
+</html>
\ No newline at end of file

Modified: sling/trunk/launchpad/test-services/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/test-services/pom.xml?rev=1808776&r1=1808775&r2=1808776&view=diff
==============================================================================
--- sling/trunk/launchpad/test-services/pom.xml (original)
+++ sling/trunk/launchpad/test-services/pom.xml Mon Sep 18 20:39:57 2017
@@ -59,7 +59,8 @@
                             *
                         </Import-Package>
                         <Export-Package>
-                          org.apache.sling.launchpad.testservices.exported.*
+                          org.apache.sling.launchpad.testservices.exported,
+                          org.apache.sling.launchpad.testservices.models
                         </Export-Package>
                         <Private-Package>
                             org.apache.sling.launchpad.testservices.*
@@ -81,6 +82,9 @@
                         <Embed-Dependency>
                         org.apache.felix.utils;inline=org/apache/felix/utils/json/JSONWriter.class
                     </Embed-Dependency>
+                        <Sling-Model-Packages>
+                          org.apache.sling.launchpad.testservices.models
+                        </Sling-Model-Packages>
                     </instructions>
                 </configuration>
             </plugin>
@@ -162,6 +166,11 @@
         </dependency>
         <dependency>
             <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.models.api</artifactId>
+            <version>1.3.6</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.junit.core</artifactId>
             <version>1.0.26</version>
             <scope>provided</scope>

Added: sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/models/DummyModel.java
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/models/DummyModel.java?rev=1808776&view=auto
==============================================================================
--- sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/models/DummyModel.java (added)
+++ sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/models/DummyModel.java Mon Sep 18 20:39:57 2017
@@ -0,0 +1,37 @@
+/*
+ * 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.testservices.models;
+
+import javax.annotation.PostConstruct;
+
+import org.apache.sling.api.SlingHttpServletRequest;
+import org.apache.sling.models.annotations.Model;
+
+@Model(adaptables = SlingHttpServletRequest.class)
+public class DummyModel {
+
+    private String message;
+    
+    @PostConstruct
+    public void init() {
+        message = "from-sling-model";
+    }
+    
+    public String getMessage() {
+        return message;
+    }
+}