title: Adding spring-cloud-starter-sleuth dependency to a Spring-Boot App some of the Rest Doc test failing
body: <p>I have a Spring-Boot 2.1.4 application with n-RestDoc tests for Flux controller.</p>
  
  <p>Environment:</p>
  
  <ul>
  <li>Spring-Boot 2.1.4</li>
  <li>Junit 5.4.0</li>
  <li>spring-restdocs-webtestclient</li>
  <li>spring-webflux</li>
  </ul>
  
  <p>If I add the spring-clout-starter-sleuth dependendcy to the app, some of the doc test fails in maven build. 
  Important on different environment different test classes fails with:</p>
  
  <pre><code>java.lang.IllegalStateException: org.springframework.boot.web.reactive.context.AnnotationConfigReactiveWebServerApplicationContext@6516dd09 has been closed already ....
  </code></pre>
  
  <p>If run the failling test with maven <code>-Dtest=OptDocTest</code> than the test will not fail, also if a set (not all) test where specified. </p>
  
  <p>Dependendcy</p>
  
  <pre><code>&lt;dependency&gt;
       &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;
       &lt;artifactId&gt;spring-cloud-starter-sleuth&lt;/artifactId&gt;
       &lt;version&gt;2.1.1.RELEASE&lt;/version&gt;
       &lt;exclusions&gt; &lt;!-- exclude old spring versions --&gt;
            &lt;exclusion&gt;
                 &lt;artifactId&gt;*&lt;/artifactId&gt;
                 &lt;groupId&gt; org.springframework.security&lt;/groupId&gt;
             &lt;/exclusion&gt;
             &lt;exclusion&gt;
                  &lt;artifactId&gt;spring-aop&lt;/artifactId&gt;
                  &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;/exclusion&gt;
        &lt;/exclusions&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
        &lt;groupId&gt;org.springframework&lt;/groupId&gt;
        &lt;artifactId&gt;spring-aop&lt;/artifactId&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>All test looks simular </p>
  
  <pre><code>@ExtendWith({ RestDocumentationExtension.class, SpringExtension.class })
  @AutoConfigureRestDocs("target/generated-snippets")
  @SpringBootTest(//webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, 
          classes = { ArchimedesApplication.class })
  class OptControllerDocTest {
  
     @MockBean
     private SrkConnector srkTConnector;
  
     @Autowired
     private ApplicationContext context;
  
     private WebTestClient webTestClient;
  
     @BeforeEach
     void beforeEach(RestDocumentationContextProvider restDocumentation) {
          this.webTestClient = WebTestClient.bindToApplicationContext(context)
                .configureClient() 
                .filter(documentationConfiguration(restDocumentation))
                .build();
  
     }
  
     @Test
     void documentationTest() throws IOException {
  
          this.webTestClient.post()
              .uri("/opt")
              .contentType(MediaType.APPLICATION_JSON)
              .body(BodyInserters.fromObject(testRequest))
              .exchange()
              .expectStatus()  // here the error occur
              .isOk()
              .expectBody() ...
      }
  </code></pre>
  
  <p>All IT Test with a running Boot Application works correct. </p>
  
  <p>I have no idea what goes wrong and why the <code>AnnotationConfigReactiveWebServerApplicationContext</code> is closed. </p>
  
  <p>On a windows box the rest doc test for controller with a flux content fails on a linux box for controller with mono content.</p>