I have the following in the test setup:

    def originalPostAsXml = RestClient.&postAsXml

    RestClient.metaClass.'static'.postAsXml = {
        String uriPath, String xml ->
        return 65536
    }

and in the test cleanup:

    RestClient.metaClass.'static'.postAsXml = originalPostAsXml

But when the next test runs, when it tries to execute RestClient.postAsXml, it runs into a StackOverflowError:

at groovy.lang.Closure.call(Closure.java:282)

It looks like RestClient.postAsXml recursively points to itself. What's the right way to reset a mocked-out static method?

Edit
Report