Matteo
Matteo

Reputation: 31

JUnit java.net.ConnectException

I'm pretty new in Java, so don't be rude ;-) I got a task to do and there are some JUnit-Tests to verify my solution. When I'm trying to run them, it takes some time 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)

Here's what I use:

Can you help me with this?

Upvotes: 3

Views: 2593

Answers (2)

Matteo
Matteo

Reputation: 31

For anyone else encountering the same issue:
There seems to be a problem with the JRE 7 in Windows 8. Using JRE 6 solves the problem! :)

Upvotes: 0

AlexWien
AlexWien

Reputation: 28767

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

Upvotes: 1

Related Questions