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

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

public class SlingClient
extends java.lang.Object

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


Field Summary
static java.lang.String HTTP_PREFIX
           
static java.lang.String LOCATION_HEADER
           
 
Constructor Summary
SlingClient(java.lang.String slingServerUrl, java.lang.String username, java.lang.String password)
           
 
Method Summary
 java.lang.String createNode(java.lang.String path, java.util.Map<java.lang.String,java.lang.Object> properties)
          Create a node at specified path, with optional properties
 java.lang.String createNode(java.lang.String path, java.lang.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(java.lang.String path)
          Delete supplied path
 boolean exists(java.lang.String path)
           
protected  java.lang.String getParentPath(java.lang.String path)
          Return parent path: whatever comes before the last / in path, empty string if no / in path.
 void mkdir(java.lang.String path)
          Create path using MKCOL
 void mkdirs(java.lang.String path)
          Create path and all its parent folders, using MKCOL
 void upload(java.lang.String path, java.io.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 java.lang.String LOCATION_HEADER
See Also:
Constant Field Values

HTTP_PREFIX

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

SlingClient

public SlingClient(java.lang.String slingServerUrl,
                   java.lang.String username,
                   java.lang.String password)
Method Detail

createNode

public java.lang.String createNode(java.lang.String path,
                                   java.lang.String... properties)
                            throws java.io.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:
java.io.IOException

createNode

public java.lang.String createNode(java.lang.String path,
                                   java.util.Map<java.lang.String,java.lang.Object> properties)
                            throws java.io.UnsupportedEncodingException,
                                   java.io.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:
java.io.UnsupportedEncodingException
java.io.IOException

delete

public void delete(java.lang.String path)
            throws java.io.IOException
Delete supplied path

Throws:
java.io.IOException

upload

public void upload(java.lang.String path,
                   java.io.InputStream data,
                   int length,
                   boolean createFolders)
            throws java.io.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:
java.io.IOException

mkdirs

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

Throws:
java.io.IOException

mkdir

public void mkdir(java.lang.String path)
           throws java.io.IOException
Create path using MKCOL

Throws:
java.io.IOException

exists

public boolean exists(java.lang.String path)
               throws java.io.IOException
Throws:
java.io.IOException

getParentPath

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



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