Copilot commented on code in PR #15478:
URL: https://github.com/apache/grails-core/pull/15478#discussion_r2910181367


##########
grails-test-examples/issue-11102/src/integration-test/groovy/issue11102/TestControllerSpec.groovy:
##########
@@ -16,38 +16,29 @@
  *  specific language governing permissions and limitations
  *  under the License.
  */
-
 package issue11102
 
+import spock.lang.Specification
+
 import grails.testing.mixin.integration.Integration
-import grails.testing.spock.OnceBefore
-import io.micronaut.http.HttpRequest
-import io.micronaut.http.HttpResponse
-import io.micronaut.http.HttpStatus
-import io.micronaut.http.client.HttpClient
+import org.apache.grails.testing.http.client.HttpClient
 
 @Integration
-class TestControllerSpec extends HttpClientCommonSpec {
+class TestControllerSpec extends Specification {
 
-    @OnceBefore
-    void init() {
-        this.baseUrl = "http://localhost:$serverPort";
-        this.client = HttpClient.create(new URL(baseUrl))
-    }
+    @Autowired HttpClient http
 

Review Comment:
   `@Autowired` is used but 
`org.springframework.beans.factory.annotation.Autowired` is not imported, so 
this spec will not compile. Add the missing import (or use the fully-qualified 
annotation name).



##########
grails-test-examples/hibernate5/grails-multiple-datasources/src/integration-test/groovy/functionaltests/MultiDataSourceWithSessionSpec.groovy:
##########
@@ -16,71 +16,61 @@
  *  specific language governing permissions and limitations
  *  under the License.
  */
-
 package functionaltests
 
-import datasources.Application
-import grails.testing.mixin.integration.Integration
-import grails.testing.spock.OnceBefore
-import io.micronaut.http.client.HttpClient
 import spock.lang.Issue
-import spock.lang.Shared
 import spock.lang.Specification
 import spock.lang.Stepwise
 
-@Integration(applicationClass = Application)
+import grails.testing.mixin.integration.Integration
+import org.apache.grails.testing.http.client.HttpClient
+
 @Stepwise
+@Integration
 class MultiDataSourceWithSessionSpec extends Specification {
 
-    @Shared
-    HttpClient client
-
-    @OnceBefore
-    void init() {
-        String baseUrl = "http://localhost:$serverPort";
-        this.client = HttpClient.create(baseUrl.toURL())
-    }
+    @Autowired HttpClient http
 

Review Comment:
   `@Autowired` is referenced but the file does not import 
`org.springframework.beans.factory.annotation.Autowired`, which will cause a 
compilation error. Add the missing import (or qualify the annotation).



##########
grails-doc/src/en/guide/testing/integrationTesting.adoc:
##########
@@ -286,6 +286,127 @@ Example usage:
 ----
 
 
+[[httpClientTestingSupport]]
+==== HTTP Client Testing Support
+
+For integration and functional tests that call live HTTP endpoints, Grails 
provides the
+`grails-testing-support-http-client` module.
+
+Add the dependency to your integration test configuration:
+
+[source,groovy]
+----
+dependencies {
+    integrationTestImplementation 
'org.apache.grails:grails-testing-support-http-client'
+}
+----
+
+You can then inject an `HttpClient` in your Spock specification and use helper 
methods for
+request building and response assertions:
+
+[source,groovy]
+----
+import java.net.http.HttpTimeoutException
+
+import spock.lang.Specification
+
+import grails.testing.mixin.integration.Integration
+import org.apache.grails.testing.http.client.HttpClient
+
+@Integration
+class DemoSpec extends Specification {
+
+    @Autowired HttpClient http
+
+    void 'simple GET with status and body assertions'() {

Review Comment:
   The new documentation snippet uses `@Autowired HttpClient http` but does not 
include the `org.springframework.beans.factory.annotation.Autowired` import, so 
the example as written won’t compile when copied. Add the missing import to the 
example block.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to