Hi
Today i have integrated code of forward proxy in my code and i have to hit the webservice using forward proxy and when i run the test case i am getting and i am using eclipse to run the testcases and i don't start wire-mock using terminal
implementation class logic
1)
getMember(){
CloseableHttpClient httpclient = HttpClients.createDefault();
HttpHost proxy = new HttpHost("127.0.0.1", 8080, "http");
RequestConfig config = RequestConfig.custom()
.setProxy(proxy)
.build();
HttpGet getRequest = new HttpGet(url);
getRequest.setConfig(config);
getRequest .addHeader("accept", "application/json");
getRequest .addHeader("Authorization", tokenFromAuthenticationAfer);
CloseableHttpResponse response = httpclient.execute(getRequest);
}
2)
from my wiremock junit class i am invoking the method
___________________________________________________________________________
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {
"classpath:spring/test_aimia_service-context.xml" })
public class AimiaEnablerServiceWireMockTest {
private static int wireMockPort = 8089;
WireMockServer wireMockServer = new WireMockServer(wireMockConfig().proxyVia("127.0.0.1", 8080));
@Rule
public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().port(wireMockPort).notifier(
new Log4jNotifier()));
@Test
public void testgetMember() throws AimiaServiceFaultException {
GetMemberRequestDto request = new GetMemberRequestDto();
request.setServiceId("success");
GetMemberResponseDto response;
response = jwsaimiaservice.getMember(request);
logWriter.logDebug("response: " + response);
if (response != null) {
assertNotNull(response);
// assertEquals("ABC", response.getGetMemberResponse().getFirstName());
}
}
___________________________________________________________________________
3)
mapping file
{
"request" : {
"method" : "GET",
"url" : "/RESTfulExample/rest/programs/OPTUS/getMemberDetails/token-type/UID/token/success"
},
"response" : {
"status" : 200,
"bodyFileName" : "body-aimia.enabler.getMember.json",
"headers" : {
"Content-Type" : "application/json"
}
}
}
4) __files
------------------------------------------------------------------------------------------------------------------------------------------
Exception Message and its failing the test case
Please help me how to achieve this forward proxy with wiremock
and if i comment below lines of code wire mock work like champ
// HttpHost proxy = new HttpHost("127.0.0.1", 8080, "http");
// RequestConfig config = RequestConfig.custom()
// .setProxy(proxy)
// .build();
Regards,
Nirmal