This repository has been archived by the owner on Nov 23, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 40
JcrSupport
Mariusz Kubiś edited this page Jul 15, 2016
·
3 revisions
Bobcat provides few utility classes that support operations directly on JCR - this allows a fast setup of the initial state for a test run.
JcrUtils class is used to obtain instances of JcrSession and JcrHelper working with a chosen AEM instance. Bobcat provides two extensions: JcrAuthorUtils and JcrPublishUtils that are built based on the properties specified in instances.properies file.
JcrHelper gives an easy way to create, delete nodes in the repository and obtain their properties. JcrHelper's API provides methods for:
- creating a node with the given name and type
- creating a node with the given name and type and set of properties
- getting node under specified path
- deleting a node
- adding a property to a node
- obtaining a property from a node
- removing a property from a node
- checking if a node has a specified property
- checking if a node has a specified valued in a given property
- copying node
@Inject
private JcrAuthorUtils jcrAuthorUtils;
private Session session;
private JcrHelper jcrHelper;
@Before
public void before() throws RepositoryException {
this.session = jcrAuthorUtils.getSession();
this.jcrHelper = jcrAuthorUtils.getJcrHelper();
@Test
public void createNode() throws RepositoryException {
jcrHelper.createNode("/content", "test", "nt:unstructured");
assertTrue("Node does not exist", session.nodeExists("/content/test"));
}
@Test
public void copyNodeTest() throws RepositoryException {
String NODE_PATH = "/content/test";
String COPIED_NODE_PATH = "/content/sites/test";
jcrHelper.createNode("/content", "test", "nt:unstructured", getPropertiesMap());
assertTrue("Node does not exist", session.nodeExists(NODE_PATH));
assertTrue("Wrong node property", jcrHelper.hasNodePropertyValue(NODE_PATH, "property1", "value1"));
jcrHelper.createNode(NODE_PATH, "test1", "nt:unstructured", getPropertiesMap());
String NODE_CHILD_PATH = "/content/test/test1";
assertTrue("Node does not exist", session.nodeExists(NODE_CHILD_PATH));
assertTrue("Wrong node property", jcrHelper.hasNodePropertyValue(NODE_CHILD_PATH, "property1", "value1"));
jcrHelper.copyNode(NODE_PATH, "/content/sites");
assertTrue("Node does not exist", session.nodeExists(COPIED_NODE_PATH));
assertTrue("Wrong node property", jcrHelper.hasNodePropertyValue(COPIED_NODE_PATH, "property1", "value1"));
String COPIED_NODE_CHILD_PATH = "/content/sites/test/test1";
assertTrue("Node does not exist", session.nodeExists(COPIED_NODE_CHILD_PATH));
assertTrue("Wrong node property", jcrHelper.hasNodePropertyValue(COPIED_NODE_CHILD_PATH, "property1", "value1"));
}
public Map<String, Pair<String, Integer>> getPropertiesMap() {
Map<String, Pair<String, Integer>> property = new HashMap<>();
Pair<String, Integer> entry = new MutablePair<>("value1", 1);
property.put("property1", entry);
return property;
}
- Configuring Bobcat
- Selenium enhancements
- Cucumber enhancements
- Traffic analyzer
- Email support
- Reporting
- Cloud integration
- Mobile integration
- Executing tests on different environments
- Working with multiple threads
- Tips and tricks
- Authoring tutorial - Classic
- AEM Classic Authoring Advanced usage
- Siteadmin
- Sidekick
- Aem Component
- Working with author pages
- Working with Publish pages
- Advanced component interactions
- Working with Context Menu
- Using Aem Content Tree
- Aem Content Finder
- Storing component configurations
- Working with packages
- Jcr Support
- Authoring tutorial - Touch UI
- Adding and editing a component
- Sites management tutorial