How can I simulate server for Unit test in Grails (Spock)? <p>I have written this simple service for doing subrequest via HTTPBuilder, to get instance of class representing obtained page for further use:</p> <pre><code>package cmspage import groovyx.net.http.HTTPBuilder import static groovyx.net.http.Method.GET import static groovyx.net.http.ContentType.HTML class CmsPageService { static transactional = false final String SUBREQUEST_HOST = "www.mydomainforsubrequest.com" CmsPage getCmsPageInstance(Object request) { String host = request.getServerName() String url = request.getRequestURI() HashMap queryMap = this.queryStringToMap(request.getQueryString()) return this.subRequest(host, url, queryMap) } CmsPage getCmsPageInstance(String host, String url, String queryString = null) { HashMap queryMap = queryStringToMap(queryString) return this.subRequest(host, url, queryMap) } private CmsPage subRequest(String host, String url, HashMap queryMap = null) { CmsPage cmsPageInstance = new CmsPage() HTTPBuilder http = new HTTPBuilder() http.request("http://" + SUBREQUEST_HOST, GET, HTML) { req -&gt; uri.path = url uri.query = queryMap headers.'X-Original-Host' = 'www.mydomain.com' response.success = { resp, html -&gt; cmsPageInstance.responseStatusCode = resp.status if (resp.status &lt; 400) { cmsPageInstance.html = html } } response.failure = { resp -&gt; cmsPageInstance.responseStatusCode = resp.status return null } } return cmsPageInstance } private HashMap queryStringToMap(String queryString) { if (queryString) { queryString = queryString.replace("?", "") String[] splitToParameters = queryString.split("&amp;") HashMap queryMap = new HashMap() splitToParameters.each { String[] split = it.split("=") for (int i = 0; i &lt; split.length; i += 2) { queryMap.put(split[i], split[i + 1]) } } return queryMap } else return null } } </code></pre> <p>Now I need to write unit test for this service. I would like to use some simple html document to test it instead of testing some "live" site. But I do not know how? Can anybody help me?</p>