AnsweredAssumed Answered

Autowiring does not work with org.activiti.engine.test.ActivitiRule

Question asked by wsalembi on Jul 17, 2013
Latest reply on Jul 17, 2013 by frederikheremans1
We had an issue with our spring beans not being autowired in our unit tests.

Our activiti.cfg.xml file contains 
<context:annotation-config/>

We call a JavaDelegate class using activiti:delegateExpression

  
 <serviceTask id="checkValidName" name="CheckValidName" activiti:delegateExpression="${nameChecker}"></serviceTask>


The cause of the problem is ActivitiRule who delegates to org.activiti.engine.impl.cfg.BeansConfigurationHelper::parseProcessEngineConfiguration to instantiate the spring context using DefaultListableBeanFactory. Because no ApplicationContext is used, the
<context:annotation-config/> 
seems to be ignored.

(BeanFactory only supports the older Autowire collaborators mechanism. http://static.springsource.org/spring/docs/3.0.0.RELEASE/reference/htmlsingle/#beans-factory-autowire)

If we instantiate the Spring context ourselves in the unit test using ClassPathXmlApplicationContext, we have no issues with autowiring.

Is it possible to review the implementation of BeansConfigurationHelper to use an application context instead of beanFactory?

Outcomes