Unit Testing: External Scripts: "deployment://file.js" Cannot find resource at path

When running unit tests you deploy through the API with something like:

@Deployment(resources = ["bpmn/ExternalScriptTest/myProcess.bpmn", "bpmn/ExternalScriptTest/file.js" ])

But the BPMN file has a “deployment://file.js” as the resource path, which functions when using Rest API deployment. If you change this to: deployment://bpmn/ExternalScriptTest/file.js the test passes.

<bpmn:scriptTask id="ScriptTask_1ujmwh7" name="My Script" scriptFormat="javascript" camunda:resource="deployment://file.js">

How do you reconcile this difference in unit testing?
As i understand it, when you @Deployment(resources = ["bpmn/ExternalScriptTest/myProcess.bpmn", "bpmn/ExternalScriptTest/file.js" ]), are you deploying the file to the classpath rather than into the database?

Currently you get the following error:

org.camunda.bpm.engine.exception.NotFoundException: ENGINE-09024 Unable to find resource at path deployment://file.js

I looked through the Unit Tests and the closest i could find was the following:

  1. https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/test/java/org/camunda/bpm/engine/test/bpmn/scripttask/ExternalScriptTaskTest.java
  2. https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/test/resources/org/camunda/bpm/engine/test/bpmn/scripttask/ExternalScriptTaskTest.testDefaultExternalScriptAsVariable.bpmn20.xml
  3. https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/test/resources/org/camunda/bpm/engine/test/bpmn/scripttask/ExternalScriptTaskTest.testScriptInDeployment.bpmn20.xml
  4. https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/test/resources/org/camunda/bpm/engine/test/bpmn/iomapping/InputOutputTest.testInputExternalDeploymentScriptValue.bpmn
  5. https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/test/resources/org/camunda/bpm/engine/test/bpmn/iomapping/InputOutputTest.testOutputExternalDeploymentScriptValue.bpmn

In each of the Unit tests that used deployment:// they all follow the folder structure rather than the style that is used in Rest API deployments.

@Niall
@thorben

Thanks!

This problem is being caused by the fact that the @Deployment unit test annotation seems to use classPath resources and thus each resource does not have a name

see: @Deployment Unit Test annotation does not support ProcessApplication deployments (only classpath)

Can see a solution to this problem here: