Add wiremock samples back as real folders

This commit is contained in:
Dave Syer
2016-07-14 15:21:35 +01:00
parent 94b6f6e0f7
commit 73c15c117c
49 changed files with 2751 additions and 4 deletions

View File

@@ -0,0 +1,55 @@
package com.example;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
@SpringBootApplication
public class WiremockTestsApplication {
@Bean
public RestTemplate restTemplate() {
return new RestTemplate();
}
public static void main(String[] args) {
SpringApplication.run(WiremockTestsApplication.class, args);
}
}
@RestController
class Controller {
private final Service service;
public Controller(Service service) {
this.service = service;
}
@RequestMapping("/")
public String home() {
return this.service.go();
}
}
@Component
class Service {
@Value("${app.baseUrl:http://example.org}")
private String base;
private RestTemplate restTemplate;
public Service(RestTemplate restTemplate) {
this.restTemplate = restTemplate;
}
public String go() {
return this.restTemplate.getForEntity(this.base + "/resource", String.class).getBody();
}
}