无法使用WireMock存根查询

时间:2018-12-07 12:17:14

标签: java http request wiremock

问题是我的查询像:

/pc/odata/api/devices?$top=3000&$skip=0&$format=json&$expand=groups&$select=ID,Name,PrimaryIPAddress,groups/GroupPathLocation&$filter=((groups/Name%20eq%20'OI%20Inventory%20Group'))&timeout=120

不能用于

的存根
  

HTTP错误500

     

访问/ __ files / pc / odata / api / devices的问题。   原因:

     

查询索引138中的非法字符:   / not-matched?$ top = 3000&$ skip = 0&$ format = json&$ expand = groups&$ select = ID,Name,PrimaryIPAddress,groups / GroupPathLocation&$ filter =((groups / Name   eq'OI库存组'))&timeout = 120

该请求有效,并且该应用可与不带参数的相同查询一起使用。

存根方法:

public void initialize( Integer D_ITEM_COUNT ) {

    writedItemsFile( D_ITEM_COUNT );

        ClasspathFileSource responseFiles = new ClasspathFileSource( "." );
        dItemService = new WireMockServer( WireMockConfiguration.wireMockConfig()
                .port( D_ITEMS_SERVICE_PORT )
                .fileSource( responseFiles )
                .enableBrowserProxying( false )
                .notifier( new ConsoleNotifier( true ) ) );

        dItemService.givenThat( get( urlEqualTo( D_D_ITEMS_SERVICE_ENDPOINT ) ).
                willReturn( WireMock.aResponse()
                        .withHeader("Content-Type", "application/json")
                        .withBodyFile( "../" + D_ITEMS_SERVICE_RESPONSE_FILE + FILE_EXTENSION )
                        .withStatus( HttpStatus.SC_OK ) ) );
}

0 个答案:

没有答案