mock-server / mockserver

MockServer enables easy mocking of any system you integrate with via HTTP or HTTPS with clients written in Java, JavaScript and Ruby. MockServer also includes a proxy that introspects all proxied traffic including encrypted SSL traffic and supports Port Forwarding, Web Proxying (i.e. HTTP proxy), HTTPS Tunneling Proxying (using HTTP CONNECT) and SOCKS Proxying (i.e. dynamic port forwarding).
http://mock-server.com
Apache License 2.0
4.59k stars 1.07k forks source link

Extension of MockServerClient to point to given endpoint #3

Closed wegax closed 10 years ago

wegax commented 10 years ago

For example I have deployed mockserver.war on apache tomcat. It's address is: http://localhost:8080/mockserver. Using MockServerClient I am unable to connect with the application becuase MockServerClient constructor only allows to provide HOSTNAME and PORT.

wegax commented 10 years ago

I have extended the MockServerClient with additional constructor which allows to provide full path to the application (i.e.: http://localhost:8080/mockserver). Unfortunatelly this has lead to problem with RequestUri in MockServerServlet which contains additionaly applicaiton context (for example requestUri for Reset is as follow: /mockserver/reset). The proposition for solving the issue is to cutoff httpServletRequest.getContextPath() from RequestUri in doPut and handlePOSTorGet.

jamesdbloom commented 10 years ago

Thanks this is a good point I missed as I typically use Jetty without any context path.

I'll look into this in the next day or two and add some tests to make sure this is covered in future.

I'll let you know once it has been committed and added to a SNAPSHOT.

jamesdbloom commented 10 years ago

I have committed a solution for this, now the MockServerClient has an additional context path parameter. In addition all matching, etc ignores the context path. As a result the context path can be changed and only the constructor call needs to be updated, all expectations should not need to change at all.

I'm closing this issue but let me know if you see anything else.

Thanks,

James

wegax commented 10 years ago

I have checked and it work as expected.

Marcin

2014/1/5 James D Bloom notifications@github.com

Closed #3 https://github.com/jamesdbloom/mockserver/issues/3.

— Reply to this email directly or view it on GitHubhttps://github.com/jamesdbloom/mockserver/issues/3 .