title: Methods using @Retryable and @Recover don't call @Recover method with @SpringBootTest
body: <p>I'm looking at some code in a SpringBoot application using @Retryable methods, with other methods marked @Recover.  When we run the entire application and make remote calls that we know will fail, it does properly call the @Recover method.</p>
  
  <p>However, when we run a test using @SpringBootTest with similar conditions, it never calls the @Recover method.  We have lots of debug output.  I did notice one situation in our running server (not the test case) where we saw something like the following:</p>
  
  <pre><code>Exception ExhaustedRetryException: Cannot locate recovery method;
  </code></pre>
  
  <p>I was looking for that in the debug output from the testcase, but I didn't find it.</p>
  
  <p>The test class has the following annotations:</p>
  
  <pre><code>@RunWith(SpringJUnit4ClassRunner.class)
  @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
  @ContextConfiguration(classes = { Application.class })
  </code></pre>
  
  <p>Our Application class has the following annotations:</p>
  
  <pre><code>@SpringBootApplication
  @PropertySource("classpath:application.properties")
  @ComponentScan(basePackages = "com")
  @EnableAsync
  @EnableRetry
  @EnableCaching
  @EnableAutoConfiguration(exclude = { DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class,
          HazelcastAutoConfiguration.class, CacheAutoConfiguration.class, CassandraAutoConfiguration.class,
          CassandraDataAutoConfiguration.class, CassandraRepositoriesAutoConfiguration.class })
  </code></pre>
  
  <p>Is there some particular method in the Spring infrastructure that I can step through to see why it's not finding, or perhaps not even looking for, the recover method?</p>
  
  <p><strong>Update</strong>:</p>
  
  <p>So I realized that when I execute the test in debug, I don't see the Spring RetryTemplate anywhere in the stacktrace.  Isn't that what controls the flow from the Retryable method to the Recover method?  That seems to point to some setup I'm missing in the test class, or perhaps an indication that this simply can't be done in a test class (I hope that's not true).</p>
  
  <p><strong>Update</strong>:</p>
  
  <p>Ok, I managed to figure this out.  This was happening because I had neglected to inject the bean from Spring, I just created one manually.  That meant it wasn't wired to use the RetryTemplate, so it never attempted to find a @Recover method at all.  Once I added "@Autowired" to the instance variable in the test class, it got past this problem (and hit me with the next problem, but I understand that one).</p>