title: How to set environment variable dynamically in spring test
body: <p>I am trying to run spring-test cases with spring-boot. My test class looks like as follows </p>
  
  <pre><code>@ContextConfiguration(initializers = TestContextInitializer.class)
  @RunWith(SpringRunner.class)
  @SpringBootTest(classes = {TestServiceApplication.class})
  
  public class SampleTest {
      @org.junit.Test
      public void getContactsByName() throws Exception {
      }
  
  }
  </code></pre>
  
  <p>While my configuration class looks like </p>
  
  <pre><code>public class TestContextInitializer implements ApplicationContextInitializer&lt;ConfigurableApplicationContext&gt; {
      @Override
      public void initialize(ConfigurableApplicationContext configurableApplicationContext) {
          System.setProperty("DATA_DB_URL","some_url");
          System.setProperty("DATA_DB_USER","some_user");
          System.setProperty("DATA_DB_PASSWORD","some_password");
          System.setProperty("DATA_DB_POOL_SIZE","2");
          System.setProperty("DATA_DB_ROW_PREFETCH_SIZE","50");
      }
  }
  </code></pre>
  
  <p>Everything is working fine but I have problem. I can not check-in PASSWORD in the source code as my company policy. How can I externalize the password so that I don't have to check it in. </p>