Package org.apache.sling.commons.testing.integration

# 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

Modifier and Type
Method
Description
`String`
`createNode(String url, Map<String,String> nodeProperties)`
Call the other createNode method with headers==null
`String`
`createNode(String url, Map<String,String> clientNodeProperties, Map<String,String> requestHeaders, boolean multiPart)`
Create a node under given path, using a POST to Sling
`String`
`createNode(String url, NameValuePairList clientNodeProperties, Map<String,String> requestHeaders, boolean multiPart)`
Create a node under given path, using a POST to Sling
`String`
`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 Sling
`int`
`delete(String url)`
Delete a file from the Sling repository
`int`
`get(String url)`
`String`
`getFolderExistsTestExtension()`
`void`
`mkdir(String url)`
Create the given directory via WebDAV, if needed, under given URL
`void`
`mkdirs(String baseUrl, String path)`
Create the given directory via WebDAV, including parent directories
`int`
`post(String url, Map<String,String> properties)`
`void`
`setFolderExistsTestExtension(String folderExistsTestExtension)`
`int`
`upload(String toUrl, InputStream is)`
Upload a file to the Sling repository
`void`
`uploadToFileNode(String url, File localFile, String fieldName, String typeHint)`
Upload to an file node structure, see SLING-168
`void`
`uploadToFileNodes(String url, File[] localFiles, String[] fieldNames, String[] typeHints)`
Upload multiple files to file node structures

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### SlingIntegrationTestClient

public SlingIntegrationTestClient(org.apache.commons.httpclient.HttpClient client)

## Method Details

### 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 created
  `multiPart` - 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 created
  `multiPart` - 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 created
  `multiPart` - if true, does a multipart POST
  `localFile` - file to upload
  `fieldName` - name of the file field
  `typeHint` - 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`