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

paulk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git


The following commit(s) were added to refs/heads/master by this push:
     new eb48eeb8e7 GroovyGROOVY-11879: A very simple DSL over the JDK's HTTP 
client (make test reliable)
eb48eeb8e7 is described below

commit eb48eeb8e7c3bba940fcdee3977758e880b2b9b5
Author: Paul King <[email protected]>
AuthorDate: Sun Mar 29 15:29:34 2026 +1000

    GroovyGROOVY-11879: A very simple DSL over the JDK's HTTP client (make test 
reliable)
---
 .../src/spec/test/HttpBuilderSpecTest.groovy       | 34 +++++++++++++---------
 1 file changed, 20 insertions(+), 14 deletions(-)

diff --git 
a/subprojects/groovy-http-builder/src/spec/test/HttpBuilderSpecTest.groovy 
b/subprojects/groovy-http-builder/src/spec/test/HttpBuilderSpecTest.groovy
index f66f784030..776c6532af 100644
--- a/subprojects/groovy-http-builder/src/spec/test/HttpBuilderSpecTest.groovy
+++ b/subprojects/groovy-http-builder/src/spec/test/HttpBuilderSpecTest.groovy
@@ -19,13 +19,10 @@
 import com.sun.net.httpserver.HttpServer
 import org.junit.jupiter.api.AfterEach
 import org.junit.jupiter.api.BeforeEach
-import org.junit.jupiter.api.Disabled
 import org.junit.jupiter.api.Test
 
 import java.nio.charset.StandardCharsets
 
-import static org.junit.jupiter.api.Assumptions.assumeFalse
-
 class HttpBuilderSpecTest {
 
     private HttpServer server
@@ -82,6 +79,20 @@ class HttpBuilderSpecTest {
                 exchange.responseBody.withCloseable { it.write(bytes) }
             }
         }
+        server.createContext('/artifact/org.apache.groovy/groovy-all') { 
exchange ->
+            String body = '''<!DOCTYPE html>
+<html>
+<head><title>Maven Repository: org.apache.groovy : groovy-all</title></head>
+<body>
+<h2 class="im-title"><a 
href="/artifact/org.apache.groovy/groovy-all">groovy-all</a></h2>
+<span class="badge badge-license">Apache 2.0</span>
+</body>
+</html>'''
+            byte[] bytes = body.getBytes(StandardCharsets.UTF_8)
+            exchange.responseHeaders.add('Content-Type', 'text/html; 
charset=UTF-8')
+            exchange.sendResponseHeaders(200, bytes.length)
+            exchange.responseBody.withCloseable { it.write(bytes) }
+        }
         server.start()
         rootUri = URI.create("http://127.0.0.1:${server.address.port}";)
     }
@@ -187,22 +198,17 @@ class HttpBuilderSpecTest {
         """
     }
 
-    @Disabled("Requires external site and may fail due to 403 error")
     @Test
     void testHtmlJsoup() {
-        // Skip on JDKs with TLS fingerprints that trigger Cloudflare bot 
detection
-        def jdkVersion = Runtime.version().feature()
-        assumeFalse(jdkVersion in [18, 19, 20, 22],
-            "Skipping on JDK ${jdkVersion} due to Cloudflare TLS 
fingerprinting")
-
-        assertScript '''
+        def mvnrepositoryUri = rootUri
+        assertScript """
         import static groovy.http.HttpBuilder.http
 
         // tag::html_jsoup[]
         // @Grab('org.jsoup:jsoup:1.22.1') // needed if running as standalone 
script
-        def client = http('https://mvnrepository.com')
-        def res = client.get('/artifact/org.codehaus.groovy/groovy-all') {
-            header 'User-Agent', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 
10_15_7) AppleWebKit/537.36'
+        def client = http('${mvnrepositoryUri}')
+        def res = client.get('/artifact/org.apache.groovy/groovy-all') {
+            header 'User-Agent', 'Mozilla/5.0 (Macintosh)'
         }
 
         assert res.status == 200
@@ -210,7 +216,7 @@ class HttpBuilderSpecTest {
         def license = 
res.parsed.select('span.badge.badge-license')*.text().join(', ')
         assert license == 'Apache 2.0'
         // end::html_jsoup[]
-        '''
+        """
     }
 
     @Test

Reply via email to