[英]JAVA: java.lang.IllegalArgumentException: Cannot subclass final class class [Lcom.package.testEntityDO;
im trying to Mock below class. 我试图嘲笑下课。
public class testEntityDO extends BasetestDO {
private String entityType;
private testCapabilityDO[] capabilities;
private testEntityDO[] testDOs;
public String getEntityType() {
return entityType;
}
public void setEntityType(String entityType) {
this.entityType = entityType;
}
public testCapabilityDO[] getCapabilities() {
return capabilities;
}
public void setCapabilities(testCapabilityDO[] capabilities) {
this.capabilities = capabilities;
}
public TestEntityDO[] getTestPortDOs() {
return testPortDOs;
}
public void setTestPortDOs(TestEntityDO[] testPortDOs) {
this.testPortDOs = testPortDOs;
}
}
Code to be Mocked: 要模拟的代码:
TestEntityDO[] testEntityMock = testmethod.getTestEntityDO();
Mocking i tried: 我试过的模拟:
TestEntityDO[] testEntityDOMock = PowerMock.createMock(TestEntityDO[].class); // exception is generating at this point
EasyMock.expect(testmethod.getTestEntityDO()).andReturn(testEntityDOMock);
exception trace: 异常跟踪:
java.lang.IllegalArgumentException: Cannot subclass final class class [Lcom.package.TestEntityDO;
at net.sf.cglib.proxy.Enhancer.generateClass(Enhancer.java:446)
at net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25)
at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:216)
at net.sf.cglib.proxy.Enhancer.createHelper(Enhancer.java:377)
at net.sf.cglib.proxy.Enhancer.createClass(Enhancer.java:317)
class is not a final class. 上课不是最后一堂课。 still the exception is pointed as final class.
仍然有例外,指的是最后一堂课。 please help me to solve this issue.
请帮助我解决此问题。
You're trying to create a subclass/mock of an array of TestEntityDO
. 您正在尝试创建
TestEntityDO
数组的子类/模拟。 Arrays are final. 数组是最终的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.