JUnit java.net.ConnectException

I'm new to Java so don't be rude ;-) I have a task to do and have some JUnit tests to test my solution. When I try to run them it takes a while and then I get the following errors:

Could not connect to:  : 51219          
java.net.ConnectException: connect: Address is invalid on local machine, or port is not valid on remote machine
    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)
    at java.net.Socket.connect(Unknown Source)
    at java.net.Socket.<init>(Unknown Source)
    at java.net.Socket.<init>(Unknown Source)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.connect(RemoteTestRunner.java:570)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:381)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

      

This is what I am using:

  • Windows 8
  • JRE 7
  • JUnit 4
  • Eclipse Classic 4.2.1

Can you help me?

+3


source to share


2 answers


It seems that your Unit test is trying to connect to port 51219, which is not possible on your local machine.
Try running a local server or "mocking" the server connection.



+1


source


For anyone else facing the same problem:
It seems like a problem with JRE 7 on Windows 8. Using JRE 6 solves the problem! :)



0


source







All Articles