File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
    Bookmark Topic Watch Topic
  • New Topic

Embedded Jetty Servers running in separate threads not accessible from unit test

 
Blikkies Marais
Ranch Hand
Posts: 50
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi,

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?

Thanks

Edit: Removed disputed code
 
Anayonkar Shivalkar
Bartender
Posts: 1557
5
Eclipse IDE Java Linux
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi Blikkies,

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).
 
Blikkies Marais
Ranch Hand
Posts: 50
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi Anayonkar Shivalkar,

Please can you delete this post, I will add a new edited one.

Thanks for the advise
 
Anayonkar Shivalkar
Bartender
Posts: 1557
5
Eclipse IDE Java Linux
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi Blikkies,

You are welcome.

As of now, I'm locking this topic.

In case if you have any more question, feel free to create a new topic.

Thanks.
 
I agree. Here's the link: http://aspose.com/file-tools
    Bookmark Topic Watch Topic
  • New Topic