Unit test failing with classcast exception in upgrade to 7.11

Unit test is failing with the below exception at the end .

java.lang.ClassCastException: org.camunda.bpm.engine.impl.history.handler.DbHistoryEventHandler cannot be cast to org.camunda.bpm.extension.process_test_coverage.listeners.FlowNodeHistoryEventHandler

I am using
<camunda.version>7.11.0</camunda.version>
<camundaSpringBoot.version>3.3.1</camundaSpringBoot.version>
<springBoot.version>2.1.5.RELEASE</springBoot.version>

But if I moved to below version, it is working fine
<camunda.version>7.10.0</camunda.version>–>
<springBoot.version>2.1.1.RELEASE</springBoot.version>
<camundaSpringBoot.version>3.2.0</camundaSpringBoot.version>

Hi @anisk,

Can you further explain your use-case? Are you modifying the default configuration in any case?

Best,
Nikola

no . I am not overriding default configuration my test class is like as below .

Usecase : The camunda process is getting triggered by a listener which is listening kafka topic for an event . Once the process kick start it will process all lined up the service task till it reached Receive message task waiting a message.

@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE,
        classes = TestApplication.class,
        properties = {
                "camunda.bpm.job-execution.enabled=false",
                "camunda.bpm.auto-deployment-enabled=false"}
)

@PropertySource("classpath:application-test.properties")
@ActiveProfiles({ "test" })
@Deployment(resources = { "process1.bpmn" })
public class AllocatePathMessageListenerTest {
    @Autowired
    private Sink sink;


    @Autowired
    private Source source;

    @Autowired
    private MessageCollector messageCollector;

    @Autowired
    public ProcessEngine processEngine;

  
    @Rule
    @ClassRule
    public static ProcessEngineRule rule;


    @PostConstruct
    void initRule() {
        rule = TestCoverageProcessEngineRuleBuilder.create(processEngine).withDetailedCoverageLogging().build();
    }


    @Before
    public void setup() throws Exception {
        MockitoAnnotations.initMocks(this);

    }

Hi @anisk,

your problem is caused by a change in the spring boot starter for Camunda 7.11. which introduced integration with Spring eventing. This is done with a custom history event handler which seems to break the current implementation of the test coverage.

There is a bug report open which you can find here: https://app.camunda.com/jira/browse/CAM-10650

One workaround could be to add the plugin to the configuration postDeploy and override the composite history handler. This would result in removing the Spring eventing integration again, though.

Best, Ben

Hi @benhoffmann - is there any example of this -to add the plugin to the configuration postDeploy and override the composite history handler? I need 7.11 but this process coverage stopping me to use the version .

Hi @anisk,

The implementation of a Process Engine Plugin in Spring Boot could look like this.

@Component
public class ProcessTestCoverageProcessEnginePlugin extends AbstractProcessEnginePlugin implements ProcessEnginePlugin {

  @Override
  public void postInit(ProcessEngineConfigurationImpl processEngineConfiguration) {
    ProcessCoverageConfigurator.initializeProcessCoverageExtensions(processEngineConfiguration);
  }
}

Calling ProcessCoverageConfigurator.initializeProcessCoverageExtensions() on postInit() overrides the CompositeEventHandler, finally. This will then, as a consequence, make ProcessTestCoverage run but breaks the functionality of every other History Event Handler that might have been registered in the Composite. As of now, only Spring Eventing Integration is affected.

The ticket @benhoffmann referred to is connected to a feature request that passed its evaluation and will bring a proper History Event Handler interface that will enable us to fix ProcessTestCoverage later on.

Hope that helps,

Best, Sebastian

1 Like

The plugin approach didn’t work for me (even after downgrading to 7.10.0) (added it via @Import on the @SpringBootTest).

An alternate work around is run the tests without coverage e.g
ProcessEngineRule rule = new ProcessEngineRule(processEngine);