Package com.adobe.cq.testing.client
Class ComponentClient
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.ComponentClient
- All Implemented Interfaces:
Closeable
,AutoCloseable
,org.apache.http.client.HttpClient
- Direct Known Subclasses:
FoundationClient
-
Nested Class Summary
Nested classes/interfaces inherited from class com.adobe.cq.testing.client.CQClient
CQClient.Builder, CQClient.InternalBuilder<T extends CQClient>
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
static final String
static final String
static final String
Fields inherited from class com.adobe.cq.testing.client.CQClient
LOG, STATISTICS_ROOT, wcmCommands
Fields inherited from class org.apache.sling.testing.clients.SlingClient
CLIENT_CONNECTION_TIMEOUT_PROP, DEFAULT_NODE_TYPE, SUDO_COOKIE_NAME
-
Constructor Summary
ConstructorDescriptionComponentClient
(URI serverUrl, String user, String password) ComponentClient
(org.apache.http.impl.client.CloseableHttpClient http, org.apache.sling.testing.clients.SlingClientConfig config) -
Method Summary
Modifier and TypeMethodDescription<T extends AbstractComponent>
TaddComponent
(Class<T> componentClass, String pagePath, int... expectedStatus) Adds a new, empty component to a CQ page.<T extends AbstractComponent>
TaddComponent
(Class<T> componentClass, String pagePath, String order, int... expectedStatus) Adds a new, empty component to a CQ page.<T extends AbstractComponent>
TaddComponent
(Class<T> componentClass, String pagePath, String location, String nameHint, String order, int... expectedStatus) Adds a new, empty component to a CQ page.void
deleteComponent
(AbstractComponent delComp) Deletes a component.void
deleteComponent
(String componentPath) Deletes a component.Class
<? extends AbstractComponent> getCompClassByResourceType
(String resourceType) Returns the component wrapper class, that has been registered with this resourceType or null if no such resourceType is known.<T extends AbstractComponent>
TgetComponent
(String componentPath) Initializes anAbstractComponent
subclass against an existing foundation component node.<T extends AbstractComponent>
TgetComponent
(String componentPath, Class<T> compClass) Initializes anAbstractComponent
subclass against an existing foundation component node.void
registerComponent
(String resourceType, Class<? extends AbstractComponent> c) Use this method to register additional component wrappers with the client.void
setDefaultComponentRelativeLocation
(String defaultComponentRelativeLocation) Sets a new value for the component's default relative locationMethods inherited from class com.adobe.cq.testing.client.CQClient
copyLanguages, copyPage, createPage, createPageWithRetry, createVersion, deletePage, deletePageWithRetry, getAuthorSitesPage, lockPage, movePage, movePage, pageExists, pageExistsWithRetry, pageExistsWithRetry, resetPageStatistics, restoreTree, restoreVersion, rolloutPage, searchAndReplaceInPages, searchInPages, setPageProperties, setPageProperty, setPagePropertyImage, unlockPage, uploadFileCQStyle
Methods inherited from class org.apache.sling.testing.clients.SlingClient
createFolder, createNode, createNodeRecursive, deletePath, doGetJson, endImpersonation, exists, getJsonNode, getJsonNode, getNodeNameFromPath, getParentPath, getUser, getUUId, getUUID, impersonate, importContent, importContent, importJson, move, setPropertiesString, setPropertyString, setPropertyStringArray, upload, waitExists, waitUntilExists
Methods inherited from class org.apache.sling.testing.clients.AbstractSlingClient
adaptTo, addValue, close, doDelete, doGet, doGet, doGet, doHead, doPatch, doPost, doPost, doPut, doRawRequest, doRequest, doStreamGet, doStreamPost, doStreamRequest, execute, execute, execute, execute, execute, execute, execute, execute, getClientId, getConnectionManager, getCookieStore, getCredentialsProvider, getParams, getPassword, getPath, getPath, getUrl, getUrl, getUrl, getValue, getValues, hasValue
-
Field Details
-
ORDER_FIRST
- See Also:
-
ORDER_LAST
- See Also:
-
ORDER_BEFORE_PREFIX
- See Also:
-
ORDER_AFTER_PREFIX
- See Also:
-
-
Constructor Details
-
ComponentClient
public ComponentClient(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
-
ComponentClient
public ComponentClient(URI serverUrl, String user, String password) throws org.apache.sling.testing.clients.ClientException - Throws:
org.apache.sling.testing.clients.ClientException
-
-
Method Details
-
addComponent
public <T extends AbstractComponent> T addComponent(Class<T> componentClass, String pagePath, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException, InterruptedException Adds a new, empty component to a CQ page. The component is added at the default location in the page inside the page.- Type Parameters:
T
- A subclass ofAbstractComponent
- Parameters:
componentClass
- theAbstractComponent
subclass to be createdpagePath
- path to the page where the component gets addedexpectedStatus
- list of expected HTTP Status to be returned, if not set, 200 is assumed.- Returns:
- A instance of the class passed in
componentClass
- Throws:
org.apache.sling.testing.clients.ClientException
- if the request failsInterruptedException
- to mark this method as waiting
-
addComponent
public <T extends AbstractComponent> T addComponent(Class<T> componentClass, String pagePath, String order, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException, InterruptedException Adds a new, empty component to a CQ page. The component is added at the default location in the page inside the page.- Type Parameters:
T
- A subclass ofAbstractComponent
- Parameters:
componentClass
- theAbstractComponent
subclass to be createdpagePath
- path to the page where the component gets addedorder
- Defines where the component should be added in relation to its siblings. Possible values arefirst
,last
,before [nodeName]
,after [nodeName]
.expectedStatus
- list of expected HTTP Status to be returned, if not set, 200 is assumed.- Returns:
- A instance of the class passed in
componentClass
- Throws:
org.apache.sling.testing.clients.ClientException
- if the request failsInterruptedException
- to mark this method as waiting
-
addComponent
public <T extends AbstractComponent> T addComponent(Class<T> componentClass, String pagePath, String location, String nameHint, String order, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException, InterruptedException Adds a new, empty component to a CQ page.- Type Parameters:
T
- A subclass ofAbstractComponent
- Parameters:
componentClass
- theAbstractComponent
subclass to be createdpagePath
- path to the page where the component gets addedlocation
- relative path inside the page where the component gets addednameHint
- proposed node for the new component node. Might get altered if the name if there is already a node with the same name on the same level.AbstractComponent.getName()
returns the name as is it is really set.order
- Defines where the component should be added in relation to its siblings. Possible values arefirst
,last
,before [nodeName]
,after [nodeName]
.expectedStatus
- list of expected HTTP Status to be returned, if not set, 200 is assumed.- Returns:
- An instance of the class passed in
componentClass
- Throws:
org.apache.sling.testing.clients.ClientException
- if the request failsInterruptedException
- to mark this method as waiting
-
getComponent
public <T extends AbstractComponent> T getComponent(String componentPath, Class<T> compClass) throws org.apache.sling.testing.clients.ClientException Initializes anAbstractComponent
subclass against an existing foundation component node.- Type Parameters:
T
- A subclass ofAbstractComponent
- Parameters:
componentPath
- complete path to the the repository node that forms the root node of a component. Must contain a property namedsling:resourceType
referencing a valid component.compClass
- The component wrapper class to be initialized- Returns:
- A instance of the class passed in
componentClass
- Throws:
org.apache.sling.testing.clients.ClientException
- if the request fails
-
getComponent
public <T extends AbstractComponent> T getComponent(String componentPath) throws org.apache.sling.testing.clients.ClientException Initializes anAbstractComponent
subclass against an existing foundation component node. t looks for the sling:resourceType property an tries to find a matching component wrapper that has been registered with the ComponentClient (seeregisterComponent(String, Class)
)- Type Parameters:
T
- A subclass ofAbstractComponent
- Parameters:
componentPath
- complete path to the the repository node that forms the root node of a component. Must contain a property namedsling:resourceType
referencing a valid component.- Returns:
- A instance of the class passed in
componentClass
- Throws:
org.apache.sling.testing.clients.ClientException
- if the request fails
-
registerComponent
Use this method to register additional component wrappers with the client. All wrappers from the framework are registered by default. The registered components are used bygetComponent(String)
to return the correct wrapper for a given component path, and by theAbstractComponent.getNext()
andAbstractComponent.getPrevious()
to return the next/previous component- Parameters:
resourceType
- the resource type to registerc
- the corresponding component wrapper class
-
getCompClassByResourceType
Returns the component wrapper class, that has been registered with this resourceType or null if no such resourceType is known. you can register additional component wrappers usingregisterComponent(String, Class)
}.- Parameters:
resourceType
- resource type to look up- Returns:
- the corresponding component wrapper class or null if not fund
-
deleteComponent
public void deleteComponent(AbstractComponent delComp) throws org.apache.sling.testing.clients.ClientException Deletes a component.- Parameters:
delComp
- The component to delete- Throws:
org.apache.sling.testing.clients.ClientException
- If the delete request fails
-
deleteComponent
public void deleteComponent(String componentPath) throws org.apache.sling.testing.clients.ClientException Deletes a component.- Parameters:
componentPath
- the path to the components node- Throws:
org.apache.sling.testing.clients.ClientException
- If the delete request fails
-
getDefaultComponentRelativeLocation
- Returns:
- the value of the component's default relative location, possibly
null
-
setDefaultComponentRelativeLocation
Sets a new value for the component's default relative location- Parameters:
defaultComponentRelativeLocation
- the new value for the default component relative location
-