简体   繁体   English

Rest Assured-java.net.ConnectException:连接被拒绝:connect

[英]Rest Assured-java.net.ConnectException: Connection refused: connect

In restassured am getting the "java.net.ConnectException: Connection refused: connect" if I execute the below function tu3 from a different class. 如果我从另一个类执行下面的函数tu3,请放心地获取“ java.net.ConnectException:连接被拒绝:connect”。 If I call the function from parent class, it is successfully executed. 如果我从父类调用该函数,则该函数将成功执行。 Please let me know how to correct this. 请让我知道如何纠正此问题。

@Parameters({"Param 1","Param 2"})
  @Test
   public void tu3(@Optional String la, @Optional int StatusCode ) throws 
    IOException


    System.out.println("Test"+la);
    System.out.println(URI);
    given().pathParam("user_ID", la)
    .when().delete("/{user_ID}")
    .then().statusCode(StatusCode);

   java.net.ConnectException: Connection refused: connect
    at java.net.DualStackPlainSocketImpl.connect0(Native Method)
    at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
    at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
    at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
    at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
    at java.net.PlainSocketImpl.connect(Unknown Source)
    at java.net.SocksSocketImpl.connect(Unknown Source)
    at java.net.Socket.connect(Unknown Source)

here is the problem i guess userid is double quotes 这是我猜userid是双引号的问题

.when().delete("/{user_ID}")

Correct line should be 正确的线应该是

.when().delete("URL/"+user_ID)

Your URL should be URL/1 where 1 is user_id, not URL/{user_id} 您的URL应该是URL / 1,其中1是user_id,而不是URL / {user_id}

You should pass userID to be deleted 您应该传递要删除的用户ID

In .delete you should provide whole API URL 在.delete中,您应该提供完整的API URL

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Quarkus 测试 rest 客户端 java.net.ConnectException:连接被拒绝:连接 - Quarkus test rest client java.net.ConnectException: Connection refused: connect Java Mail错误:java.net.ConnectException:连接被拒绝:connect - Java Mail Error : java.net.ConnectException: Connection refused: connect Java套接字 - java.net.ConnectException:连接被拒绝:连接 - Java sockets - java.net.ConnectException: Connection refused: connect Java网络问题:java.net.ConnectException:连接被拒绝:连接 - Java Networking Problem: java.net.ConnectException: Connection refused: connect Java 中的 ssh 异常:java.net.ConnectException:连接被拒绝:连接 - ssh Exception in Java: java.net.ConnectException: Connection refused: connect java.net.ConnectException:连接被拒绝:connect java nio - java.net.ConnectException: Connection refused: connect java nio 码头9.0.6-java.net.ConnectException:连接被拒绝:连接 - Jetty 9.0.6 - java.net.ConnectException: Connection refused: connect java.net.ConnectException:连接被拒绝:连接,启动已取消 - java.net.ConnectException: Connection refused: connect,Launch canceled java.net.ConnectException:连接被拒绝:connect openshift - java.net.ConnectException: Connection refused: connect openshift java.net.ConnectException:拒绝连接:连接HTTPS连接 - java.net.ConnectException: Connection refused: connect for HTTPS connections
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM