title: How to inject ServletContext for JUnit tests with Spring?
body: <p>I want to unit test a RESTful interface written with Apache CXF. </p>
  
  <p>I use a ServletContext to load some resources, so I have:</p>
  
  <pre><code>@Context
  private ServletContext servletContext;
  </code></pre>
  
  <p>If I deploy this on Glassfish, the ServletContext is injected and it works like expected. But I don't know how to inject the ServletContext in my service class, so that I can test it with a JUnit test. </p>
  
  <p>I use Spring 3.0, JUnit 4, CXF 2.2.3 and Maven.</p>