title: Loading a partial Spring context
body: <p>I am not much of a Spring expert, but was given a legacy system with a huge context file (not separated into modules).</p>
  
  <p>I want to add some unit tests - that validates different parts of the system, with the actual production configuration.
  I started using the <code>ClassPathXmlApplicationContext/FileSystemXmlApplicationContext</code> classes to load the context, however - that takes forever.
  Is it possible to load only parts of the context file (recursively) without the need to separate the original file into modules? </p>
  
  <p>Update:
  I'll just post here my implementation of Ralph's solution using maven:
  my pom.xml:</p>
  
  <pre><code>      &lt;plugin&gt;
          &lt;groupId&gt;com.google.code.maven-config-processor-plugin&lt;/groupId&gt;
          &lt;artifactId&gt;maven-config-processor-plugin&lt;/artifactId&gt;
          &lt;version&gt;2.0&lt;/version&gt;
          &lt;configuration&gt;
              &lt;namespaceContexts&gt;
                  &lt;s&gt;http://www.springframework.org/schema/beans&lt;/s&gt;
              &lt;/namespaceContexts&gt;
              &lt;transformations&gt;
                  &lt;transformation&gt;
                      &lt;input&gt;context.xml&lt;/input&gt;
                      &lt;output&gt;context-test.xml&lt;/output&gt;
                      &lt;config&gt;test-context-transformation.xml&lt;/config&gt;
                  &lt;/transformation&gt;
              &lt;/transformations&gt;
          &lt;/configuration&gt;
          &lt;executions&gt;
              &lt;execution&gt;
                  &lt;goals&gt;
                      &lt;goal&gt;process&lt;/goal&gt;
                  &lt;/goals&gt;
                  &lt;phase&gt;test&lt;/phase&gt;
              &lt;/execution&gt;
          &lt;/executions&gt;
      &lt;/plugin&gt;
  </code></pre>
  
  <p>my test-context-transformation.xml:</p>
  
  <pre><code>&lt;processor&gt;
      &lt;add&gt;
          &lt;name&gt;/s:beans&lt;/name&gt;
          &lt;value&gt;
              &lt;![CDATA[
                  default-lazy-init="true"
              ]]&gt;
          &lt;/value&gt;
      &lt;/add&gt;
  &lt;/processor&gt;
  </code></pre>