Class PackageManagerClient

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

public class PackageManagerClient extends CQClient

The PackageManagerClient encapsulates operations on content packages just like those available in the /crx/packmgr/index.jsp application. It also uses the same API to invoke them (HTTP requests).

Provides methods to create a new empty package or upload one from the local disk

To manipulate an existing package, use PackageManagerClient.Package, which can be obtained using getPackage(String path).
  • Constructor Details

    • PackageManagerClient

      public PackageManagerClient(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
    • PackageManagerClient

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

    • createPackage

      public PackageManagerClient.Package createPackage(String name, String version, String group) throws org.apache.sling.testing.clients.ClientException
      Throws:
      org.apache.sling.testing.clients.ClientException
    • getPackage

      public PackageManagerClient.Package getPackage(String path) throws org.apache.sling.testing.clients.ClientException
      Throws:
      org.apache.sling.testing.clients.ClientException
    • uploadPackage

      public PackageManagerClient.Package uploadPackage(InputStream is, String fileName) throws org.apache.sling.testing.clients.ClientException
      Throws:
      org.apache.sling.testing.clients.ClientException
    • createPackage

      public org.apache.sling.testing.clients.SlingHttpResponse createPackage(String packageName, String packageVersion, String groupName, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException
      Creates a new package.
      Parameters:
      packageName - name of the package.
      packageVersion - version of the package.
      groupName - name of the group where the package will be created.
      expectedStatus - list of accepted statuses
      Returns:
      the response of post
      Throws:
      org.apache.sling.testing.clients.ClientException - if the request failed
    • deletePackage

      public org.apache.sling.testing.clients.SlingHttpResponse deletePackage(String packageName, String packageVersion, String groupName, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException
      Deletes a package.
      Parameters:
      packageName - Name of the package.
      packageVersion - Package version.
      groupName - Package group name.
      expectedStatus - list of accepted statuses
      Returns:
      the response
      Throws:
      org.apache.sling.testing.clients.ClientException - if the request failed
    • renamePackages

      public org.apache.sling.testing.clients.SlingHttpResponse renamePackages(String oldName, String oldVersion, String oldGroup, String newName, String newVersion, String newGroup, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException
      Renames a package.
      Parameters:
      oldName - The old package name.
      oldVersion - The old package version.
      oldGroup - The old package group.
      newName - The The new name for the package.
      newVersion - The new version for the package.
      newGroup - The new group for the package
      expectedStatus - list of accepted statuses
      Returns:
      the response
      Throws:
      org.apache.sling.testing.clients.ClientException - if the request failed
    • isPackageCreated

      public boolean isPackageCreated(String packageName, String packageVersion, String groupName) throws org.apache.sling.testing.clients.ClientException
      Checks if the package is created.
      Parameters:
      packageName - Name of the package.
      packageVersion - Name of the version.
      groupName - Name of the group.
      Returns:
      True if the package is created or false otherwise.
      Throws:
      org.apache.sling.testing.clients.ClientException - if the request failed
    • buildPackage

      public org.apache.sling.testing.clients.SlingHttpResponse buildPackage(String packageName, String packageVersion, String groupName, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException
      Builds the specific package.
      Parameters:
      packageName - Name of the package.
      packageVersion - Version for the package.
      groupName - Group name for the package.
      expectedStatus - list of accepted statuses
      Returns:
      the response
      Throws:
      org.apache.sling.testing.clients.ClientException - if the request failed
    • rewrapPackage

      public org.apache.sling.testing.clients.SlingHttpResponse rewrapPackage(String packageName, String packageVersion, String groupName, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException
      Re-wraps the specific package.
      Parameters:
      packageName - Name of the package.
      packageVersion - Version for the package.
      groupName - Group name for the package.
      expectedStatus - List of expected statuses
      Returns:
      The response
      Throws:
      org.apache.sling.testing.clients.ClientException - if the request failed
    • installPackage

      public org.apache.sling.testing.clients.SlingHttpResponse installPackage(String packageName, String packageVersion, String groupName, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException
      Installs the specific package.
      Parameters:
      packageName - Name of the package.
      packageVersion - Version for the package.
      groupName - Group name for the package.
      expectedStatus - List of expected statuses
      Returns:
      the response
      Throws:
      org.apache.sling.testing.clients.ClientException - if the request failed
    • uninstallPackage

      public org.apache.sling.testing.clients.SlingHttpResponse uninstallPackage(String packageName, String packageVersion, String groupName, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException
      Uninstall the specific package.
      Parameters:
      packageName - Name of the package.
      packageVersion - Version for the package.
      groupName - Group name for the package.
      expectedStatus - list of expected status
      Returns:
      the response
      Throws:
      org.apache.sling.testing.clients.ClientException - if the request failed
    • testInstallPackage

      public org.apache.sling.testing.clients.SlingHttpResponse testInstallPackage(String packageName, String packageVersion, String groupName, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException
      Test installation for the specific package.
      Parameters:
      packageName - Name of the package.
      packageVersion - Version for the package.
      groupName - Group name for the package.
      expectedStatus - list of expected statuses
      Returns:
      the response
      Throws:
      org.apache.sling.testing.clients.ClientException - if the request failed
    • uploadPackage

      public org.apache.sling.testing.clients.SlingHttpResponse uploadPackage(String resourcePath, String fileName, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException
      Uploads a package.
      Parameters:
      resourcePath - File's path.
      fileName - Name of the file.
      expectedStatus - list of expected statuses
      Returns:
      the response
      Throws:
      org.apache.sling.testing.clients.ClientException - if the request failed
    • getPackageContentResponse

      public String getPackageContentResponse(String packageName, String packageVersion, String groupName) throws org.apache.sling.testing.clients.ClientException
      Returns the HTTP response for the package content request.
      Parameters:
      packageName - name of the package
      packageVersion - version of the package
      groupName - group of the package
      Returns:
      the response
      Throws:
      org.apache.sling.testing.clients.ClientException - if the request failed
    • getPackageCoverageResponse

      public String getPackageCoverageResponse(String packageName, String packageVersion, String groupName) throws org.apache.sling.testing.clients.ClientException
      Returns the HTTP response for the package content request.
      Parameters:
      packageName - name of the package
      packageVersion - version of the package
      groupName - group of the package
      Returns:
      the response
      Throws:
      org.apache.sling.testing.clients.ClientException - if the request failed
    • updateThumbnail

      public org.apache.sling.testing.clients.SlingHttpResponse updateThumbnail(String packageName, String packageVersion, String groupName, String resourcePath, String fileName, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException
      Updates the thumbnail for a specific package.
      Parameters:
      packageName - Name of the package
      packageVersion - Version of the package
      groupName - Name of the group
      resourcePath - Path to the thumbnail
      fileName - Name of the thumbnail
      expectedStatus - list of expected statuses
      Returns:
      the response
      Throws:
      org.apache.sling.testing.clients.ClientException - if the request failed
    • uploadPictureAsScreenshot

      public org.apache.sling.testing.clients.SlingHttpResponse uploadPictureAsScreenshot(String packageName, String packageVersion, String groupName, String resourcePath, String fileName, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException
      Uploads a screenshot for a package.
      Parameters:
      packageName - name of the package
      packageVersion - version of the package
      groupName - group of the package
      resourcePath - path to the thumbnail
      fileName - name of the thumbnail
      expectedStatus - list of expected statuses
      Returns:
      the response
      Throws:
      org.apache.sling.testing.clients.ClientException - if the request failed