2014-10-13 2 views
1

ESB를 처음 사용합니다. 나는 뮬 흐름을 통해 노출 된 나머지 엔드 포인트에 대한 통합 테스트를 수행하려고합니다. 다음 코드는 POST REST 엔드 포인트 안타 그러나 우리는 나머지 PARAMS 및 HTTP 메소드 (등의 취득 또는 포스트 또는 삭제) 말할 수있는 방법 :Mule ESB - 통합 테스트 - REST 엔드 포인트 - MuleClient 사용

MuleClient client = new MuleClient(muleContext); 
    String payload = "foo"; 
    Map<String, Object> properties = new HashMap<String, Object>(); 
    MuleMessage result = client.send("http://localhost:5000/rest/resource", payload, properties); 

우리가 페이로드 또는 속성 (지도에서 어떤 일을 설정해야을)가 전달됩니까?

답변

1

소스 코드에보고 후, 나는 다음과 같은 특성을 가진 HTTP 메서드를 설정할 수 있어요,

예 얻기 요청 :.

MuleClient client = new MuleClient(muleContext); 
    Map<String, Object> properties = new HashMap<String, Object>(); 
    properties.put("Content-type", "text/plain"); 
    properties.put("Accept", "text/plain"); 
    properties.put("http.method", "GET"); 

    MuleMessage result = client.send("http://localhost:5000/rest/resource?param1=268", null, properties); 

예 포스트 요청 :

MuleClient client = new MuleClient(muleContext); 
    Map<String, Object> properties = new HashMap<String, Object>(); 
    properties.put("Content-Type", "application/json"); 
    properties.put("http.method", "POST"); 

    String payload = "{...json here...}"; 

    MuleMessage result = client.send("http://localhost:5000/rest/resource", payload, properties); 

그것을 희망 다른 사용자에게 도움이됩니다.,

관련 문제