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

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

public class RepositoryUtil
extends java.lang.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 java.lang.String ADMIN_NAME
           
static java.lang.String ADMIN_PASSWORD
           
static java.lang.String CONFIG_FILE
           
static java.lang.String CONTEXT_FACTORY
           
static java.lang.String HOME_DIR
           
static java.lang.String PROVIDER_URL
           
static java.lang.String REPOSITORY_NAME
           
 
Constructor Summary
RepositoryUtil()
           
 
Method Summary
protected static javax.naming.InitialContext getInitialContext()
           
static org.apache.sling.jcr.api.SlingRepository getRepository()
          Get a repository
static boolean registerNodeType(javax.jcr.Session session, java.io.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 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

REPOSITORY_NAME

public static final java.lang.String REPOSITORY_NAME
See Also:
Constant Field Values

ADMIN_NAME

public static final java.lang.String ADMIN_NAME
See Also:
Constant Field Values

ADMIN_PASSWORD

public static final java.lang.String ADMIN_PASSWORD
See Also:
Constant Field Values

CONTEXT_FACTORY

public static final java.lang.String CONTEXT_FACTORY
See Also:
Constant Field Values

PROVIDER_URL

public static final java.lang.String PROVIDER_URL
See Also:
Constant Field Values

CONFIG_FILE

public static final java.lang.String CONFIG_FILE
See Also:
Constant Field Values

HOME_DIR

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

RepositoryUtil

public RepositoryUtil()
Method Detail

getInitialContext

protected static javax.naming.InitialContext getInitialContext()
                                                        throws javax.naming.NamingException
Throws:
javax.naming.NamingException

startRepository

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

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

stopRepository

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

Throws:
javax.naming.NamingException - when it is not possible to stop the repository
javax.naming.NamingException

getRepository

public static org.apache.sling.jcr.api.SlingRepository getRepository()
                                                              throws javax.naming.NamingException
Get a repository

Returns:
a JCR repository reference
Throws:
javax.naming.NamingException - when it is not possible to get the repository. Before calling this method, the repository has to be registered (@see RepositoryUtil#registerRepository(String, String, String)
javax.naming.NamingException

registerNodeType

public static boolean registerNodeType(javax.jcr.Session session,
                                       java.io.InputStream source)
                                throws java.io.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.

The NodeTypeManager returned by the session's workspace is expected to be of type org.apache.jackrabbit.api.JackrabbitNodeTypeManager for the node type registration to succeed.

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:
java.io.IOException
javax.jcr.RepositoryException


Copyright © 2007-2009. All Rights Reserved.