title: How to write Integration test to check contents in MDC context?
body: <p>Here is the code which I use to add filter to headers and add a UUID</p>
  
  <pre><code>@Slf4j
  public class ReqTxIdFilterImpl implements Filter {
  
      @Override
      public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)
              throws IOException, ServletException {
  
          HttpServletRequest request = (HttpServletRequest) servletRequest;
          List&lt;String&gt; headerNames = Collections.list(request.getHeaderNames());
          String requestTxId = "";
          if(!headerNames.isEmpty()){
              requestTxId = request.getHeader(
                      headerNames.stream()//
                              .filter(header -&gt; header.contains("txId"))
                              .findAny()
                              .orElse("")//
                      );
          }
          if (StringUtils.isEmpty(requestTxId)) {
              requestTxId = UUID.randomUUID().toString();
          }
          MDC.put("txId", requestTxId);
          filterChain.doFilter(servletRequest, servletResponse);
          MDC.clear();
      }
  }
  </code></pre>
  
  <p>I use spring boot and MockMvc to test APIs</p>
  
  <pre><code>@Autowired
      private MockMvc mockMvc;
  
      @Test
      public void test_generatePolicyNumber() throws Exception {
          MvcResult mvcResult = this.mockMvc.perform(post("/test"))
                  .header("txId", "test-id")
                  .andDo(print()).andExpect(status().isOk())
                  .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
                  .andReturn();
          Assert.assertTrue(mvcResult.getResponse().getContentAsString().contains("test"));
      }
  </code></pre>
  
  <p>I also want to check the MDC context and check if this <em>test-id</em> is set as txId in the MDC context map and verify it. Is it possible ?</p>