title: How to mock ResourceBundle.getString()?
body: <p>I'm failing to mock <code>ResourceBundle.getString()</code>.</p>
  
  <p>This is my code:</p>
  
  <pre><code>ResourceBundle schemaBundle = Mockito.mock(ResourceBundle.class);
  Mockito.when(schemaBundle.getString("testKey_testPropertyName_ect")).thenReturn("testString1");
  </code></pre>
  
  <p>This gives the following exception on the second line:</p>
  
  <pre><code>java.util.MissingResourceException: Can't find resource for bundle $java.util.ResourceBundle$$EnhancerByMockitoWithCGLIB$$9e259f03, key testKey_testPropertyName_ect
      at java.util.ResourceBundle.getObject(ResourceBundle.java:374)
      at java.util.ResourceBundle.getString(ResourceBundle.java:334)
      at com.foo.bar.resource.PropertyResourceTest.testGet(PropertyResourceTest.java:104)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
      at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
      at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
      at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
      at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
      at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
      at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
      at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
      at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
      at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
      at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
      at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
      at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
  </code></pre>
  
  <p>To me this looks as if <code>schemaBundle</code> isn't mocked at all. But the debuger clearly shows, that the instance is wrapped by mockito.</p>
  
  <p>I also tried with</p>
  
  <pre><code>Mockito.doReturn("testString1").when(schemaBundle).getString("testKey_testPropertyName_ect");
  </code></pre>
  
  <p>but this returns the same exception.</p>
  
  <p>Any idea what's wrong?</p>