File tree Expand file tree Collapse file tree
httpclient/src/test/java/org/baeldung/httpclient/advancedconfig Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -58,16 +58,17 @@ public void givenClientWithCustomUserAgentHeader_whenExecuteRequest_shouldReturn
5858 @ Test
5959 public void givenClientThatSendDataInBody_whenSendXmlInBody_shouldReturn200 () throws IOException {
6060 //given
61+ String xmlBody = "<xml><id>1</id></xml>" ;
6162 serviceMock .stubFor (post (urlEqualTo ("/person" ))
6263 .withHeader ("Content-Type" , equalTo ("application/xml" ))
63- .withRequestBody (equalTo ("<xml><id>1</id></xml>" ))
64+ .withRequestBody (equalTo (xmlBody ))
6465 .willReturn (aResponse ()
6566 .withStatus (200 )));
6667
6768 HttpClient httpClient = HttpClients .createDefault ();
6869 HttpPost httpPost = new HttpPost ("http://localhost:8089/person" );
6970 httpPost .setHeader ("Content-Type" , "application/xml" );
70- StringEntity xmlEntity = new StringEntity ("<xml><id>1</id></xml>" );
71+ StringEntity xmlEntity = new StringEntity (xmlBody );
7172 httpPost .setEntity (xmlEntity );
7273
7374 //when
You can’t perform that action at this time.
0 commit comments