Mocking java.security.KeyStore

2,300 views
Skip to first unread message

Rajesh

unread,
Aug 28, 2009, 5:50:02 PM8/28/09
to mockito
Hi,
I was trying to mock KeyStore class, hit into the this issue.
"java.security.KeyStoreException: Uninitialized keystore". Here is a
sample code to reproduce this issue. I am expecting it to print null,
but throws Uninitialized KeyStore as if you have called a method on
real keystore object.

import static org.mockito.Mockito.mock;
import java.security.KeyStore;

public class MockTest {
public static void main(String[] args) throws Exception {
KeyStore keyStore = mock(KeyStore.class);
System.out.println(keyStore.getKey("","".toCharArray()));
}
}

Please help, or a workaround.

Thanks
Rajesh

Rajesh

unread,
Aug 28, 2009, 6:04:13 PM8/28/09
to mockito
Sorry about this post. It is clearly documented, mockito can not mock
final methods.

-Rajesh
Reply all
Reply to author
Forward
0 new messages