org.apache.sling.commons.testing.jcr
Class RepositoryUtil

java.lang.Object
  extended by org.apache.sling.commons.testing.jcr.RepositoryUtil

public class RepositoryUtil
extends Object

Utility class for managing JCR repositories, used to initialize temporary Jackrabbit repositories for testing.


Nested Class Summary
static class RepositoryUtil.RepositoryWrapper
           
 
Field Summary
static String ADMIN_NAME
           
static String ADMIN_PASSWORD
           
static String CONFIG_FILE
           
static String HOME_DIR
           
 
Constructor Summary
RepositoryUtil()
           
 
Method Summary
static SlingRepository getRepository()
          Get a repository
static boolean registerNodeType(javax.jcr.Session session, InputStream source)
          Registers node types from the CND file read from the source with the node type manager available from the given session.
static void registerSlingNodeTypes(javax.jcr.Session adminSession)
           
static void startRepository()
          Start a new repository
static void stopRepository()
          Stop a repository.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ADMIN_NAME

public static final String ADMIN_NAME
See Also:
Constant Field Values

ADMIN_PASSWORD

public static final String ADMIN_PASSWORD
See Also:
Constant Field Values

HOME_DIR

public static final String HOME_DIR
See Also:
Constant Field Values

CONFIG_FILE

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

RepositoryUtil

public RepositoryUtil()
Method Detail

startRepository

public static void startRepository()
                            throws javax.jcr.RepositoryException
Start a new repository

Throws:
javax.jcr.RepositoryException - when it is not possible to start the repository.

stopRepository

public static void stopRepository()
                           throws NamingException
Stop a repository.

Throws:
NamingException

getRepository

public static SlingRepository getRepository()
Get a repository

Returns:
a JCR repository reference

registerNodeType

public static boolean registerNodeType(javax.jcr.Session session,
                                       InputStream source)
                                throws IOException,
                                       javax.jcr.RepositoryException
Registers node types from the CND file read from the source with the node type manager available from the given session.

This method is not synchronized. It is up to the calling method to prevent paralell execution.

Parameters:
session - The Session providing the node type manager through which the node type is to be registered.
source - The InputStream from which the CND file is read.
Returns:
true if registration of all node types succeeded.
Throws:
IOException
javax.jcr.RepositoryException

registerSlingNodeTypes

public static void registerSlingNodeTypes(javax.jcr.Session adminSession)
                                   throws IOException,
                                          javax.jcr.RepositoryException
Throws:
IOException
javax.jcr.RepositoryException


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