title: Spring SimpleThreadScope does not support descruction callbacks
body: <p>I would like to run parallel selenium tests (using webriver and the Spring JUnit runner). Webdriver is a spring bean with the custom thread scope. But I get a following warning <code>SimpleThreadScope does not support descruction callbacks</code> So the browsers are not closed. Any idea how to close them (more precisely call the quit method)?</p>
  
  <p>spring config</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;bean id="threadScope" class="org.springframework.context.support.SimpleThreadScope" /&gt;
  
  &lt;bean class="org.springframework.beans.factory.config.CustomScopeConfigurer"&gt;
      &lt;property name="scopes"&gt;
             &lt;map&gt;
                 &lt;entry key="thread" value-ref="threadScope" /&gt;
             &lt;/map&gt;
         &lt;/property&gt;
  &lt;/bean&gt;
  
  &lt;bean id="webDriver" class="org.openqa.selenium.remote.RemoteWebDriver" scope="thread" destroy-method="quit"&gt;
      &lt;constructor-arg name="remoteAddress" value="http://localhost:4444/wd/hub" /&gt;
      &lt;constructor-arg name="desiredCapabilities" ref="browserAgent" /&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>maven config</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;plugin&gt;
      &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
      &lt;artifactId&gt;maven-failsafe-plugin&lt;/artifactId&gt;
      &lt;version&gt;2.12&lt;/version&gt;
      &lt;configuration&gt;
          &lt;includes&gt;
              &lt;include&gt;**/*Test.class&lt;/include&gt;
          &lt;/includes&gt;
          &lt;reportsDirectory&gt;${basedir}/target/surefire-reports&lt;/reportsDirectory&gt;
          &lt;parallel&gt;classes&lt;/parallel&gt;
          &lt;threadCount&gt;2&lt;/threadCount&gt;
          &lt;perCoreThreadCount&gt;false&lt;/perCoreThreadCount&gt;
      &lt;/configuration&gt;
  &lt;/plugin&gt;
  </code></pre>
  
  <p>This post <a href="http://www.springbyexample.org/examples/custom-thread-scope-module-code-example.html" rel="nofollow">http://www.springbyexample.org/examples/custom-thread-scope-module-code-example.html</a> suggests a custom Thread implementations. But where is an extension point type of Runnable using any JUnit runner?</p>
  
  <pre class="lang-java prettyprint-override"><code>public class ThreadScopeRunnable implements Runnable {
  
      protected Runnable target = null;
  
      /**
       * Constructor
       */
      public ThreadScopeRunnable(Runnable target) {
          this.target = target;
      }
  
      /**
       * Runs &lt;code&gt;Runnable&lt;/code&gt; target and 
       * then afterword processes thread scope 
       * destruction callbacks.
       */
      public final void run() {
          try {
              target.run();
          } finally {
              ThreadScopeContextHolder.currentThreadScopeAttributes().clear();
          }
      }
  
  }
  </code></pre>