This is an automated email from the ASF dual-hosted git repository. rombert pushed a commit to branch issue/SLING-13071 in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-starter-integration-tests.git
commit b8ac6703b46fe88ee89212cea51e2d11a801ab6d Author: Robert Munteanu <[email protected]> AuthorDate: Fri Jan 23 13:55:14 2026 +0100 SLING-13071 - HTL use objects that adapt from the javax SlingHttpServletRequest cannot be instantiated a Jakarta context Add an integration test demonstarting the problem --- .../integrationtest/scripting/htl/HtlTest.java | 21 ++++++++++++++++ .../integration-test/htl/requesthashcode.html | 29 ++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/src/main/java/org/apache/sling/starter/webapp/integrationtest/scripting/htl/HtlTest.java b/src/main/java/org/apache/sling/starter/webapp/integrationtest/scripting/htl/HtlTest.java index f57f43d..4be239b 100644 --- a/src/main/java/org/apache/sling/starter/webapp/integrationtest/scripting/htl/HtlTest.java +++ b/src/main/java/org/apache/sling/starter/webapp/integrationtest/scripting/htl/HtlTest.java @@ -89,4 +89,25 @@ public class HtlTest extends HttpTestBase { assertTrue("Expected content to contain 'from-sling-model'", content.contains("from-sling-model")); } + + public void testScriptWithAdapterFactoryFromJavaxServlet() throws IOException { + + testClient.mkdirs(HTTP_BASE_URL, "/apps/sling/test/htl/requesthashcode"); + testClient.mkdirs(HTTP_BASE_URL, "/content/htl"); + + testClient.upload( + HTTP_BASE_URL + "/apps/sling/test/htl/requesthashcode/requesthashcode.html", + getClass().getResourceAsStream("/integration-test/htl/requesthashcode.html")); + + testClient.createNode( + HTTP_BASE_URL + "/content/htl/request-hashcode", + Collections.singletonMap("sling:resourceType", "sling/test/htl/requesthashcode")); + + String content = + getContent(HTTP_BASE_URL + "/content/htl/request-hashcode.html", CONTENT_TYPE_DONTCARE, null, 200); + + assertTrue( + "Expected content to contain 'Request hash code:' followed by a hash code", + content.matches("(?s).*Request hash code:\\s*\\d+.*")); + } } diff --git a/src/main/resources/integration-test/htl/requesthashcode.html b/src/main/resources/integration-test/htl/requesthashcode.html new file mode 100644 index 0000000..5928de4 --- /dev/null +++ b/src/main/resources/integration-test/htl/requesthashcode.html @@ -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 RequestHashCodePojo</title> + </head> + <body> + <div data-sly-use.pojo="org.apache.sling.starter.testservices.exported.RequestHashCodePojo"> + Request hash code: ${pojo.hashCode} + </div> + </body> +</html>
