title: Mockito when/then not returning expected value
body: <p>I'm trying to stub this getKeyFromStream method, using the 'any' matchers.  I've tried being more explicit and less explicit (anyObject()), but it seems like no matter what I try, this stub will not return the fooKey in my unit test.</p>
  
  <p>I'm wondering if it is because it is protected or there is something else I'm missing or doing incorrectly.  I have other when/then statements throughout the tests that <em>are working</em> but for some reason here, it is not.</p>
  
  <p>Note: The getKeyFromStream generally uses a byteArrayInputStream, but I'm trying to match it with an InputStream, I've tried both to no avail.</p>
  
  <pre><code>public class FooKeyRetriever() //Mocked this guy
  {
      public FooKey getKey(String keyName) throws KeyException {
  
          return getKeyFromStream(getKeyStream(keyName, false), keyName);
      }
  
      //Stubbed this method to return a key object which has been mocked
      protected FooKey getKeyFromStream(InputStream keyStream, String keyName){
          //Some code
          return fooKey;
      }
  }
  </code></pre>
  
  <p>Unit Test</p>
  
  <pre><code>@Mock
  private FooKeyRetriever mockKeyRetriever;
  
  @Mock
  private FooKey fooKey;
  
  @Before
  public void setUp() throws Exception {
          MockitoAnnotations.initMocks(this);
  }
  
  @Test
  public void testGetFooKey() throws Exception {
  
  
  
      when(foo.getKeyFromStream(any(InputStream.class),any(String.class))).thenReturn(fooKey);
  
      FooKey fooKey = mockKeyRetriever.getKey("irrelevant_key");
  
      assertNotNull(fooKey);
  }
  </code></pre>