Using RestTemplate, how to send the request to a proxy first so I can use my junits with JMeter?

后端 未结 5 1776
夕颜
夕颜 2020-12-02 22:06

I have a web service running on my dev box implemented using Spring-MVC 3.0. I have various JUnits that test against that service using RestTemplate. What I would like to do

5条回答
  •  鱼传尺愫
    2020-12-02 22:42

    put these lines before calling your get or post method. so proxy get set .

        HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory();
        DefaultHttpClient httpClient = (DefaultHttpClient) requestFactory.getHttpClient();
        HttpHost proxy = new HttpHost("proxtserver", port);
        httpClient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY,proxy);
        restTemplate.setRequestFactory(requestFactory);
    

提交回复
热议问题