Reputation: 873
Below is my method for which i want to write Junit test case:
public static byte[] getDecodeBase64(JSONObject object,String key) {
return Base64.decodeBase64(object.getString(key));
}
I wrote this:
@Test
public void testGetDecodeBase64(){
JSONObject test = new JSONObject();
test.put("clientId", "test");
String value = "[B@[2807bdeb]";
assertEquals(value, JSONUtil.getDecodeBase64(test, "clientId").toString());
}
But each time the value returned by the method is different.
Upvotes: 1
Views: 1185
Reputation: 1720
You should use assertArrayEquals
to check what's in the array.
Or, if you want to test with String, to convert your byte array into a String with :
byte[] bytes = {...}
String str = new String(bytes, "UTF-8");
Upvotes: 0
Reputation: 399
toString method of an array returns a string representing the Id of the array.
Upvotes: 1