Class CQAssetsClient

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.CQAssetsClient
All Implemented Interfaces:
Closeable, AutoCloseable, org.apache.http.client.HttpClient

public class CQAssetsClient extends CQClient
  • Field Details

    • ASSET_PROCESSED_TIMEOUT

      protected static final long ASSET_PROCESSED_TIMEOUT
      The default timeout for asset processing, 30000L milliseconds.
      See Also:
    • ASSET_PROCESSED_DELAY

      protected static final long ASSET_PROCESSED_DELAY
      The default delay between polling for asset processing status, 500L milliseconds.
      See Also:
  • Constructor Details

    • CQAssetsClient

      public CQAssetsClient(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
  • Method Details

    • isDirectBinaryAccessSupported

      public boolean isDirectBinaryAccessSupported() throws org.apache.sling.testing.clients.ClientException
      Check if Direct Binary Access is enabled
      Returns:
      True if enabled, false otherwise
      Throws:
      org.apache.sling.testing.clients.ClientException - if something fails during the request/response cycle
    • uploadAsset

      public org.apache.sling.testing.clients.SlingHttpResponse uploadAsset(String fileName, String resourcePath, String mimeType, String parentPath, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException
      Uploads an Asset to the repository. Same as using New File... in the DAM admin or when uploading a file below Digital Assets in the Site Admin.

      This will upload the file and store it in a node typed dam:Asset. This will trigger all DAM related workflows for generating rendition nodes, extract metadata etc.

      To upload a file that is not to be handled as an asset use CQClient.uploadFileCQStyle(java.lang.String, java.lang.String, java.lang.String, java.lang.String, int...) instead.
      To upload a file directly using sling use SlingClient.upload(java.io.File, String, String, boolean, int...).

      This implementation will pick Direct Binary Access upload when available or fallback to the original AEM implementation
      Parameters:
      fileName - file name
      resourcePath - defines the path to the resource
      mimeType - MIME type of the image getting uploaded
      parentPath - parent page (folder) that will contain the file
      expectedStatus - list of expected HTTP Status to be returned, if not set, 200 is assumed.
      Returns:
      the response
      Throws:
      org.apache.sling.testing.clients.ClientException - if something fails during the request/response cycle
    • waitAssetProcessed

      public ProcessedAsset waitAssetProcessed(String assetPath) throws org.apache.sling.testing.clients.ClientException, TimeoutException, InterruptedException
      Wait for an asset to complete processing. The total timeout is 30000L milliseconds. Polling the asset status occurs every 500L milliseconds.
      Parameters:
      assetPath - Path to an asset
      Returns:
      ProcessedAsset
      Throws:
      org.apache.sling.testing.clients.ClientException - if something fails during the request/response cycle, or if the asset failed to process
      TimeoutException - if the wait times out
      InterruptedException - if the wait is interrupted
    • waitAssetProcessed

      public ProcessedAsset waitAssetProcessed(String assetPath, long timeout, long delay) throws org.apache.sling.testing.clients.ClientException, TimeoutException, InterruptedException
      Wait for an asset to complete processing. The asset state will be checked at least once. If the timeout is 0 or less, then the asset state will be executed exactly once.
      Parameters:
      assetPath - Path to an asset
      timeout - total time to wait, in milliseconds
      delay - time to wait between polls of asset status, in milliseconds
      Returns:
      ProcessedAsset
      Throws:
      org.apache.sling.testing.clients.ClientException - if something fails during the request/response cycle, or if the asset failed to process
      TimeoutException - if the wait times out
      InterruptedException - if the wait is interrupted
    • getAssetStatus

      public String getAssetStatus(String assetPath) throws org.apache.sling.testing.clients.ClientException
      Retrieve the asset processing status.
      Parameters:
      assetPath - Asset path
      Returns:
      dam:assetState value (i.e. unProcessed, processing, processed)
      Throws:
      org.apache.sling.testing.clients.ClientException - if something fails during the request/response cycle
    • getAssetProcessingFailures

      public List<FailedRendition> getAssetProcessingFailures(String assetPath) throws org.apache.sling.testing.clients.ClientException
      Retrieve any processing failures with an asset. Only able to find failures when Asset Compute is enabled, will return an empty List otherwise.
      Parameters:
      assetPath - Asset path
      Returns:
      List of FailedRendition
      Throws:
      org.apache.sling.testing.clients.ClientException - if something fails during the request/response cycle
    • getAssetsProcessedRenditions

      public List<String> getAssetsProcessedRenditions(String assetPath) throws org.apache.sling.testing.clients.ClientException
      Retrieve all processed renditions of an asset.
      Parameters:
      assetPath - Asset path
      Returns:
      List of String
      Throws:
      org.apache.sling.testing.clients.ClientException - if something fails during the request/response cycle