title: How to write the unit test case for the Classes which are annotated with @Configuration in Spring Boot application
body: <p>I have a <strong>Configuration Class</strong>, which creates the bean for <code>RedissonClient</code> and also Creates the <code>CacheManager</code>. How to create the Unit Test case for this Configuration classes. </p>
  
  <ol>
  <li>Can we write unit test case for <code>@Configuration</code> Class?</li>
  <li>If we can, How we need to develop.             </li>
  </ol>
  
  <p>I prefer to write the test case in Spock Framework, with Groovy. If not, using Junit or Mockito Framework. How to write the unit test case for the Classes which are annotated with <code>@Configuration</code> in Spring Boot application</p>
  
  <pre><code>@Configuration
  public class CacheConfiguration {
      private static final String CONFIG= "Configuration";
  
      @Value("${redis.server.url}")
      private String redisUrl;
  
      @Value("${redis.server.password}")
      private String password;
  
      @Bean 
      public RedissonClient redissonClient() {
          Config config = new Config();
          config.useSingleServer().setAddress(redisUrl).setPassword(password);
          RedissonClient client = Redisson.create(config);
          return client;
      }
      @Bean
      public CacheManager redissonCacheManager(RedissonClient redissonClient) {
          Map&lt;String, CacheConfig&gt; config = new HashMap&lt;String, CacheConfig&gt;();
          config.put(CONFIG, new CacheConfig(24*60*1000, 12*60*1000));
          return new RedissonSpringCacheManager(redissonClient, config);
      }
  
  }
  </code></pre>