title: How do I reset a mocked static method in Groovy?
body: <p>I have the following in the test setup:</p>
  
  <pre><code>    def originalPostAsXml = RestClient.&amp;postAsXml
  
      RestClient.metaClass.'static'.postAsXml = {
          String uriPath, String xml -&gt;
          return 65536
      }
  </code></pre>
  
  <p>and in the test cleanup:</p>
  
  <pre><code>    RestClient.metaClass.'static'.postAsXml = originalPostAsXml
  </code></pre>
  
  <p>But when the next test runs, when it tries to execute RestClient.postAsXml, it runs into a StackOverflowError:</p>
  
  <pre><code>at groovy.lang.Closure.call(Closure.java:282)
  </code></pre>
  
  <p>It looks like RestClient.postAsXml recursively points to itself.  What's the right way to reset a mocked-out static method?</p>