title: Modify a parameter value used in multiple beans in Java unit test
body: <p>I'm wrting a JUnit to test a threshold value, which is passed from a <code>.properties</code> file like:</p>
  
  <pre><code>threshold=8
  </code></pre>
  
  <p>And I use a spring context to apply this threshold value:</p>
  
  <pre><code>&lt;context:property-placeholder location="classpath:test.properties"/&gt;
  
  &lt;si:channel id="thresholdInputChannel"/&gt;
  &lt;si:recipient-list-router input-channel="thresholdInputChannel" default-output-channel="nullChannel"&gt;
      &lt;si:recipient channel = "recipientChannel" selector-expression = "${threshold} &gt; 0"/&gt;
  &lt;/si:recipient-list-router&gt;
  ...
  
  &lt;si:chain input-channel = "fileTransformationChannel" output-channel="endChannel"&gt;
      &lt;si:transformer method = "transform"&gt;
          &lt;bean class = "fileTransformer" &gt;
              &lt;property name = "fixedProperties"&gt;
                  &lt;map&gt;
                      &lt;entry key="threshold" value="${threshold}"/&gt;
                  &lt;/map&gt;
              &lt;/property&gt;
          &lt;/bean&gt;
      &lt;/si:transformer&gt;
  &lt;/si:chain&gt;
  ...
  </code></pre>
  
  <p>Before in the JUnit test, I used <code>@ContextConfiguration(locations = {"classpath:test.properties"})</code> to load the context and <code>@RunWith(SpringJUnit4ClassRunner.class)</code>
  and <code>@Autowired</code> to get all the channels defined in context file and it worked fine. But the problem is that like this I can test at one time one single value of <code>${threshold}</code> which is predefined in the <code>test.properties</code>. </p>
  
  <p>To be able to change <code>${threshold}</code> value, I tried all the ways mentioned in <a href="https://stackoverflow.com/questions/3405422/how-can-i-use-the-parameterized-junit-test-runner-with-a-field-thats-injected-u">this answer</a>:</p>
  
  <ol>
  <li><p>Use <code>@RunWith(Parameterized.class)</code></p>
  
  <pre><code>@Parameterized.Parameters
  public static List&lt;Object[]&gt; params() {
      return Arrays.asList(new Object[][]{
              {"0"},
              {"8"},
      });
  }
  </code></pre>
  
  <p>but in this way I can't use injected beans any more, hence I lost the channels in JUnit.</p></li>
  <li><p><code>public abstract class AbstractJunitTest extends AbstractJUnit4SpringContextTests</code> same problem with injected beans. </p></li>
  <li><p><code>@Value("${threshold}")
   private String threshold;</code> origin value don't get erased and invoke a problem of variable type as there is <code>selector-expression = "${threshold} &gt; 0"</code> in context file.</p></li>
  </ol>
  
  <p>I'd like to know if there is any other possible ways to do this. Dropping the context file and creating an <code>ApplicationConfig.class</code> with all the beans and parameters may be a solution but not a prefered one, as the context file is really great. </p>
  
  <p>By the way, the reason I have to autowire the channels in JUnit is that I have to send a local file into the <code>fileTransformationChannel</code> and get it transformed in some way.</p>