I have the following integration test case that starts up 3 embedded jetty servers, and runs unit tests against them. My problem is that while the JUnit class is running, it gets stuck in the waitForStartup method, while the servers return "Connection to https://localhost:8440 refused" ("Connect to localhost:8440 timed out. Connection will be retried using another IP address") it is stuck in a loop waiting for the servers to be ready to run the tests against.
Once I terminate the JUnit test, with the servers still running, then I can access the servers via a browser or Poster (i.e. 200 return code). It is as if the unit test is holding onto the server threads I think. I want the servers to run in separate threads (see where I start the serves).
(While the test is still running the tests httpClient, a browser and Poster all timeout. But once the test is terminated, a browser and Poster can do a GET returning a 200.)
I think it's something to do with the processes are not released from the unit test thread.
Please can you have a look at my code and if you know why the servers seem stuck, please can you advise?
I'm not expert in jetty. However, I have few questions:
1) Does this source code belong to you? I'm asking because the part
<problematic code here>
does not look good to me. If you've copied the code from workplace (or basically if you do not own the code), please do not post it on any forum(also, please let us know if this is the case - so that the code can be removed). Publishing code owned by somebody else(especially a corporation) might be (very)troublesome for you.
If you own this code, then it'll be better if you change the name of your package.
2) What is exact output on console? That is, what does the get method returns? Please print and share the exact output. Also, you can simply return from the waitForStartup method instead of breaking the loop.
3) Is it that when your test is running, you can't access the server, but if test is not running, you can access the server? Sounds pretty weird to me (again, since I'm not familiar with jetty).