Following is the code in actual Java class:
try {
byte[] encodedBytes = Base64.encodeBase64(queryParams.getBytes("UTF-8"));
} catch (UnsupportedEncodingException e) {
...
}
queryParams
is a String
.
Now I want to cover the catch block. So in my test, I am writing like this:-
EasyMock.expect(anyObject(String.class).getBytes("UTF-8")).andThrow(new UnsupportedEncodingException());
But it doesn't seem to work. Can someone tell what can be here?
Aucun commentaire:
Enregistrer un commentaire