title: Spring Boot does not register HttpMessageConverter during test run
body: <p>I'm running a Spring Boot app and I've registered a new <code>HttpMessageConverter</code> called <code>CsvCompactVenueHttpMessageConverter</code>, here's the code for it:</p>
  
  <pre><code>@Component
  public class CsvCompactVenueHttpMessageConverter extends
      AbstractHttpMessageConverter&lt;Collection&lt;CompactVenue&gt;&gt; {
  
      public CsvCompactVenueHttpMessageConverter() {
         super(MediaType.valueOf(TEXT_CSV));
      }
  
     &gt;&gt; message converter implementation code &lt;&lt;
  }
  </code></pre>
  
  <p>It extends <code>AbstractHttpMessageConverter</code> and is registered as a bean on class <code>WebConfiguration</code>:</p>
  
  <pre><code>@Configuration
  public class WebConfiguration extends WebMvcConfigurerAdapter {
  
      @Bean
      public CsvCompactVenueHttpMessageConverter csvCompactVenueHttpMessageConverter() {
          return new CsvCompactVenueHttpMessageConverter();
      }
  }
  </code></pre>
  
  <p>Then I have a rest resource called <code>FoursquareResource</code>:</p>
  
  <pre><code>@RestController
  @RequestMapping("/foursquare")
  public class FoursquareResource {
  
      @Autowired
      FoursquareService foursquareService;
  
      @GetMapping(value = "/{location}", produces = {"application/json", "text/csv"})
      public Collection&lt;CompactVenue&gt; searchVenuesByLocationAndIncreasingRange(@PathVariable String location, @RequestParam(defaultValue = "1") Integer numQueries) throws FoursquareApiException, FoursquareServiceException {
          return foursquareService.searchVenuesByLocationAndIncreasingRange(location, numQueries);
      }
  }
  </code></pre>
  
  <p>When I run the app and call <code>http://localhost:8080/foursquare/New York NY</code> it works fine and renders the <code>text/csv</code> response.</p>
  
  <p>But when running the test with RestAssured and <code>@SpringBootTest</code> I get a HTTP 406 response (because I think it did not register correctly the <code>HttpMessageConverter</code> for <code>text/csv</code>), here's the code:</p>
  
  <pre><code>@RunWith(SpringRunner.class)
  @SpringBootTest
  @Slf4j
  public class FoursquareResourceTest {
  
      @Mock
      FoursquareService foursquareService;
  
      @InjectMocks
      FoursquareResource foursquareResource;
  
      @Before
      public void before() throws Exception {
          CompactVenue venue = new CompactVenue();
          FieldUtils.writeField(venue, "id", "aUfmEW745", true);
          Collection&lt;CompactVenue&gt; venues = new ArrayList&lt;&gt;();
          venues.add(venue);
          when(foursquareService.searchVenuesByLocationAndIncreasingRange(any(), any())).thenReturn(venues);
      }
  
      @Test
      public void testSearchVenuesByLocationAndIncreasingRangeCsv() throws Exception {
          MockMvcResponse response =
          given().
              accept("text/csv").
              standaloneSetup(foursquareResource).
          when().
              get(String.format("/foursquare/%s?numQueries=%d",location,numQueries)).
          then().
              statusCode(200).
          extract().response();
  
          log.info(response.body().print());
      }
  </code></pre>
  
  <p>}</p>
  
  <p>I'm not sure why do I get a right answer when running the Spring Boot app but the 406 error when running as a Test. It looks like the new <code>HttpMessageConverter</code> is not registered on the tests but I can't see why.
  Thanks and regards.</p>