2016-03-05 2 views
6

Ich habe wireMock Server wie folgt definiert: -Wiremock 404 für eine gekürzte URL Rückkehr

private WireMockServer wireMockServer; 
    @Before 
    public void preSetup() throws Exception { 
    wireMockServer = new WireMockServer(56789); 
    wireMockServer.start(); 
    }; 

    @Override 
    @After 
    public void tearDown() { 
    wireMockServer.stop(); 
    } 

    @Test 
    public void testSendMatchingMessage() throws Exception { 

    wireMockServer.stubFor(get(urlEqualTo("/orders/v1/ordersearch/")) 
     .willReturn(aResponse().withStatus(200).withBody("<response>Some content</response>"))); 

    } 

Aber immer, wenn ich die URL so etwas wie unten

http://0.0.0.0:56789/orders/v1/ordersearch/?field=address%2Cfinance%2Cshipping&limit=10&page=2&q=createdFrom.gt%7E2016-01-11T10%3A12%3A13 

bin Schlage ich die unten stehende Störung erhalte: -

<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/> 
<title>Error 404 NOT_FOUND</title> 
</head> 
<body><h2>HTTP ERROR 404</h2> 
<p>Problem accessing /__files/orders/v1/ordersearch/. Reason: 
<pre> NOT_FOUND</pre></p><hr /><i><small>Powered by Jetty://</small></i><br/>             
<br/>             
<br/>             
<br/>             
<br/>             
<br/>             
<br/>             
<br/>             
<br/>  
</body> 
</html> 

Kann mir jemand sagen, was ich falsch mache?

Antwort

11

Per Stubbing - Wiremock (der erste in Google auf "wiremockserver urlequalto"):

Note: you must use urlPathEqualTo or urlPathMatching to specify the path, as urlEqualTo or urlMatching will attempt to match the whole request URL, including the query parameters.

Verwandte Themen