我找到了这个有用的库PODAM,但是我遇到了自动字节数组的麻烦。我使用了实现的AttributeStrategy
public class LogoStrategy implements AttributeStrategy<byte[]>{
private static final int MAX_SIZE_FILE = 512*1024;
@Override
public byte[] getValue() throws PodamMockeryException {
byte[] b = new byte[20];
new Random().nextBytes(b);
return b;
}
}
但是当我使用时,我得到了这个错误:
2014-10-21 20:13:04 PodamFactoryImpl [ERROR] The type of the Podam Attribute
Strategy is not java.lang.String but [B. An exception will be thrown.
Exception in thread "main" uk.co.jemos.podam.exceptions.PodamMockeryException: An illegal argument was passed
at uk.co.jemos.podam.api.PodamFactoryImpl.manufacturePojoInternal(PodamFactoryImpl.java:1569)
at uk.co.jemos.podam.api.PodamFactoryImpl.manufacturePojo(PodamFactoryImpl.java:129)
at uk.co.jemos.podam.api.PodamFactoryImpl.manufacturePojo(PodamFactoryImpl.java:119)
at cl.molavec.jpa.entities.singleton.QuotationPropertiesSingleton.getNewInstance(QuotationPropertiesSingleton.java:26)
at cl.molavec.main.InsertDummyData.main(InsertDummyData.java:66)
Caused by: java.lang.IllegalArgumentException: The type of the Podam Attribute Strategy is not java.lang.String but [B. An exception will be thrown.
at uk.co.jemos.podam.api.PodamFactoryImpl.returnAttributeDataStrategyValue(PodamFactoryImpl.java:2888)
at uk.co.jemos.podam.api.PodamFactoryImpl.manufacturePojoInternal(PodamFactoryImpl.java:1493)
... 4 more
我实现了AttributeStrategy但是使用了char []属性并且很好。错误我无法理解为什么期待一个字符串。
有什么建议吗?
提前致谢。