Create an initial web service
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
This commit is contained in:
9
target/classes/application.properties
Normal file
9
target/classes/application.properties
Normal file
@@ -0,0 +1,9 @@
|
||||
server.port = 8099
|
||||
spring.output.ansi.enabled = always
|
||||
|
||||
logging.file.name=/var/log/klaus/
|
||||
logging.level.root=INFO
|
||||
logging.level.org.springframework.web=DEBUG
|
||||
logging.level.com.release11=DEBUG
|
||||
logging.file.max-size = 10MB
|
||||
spring.mvc.log-request-details=true
|
||||
BIN
target/classes/com/release11/klaus/KlausApplication.class
Normal file
BIN
target/classes/com/release11/klaus/KlausApplication.class
Normal file
Binary file not shown.
BIN
target/classes/com/release11/klaus/config/RedisConfig.class
Normal file
BIN
target/classes/com/release11/klaus/config/RedisConfig.class
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
target/classes/com/release11/klaus/model/MockedResponseDto.class
Normal file
BIN
target/classes/com/release11/klaus/model/MockedResponseDto.class
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
target/classes/com/release11/klaus/service/KlausService.class
Normal file
BIN
target/classes/com/release11/klaus/service/KlausService.class
Normal file
Binary file not shown.
Binary file not shown.
3
target/classes/data-access.properties
Normal file
3
target/classes/data-access.properties
Normal file
@@ -0,0 +1,3 @@
|
||||
//redis.host = redis-server
|
||||
redis.host = localhost
|
||||
redis.port = 6379
|
||||
112
target/classes/templates/index.html
Normal file
112
target/classes/templates/index.html
Normal file
@@ -0,0 +1,112 @@
|
||||
<!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>
|
||||
20
target/classes/templates/login.html
Normal file
20
target/classes/templates/login.html
Normal file
@@ -0,0 +1,20 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" xmlns:th="http://thymeleaf.org">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Login</title>
|
||||
</head>
|
||||
<body>
|
||||
<div><br>Please move to the next step with your own client UUID: </div>
|
||||
<form action="#" th:action="@{/home}" method="get">
|
||||
<br><label >Please provide your client UUID:</label><br/>
|
||||
<input type="text" name="clientUUID" value="436c4774-038f-4540-9c18-2691ca9b53d4" />
|
||||
<input type="submit" value="Proceed"/>
|
||||
</form>
|
||||
|
||||
<div><br>You can also register new UUID. *some logic to register UUID*:
|
||||
<br><a th:text="${clientUUID}">clientUUID should be here</a>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user