I am writing test cases for content backup service in AEM 6.0 using assemble(JcrPackage pack, ProgressTrackerListener listener)
API in JcrPackageManager
class. How can I test whether package is assembled or not in my JUnit test cases?
If your unit tests are executed in an AEM environment (1) you might check if the package is existing in the expected repository path (/etc/packages/GROUP/PACKAGE
) and if the size is > 0 (jcrPackage.getSize()
).
Be aware that this will not work with
assemble(JcrPackage pack, ProgressTrackerListener listener, OutputStream out)
as the package will not be stored in the repo after the assembly has been done. It will be streamed to the output stream.
(1): https://sling.apache.org/documentation/development/sling-testing-tools.html