Class FormClient

java.lang.Object
org.apache.sling.testing.clients.AbstractSlingClient
org.apache.sling.testing.clients.SlingClient
com.adobe.cq.testing.client.CQClient
com.adobe.cq.testing.client.FormClient
All Implemented Interfaces:
Closeable, AutoCloseable, org.apache.http.client.HttpClient
Direct Known Subclasses:
CommerceClient

public class FormClient extends CQClient
The base client for all form-related actions. It provides a core set of commonly used foundation/form functions such as post.

It extends from CQClient which in turn provides a core set of commonly used website and page functionality.
  • Constructor Details

    • FormClient

      public FormClient(org.apache.http.impl.client.CloseableHttpClient http, org.apache.sling.testing.clients.SlingClientConfig config) throws org.apache.sling.testing.clients.ClientException
      Throws:
      org.apache.sling.testing.clients.ClientException
    • FormClient

      public FormClient(URI serverUrl, String user, String password) throws org.apache.sling.testing.clients.ClientException
      Throws:
      org.apache.sling.testing.clients.ClientException
  • Method Details

    • doFormPost

      public org.apache.sling.testing.clients.SlingHttpResponse doFormPost(String path, String sessionCookie, String formId, String formStart, String redirect, Map<String,String> parameters, String... expectedValidationErrors) throws org.apache.sling.testing.clients.ClientException
      Mimics a submit of a foundation form.
      Parameters:
      path - path to the cq:Page containing the form
      sessionCookie - an optional session cookie to add to the request
      formId - the id of the form on the page
      formStart - the path to the form-start component on the page
      redirect - the redirect to follow after a successful submission
      parameters - the form parameters to post
      expectedValidationErrors - an optional list of expected validation messages
      Returns:
      a SlingHttpResponse with a 302 redirect assuming a successful submission
      Throws:
      org.apache.sling.testing.clients.ClientException - if the request fails