DbUnit 和二进制数据
我使用 DbUnit 对 DAO 对象进行单元测试。到目前为止效果很好。
我有一个问题,我有字段 ob 类型 byte[]
,它以 BLOB 形式存储在数据库中。该列不为空。如何在 DbUnit 使用的 XML 数据集文件中指定此列的值?该值可以不花哨,5 个字节就足够了。我想避免为此创建额外的二进制文件。
有什么建议吗?
I use DbUnit for unit-testing of my DAO objects. It works great so far.
I have a problem, I have field ob type byte[]
which is stored as BLOB in the database. The column is not-null. How can I specify the value for this column in the XML dataset file, that DbUnit uses? The value can be nothing fancy, 5 bytes will be enough. I would like to avoid necessity to create extra binary files just for this.
Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
毕竟我是这样解决的:
XML 数据集文件:
DbUnit 内置了对 Base64 编码数据的支持,它可以正确转换为字节数组。
测试用例代码:
After all I solved it like that:
XML dataset file:
DbUnit has built-in support for Base64 encoded data, it transformes correctly into byte array.
Test case code: