使用testng进行测试活动部署时遇到了一些大问题

时间:2016-07-01 07:32:01

标签: java unit-testing testng activiti

我使用testng来测试 activiti 5.19 的并发性。 首先,我编写一个单元测试来部署我的bpm文件。 java代码为blow:

@ContextConfiguration(value = { "classpath:springTypicalUsageTest-context.xml" })
    public class TaskTestPerformance extends AbstractTestNGSpringContextTests{
    private static final Logger log =  LoggerFactory.getLogger(TaskTestPerformance.class);
    @Autowired
    private ItsProcessInstanceImp itsProcessInstanceService;
    @Autowired
    private ItsDeploymentImp itsDeploymentService;
    @Autowired
    private ItsProcessDefinitionImp itsProcessDefinitionService;
    @Autowired
    private ItsTaskImp itsTaskService;

    private static String bpmfile = "com/jsits/bpm/activiti/test/task/taskTest.bpmn";
    private static String deploymentname = "taskTasks";

    @Test(invocationCount=20,threadPoolSize=10,invocationTimeOut=60000)
    public void testTaskId(){
        Deployment deployment = itsDeploymentService.deploy(deploymentname, bpmfile);
        log.info(deployment.getId());
    }

}

注意:此方法将执行20次并使用10个线程,并在60秒后超时,就像上面的代码所示:

 (invocationCount=20,threadPoolSize=10,invocationTimeOut=60000)

我使用testNG runner运行单元测试,结果是:

===============================================

Default test

Tests run: 20, Failures: 13, Skips: 0

===============================================

错误详情如下:

Caused by: org.h2.jdbc.JdbcSQLException: Unique index or primary key violation: "ACT_UNIQ_PROCDEF_INDEX_6 ON PUBLIC.ACT_RE_PROCDEF(KEY_, VERSION_, TENANT_ID_) VALUES ( /* key:7 */ 'tasktestid:5:69', 1, 'http://www.activiti.org/test', 'tasktestname', 'tasktestid', 5, '53', 'com/jsits/bpm/activiti/test/task/taskTest.bpmn', 'com/jsits/bpm/activiti/test/task/taskTest.tasktestid.png', NULL, FALSE, TRUE, 1, '')"; SQL statement:
insert into ACT_RE_PROCDEF(ID_, REV_, CATEGORY_, NAME_, KEY_, VERSION_, DEPLOYMENT_ID_, RESOURCE_NAME_, DGRM_RESOURCE_NAME_, DESCRIPTION_, HAS_START_FORM_KEY_, HAS_GRAPHICAL_NOTATION_ , SUSPENSION_STATE_, TENANT_ID_)
    values (?,
            1,
            ?,
            ?,
            ?, 
            ?,
            ?,
            ?,
            ?,
            ?,
            ?,
            ?,
            ?,
            ?) [23505-176]
    at org.h2.message.DbException.getJdbcSQLException(DbException.java:344)
    at org.h2.message.DbException.get(DbException.java:178)
    at org.h2.message.DbException.get(DbException.java:154)
    at org.h2.index.BaseIndex.getDuplicateKeyException(BaseIndex.java:103)
    at org.h2.index.TreeIndex.add(TreeIndex.java:69)
    at org.h2.table.RegularTable.addRow(RegularTable.java:120)
    at org.h2.command.dml.Insert.insertRows(Insert.java:157)
    at org.h2.command.dml.Insert.update(Insert.java:115)
    at org.h2.command.CommandContainer.update(CommandContainer.java:79)
    at org.h2.command.Command.executeUpdate(Command.java:254)
    at org.h2.jdbc.JdbcPreparedStatement.execute(JdbcPreparedStatement.java:199)
    at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:41)
    at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:66)
    at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:45)
    at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:100)
    at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:75)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:148)
    ... 36 more

所有这些错误!!

我将数据库表单mysql更改为h2,并将invocationCount从100更改为20,threadPoolSize从10更改为100,错误不会更改。< / p>

但如果我修改threadPoolSize = 1,则错误消失。

这是否意味着activiti部​​署bpm,并发性不好?

谢谢你们所有人!

0 个答案:

没有答案