title: SpringBoot unit test configuration
body: <p>I created a spring-boot 1.4.0 application and I would like to internationlize it using yaml file.</p>
  
  <p>I created a class for loading the configuration from the yaml file like it is explained in the documentation here <a href="http://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html#boot-features-external-config-typesafe-configuration-properties" rel="nofollow noreferrer">http://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html#boot-features-external-config-typesafe-configuration-properties</a>.</p>
  
  <p>I would like to create a test to check that my class has correctly loaded the properties from the yaml file.</p>
  
  <p>If we keep the exemple from the documentation how to create a unit test that will load a yaml file (with a different name that application.yml) and check that the method <code>getUsername()</code> will return the value from the yaml file ?</p>
  
  <hr>
  
  <p>Here is the code I have but still can't load the username :</p>
  
  <pre><code>@Component
  @ConfigurationProperties(locations = "classpath:mylocalizedprops.yml", prefix="connection")
  public class ConnectionProperties {
  
      private String username;
  
      // ... getters and setters
  
  }
  </code></pre>
  
  <p>and the test class</p>
  
  <pre><code>@RunWith(SpringJUnit4ClassRunner.class)
  @SpringBootTest(classes = Application.class)
  public class InternationalizationTest {
      @Autowired
      private ConnectionProperties connectionProperties;
  
      public void propsShouldBeNotNull() {
          assertNotNull(connectionProperties);
      }
  
      public void userNameShouldBeCorrect() {
          assertEquals(connectionProperties.getUsername(), expectedUserName);
      }
  }
  </code></pre>
  
  <p>I have failed the userNameShouldBeCorrect test.  The file mylocalizedprops.yml is located in the src/main/resources folder of a Maven structured application.</p>