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;
}
}
要被嘲笑的代码:
TestEntityDO[] testEntityMock = testmethod.getTestEntityDO();
我试着嘲笑:
TestEntityDO[] testEntityDOMock = PowerMock.createMock(TestEntityDO[].class); // exception is generating at this point
EasyMock.expect(testmethod.getTestEntityDO()).andReturn(testEntityDOMock);
异常追踪:
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)
课程不是最后一堂课。仍然将异常指向最终类。 请帮我解决这个问题。
答案 0 :(得分:5)
您正在尝试创建TestEntityDO
数组的子类/模拟。数组是最终的。