com.github.tomakehurst.wiremock.client.VerificationException:任何存根映射都无法匹配请求

问题描述

我正在尝试创建简单的wiremock 测试应用程序。我在 mapping.json 文件中创建了存根,但是在使用“mvn clean test”运行测试时,我收到了 VerificationException。我的java代码是-

String url = "http://localhost:8080/api/resources/";
    HttpClient client = HttpClientBuilder.create().build();
    HttpUriRequest request = new HttpGet(url);
    request.addHeader("Content-Type","application/json");
    request.addHeader("Accept","application/json");
    HttpResponse response = client.execute(request);
    verify(getRequestedFor(urlPathEqualTo("/api/resources/"))
            .withHeader("Content-Type",equalTo("application/json")));

有人可以让我知道我错过了什么。 json文件-


        {
        "mappings": [
            {
                "request": {
                    "method": "GET","url": "/api/resources"
                },"response": {
                    "status": 200,"bodyFileName": "wiremock-test.json","headers": {
                        "Content-Type": "application/json"
                    }
                }
            }
        ]
        }

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)