@@ -99,6 +99,54 @@ public void simpleRequestGet() throws IOException, SaxonApiException, ParserConf
9999 assertSimpleRequest (endpoint , inputXmlFilename , expectedResultFilename );
100100 }
101101
102+ @ Test
103+ public void simpleRequestPut () throws IOException , SaxonApiException , ParserConfigurationException {
104+ final String endpoint = "/simpleRequestPut" ;
105+
106+ // Stub the HTTP Server endpoint for this test
107+ wireMockRule .stubFor (
108+ put (endpoint )
109+ .withHeader ("Content-Type" , equalTo ("application/xml; charset=UTF-8" ))
110+ .withRequestBody (equalToXml ("<data>hello</data>" ))
111+ .willReturn (created ()
112+ .withHeader ("Content-Type" , "application/xml" )
113+ .withBody ("<response>SUCCESS</response>" ))
114+ );
115+
116+ // the EXPath HTTP Client request to test
117+ final String inputXmlFilename = "simple-request-put.input.xml" ;
118+
119+ // the expected result
120+ final String expectedResultFilename = "simple-request-put.expected.xml" ;
121+
122+ // perform the request and assert the result
123+ assertSimpleRequest (endpoint , inputXmlFilename , expectedResultFilename );
124+ }
125+
126+ @ Test
127+ public void simpleRequestPost () throws IOException , SaxonApiException , ParserConfigurationException {
128+ final String endpoint = "/simpleRequestPost" ;
129+
130+ // Stub the HTTP Server endpoint for this test
131+ wireMockRule .stubFor (
132+ post (endpoint )
133+ .withHeader ("Content-Type" , equalTo ("application/json" ))
134+ .withRequestBody (equalToJson ("{ \" key1\" : \" value1\" , \" key2\" : \" value2\" }" ))
135+ .willReturn (aResponse ().withStatus (202 )
136+ .withHeader ("Content-Type" , "application/xml" )
137+ .withBody ("<response>SUCCESS</response>" ))
138+ );
139+
140+ // the EXPath HTTP Client request to test
141+ final String inputXmlFilename = "simple-request-post.input.xml" ;
142+
143+ // the expected result
144+ final String expectedResultFilename = "simple-request-post.expected.xml" ;
145+
146+ // perform the request and assert the result
147+ assertSimpleRequest (endpoint , inputXmlFilename , expectedResultFilename );
148+ }
149+
102150 private void assertSimpleRequest (final String endpoint , final String inputXmlFilename , final String expectedResultFilename ) throws IOException , SaxonApiException , ParserConfigurationException {
103151 final String request ;
104152 try (final InputStream isRequest = getClass ().getResourceAsStream (inputXmlFilename )) {
@@ -112,13 +160,13 @@ private void assertSimpleRequest(final String endpoint, final String inputXmlFil
112160
113161 assertNotNull (result );
114162
115- // START TEMP
163+ // NOTE(AR) - START DEBUG RESPONSE
116164// final StringWriter stringWriter = new StringWriter();
117165// Serializer serializer = PROCESSOR.newSerializer(stringWriter);
118166// XdmNode source = PROCESSOR.newDocumentBuilder().wrap(result);
119167// serializer.serializeNode(source);
120168// System.out.println(stringWriter);
121- // END TEMP
169+ // NOTE(AR) - END DEBUG RESPONSE
122170
123171 try (final InputStream is = getClass ().getResourceAsStream (expectedResultFilename )) {
124172 final Source expected = Input .fromStream (is ).build ();
0 commit comments