Use apache HTTP client instead of JDK
Never got to the bottom of this, but the test failure with the dropped connection (EOF on socket) seems to go away if we use the Apache client instead of the JDK.
This commit is contained in:
@@ -32,6 +32,10 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- tag::stub_runner[] -->
|
||||
<dependency>
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.example.loan;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.web.client.RestTemplateBuilder;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
@@ -24,8 +26,9 @@ public class LoanApplicationService {
|
||||
|
||||
private int port = 6565;
|
||||
|
||||
public LoanApplicationService() {
|
||||
this.restTemplate = new RestTemplate();
|
||||
@Autowired
|
||||
public LoanApplicationService(RestTemplateBuilder builder) {
|
||||
this.restTemplate = builder.build();
|
||||
}
|
||||
|
||||
public LoanApplicationResult loanApplication(LoanApplication loanApplication) {
|
||||
|
||||
@@ -16,13 +16,11 @@ import com.example.loan.model.LoanApplication;
|
||||
import com.example.loan.model.LoanApplicationResult;
|
||||
import com.example.loan.model.LoanApplicationStatus;
|
||||
|
||||
// tag::autoconfigure_stubrunner[]
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment=WebEnvironment.NONE, properties="server.context-path=/app")
|
||||
@AutoConfigureStubRunner(ids = {"com.example:http-server-dsl:+:stubs:6565"}, workOffline = true)
|
||||
@DirtiesContext
|
||||
public class LoanApplicationServiceContextPathTests {
|
||||
// end::autoconfigure_stubrunner[]
|
||||
|
||||
@Autowired
|
||||
private LoanApplicationService service;
|
||||
@@ -40,7 +38,6 @@ public class LoanApplicationServiceContextPathTests {
|
||||
assertThat(loanApplication.getRejectionReason()).isNull();
|
||||
}
|
||||
|
||||
// tag::client_tdd[]
|
||||
@Test
|
||||
public void shouldBeRejectedDueToAbnormalLoanAmount() {
|
||||
// given:
|
||||
@@ -53,6 +50,5 @@ public class LoanApplicationServiceContextPathTests {
|
||||
.isEqualTo(LoanApplicationStatus.LOAN_APPLICATION_REJECTED);
|
||||
assertThat(loanApplication.getRejectionReason()).isEqualTo("Amount too high");
|
||||
}
|
||||
// end::client_tdd[]
|
||||
|
||||
}
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
server:
|
||||
port: 6565
|
||||
port: 6565
|
||||
|
||||
Reference in New Issue
Block a user