Class SlingIntegrationTestClient
- java.lang.Object
-
- org.apache.sling.commons.testing.integration.SlingIntegrationTestClient
-
public class SlingIntegrationTestClient extends Object
Client functions to interact with Sling in integration tests
-
-
Constructor Summary
Constructors Constructor Description SlingIntegrationTestClient(org.apache.commons.httpclient.HttpClient client)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
createNode(String url, Map<String,String> nodeProperties)
Call the other createNode method with headers==nullString
createNode(String url, Map<String,String> clientNodeProperties, Map<String,String> requestHeaders, boolean multiPart)
Create a node under given path, using a POST to SlingString
createNode(String url, NameValuePairList clientNodeProperties, Map<String,String> requestHeaders, boolean multiPart)
Create a node under given path, using a POST to SlingString
createNode(String url, NameValuePairList clientNodeProperties, Map<String,String> requestHeaders, boolean multiPart, File localFile, String fieldName, String typeHint)
Create a node under given path, using a POST to Slingint
delete(String url)
Delete a file from the Sling repositoryint
get(String url)
String
getFolderExistsTestExtension()
void
mkdir(String url)
Create the given directory via WebDAV, if needed, under given URLvoid
mkdirs(String baseUrl, String path)
Create the given directory via WebDAV, including parent directoriesint
post(String url, Map<String,String> properties)
void
setFolderExistsTestExtension(String folderExistsTestExtension)
int
upload(String toUrl, InputStream is)
Upload a file to the Sling repositoryvoid
uploadToFileNode(String url, File localFile, String fieldName, String typeHint)
Upload to an file node structure, see SLING-168void
uploadToFileNodes(String url, File[] localFiles, String[] fieldNames, String[] typeHints)
Upload multiple files to file node structures
-
-
-
Method Detail
-
getFolderExistsTestExtension
public String getFolderExistsTestExtension()
-
setFolderExistsTestExtension
public void setFolderExistsTestExtension(String folderExistsTestExtension)
-
upload
public int upload(String toUrl, InputStream is) throws IOException
Upload a file to the Sling repository- Returns:
- the HTTP status code
- Throws:
IOException
-
delete
public int delete(String url) throws IOException
Delete a file from the Sling repository- Returns:
- the HTTP status code
- Throws:
IOException
-
mkdir
public void mkdir(String url) throws IOException
Create the given directory via WebDAV, if needed, under given URL- Throws:
IOException
-
mkdirs
public void mkdirs(String baseUrl, String path) throws IOException
Create the given directory via WebDAV, including parent directories- Throws:
IOException
-
createNode
public String createNode(String url, Map<String,String> nodeProperties) throws IOException
Call the other createNode method with headers==null- Throws:
IOException
-
createNode
public String createNode(String url, Map<String,String> clientNodeProperties, Map<String,String> requestHeaders, boolean multiPart) throws IOException
Create a node under given path, using a POST to Sling- Parameters:
url
- under which node is createdmultiPart
- if true, does a multipart POST- Returns:
- the URL that Sling provides to display the node
- Throws:
IOException
-
createNode
public String createNode(String url, NameValuePairList clientNodeProperties, Map<String,String> requestHeaders, boolean multiPart) throws IOException
Create a node under given path, using a POST to Sling- Parameters:
url
- under which node is createdmultiPart
- if true, does a multipart POST- Returns:
- the URL that Sling provides to display the node
- Throws:
IOException
-
createNode
public String createNode(String url, NameValuePairList clientNodeProperties, Map<String,String> requestHeaders, boolean multiPart, File localFile, String fieldName, String typeHint) throws IOException
Create a node under given path, using a POST to Sling- Parameters:
url
- under which node is createdmultiPart
- if true, does a multipart POSTlocalFile
- file to uploadfieldName
- name of the file fieldtypeHint
- typeHint of the file field- Returns:
- the URL that Sling provides to display the node
- Throws:
IOException
-
uploadToFileNode
public void uploadToFileNode(String url, File localFile, String fieldName, String typeHint) throws IOException
Upload to an file node structure, see SLING-168- Throws:
IOException
-
uploadToFileNodes
public void uploadToFileNodes(String url, File[] localFiles, String[] fieldNames, String[] typeHints) throws IOException
Upload multiple files to file node structures- Throws:
IOException
-
post
public int post(String url, Map<String,String> properties) throws org.apache.commons.httpclient.HttpException, IOException
- Throws:
org.apache.commons.httpclient.HttpException
IOException
-
get
public int get(String url) throws org.apache.commons.httpclient.HttpException, IOException
- Throws:
org.apache.commons.httpclient.HttpException
IOException
-
-