0

I am writing test case using jayway. I am getting connection refused error.

@RunWith(OrderitoJUnitRunner.class)
public class TestOrderService extends TestCaseSrs {

    @Test
    public void testFindUsingGroovyClosure() throws IOException
    {
        RestAssured.baseURI = "http://localhost";                   
        String responseString = "Some Json";            
        String json = get("/test/Order/").asString();
        JsonPath jp = new JsonPath(json);
        String ssn = jp.get("customer.personId");
        assertEquals("123456", ssn);
    }
}

Error:

java.net.ConnectException: Connection refused: connect

Connect to localhost:8080 timed out. Connection will be retried using another IP address

Am I doing anything wrong?

ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199
Patan
  • 17,073
  • 36
  • 124
  • 198

2 Answers2

2

I would say that you don't have anything listening on localhost:8080

What happens if you point your browser there?

If you're running on a *nix system, then try running

netstat -an | grep 8080

does anything print? If not, you don't have anything listening on 8080.

It's always worth having a read of the javadoc

http://docs.oracle.com/javase/7/docs/api/java/net/ConnectException.html

Signals that an error occurred while attempting to connect a socket to a remote address and port. Typically, the connection was refused remotely (e.g., no process is listening on the remote address/port).

Hope this helps

Will

Will
  • 6,561
  • 3
  • 30
  • 41
-1

you can also check this link on Stack Overflow which sheds more light on the "Connection Refused Error " java.net.ConnectException: Connection refused

Community
  • 1
  • 1
tushar_sappal
  • 308
  • 4
  • 16