title: How to test ws-security?
body: <p>I am about to develop web application with web services. I've already tuned jax-ws and ws-security. I used soapUI and sent next request:</p>
  
  <pre><code>&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="..." &gt;
   &lt;soapenv:Header&gt;
    &lt;wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" soapenv:mustUnderstand="1"&gt;
      &lt;wsu:Timestamp xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="Timestamp-2"&gt;
        &lt;wsu:Created&gt;2011-11-11T00:05:05.044Z&lt;/wsu:Created&gt;
        &lt;wsu:Expires&gt;2012-11-11T00:10:05.044Z&lt;/wsu:Expires&gt;
      &lt;/wsu:Timestamp&gt;
      &lt;wsse:UsernameToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="UsernameToken-1"&gt;
        &lt;wsse:Username&gt;user&lt;/wsse:Username&gt;
        &lt;wsse:Password&gt;password&lt;/wsse:Password&gt;
      &lt;/wsse:UsernameToken&gt;
    &lt;/wsse:Security&gt;
  &lt;/soapenv:Header&gt;
     &lt;soapenv:Body&gt;
        &lt;soap:foo&gt;
           &lt;arg0&gt;1&lt;/arg0&gt;
        &lt;/soap:foo&gt;
     &lt;/soapenv:Body&gt;
  &lt;/soapenv:Envelope&gt;
  </code></pre>
  
  <p>I need get Username and Password from header. On the application I can get it by next code:</p>
  
  <pre><code>@Resource
  WebServiceContext context;
  ...
  private static final String PRINCIPAL_RESULT = "wss4j.principal.result";
  ...
  WSUsernameTokenPrincipal wsutp = (WSUsernameTokenPrincipal) context.getMessageContext().get(PRINCIPAL_RESULT);       
  ..
  String user = wsutp.getName()
  String password = wsutp.getPassword();
  </code></pre>
  
  <p>But I have no idea how should I test it with jUnit tests, because <strong>context.getMessageContext() will be NULL</strong> on test class. </p>
  
  <p>Does anyone knows a good guide or provide a code-sample?</p>