• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to Unit test an axis service that extends ServletEndpointSupport?  RSS feed

 
Joshua White
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I am trying to figure out how to write a JUnit test case that can test my service endpoint outside of the servlet container. My axis service endpoint extends springs ServletEndpointSupport but I cannot seem to find any mock objects that will help me initialize this object correctly.

To initialize the servlet, I need to call the init method from the ServiceLifecycle Interface:

init(Object context)

Trouble is, the context here is of the type javax.xml.rpc.server.ServletEndpointContext. As I mentioned earlier, I have been unable to find any Mock objects for this class. Can someone point me to an example?

Regards,

Josh
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not familiar with ServletEndpointSupport, but most WS are at the core based on a Java POJO that has no dependencies on external objects (only the libraries it needs to complete its service). Wouldn't it make more sense to unit-test that?
 
Joshua White
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Normally it would. This class however makes use of the Spring Context to get some of its dependencies. If this was a normal Spring servlet, I could create a spring context and insert it into a mock servlet context and initialize the servlet with that. Unfortunately, because this class implements ServiceLifecycle, the init method is now looking for ServletEndpointContext instead.

Any other ideas?

Joshua
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!