You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ra...@apache.org on 2022/10/04 07:17:49 UTC

[sling-org-apache-sling-scripting-sightly-testing] branch master updated: SLING-11608 - Cache script dependency resolution

This is an automated email from the ASF dual-hosted git repository.

radu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scripting-sightly-testing.git


The following commit(s) were added to refs/heads/master by this push:
     new 832200f  SLING-11608 - Cache script dependency resolution
832200f is described below

commit 832200fba643abda49a76c5882909e8bb30d875d
Author: Radu Cotescu <ra...@apache.org>
AuthorDate: Tue Oct 4 09:13:43 2022 +0200

    SLING-11608 - Cache script dependency resolution
    
    * updated the tests to use the new HTL engine
    * made the launchpad checks more resilient
---
 pom.xml                               |  4 ++--
 src/test/java/LaunchpadReadyIT.java   |  8 --------
 src/test/java/LaunchpadReadyRule.java | 36 +++++++++++++++++++++++++++++++----
 3 files changed, 34 insertions(+), 14 deletions(-)

diff --git a/pom.xml b/pom.xml
index e70fd57..23e5319 100644
--- a/pom.xml
+++ b/pom.xml
@@ -402,13 +402,13 @@ Require-Capability: osgi.extender;filter:="(&(osgi.extender=sling.scripting)(ver
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.scripting.spi</artifactId>
-            <version>1.0.2</version>
+            <version>1.0.4</version>
             <scope>provided</scope>
         </dependency>
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.scripting.core</artifactId>
-            <version>2.4.0</version>
+            <version>2.4.8</version>
             <scope>provided</scope>
         </dependency>
         <dependency>
diff --git a/src/test/java/LaunchpadReadyIT.java b/src/test/java/LaunchpadReadyIT.java
index 7762558..944f121 100644
--- a/src/test/java/LaunchpadReadyIT.java
+++ b/src/test/java/LaunchpadReadyIT.java
@@ -34,7 +34,6 @@ import org.apache.http.impl.client.BasicAuthCache;
 import org.apache.http.impl.client.BasicCredentialsProvider;
 import org.apache.http.impl.client.CloseableHttpClient;
 import org.apache.http.impl.client.HttpClientBuilder;
-import org.apache.sling.testing.clients.SlingClient;
 import org.apache.sling.testing.junit.rules.SlingInstanceRule;
 import org.hamcrest.CoreMatchers;
 import org.junit.Before;
@@ -142,13 +141,6 @@ public class LaunchpadReadyIT {
         }
     }
 
-    @Test
-    public void testLaunchpadReady() throws Exception {
-        SlingClient client = SLING_INSTANCE_RULE.getAdminClient();
-        client.waitUntilExists("/apps/sightly", 1000, 60);
-        client.waitUntilExists("/sightlytck", 1000, 60);
-    }
-
     private static class BundleStatus {
 
         long totalBundles;
diff --git a/src/test/java/LaunchpadReadyRule.java b/src/test/java/LaunchpadReadyRule.java
index 0e9325d..a6f850d 100644
--- a/src/test/java/LaunchpadReadyRule.java
+++ b/src/test/java/LaunchpadReadyRule.java
@@ -21,11 +21,20 @@ import java.net.ConnectException;
 import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.http.HttpHost;
 import org.apache.http.HttpResponse;
+import org.apache.http.auth.AuthScope;
+import org.apache.http.auth.UsernamePasswordCredentials;
+import org.apache.http.client.AuthCache;
+import org.apache.http.client.CredentialsProvider;
 import org.apache.http.client.methods.CloseableHttpResponse;
 import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.protocol.HttpClientContext;
+import org.apache.http.impl.auth.BasicScheme;
+import org.apache.http.impl.client.BasicAuthCache;
+import org.apache.http.impl.client.BasicCredentialsProvider;
 import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
+import org.apache.http.impl.client.HttpClientBuilder;
 import org.junit.rules.ExternalResource;
 
 public class LaunchpadReadyRule extends ExternalResource {
@@ -35,9 +44,24 @@ public class LaunchpadReadyRule extends ExternalResource {
 
     private final List<Check> checks = new ArrayList<>();
 
+    private final HttpClientContext context;
+
     public LaunchpadReadyRule(int launchpadPort) {
 
+        HttpHost targetHost = new HttpHost("localhost", launchpadPort, "http");
+        CredentialsProvider credsProvider = new BasicCredentialsProvider();
+        credsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials("admin", "admin"));
+
+        AuthCache authCache = new BasicAuthCache();
+        authCache.put(targetHost, new BasicScheme());
+
+        context = HttpClientContext.create();
+        context.setCredentialsProvider(credsProvider);
+        context.setAuthCache(authCache);
+
         checks.add(new Check("http://localhost:" + launchpadPort + "/server/default/jcr:root/content"));
+        checks.add(new Check("http://localhost:" + launchpadPort + "/apps/sightly.json"));
+        checks.add(new Check("http://localhost:" + launchpadPort + "/sightlytck.json"));
         checks.add(new Check("http://localhost:" + launchpadPort + "/content/starter.html") {
             @Override
             public String runCheck(HttpResponse response) throws Exception {
@@ -59,21 +83,25 @@ public class LaunchpadReadyRule extends ExternalResource {
 
     @Override
     protected void before() throws Throwable {
-
-        try (CloseableHttpClient client = HttpClients.createDefault()) {
+        try (CloseableHttpClient client = newClient()) {
             for (Check check : checks) {
                 runCheck(client, check);
             }
         }
     }
 
+    private CloseableHttpClient newClient() {
+
+        return HttpClientBuilder.create().build();
+    }
+
     private void runCheck(CloseableHttpClient client, Check check) throws Exception {
 
         String lastFailure = null;
         HttpGet get = new HttpGet(check.getUrl());
 
         for (int i = 0; i < TRIES; i++) {
-            try (CloseableHttpResponse response = client.execute(get)) {
+            try (CloseableHttpResponse response = client.execute(get, context)) {
 
                 if (response.getStatusLine().getStatusCode() != 200) {
                     lastFailure = "Status code is " + response.getStatusLine();