Pretty much as the question states above.
My understanding is when the pipeline executes you get essentially vanilla instances of AEM author and publisher to test against. I can think of a few ways I could probably inject a content package of a barebones site to test against, but what's the recommended approach?
Can't see any mention of it in the docs.
Cheers in advance!
Solved! Go to Solution.
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes
Hi @raininglemons ,
To populate test content in your AEM (Adobe Experience Manager) repository for UI tests, you need a strategy that ensures your tests have consistent and predictable content to interact with each time the pipeline runs. Here’s a recommended approach:
Content packages are a robust way to inject necessary content into AEM instances. This involves creating and deploying a content package that contains the test content, which gets installed on the AEM instances during the pipeline execution. Here’s how you can do it:
Create a Content Package:
Automate Content Package Deployment:
Validation:
curl -u admin:admin -F file=@your-content-package.zip http://localhost:4502/crx/packmgr/service.jsp?cmd=upload
curl -u admin:admin -F file=@your-content-package.zip http://localhost:4502/crx/packmgr/service.jsp?cmd=install
Example Using Maven:
<plugin>
<groupId>com.day.jcr.vault</groupId>
<artifactId>content-package-maven-plugin</artifactId>
<version>1.0.2</version>
<executions>
<execution>
<id>install-package</id>
<phase>install</phase>
<goals>
<goal>install</goal>
</goals>
<configuration>
<vaultFiles>
<vaultFile>${project.basedir}/target/your-content-package.zip</vaultFile>
</vaultFiles>
</configuration>
</execution>
</executions>
</plugin>
AEM Repository Initializer is a feature that allows you to define repository structure and content through OSGi configurations or files. This is typically more lightweight than a content package and can be easier to manage for simple setups.
Create an Initialization Script:
Deploy the Initialization Script:
<Configuration xmlns:rep="http://www.jcp.org/jcr/1.0">
<repository>
<node name="content" primaryType="nt:unstructured">
<node name="my-test-page" primaryType="cq:Page">
<!-- Define page content here -->
</node>
</node>
</repository>
</Configuration>
The Sling Content Loader allows for automatic loading of content from the filesystem into the JCR repository. It is suitable for simple, static content setups.
Organize Content Files:
Configure Sling Content Loader:
<content>
<my-test-page jcr:primaryType="cq:Page">
<!-- Define content here -->
</my-test-page>
</content>
For testing at a more granular level, AEM Mocks provided by tools like wcm.io AEM Mocks can be used for unit testing without the need for a full AEM instance. This is more suitable for unit tests rather than UI tests.
For most UI test scenarios, content packages are the preferred method due to their flexibility and ease of deployment. They allow you to bundle any content and configurations needed, making them ideal for setting up a consistent testing environment.
Following these steps should give you a structured approach to populating test content in your AEM repository and ensure your UI tests have the necessary context to execute reliably.
Views
Replies
Total Likes
Hi @raininglemons ,
To populate test content in your AEM (Adobe Experience Manager) repository for UI tests, you need a strategy that ensures your tests have consistent and predictable content to interact with each time the pipeline runs. Here’s a recommended approach:
Content packages are a robust way to inject necessary content into AEM instances. This involves creating and deploying a content package that contains the test content, which gets installed on the AEM instances during the pipeline execution. Here’s how you can do it:
Create a Content Package:
Automate Content Package Deployment:
Validation:
curl -u admin:admin -F file=@your-content-package.zip http://localhost:4502/crx/packmgr/service.jsp?cmd=upload
curl -u admin:admin -F file=@your-content-package.zip http://localhost:4502/crx/packmgr/service.jsp?cmd=install
Example Using Maven:
<plugin>
<groupId>com.day.jcr.vault</groupId>
<artifactId>content-package-maven-plugin</artifactId>
<version>1.0.2</version>
<executions>
<execution>
<id>install-package</id>
<phase>install</phase>
<goals>
<goal>install</goal>
</goals>
<configuration>
<vaultFiles>
<vaultFile>${project.basedir}/target/your-content-package.zip</vaultFile>
</vaultFiles>
</configuration>
</execution>
</executions>
</plugin>
AEM Repository Initializer is a feature that allows you to define repository structure and content through OSGi configurations or files. This is typically more lightweight than a content package and can be easier to manage for simple setups.
Create an Initialization Script:
Deploy the Initialization Script:
<Configuration xmlns:rep="http://www.jcp.org/jcr/1.0">
<repository>
<node name="content" primaryType="nt:unstructured">
<node name="my-test-page" primaryType="cq:Page">
<!-- Define page content here -->
</node>
</node>
</repository>
</Configuration>
The Sling Content Loader allows for automatic loading of content from the filesystem into the JCR repository. It is suitable for simple, static content setups.
Organize Content Files:
Configure Sling Content Loader:
<content>
<my-test-page jcr:primaryType="cq:Page">
<!-- Define content here -->
</my-test-page>
</content>
For testing at a more granular level, AEM Mocks provided by tools like wcm.io AEM Mocks can be used for unit testing without the need for a full AEM instance. This is more suitable for unit tests rather than UI tests.
For most UI test scenarios, content packages are the preferred method due to their flexibility and ease of deployment. They allow you to bundle any content and configurations needed, making them ideal for setting up a consistent testing environment.
Following these steps should give you a structured approach to populating test content in your AEM repository and ensure your UI tests have the necessary context to execute reliably.
Views
Replies
Total Likes
Great, thanks!
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies