stub not matching, how do I debug?

9,823 views
Skip to first unread message

Martin d'Anjou

unread,
Jan 8, 2016, 11:36:00 AM1/8/16
to wiremock-user
Hi,

I have a simple stub that I can't match, and I do not know why. Can someone help me debug it? WireMock returns a 404 (Problem accessing /__files/path. Reason: Not Found).

The code is on my fork of the http-request-plugin github project.

It takes a few seconds to reproduce:
git clone --branch feature/wiremock-tests https://github.com/martinda/http-request-plugin.git
mvn
-Dtest=HttpRequestTestWireMock#testWithMock test

I would also be interested in knowing if there is a way display the actual packets. I tried a few maven options with no luck:
mvn \
 
-Dorg.eclipse.jetty.LEVEL=ALL \
 
-Dorg.apache.commons.logging.simplelog.log.org.apache.http=DEBUG \
 
-Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.SimpleLog \
 
-Dtest=HttpRequestTestWireMock#testWithMock \
  test

Thanks in advance,
Martin

Tom Akehurst

unread,
Jan 12, 2016, 7:28:37 AM1/12/16
to wiremock-user
Suggest you enable verbose logging by WireMock. If you're using the standalone runner it's just --verbose on the CLI, or add new ConsoleNotifier(true) as the notifier in wireMockConfig()... if you're newing up WireMock programmatically.

Martin d'Anjou

unread,
Jan 12, 2016, 7:20:57 PM1/12/16
to wiremock-user

Tom Akehurst

unread,
Jan 13, 2016, 3:05:18 AM1/13/16
to wiremock-user
Can you post the stub details, the request you're making and the log output?

Martin d'Anjou

unread,
Jan 13, 2016, 9:22:53 AM1/13/16
to wiremock-user
On Wednesday, January 13, 2016 at 3:05:18 AM UTC-5, Tom Akehurst wrote:
Can you post the stub details, the request you're making and the log output?

Certainly.

The stub:
 wireMockServer.stubFor(get(urlEqualTo("path"))
     
.willReturn(aResponse()
     
.withHeader("Content-Type", "text/plain")
     
.withBody("Hello World")));


The request:
// The following is NOT apache's HttpRequest
// It is from: https://github.com/martinda/http-request-plugin/blob/feature/wiremock-tests/src/main/java/jenkins/plugins/http_request/HttpRequest.java
project
.getBuildersList().add(new HttpRequest(urlForTest+"path",
     
HttpMode.GET, "", MimeType.NOT_SET, MimeType.NOT_SET, "",
     
null, true, false, null, 0, "", ""));

The response:
Failed tests:
 
HttpRequestTestWireMock.testWithMock:96 unexpected build status; build log was:
------
Legacy code started this job.  No cause information is available
Building in workspace /tmp/hudson6469019283126156188test/workspace/test0
HttpMode: GET
URL
: http://localhost:49152/path
Sending request to url: http://localhost:49152/path
Response Code: HTTP/1.1 404 Not Found
Response:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1"/>
<title>Error 404 </title>
</
head>
<body>
<h2>HTTP ERROR: 404</h2>
<p>Problem accessing /
__files/path. Reason:
<pre>    Not Found</pre></p>
<hr /><i><small>Powered by Jetty://</small></i>
</body>
</
html>

Fail: Any code list ([[100?399]]) match the returned code 404
Build step 'HTTP Request' marked build as failure
Finished: FAILURE

------

Expected: is <SUCCESS>
     but
: was <FAILURE>

Tests run: 1, Failures: 1, Errors: 0, Skipped: 0


Tom Akehurst

unread,
Jan 13, 2016, 10:11:27 AM1/13/16
to wiremock-user
Try /path in the stub definition

Martin d'Anjou

unread,
Jan 13, 2016, 11:00:17 AM1/13/16
to wiremock-user
On Wednesday, January 13, 2016 at 10:11:27 AM UTC-5, Tom Akehurst wrote:
Try /path in the stub definition

That worked. Thank you!

Unfortunately, when combining Jenkins and jetty in the same test, there are warnings that come up, so I am not sure where this will lead in the end. It is probably an issue with Jenkins. I am also experimenting with org.apache.http.localserver.LocalServerTestBase which does not create those warnings.

Thanks again.
Martin
Reply all
Reply to author
Forward
0 new messages