title: Set resource annotated field of a class in unit tests
body: <p>I have a class.</p>
  
  <pre><code>public class Definitions{
  @Resource(name="schemas")
  private Collection&lt;String&gt; schemas;
  }
  </code></pre>
  
  <p>This class is initialized via spring.
  Spring file:test.xml</p>
  
  <pre><code>&lt;util:list id="schemas"&gt;
      &lt;value&gt;"A"&lt;/value&gt;
      &lt;value&gt;"b"&lt;/value&gt;
  &lt;/util:list
  
  
  
  &lt;bean id="Definitions" /&gt;
  </code></pre>
  
  <p>Is there some way I can insert value to private field schemas(annotated with Resource) in my unit test without using spring. I tried using setting private variable via Reflection but that also did not help(probably due to security restrictions).</p>
  
  <p>Even using spring,
  ApplicationContext context = new ClassPathXmlApplicationContext("test.xml");
  It is not able to load schemas in Definitions bean. I get "NullPointerException" while accessing schemas.</p>