Код: Выделить всё
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public abstract class BaseIntegration {
@Value("${local.server.port}")
private int serverPort;
@Before
public void setup() {
RestAssured.port = serverPort;
}}
Код: Выделить всё
public class TestIT extends BaseIntegration{//Test Code}
Код: Выделить всё
RestClient
Код: Выделить всё
public static TestResponse postResponse(TestRequest request) {
return given().log().all()
.contentType(ContentType.JSON)
.body(request)
.when()
.log().all()
.post("/weather")
.as(TestResponse.class);
}
Код: Выделить всё
java.lang.IllegalArgumentException: URI must not be null
at org.springframework.util.Assert.notNull(Assert.java:134) ~[spring-core-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.web.util.UriComponentsBuilder.fromUriString(UriComponentsBuilder.java:189) ~[spring-web-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.web.util.DefaultUriTemplateHandler.initUriComponentsBuilder(DefaultUriTemplateHandler.java:114) ~[spring-web-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.web.util.DefaultUriTemplateHandler.expandInternal(DefaultUriTemplateHandler.java:103) ~[spring-web-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.web.util.AbstractUriTemplateHandler.expand(AbstractUriTemplateHandler.java:106) ~[spring-web-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:612) ~[spring-web-4.3.10.RELEASE.jar:4.3.10.RELEASE]
at org.springframework.web.client.RestTemplate.postForEntity(RestTemplate.java:407) ~[spring-web-4.3.10.RELEASE.jar:4.3.10.RELEASE]
РЕДАКТИРОВАТЬ:
Похоже, что конечная точка службы использует RestTemplate
Код: Выделить всё
restTemplate.postForEntity(url, body, TestResponse.class);
Подробнее здесь: https://stackoverflow.com/questions/466 ... sing-resta