In a specific integration test module of a project I'm working on, we have only 
three test classes - one test that subclasses a hierarchy of TestCase classes 
that are responsible for setting up a test harness to run full end to end tests 
of our app.  

The other two tests basically take a JAX-WS annotated interface and its 
implementation, exposes the service with Endpoint.publish, and returns a proxy 
to that service for the test to actually use to verify things work when done 
over SOAP.  Here's the method used to actually publish that service and return 
the proxy:

https://gist.github.com/1090795 

When I run the two tests that call Endpoint.publish by themselves, all works as 
expected.  If I run all three tests together with the first class that inherits 
the hierarchy of classes to setup the harness, then each of the test methods in 
the latter two tests, once run always fail with a stack trace that contains the 
following in the exception chain:

Caused by: java.net.ConnectException: ConnectException invoking 
http://localhost:1031/service: Connection refused
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at 
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
        at 
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
        at 
org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.mapException(HTTPConduit.java:2128)
        at 
org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:2113)

This is happening on the client side.  I attached a debugger to the test 
invocation and noticed that Endpoint.publish is actually being called and 
returning successful, but immediately after the method returns there is nothing 
listening on the port specified in the URL string passed to Endpoint.publish.   
 There is nothing logged nor anything that I could see within the internal CXF 
code I stepped through that indicated the service publishing actually failed, 
but the service is never exposed.

What I'd like to know is:

1) is this the expected behavior of Endpoint.publish that implementers are 
supposed to provided?  It appears the API for Endpoint.publish says it only 
throws a SecurityException when the Securitymanager is setup to not allow 
publishing but nothing else.

2) What could be the possible cause of this?  Is there anything specific I 
should be hunting down during the @Setup and running of the other test methods? 
 As far as I can tell that test method is cleaning up its resources.  

Any help is very much appreciated.


Reply via email to