我找到了这个有用的库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[] 属性并且一切都很好。我不明白为什么需要一个字符串的错误。
有什么建议么?
提前致谢。