JAVA: java.lang.IllegalArgumentException: Cannot subclass fi



我想模仿下面的班级。

 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)

类不是final类。异常仍然指向final类。请帮我解决这个问题

您正在尝试创建TestEntityDO数组的子类/模拟。

相关内容

  • 没有找到相关文章

最新更新