org.apache.directory.server.core.unit
Class AbstractTestCase

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.apache.directory.server.core.unit.AbstractTestCase
All Implemented Interfaces:
junit.framework.Test
Direct Known Subclasses:
AbstractAdminTestCase, AbstractNonAdminTestCase, AbstractPerformanceTest

public abstract class AbstractTestCase
extends junit.framework.TestCase

A simple testcase for testing JNDI provider functionality.

Version:
$Rev: 498451 $
Author:
Apache Directory Project

Field Summary
protected  MutableStartupConfiguration configuration
           
protected  boolean doDelete
          flag whether to delete database files for each test or not
static java.lang.String LDIF
           
protected  java.lang.String password
           
protected  javax.naming.ldap.LdapContext sysRoot
          the context root for the system partition
protected  java.util.List testEntries
          A testEntries of entries as Attributes to add to the DIT for testing
protected  java.lang.String username
           
 
Constructor Summary
protected AbstractTestCase(java.lang.String username, java.lang.String password)
           
 
Method Summary
protected  void doDelete(java.io.File wkdir)
          Deletes the Eve working directory.
protected  java.util.Hashtable getOverriddenEnvironment()
           
protected  void overrideEnvironment(java.lang.String key, java.lang.Object value)
          Overrides default JNDI environment properties.
protected  void setLdifPath(java.lang.String ldifPath)
          Sets the LDIF path to use.
protected  void setLdifPath(java.lang.String ldifPath, java.lang.Class loadClass)
          Sets the LDIF path as a relative resource path to use with the loadClass parameter to load the resource.
protected  void setLoadClass(java.lang.Class loadClass)
           
protected  javax.naming.ldap.LdapContext setSysRoot(java.util.Hashtable env)
          Sets the system root taking into account the extras and overrides properties.
protected  javax.naming.ldap.LdapContext setSysRoot(java.lang.String user, java.lang.String passwd, Configuration cfg)
          Sets and returns the system root.
protected  void setUp()
          Get's the initial context factory for the provider's ou=system context root.
protected  void tearDown()
          Sets the system context root to null.
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail, failNotEquals, failNotSame, failSame, format
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

LDIF

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

username

protected final java.lang.String username

password

protected final java.lang.String password

sysRoot

protected javax.naming.ldap.LdapContext sysRoot
the context root for the system partition


doDelete

protected boolean doDelete
flag whether to delete database files for each test or not


configuration

protected MutableStartupConfiguration configuration

testEntries

protected java.util.List testEntries
A testEntries of entries as Attributes to add to the DIT for testing

Constructor Detail

AbstractTestCase

protected AbstractTestCase(java.lang.String username,
                           java.lang.String password)
Method Detail

setLdifPath

protected void setLdifPath(java.lang.String ldifPath,
                           java.lang.Class loadClass)
Sets the LDIF path as a relative resource path to use with the loadClass parameter to load the resource.

Parameters:
ldifPath - the relative resource path to the LDIF file
loadClass - the class used to load the LDIF as a resource stream

setLdifPath

protected void setLdifPath(java.lang.String ldifPath)
Sets the LDIF path to use. If the path is relative to this class then it is first tested

Parameters:
ldifPath - the path to the LDIF file

setUp

protected void setUp()
              throws java.lang.Exception
Get's the initial context factory for the provider's ou=system context root.

Overrides:
setUp in class junit.framework.TestCase
Throws:
java.lang.Exception
See Also:
TestCase.setUp()

doDelete

protected void doDelete(java.io.File wkdir)
                 throws java.io.IOException
Deletes the Eve working directory.

Throws:
java.io.IOException

setSysRoot

protected javax.naming.ldap.LdapContext setSysRoot(java.lang.String user,
                                                   java.lang.String passwd,
                                                   Configuration cfg)
                                            throws javax.naming.NamingException
Sets and returns the system root. Values of user and password used to set the respective JNDI properties. These values can be overriden by the overrides properties.

Parameters:
user - the username for authenticating as this user
passwd - the password of the user
Returns:
the sysRoot context which is also set
Throws:
javax.naming.NamingException - if there is a failure of any kind

setSysRoot

protected javax.naming.ldap.LdapContext setSysRoot(java.util.Hashtable env)
                                            throws javax.naming.NamingException
Sets the system root taking into account the extras and overrides properties. In between these it sets the properties for the working directory, the provider URL and the JNDI InitialContexFactory to use.

Parameters:
env - an environment to use while setting up the system root.
Returns:
the sysRoot context which is also set
Throws:
javax.naming.NamingException - if there is a failure of any kind

overrideEnvironment

protected void overrideEnvironment(java.lang.String key,
                                   java.lang.Object value)
Overrides default JNDI environment properties. Please call this method to override any JNDI environment properties this test case will set.


getOverriddenEnvironment

protected java.util.Hashtable getOverriddenEnvironment()

tearDown

protected void tearDown()
                 throws java.lang.Exception
Sets the system context root to null.

Overrides:
tearDown in class junit.framework.TestCase
Throws:
java.lang.Exception
See Also:
TestCase.tearDown()

setLoadClass

protected void setLoadClass(java.lang.Class loadClass)


Copyright © 2003-2012 Apache Software Foundation. All Rights Reserved.