Packaging Junit

Avatar

Avatar

santhoshsrg

Avatar

santhoshsrg

santhoshsrg

15-06-2020

Hi,

 

I have created a service to create packages. I want to know how to write Junit test for this service. PFB the service code for creating package. 

 

Any help would be great. Thanks in advance!!

 

     @reference
     private Packaging packaging;

     public void createPackage(Node rootNode, String pkgName) {
        JcrPackageManager jcrPackageManager = packaging.getPackageManager(session);
        JcrPackage jcrPackage = jcrPackageManager.create(rootNode, pkgName);
		JcrPackageDefinition jcrPackageDefinition = jcrPackage.getDefinition();
		DefaultWorkspaceFilter workspaceFilter = new DefaultWorkspaceFilter();
		
		for (PathFilterSet packageFilter : packageFilters) {
			workspaceFilter.add(packageFilter);
		}
		jcrPackageDefinition.setFilter(workspaceFilter, AUTO_SAVE); 
		jcrPackageDefinition.set(JcrPackageDefinition.PN_DESCRIPTION, PACKAGE_DESCRIPTION + pkgName, false);
		jcrPackageDefinition.set(JcrPackageDefinition.PN_GROUP, rootNode.getName() , false);
		jcrPackageManager.assemble(jcrPackage, listener);
     }

 

View Entire Topic

Avatar

Avatar

santhoshsrg

Avatar

santhoshsrg

santhoshsrg

22-06-2020

In the example https://github.com/Adobe-Consulting-Services/acs-aem-commons/blob/master/bundle/src/test/java/com/ad..., they have used jcrPackageManager.create(groupName, name, version) which is also working for me. But methods mentioned below are not working. These are throwing exceptions in "org.apache.jackrabbit" classes.

 

Methods not working:

  • jcrPackageManager.create(rootNode, pkgName)
  • jcrPackageManager.assemble(jcrPackage, listener)