java - 如何为 Base64.decodeBase64 编写 JUnit 测试
问题描述
下面是我要编写Junit测试用例的方法:
public static byte[] getDecodeBase64(JSONObject object,String key) {
return Base64.decodeBase64(object.getString(key));
}
我写了这个:
@Test
public void testGetDecodeBase64(){
JSONObject test = new JSONObject();
test.put("clientId", "test");
String value = "[B@[2807bdeb]";
assertEquals(value, JSONUtil.getDecodeBase64(test, "clientId").toString());
}
但是每次方法返回的值都不一样。
解决方案
数组的 toString 方法返回一个表示数组 Id 的字符串。
推荐阅读
- c - 编程语言语法的 Bison Shift/Reduce Conflict
- oracle - 如何将游标内的记录转换为选择语句的列名?
- go - Colly 没有找到任何链接
- postgresql - PostgreSQL 将 SERIAL 列添加到现有表中,其值基于 ORDER BY
- javascript - JQuery animate() 没有动画
- arrays - 为什么不能使用 map() 函数迭代我的模型中的数组
- php - Dompdf 未在 php 标签内呈现内容
- ibm-watson - 使用 GraphQl 的 Watson 助手
- php - 使用mysql和php插入查询的问题
- ruby-on-rails - 如何使用 rails 初始化事件?