Skip to content

Commit

Permalink
Fix failing unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanjbaxter committed Jan 26, 2018
1 parent f7e5b7f commit c3475f1
Showing 1 changed file with 5 additions and 6 deletions.
Expand Up @@ -31,14 +31,13 @@
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.util.ReflectionUtils; import org.springframework.util.ReflectionUtils;
import org.springframework.util.SocketUtils; import org.springframework.util.SocketUtils;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
Expand All @@ -53,16 +52,18 @@
/** /**
* @author Spencer Gibb * @author Spencer Gibb
*/ */
@RunWith(SpringJUnit4ClassRunner.class) @RunWith(SpringRunner.class)
@SpringBootTest(classes = FeignHttpClientUrlTests.TestConfig.class, webEnvironment = WebEnvironment.DEFINED_PORT, value = { @SpringBootTest(classes = FeignHttpClientUrlTests.TestConfig.class, webEnvironment = WebEnvironment.DEFINED_PORT, value = {
"spring.application.name=feignclienturltest", "feign.hystrix.enabled=false", "spring.application.name=feignclienturltest", "feign.hystrix.enabled=false",
"feign.okhttp.enabled=false" }) "feign.okhttp.enabled=false" })
@DirtiesContext @DirtiesContext
public class FeignHttpClientUrlTests { public class FeignHttpClientUrlTests {


static int port;

@BeforeClass @BeforeClass
public static void beforeClass() { public static void beforeClass() {
int port = SocketUtils.findAvailableTcpPort(); port = SocketUtils.findAvailableTcpPort();
System.setProperty("server.port", String.valueOf(port)); System.setProperty("server.port", String.valueOf(port));
} }


Expand Down Expand Up @@ -103,8 +104,6 @@ protected interface BeanUrlClientNoProtocol {
@RestController @RestController
@EnableFeignClients(clients = { UrlClient.class, BeanUrlClient.class, BeanUrlClientNoProtocol.class }) @EnableFeignClients(clients = { UrlClient.class, BeanUrlClient.class, BeanUrlClientNoProtocol.class })
protected static class TestConfig { protected static class TestConfig {
@Value("${server.port}")
private int port;


@RequestMapping(method = RequestMethod.GET, value = "/hello") @RequestMapping(method = RequestMethod.GET, value = "/hello")
public Hello getHello() { public Hello getHello() {
Expand Down

0 comments on commit c3475f1

Please sign in to comment.