automated tests - Tirggering a get request is giving me a java.net.ConnectException: Connection Refused: connect -
i have written simple functional api test using restassured, org.json , testng. here code:
what's interesting everytime run test i'm getting following error message:
when copy url in browser http:/restcountries.eu/rest/v1/name/norway
i'm getting results. dont think it's firewall issue
package com.jaway.restassured.rest_assured; import static com.jayway.restassured.restassured.get; import org.json.jsonexception; import org.json.jsonarray; import org.testng.assert; import org.testng.*; import org.testng.annotations.test; import org.testng.annotations.*; import com.jayway.restassured.response.*; public class apptest { @test() public void getrequestfindcapital() throws jsonexception{ //make request fetch capital of norway response resp = get("http:/restcountries.eu/rest/v1/name/norway"); jsonarray jsonresponse =new jsonarray(resp.asstring()); system.out.println(resp.asstring()); string capital = jsonresponse.getjsonobject(0).getstring("capital"); assert.assertequals(capital, "oslo"); } }
here error message
failed: getrequestfindcapital java.net.connectexception: connection refused: connect @ java.net.dualstackplainsocketimpl.connect0(native method) @ java.net.dualstackplainsocketimpl.socketconnect(dualstackplainsocketimpl.java:79) @ java.net.abstractplainsocketimpl.doconnect(abstractplainsocketimpl.java:345) @ java.net.abstractplainsocketimpl.connecttoaddress(abstractplainsocketimpl.java:206) @ java.net.abstractplainsocketimpl.connect(abstractplainsocketimpl.java:188) @ java.net.plainsocketimpl.connect(plainsocketimpl.java:172) @ java.net.sockssocketimpl.connect(sockssocketimpl.java:392) @ java.net.socket.connect(socket.java:589) @
Comments
Post a Comment