Class Page

java.lang.Object
org.junit.rules.ExternalResource
com.adobe.cq.testing.junit.rules.Page
All Implemented Interfaces:
org.junit.rules.TestRule

public class Page extends org.junit.rules.ExternalResource
Create a new page. This rule can be sub-classed to specify the parent page and the template of the newly created page. Subclasses can also specify which client to use or which server to target when a new page is created.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Page(org.apache.sling.testing.junit.rules.instance.Instance quickstartRule)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
     
    protected void
     
    protected CQClient
    The client to use to create and delete this page.
    The node name of this page.
    The path of the parent of this page.
    final String
    The absolute path of this page.
    The path of the template of this page.
    The title of this page.
    protected String
    The initial page name to be used when creating the page This implementation returns "testpage_[randomUUID]" You can override this with dynamic names for each thread
    protected String
    The initial parent path to be used when creating the page This implementation returns "/content/test-site" You can override this with dynamic names for each threads
    protected String
    The initial template path to be used when creating the page This implementation returns "/conf/test-site/settings/wcm/templates/content-page" You can override this with dynamic names for each threads
    protected void
    Method to be called before creating the page.

    Methods inherited from class org.junit.rules.ExternalResource

    apply

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Page

      public Page(org.apache.sling.testing.junit.rules.instance.Instance quickstartRule)
  • Method Details

    • before

      protected void before() throws org.apache.sling.testing.clients.ClientException
      Overrides:
      before in class org.junit.rules.ExternalResource
      Throws:
      org.apache.sling.testing.clients.ClientException
    • after

      protected void after()
      Overrides:
      after in class org.junit.rules.ExternalResource
    • initialParentPath

      protected String initialParentPath()
      The initial parent path to be used when creating the page This implementation returns "/content/test-site" You can override this with dynamic names for each threads
      Returns:
      the parent path used to create the page
    • initialName

      protected String initialName()
      The initial page name to be used when creating the page This implementation returns "testpage_[randomUUID]" You can override this with dynamic names for each thread
      Returns:
      the page name used to create the page
    • initialTemplatePath

      protected String initialTemplatePath()
      The initial template path to be used when creating the page This implementation returns "/conf/test-site/settings/wcm/templates/content-page" You can override this with dynamic names for each threads
      Returns:
      the template path used to create the page
    • getClient

      protected CQClient getClient() throws org.apache.sling.testing.clients.ClientException
      The client to use to create and delete this page. The default implementation creates a CQClient. The default implementation also uses the default admin user.
      Returns:
      The client to use to create and delete this page.
      Throws:
      org.apache.sling.testing.clients.ClientException - if the client cannot be retrieved
    • prepare

      protected void prepare() throws org.apache.sling.testing.clients.ClientException
      Method to be called before creating the page. You can override this to perform custom operations before creating the page. This implementation creates, if needed, the test template and site.
      Throws:
      org.apache.sling.testing.clients.ClientException - if the content cannot be created
    • getTitle

      public String getTitle()
      The title of this page. The default implementation returns the value "Test Page".
      Returns:
      The title of this page.
    • getName

      public String getName()
      The node name of this page. The default implementation returns the value of initialName().
      Returns:
      The node name of this page.
    • getParentPath

      public String getParentPath()
      The path of the parent of this page. The default implementation returns the value initialParentPath()
      Returns:
      The parent path of this page. The path must be absolute and must not end with a slash.
    • getTemplatePath

      public String getTemplatePath()
      The path of the template of this page. The default implementation returns the value initialTemplatePath()
      Returns:
      The parent path of this page. The path must be a valid template path.
    • getPath

      public final String getPath()
      The absolute path of this page.
      Returns:
      The absolute path of the page.