jersey - Embedded Java HTTPS server for integration testing -
i'm writing integration tests mule esb application connects external api via https. i'd mock external api , run end-to-end integration test during maven build. question setting embedded https server. i've tried use jersey, provides http. looking @ example
https://github.com/jersey/jersey/tree/master/examples/https-clientserver-grizzly
and wondering if there still manual step involved, or if works automatically setting every time build kicked off.
any suggestions or ideas?
edit. final goal deploy jax-rs service in embedded server accessible via https. , needs no client-side keys/certificate configuration.
edit 2. problem concerns certificates. point of integration tests mock external components , verify application works. now, if set embedded https server , use cmd-line built certificate, need add ssl configuration in client (as @ryan hoegg pointed out). not ideally want: there solution working without having modify client application code? should general java question goes beyond mule.
i use confluex-mock-http this. under hood uses jetty, configuration you. creating mockhttpsserver starts https server:
public static final int port = 1443; private mockhttpsserver mockserver; @before public void inithttps() { mockserver = new mockhttpsserver(port); mockserver.respondto(get("a-service/resource")).withbody(expectedresponse); }
you can set mule application trust certificate used mock server. jks formatted truststore available on classpath, , can provide https connector so:
<https:connector name="somehttpsconnector"> <https:tls-server path="confluex-mock.truststore" storepassword="confluex" /> </https:connector>
i think older versions of mule have trouble approach, because needed use workaround here.
edit: can include configuration https connector when tests running using spring profile:
<spring:beans profile="test"> <mule> <!-- connector configuration goes here --> </mule> </spring:beans>
one way make sure profile indeed active when tests run set in @beforeclass method:
@beforeclass public void initenvironment() { system.setproperty("spring.profiles.active", "test"); }
Comments
Post a Comment