org.apache.sling.testing.tools.sling
Class SlingClient

java.lang.Object
  extended by org.apache.sling.testing.tools.sling.SlingClient

public class SlingClient
extends Object

Simple Sling client, created for integration tests but should be general purpose


Field Summary
static String HTTP_PREFIX
           
static String LOCATION_HEADER
           
 
Constructor Summary
SlingClient(String slingServerUrl, String username, String password)
           
 
Method Summary
 String createNode(String path, Map<String,Object> properties)
          Create a node at specified path, with optional properties
 String createNode(String path, String... properties)
          Create a node at specified path, with optional properties specified as a list of String arguments, odd values are keys and even arguments are values.
 void delete(String path)
          Delete supplied path
 boolean exists(String path)
           
protected  String getParentPath(String path)
          Return parent path: whatever comes before the last / in path, empty string if no / in path.
 void mkdir(String path)
          Create path using MKCOL
 void mkdirs(String path)
          Create path and all its parent folders, using MKCOL
 void upload(String path, InputStream data, int length, boolean createFolders)
          Upload using a PUT request.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOCATION_HEADER

public static final String LOCATION_HEADER
See Also:
Constant Field Values

HTTP_PREFIX

public static final String HTTP_PREFIX
See Also:
Constant Field Values
Constructor Detail

SlingClient

public SlingClient(String slingServerUrl,
                   String username,
                   String password)
Method Detail

createNode

public String createNode(String path,
                         String... properties)
                  throws IOException
Create a node at specified path, with optional properties specified as a list of String arguments, odd values are keys and even arguments are values.

Throws:
IOException

createNode

public String createNode(String path,
                         Map<String,Object> properties)
                  throws UnsupportedEncodingException,
                         IOException
Create a node at specified path, with optional properties

Parameters:
path - Used in POST request to Sling server
properties - If not null, properties are added to the created node
Returns:
The actual path of the node that was created
Throws:
UnsupportedEncodingException
IOException

delete

public void delete(String path)
            throws IOException
Delete supplied path

Throws:
IOException

upload

public void upload(String path,
                   InputStream data,
                   int length,
                   boolean createFolders)
            throws IOException
Upload using a PUT request.

Parameters:
path - the path of the uploaded file
data - the content
length - Use -1 if unknown
createFolders - if true, intermediate folders are created via mkdirs
Throws:
IOException

mkdirs

public void mkdirs(String path)
            throws IOException
Create path and all its parent folders, using MKCOL

Throws:
IOException

mkdir

public void mkdir(String path)
           throws IOException
Create path using MKCOL

Throws:
IOException

exists

public boolean exists(String path)
               throws IOException
Throws:
IOException

getParentPath

protected String getParentPath(String path)
Return parent path: whatever comes before the last / in path, empty string if no / in path.



Copyright © 2007-2013 The Apache Software Foundation. All Rights Reserved.