title: How to create TestContext for Spring Test?
body: <p>I have a relatively small Java library that implements a few dozen beans (no database or GUI). I have created a Spring Bean configuration file that other Java projects use to inject my beans into their stuff.</p>
  
  <p>I am now for the first time trying to use Spring Test to inject some of these beans into my junit test classes (rather than simply instantiating them).</p>
  
  <p>I am doing this partly to learn Spring Test and partly to force the tests to use the same bean configuration file I provide for others.</p>
  
  <p>In the Spring documentation is says I need to create an application context using the "TestContext" class that comes with Spring. I believe this should be done in a spring XML file that I reference via the @ContextConfiguration annotation on my test class.</p>
  
  <pre><code>@ContextConfiguration({"/test-applicationContext.xml"})
  </code></pre>
  
  <p>However, there is no hint as to what to put in the file! </p>
  
  <p>When I go to run my tests from within Eclipse it errors out saying "failed to load Application Context"....of course.</p>
  
  <p><strong>Update:</strong> </p>
  
  <p>Here is test-applicationContext.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:context="http://www.springframework.org/schema/context"
      xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
          http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"&gt;
      &lt;description&gt;Holds application context for testing of the domain module.&lt;/description&gt;
  
      &lt;!-- Imports the uuid generator bean definitions --&gt;
      &lt;import resource="resources/domain-uuid.xml"/&gt;  
  &lt;/beans&gt;
  </code></pre>
  
  <p>My project directory is like this:</p>
  
  <pre><code>domain/
     src/
        main/
           java/
           resources/
        test/
           java/
           resources/ (location of test-applicationContext.xml)
  </code></pre>
  
  <p>Just for fun I also tried to build from the mvn command line via "mvn clean test" and I got the following errors which may be my real problem:</p>
  
  <pre><code>package org.springframework.test.context does not exist
  
  package org.springframework.test.context.junit4 does not exist
  
  cannot find symbol
  symbol: class ContextConfiguration
  @ContextConfiguration({"/resources/test-applicationContext.xml"})
  
  cannot find symbol
  symbol: class SpringJUnit4ClassRunner
  @RunWith(SpringJUnit4ClassRunner.class)
  </code></pre>