Help with TestNG test trying to hit Apigee endpoints but getting "java.net.ConnectException:Connection refused"?

Not applicable

This is for cloud (not on-prem) Apigee. I have a Java functional TestNG test which is hitting a REST API endpoint.

Same test worked on Windows PC with IntelliJ and JBoss with no special settings.

I can hit this endpoint in Postman, so I know it's up/alive!

We also made a simple Node Express server / Java ping program that listens on various ports (e.g. in the 6xxxx range) and replies if the ping was successful. This works in IntelliJ.

But in IntelliJ and JBoss Dev Studio IDEs AND on mvn test commandline (!) on Mac, it fails immediately, doesn't even touch any of my test code, and I get:

Connected to the target VM, address:'127.0.0.1:60329', transport:'socket'[TestNG]Running:
java.net.ConnectException:Connection refused

at java.net.PlainSocketImpl.socketConnect(NativeMethod)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:579)
at org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:117)

...

at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1198)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1123)
at org.testng.TestNG.run(TestNG.java:1031)
at org.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:74)
at org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:124)

I've tried a few things with no luck:

  1. Allow IntelliJ in firewall, and even turn off Mac firewall completely
  2. java.net.preferIPv4Stack in VM options and in Info.plist for IntelliJ in case it was an IPv6 thing
  3. Auto-detect proxy settings in IntelliJ settings (never had to do this on Windows IntelliJ, but just to make sure)

Versions:

  • IntelliJ 2016.2
  • Java 1.7.0_79
  • Mac 10.11.5
Solved Solved
0 3 791
1 ACCEPTED SOLUTION

Not applicable

Well, I ended up deleting my entire set of Git repos and starting over from scratch. My TestNG tests are now running. Why that worked? I have no idea. Just glad to get back to work.

View solution in original post

3 REPLIES 3

What do you mean by this:

> Same test worked on Windows PC with IntelliJ and JBoss with no special settings.

What is different? I'm not quite clear on what you're doing.

Are you saying that you are having trouble running IntelliJ on a Mac, but everything works on Windows? I don't think we can diagnose that. Sounds like something independent of Edge. Amirite?

What is supposed to be listening on 127.0.0.1:60329 ? That's obviously not an endpoint that is running in Edge.

The difference is the operating system.

I'm trying to run a TestNG test. It fails in IntelliJ, JBoss, and mvn test on the commandline on the Mac. These things work on the Windows machine with the same code.

The localhost was to prove that my connectivity is working. Seems to be some TestNG failure.

Not applicable

Well, I ended up deleting my entire set of Git repos and starting over from scratch. My TestNG tests are now running. Why that worked? I have no idea. Just glad to get back to work.