title: Resolve Spring @Value expression in JUnit tests
body: <p>Here's a snippet of a Spring bean:</p>
  
  <pre><code>@Component
  public class Bean {
  
      @Value("${bean.timeout:60}")
      private Integer timeout;
  
      // ...
  }
  </code></pre>
  
  <p>Now I want to test this bean with a JUnit test. I'm therefore using the <a href="http://docs.spring.io/spring/docs/3.2.6.RELEASE/javadoc-api/org/springframework/test/context/junit4/SpringJUnit4ClassRunner.html">SpringJUnit4ClassRunner</a> and the <a href="http://docs.spring.io/spring/docs/3.2.x/javadoc-api/org/springframework/test/context/ContextConfiguration.html">ContextConfiguration</a> annotation.</p>
  
  <pre><code>@RunWith(SpringJUnit4ClassRunner.class)
  @ContextConfiguration
  public class BeanTest {
  
      @Autowired
      private Bean bean;
  
      // tests ...
  
      @Configuration
      public static class SpringConfiguration {
          @Bean
          public Bean bean() {
              return new Bean();
          }
      }
  }
  </code></pre>
  
  <p>Unfortunately the SpringJUnit4ClassRunner can't resolve the <code>@Value</code> expression, even though a default value is supplied (a <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/NumberFormatException.html">NumberFormatException</a> is thrown). It seems that the runner isn't even able to parse the expression.</p>
  
  <p>Is something missing in my test?</p>