title: Can gmock mock static methods of Java classes? Alternative?
body: <p>I could not get it to work. It's like the method is not mocked.</p>
  
  <p>Are there alternative groovy testing frameworks that work better to mock static Java methods?</p>
  
  <p><strong>Update 02/Mar/2011</strong>: Adding code:</p>
  
  <p>I am actually trying to mock the Scala XML.loadXml (I am trying Groovy for unit testing) class:</p>
  
  <p>This is my test case:</p>
  
  <pre><code>// ContentManagementGatewayTest.groovy
  class ContentManagementGatewayTest extends GMockTestCase
  {
    void testGetFileList()
    { 
        // Preparing mocks code will go here, see below
  
        play {
             GetFileGateway gateway = new GetFileGateway();
             gateway.getData();
        }
    }
  }
  
  // GetFileGateway.scala
  class GetFileGateway {
      def getData() 
      {  
           // ...
           val xmlData = XML.loadData("file1.txt");
      }
  }
  </code></pre>
  
  <p>I tried testing using both gmock and metaClass:</p>
  
  <pre><code>// metaClass:
  XML.metaClass.'static'.loadFile = {file -&gt;
        return "test"
  }
  
  // gmock:
  def xmlMock = mock(XML)
  xmlMock.static.loadFile().returns(stream.getText())
  </code></pre>