 dcc996c006
			
		
	
	dcc996c006
	
	
	
		
			
			Create a maven project structure. One mock webservice should be included. Both Json and XML payload accepted. Configuration of this webservice (response body, response headers, http status code) should be fully configured in a configuration file. Invoication details (headers, payload) should be logged. Closes #T124
		
			
				
	
	
		
			112 lines
		
	
	
		
			5.2 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			112 lines
		
	
	
		
			5.2 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
| <!DOCTYPE html>
 | |
| <html lang="en" xmlns:th="http://thymeleaf.org">
 | |
| <head>
 | |
|     <meta charset="UTF-8">
 | |
|     <title>Title</title>
 | |
|     <script type='text/javascript'>
 | |
| 
 | |
| 
 | |
|     function httpGetAsync()
 | |
| {
 | |
|    var clientUUID = document.getElementById("clientUUID").value;
 | |
|    var mockedResponseId = document.getElementById("mockedResponseId").value;
 | |
|    var url = "http://localhost:8097/klaus/v1/get/" + clientUUID + "/" + mockedResponseId;
 | |
|    var xmlHttp = new XMLHttpRequest();
 | |
|     xmlHttp.onreadystatechange = function() {
 | |
|         if (xmlHttp.readyState == 4 && xmlHttp.status == 200)
 | |
|             alert(xmlHttp.responseText);
 | |
|     }
 | |
|     xmlHttp.open("GET", url, true);
 | |
|     xmlHttp.send(null);
 | |
|      var container = document.getElementById("getMockedResponse");
 | |
|     container.appendChild(document.createElement("br"));
 | |
|     container.appendChild(document.createTextNode(xmlHttp.responseText));
 | |
| }
 | |
| 
 | |
| function httpGet()
 | |
| {
 | |
|   var clientUUID = document.getElementById("getClientUUID").value;
 | |
|    var mockedResponseId = document.getElementById("getMockedResponseId").value;
 | |
|    var url = "http://localhost:8097/klaus/v1/get/" + clientUUID + "/" + mockedResponseId;
 | |
|     var xmlHttp = new XMLHttpRequest();
 | |
|     xmlHttp.open( "GET", url, false ); // false for synchronous request
 | |
|     xmlHttp.send( null );
 | |
| 
 | |
|     var container = document.getElementById("getMockedResponse");
 | |
|     var headers = xmlHttp.getAllResponseHeaders();
 | |
|     container.appendChild(document.createTextNode(headers));
 | |
|     container.appendChild(document.createTextNode("Your message: "));
 | |
|     container.appendChild(document.createElement("br"));
 | |
|     container.appendChild(document.createTextNode((xmlHttp.responseText)));
 | |
|     return xmlHttp.responseText;
 | |
| 
 | |
| }
 | |
| 
 | |
|         var numberOfHeaders = 0;
 | |
|             function addFields(){
 | |
|             var container = document.getElementById("headers");
 | |
| 
 | |
|                 numberOfHeaders++;
 | |
|                 container.appendChild(document.createElement("br"));
 | |
|                 container.appendChild(document.createTextNode("Header " + (numberOfHeaders)));
 | |
|                 var headerInput = document.createElement("input");
 | |
|                 headerInput.type = "text";
 | |
|                 headerInput.name = "header";
 | |
|                 container.appendChild(headerInput);
 | |
| 
 | |
|                 container.appendChild(document.createTextNode("Value " + (numberOfHeaders)));
 | |
|                 var valueInput = document.createElement("input");
 | |
|                 valueInput.type = "text";
 | |
|                 valueInput.name = "value";
 | |
|                 container.appendChild(valueInput);
 | |
|         }
 | |
|     </script>
 | |
| </head>
 | |
| <body>
 | |
| <br>----------------------------------------------------------------------------------------------------------------
 | |
|     <div><br>In order to set mockup response. Please send the response, that you want to receive, on:
 | |
|     <br>http://localhost:8097/klaus/v1/set/ <a th:text="${mockedResponseDto.clientUUID}">clientUUID should be here</a>/{mockedResponseId}?httpStatus=200
 | |
|     <br>or simply fill and submit the below form:</div>
 | |
| 
 | |
| <div class="col-lg-4 form-max">
 | |
|     <form action="#" th:action="@{/home}" th:object="${mockedResponseDto}" method="post">
 | |
|         <input type="text" th:field="*{clientUUID}" th:placeholder="*{clientUUID}" hidden/>
 | |
|         <br><label >Mocked response id:</label><br/>
 | |
|         <input type="text" th:field="*{mockedResponseId}" th:value=1/>
 | |
|         <br><label >Mocked response body:</label><br/>
 | |
|         <textarea rows="4" cols="50" th:field="*{messageBody}" th:placeholder='messageBody'></textarea>
 | |
|         <br><label >Mocked response http code status:</label><br/>
 | |
|         <input type="text" th:name="httpStatus" th:value='200' />
 | |
|         <br>Provide mocked response headers: <a href="#" id="addHeader" onclick="addFields()">Add a new header</a>
 | |
|         <div id="headers"></div>
 | |
|         <br><label >Media type:</label>
 | |
|         <select th:field="*{mediaType}">
 | |
|             <option value="application/xml">application/xml</option>
 | |
|             <option value="application/json">application/json</option>
 | |
|             <option value="text/xml">text/xml</option>
 | |
|         </select>
 | |
|         <input type="submit" value="Save mocked response" onclick="submit()"/>
 | |
|     </form>
 | |
|     <p th:if="${mockSaved}">Mock has been saved</p>
 | |
| 
 | |
| 
 | |
|     <br>----------------------------------------------------------------------------------------------------------------
 | |
|     <div><br>In order to use the mocked response in your integration tests or simply
 | |
|         get your mocked response please send a request to
 | |
|         <br>http://localhost:8097/klaus/v1/get/<a th:text="${mockedResponseDto.clientUUID}">clientUUID should be here</a>/{mockedResponseId}
 | |
|     </div>
 | |
| 
 | |
|     <div><br>You will receive the same body and headers as you sent them in the step 1.</div>
 | |
|     <div><br>You can also use the form below:</div>
 | |
|     <form action="#" th:action="@{/home/getMockedResponse}" th:object="${mockedResponseDto}" method="get">
 | |
|         <input type="text" th:field="*{clientUUID}" th:placeholder="*{clientUUID}" hidden/>
 | |
|         <br><label >Mocked response id:</label><br/>
 | |
|         <input type="text" th:field="*{mockedResponseId}" th:placeholder="12345"/>
 | |
|         <input type="submit" value="Get mocked response"/>
 | |
|     </form>
 | |
|     <br>----------------------------------------------------------------------------------------------------------------
 | |
| </div>
 | |
| </div>
 | |
| 
 | |
| </body>
 | |
| </html> |