Moving an ignored test to samples

since the releaser ignores the modules that do not get deployed, then it's safe to bring back this test

fixes gh-626
This commit is contained in:
Marcin Grzejszczak
2018-10-18 08:21:17 +02:00
parent 50d62b6ee8
commit bd4783eefd
10 changed files with 637 additions and 10 deletions

View File

@@ -0,0 +1,91 @@
package com.example;
import java.net.URI;
import java.util.stream.Stream;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.http.MediaType;
import org.springframework.http.RequestEntity;
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;
@Configuration
@EnableAutoConfiguration
@Import({ Service.class, Controller.class })
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}")
String base;
private RestTemplate restTemplate;
public Service(RestTemplate restTemplate) {
this.restTemplate = restTemplate;
}
public String go() {
return this.restTemplate.getForEntity(this.base + "/test", String.class)
.getBody();
}
public String pom() {
return this.restTemplate
.exchange(RequestEntity.get(URI.create(this.base + "/pom.xml"))
.accept(mediaTypes()).build(), String.class)
.getBody();
}
private MediaType[] mediaTypes() {
return Stream
.of("text/plain", "text/plain", "application/json", "application/json",
"application/*+json", "application/*+json", "*/*", "*/*")
.map(MediaType::valueOf).toArray(MediaType[]::new);
}
public String go2() {
return this.restTemplate.getForEntity(this.base + "/test2", String.class)
.getBody();
}
public void setBase(String base) {
this.base = base;
}
}