title: PowerMocking static does not return expected object
body: <p>I have a problem mocking <code>Calendar.getInstance()</code>. As you now this method returns a Calendar - the object I am mocking.</p>
  
  <p>Right now my code looks like this:</p>
  
  <pre class="lang-java prettyprint-override"><code>@RunWith(PowerMockRunner.class)
  @PrepareForTest(Calendar.class)
  public class SurveillanceDatabaseTest {
      @Test
      public void testFailingDatabase() throws Exception {
          mockStatic(Calendar.class);
          Calendar calendar = new GregorianCalendar();
          calendar.add(Calendar.HOUR, 1);
          when(Calendar.getInstance()).thenReturn(calendar);
          final Surveillance surveillance = new Surveillance();
          surveillance.checkDatabase();
     }
  }
  </code></pre>
  
  <p><code>Calendar.getInstance()</code> gets called various times in <code>surveillance.checkDatabase()</code> and every time it is a new object and not the expected mock of Calendar.</p>
  
  <p>Can anyone see what I am doing wrong?</p>