Merge branch '1.0.x'

fixes #179 #117
This commit is contained in:
Marcin Grzejszczak
2016-12-28 19:40:42 +01:00
14 changed files with 377 additions and 92 deletions

View File

@@ -4,12 +4,14 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.embedded.LocalServerPort;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.cloud.contract.stubrunner.StubFinder;
import org.springframework.cloud.contract.stubrunner.spring.AutoConfigureStubRunner;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.web.client.RestTemplate;
import com.example.loan.model.Client;
import com.example.loan.model.LoanApplication;
@@ -20,19 +22,28 @@ import static org.assertj.core.api.Assertions.assertThat;
// tag::autoconfigure_stubrunner[]
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment=WebEnvironment.NONE)
@SpringBootTest(webEnvironment=WebEnvironment.RANDOM_PORT)
@AutoConfigureStubRunner(repositoryRoot = "classpath:m2repo/repository/",
ids = { "org.springframework.cloud.contract.verifier.stubs:fraudDetectionServer" })
ids = { "org.springframework.cloud.contract.verifier.stubs:contextPathFraudDetectionServer" })
@DirtiesContext
public class LoanApplicationServiceTests {
// end::autoconfigure_stubrunner[]
@Autowired private LoanApplicationService service;
@Autowired private StubFinder stubFinder;
@LocalServerPort Integer port;
@Before
public void setPort() {
this.service.setFraudUrl(this.stubFinder.findStubUrl("fraudDetectionServer").toString());
this.service.setFraudUrl(this.stubFinder.findStubUrl("contextPathFraudDetectionServer").toString() + "/fraud-path/");
}
@Test
public void shouldStartThisAppWithContextPath() {
String response = new RestTemplate()
.getForObject("http://localhost:" + this.port + "/my-path/health", String.class);
assertThat(response).isNotEmpty();
}
@Test

View File

@@ -19,7 +19,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>org.springframework.cloud.contract.verifier.stubs</groupId>
<artifactId>fraudDetectionServer</artifactId>
<artifactId>contextPathFraudDetectionServer</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
</project>

View File

@@ -17,7 +17,7 @@
<metadata>
<groupId>org.springframework.cloud.contract.verifier.stubs</groupId>
<artifactId>fraudDetectionServer</artifactId>
<artifactId>contextPathFraudDetectionServer</artifactId>
<version>0.0.1-SNAPSHOT</version>
<versioning>
<versions>