I struggled with this for some time. I would like to use restAssured to test my RESTBEST REST application.
As long as the container seems to rotate correctly, be sure (and something else has problems associated with it.
All the time when I get Connection, I threw an exception.
java.net.ConnectException: Connection refused at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at java.net.Socket.connect(Socket.java:589) ...
my test class:
@RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) public class SizesRestControllerIT { @Autowired private TestRestTemplate restTemplate; @Test public void test() { System.out.println(this.restTemplate.getForEntity("/clothes", List.class)); } @Test public void test2() throws InterruptedException { given().basePath("/clothes").when().get("").then().statusCode(200); } }
and now for the weird part, test passes and prints what it should, but test2 gets a Connection rejection.
Any ideas what is wrong with this setting?
java spring rest spring-boot rest-assured
klubi
source share