title: Test @Webservice EJBs with WebServiceContext (using OpenEJB?)
body: <p>I have some EJBs as JAX-WS Web Service:</p>
  
  <pre><code>@WebService
  @Stateless
  @Remote(MobileFacade.class)
  public class MobileFacadeBean implements MobileFacade {
      ... 
  
     @Resource
     WebServiceContext wsc;
  
      ...
  }
  </code></pre>
  
  <p>Within this Web Service class, a WebServiceContext is injected via @Resource. I use this WebServiceContext to get the principal in the implementation. This works quite well, but now I wonder how to (Unit-)test this class!</p>
  
  <p>So far, I was using OpenEJB to test my EJBs. Since the Web Service class also is an Stateless Session Bean, I would really like to use the same approach here. However, it does not work that easy - of course, it complains that there is no WebServiceContext when not called as a Web Service.</p>
  
  <p>So the first question is: are there any ways to mock the WebServiceContext in OpenEJB?</p>
  
  <p>And if no, what approach would you favour to test this kind of Web Service classes?</p>
  
  <p>Cheers,
  Frank</p>