title: Spring Boot Integration Tests With @MockBean don't release jdbc connections
body: <p>I have a problem with integration tests. </p>
  
  <p>We're using spring boot 1.4.4 + spring batch + testcontainers + postgres.</p>
  
  <p>Each integration test annotated:</p>
  
  <pre><code>@RunWith(SpringRunner.class)
  @ActiveProfiles(value = { "integrationtest" })
  @SpringBootTest(classes = ServiceApplication.class)
  </code></pre>
  
  <p>The problem is:</p>
  
  <p>Looks like each integration test that contains @MockBean annotation creates a new context.
  Each new context creates a new connection pool with a 10 connections.
  But previous context doesn't release its connections.</p>
  
  <p>So before each such kind of test I can select connections count from postgres:</p>
  
  <pre><code>select sum(numbackends) from pg_stat_database;
  </code></pre>
  
  <p>And see that each test adds 10 new connections.</p>
  
  <p>10th test fails because of 100 connections limit.</p>
  
  <p>Could you advice how to solve it?</p>