3

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:

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

Can you help me with this?

AlexWien
  • 28,470
  • 6
  • 53
  • 83
Matteo
  • 31
  • 2
  • pls share the code, where it actually throws the exception. – Rahul Feb 18 '13 at 11:01
  • The setup does not seems to be complete. Is your remote runner ready? – Jayan Feb 18 '13 at 11:19
  • @R.J the error occurs for every JUnit test, also for a small example test case. – Matteo Feb 19 '13 at 08:46
  • @Jayan That's odd.. do I have do set something up for JUnit? In the past, I never had to set up anything special for JUnit... How do I set up the remote runner? – Matteo Feb 19 '13 at 08:48

2 Answers2

1

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.

AlexWien
  • 28,470
  • 6
  • 53
  • 83
  • 1
    But why does JUnit need to connect to a port? And how do I "mock" the server connection? Past JUnit tests I ran always worked without setup... – Matteo Feb 19 '13 at 08:50
0

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! :)

Matteo
  • 31
  • 2