title: Jasypt not decrypting properties during junit testing, but works fine when spring boot app runs
body: <p>I have a Spring Boot application with a few properties encrypted with Jasypt, and I provide the secret key with the following VM option: <code>-Djasypt.encryptor.password=secretkey</code></p>
  <p>Everything is working perfectly when I run my application locally and in production. The issue is, I'm not sure what I need to do to decrypt the properties I have encrypted in my application-test.properties file I am using during jUnit tests. I'm even passing the same VM option above to my jUnit test.</p>
  <p>I'm not receiving any sort of exception during jUnit testing that is telling me why I'm unable to decrypt, but the properties I need decrypted just simply are not being decrypted. Is this even possible or is there some sort of configuration I can setup my tests with to utilize Jasypt decrypting.</p>
  <p>I'll include the code I have below. The test I am running in particular is for a JavaMailService method. I have the password encrypted in application-test.properties, and the test fails because it cannot authenticate the user (because password is still encrypted)</p>
  <p>application-test.properties:</p>
  <pre><code>spring.mail.password=ENC(1NrovUC7+YAzVNhbbpHkRi9TghEPys0aQk1nXonk354=)
  </code></pre>
  <p>Main Test Class:</p>
  <pre><code>@RunWith(SpringRunner.class)
  @WebMvcTest(value = { ApiController.class, RestController.class })
  @ContextConfiguration(classes = { MyApplication.class, EmailService.class, EmailServiceTestConfig.class })
  @ActiveProfiles(&quot;test&quot;)
  class MyApplicationTests {
  
      @Autowired
      private MockMvc mockMvc;
  
      @Test
      public void testSendEmail() throws Exception {
          ...
      }
  
  }
  </code></pre>
  <p>EmailServiceTestConfig Class:</p>
  <pre><code>@SpringBootConfiguration
  public class EmailServiceTestConfig {
  
      @Value(&quot;${spring.mail.username}&quot;)
      private String username;
  
      @Value(&quot;${spring.mail.password}&quot;)
      private String password;
  
      @Bean
      public JavaMailSender javaMailService() {
          ...
      }
  
      private Properties getMailProperties() {
          ...
      }
  }
  </code></pre>
  <p>I left out some unimportant information, however from this EmailServiceTestConfig class, I've checked the password retrieved from the properties file, and It has not been decrypted. Any ideas, please let me know! If I find a solution, I'll post here as well. Any additional information you might need, please let me know!</p>