Class AbstractLDAPTest

java.lang.Object
de.hybris.platform.ldap.jalo.AbstractLDAPTest
Direct Known Subclasses:
AbstractEmbeddedLDAPTest, AbstractRemoteLDAPTest

public abstract class AbstractLDAPTest extends Object
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected org.apache.directory.server.core.DirectoryService
     
    protected org.apache.directory.server.ldap.LdapServer
     
    protected org.apache.directory.server.core.CoreSession
    the context root for the rootDSE
    protected LdapContext
    the context root for the schema
    protected LdapContext
    the context root for the system partition
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    addIndex(org.apache.directory.server.core.partition.Partition partition, String... attrs)
    Add a new set of index on the given attributes
    protected void
    configure here test specific data ,load LDIF files
    protected void
    configureLdapServer(org.apache.directory.server.ldap.LdapServer ldapServer)
    register some dynamic mappings
    protected abstract org.apache.directory.server.core.partition.Partition
    prepare partition , be aware at this method DirectoryService is not started yet so no session will be available
    protected org.apache.directory.server.core.partition.Partition
    createPartition(String partitionId, String partitionDn)
    creates new JdbmPartition partition and registers for it defeault set of mappings using current directory service e.g.
    protected void
    doDelete(File wkdir)
    Deletes the Eve working directory.
    protected String
     
    protected String
     
    protected abstract String
    ldap host domain name/IP
    protected String
     
    protected abstract int
    port to listen ldap for either embedded or external
    protected LdapContext
    Common code to get an initial context via a simple bind to the server over the wire using the SUN JNDI LDAP provider.
    protected LdapContext
    getWiredContext(String bindPrincipalDn, String password)
    Common code to get an initial context via a simple bind to the server over the wire using the SUN JNDI LDAP provider.
    protected File
    configure custom working directory here
    protected void
    importLdif(InputStream inputStream)
    Imports the LDIF entries packaged with the Eve JNDI provider jar into the newly created system partition to prime it up for operation.
    protected void
    Inject an ldif String into the server.
    protected boolean
    flag whether to delete database files for each test or not
    protected boolean
     
    protected List<org.apache.directory.shared.ldap.ldif.LdifEntry>
    loadLdif(InputStream inputStream, boolean verifyEntries)
    Loads an LDIF from an input stream and adds the entries it congtains to the server.
    protected List<org.apache.directory.shared.ldap.ldif.LdifEntry>
    loadTestLdif(boolean verifyEntries)
    If there is an LDIF file with the same name as the test class but with the .ldif extension then it is read and the entries it contains are added to the server.
    protected void
    setContexts(String user, String passwd)
    Sets the contexts for this base class.
    protected void
    Sets the contexts of this class taking into account the extras and overrides properties.
    void
    Get's the initial context factory for the provider's ou=system context root.
    void
    Sets the system context root to null.
    static void
     
    protected void
    verify(org.apache.directory.shared.ldap.ldif.LdifEntry entry)
    Verifies that an entry exists in the directory with the specified attributes.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • sysRoot

      protected LdapContext sysRoot
      the context root for the system partition
    • rootDSE

      protected org.apache.directory.server.core.CoreSession rootDSE
      the context root for the rootDSE
    • schemaRoot

      protected LdapContext schemaRoot
      the context root for the schema
    • directoryService

      protected org.apache.directory.server.core.DirectoryService directoryService
    • ldapServer

      protected org.apache.directory.server.ldap.LdapServer ldapServer
  • Constructor Details

    • AbstractLDAPTest

      public AbstractLDAPTest()
  • Method Details

    • getLDAPPort

      protected abstract int getLDAPPort()
      port to listen ldap for either embedded or external
    • getLDAPHost

      protected abstract String getLDAPHost()
      ldap host domain name/IP
    • isDeleteLDAPServer

      protected boolean isDeleteLDAPServer()
      flag whether to delete database files for each test or not
    • isEmbeddedLdap

      protected boolean isEmbeddedLdap()
    • getLDAPCredenetial

      protected String getLDAPCredenetial()
      Returns:
      the ldapCredenetial
    • getLDAPPassword

      protected String getLDAPPassword()
      Returns:
      the ldapPassword
    • getAuthenticationType

      protected String getAuthenticationType()
      Returns:
      the authenticationType
    • loadTestLdif

      protected List<org.apache.directory.shared.ldap.ldif.LdifEntry> loadTestLdif(boolean verifyEntries) throws Exception
      If there is an LDIF file with the same name as the test class but with the .ldif extension then it is read and the entries it contains are added to the server. It appears as though the administor adds these entries to the server.
      Parameters:
      verifyEntries - whether or not all entry additions are checked to see if they were in fact correctly added to the server
      Returns:
      a list of entries added to the server in the order they were added
      Throws:
      NamingException - of the load fails
      Exception
    • loadLdif

      protected List<org.apache.directory.shared.ldap.ldif.LdifEntry> loadLdif(InputStream inputStream, boolean verifyEntries) throws Exception
      Loads an LDIF from an input stream and adds the entries it congtains to the server. It appears as though the administrator added these entries to the server.
      Parameters:
      inputStream - the input stream containing the LDIF entries to load
      verifyEntries - whether or not all entry additions are checked to see if they were in fact correctly added to the server
      Returns:
      a list of entries added to the server in the order they were added
      Throws:
      NamingException - of the load fails
      Exception
    • verify

      protected void verify(org.apache.directory.shared.ldap.ldif.LdifEntry entry) throws Exception
      Verifies that an entry exists in the directory with the specified attributes.
      Parameters:
      entry - the entry to verify
      Throws:
      NamingException - if there are problems accessing the entry
      Exception
    • getWiredContext

      protected LdapContext getWiredContext() throws Exception
      Common code to get an initial context via a simple bind to the server over the wire using the SUN JNDI LDAP provider. Do not use this method until after the setUp() method is called to start the server otherwise it will fail.
      Returns:
      an LDAP context as the the administrator to the rootDSE
      Throws:
      NamingException - if the server cannot be contacted
      Exception
    • getWiredContext

      protected LdapContext getWiredContext(String bindPrincipalDn, String password) throws Exception
      Common code to get an initial context via a simple bind to the server over the wire using the SUN JNDI LDAP provider. Do not use this method until after the setUp() method is called to start the server otherwise it will fail.
      Parameters:
      bindPrincipalDn - the DN of the principal to bind as
      password - the password of the bind principal
      Returns:
      an LDAP context as the the administrator to the rootDSE
      Throws:
      NamingException - if the server cannot be contacted
      Exception
    • setUp

      public void setUp() throws Exception
      Get's the initial context factory for the provider's ou=system context root.
      Throws:
      Exception
      See Also:
      • TestCase.setUp()
    • getWorkingDirectory

      protected File getWorkingDirectory()
      configure custom working directory here
    • configurePartition

      protected abstract org.apache.directory.server.core.partition.Partition configurePartition() throws Exception
      prepare partition , be aware at this method DirectoryService is not started yet so no session will be available
      Throws:
      Exception
    • configureLdapServer

      protected void configureLdapServer(org.apache.directory.server.ldap.LdapServer ldapServer) throws Exception
      register some dynamic mappings
      Throws:
      Exception
    • configureLdapData

      protected void configureLdapData() throws Exception
      configure here test specific data ,load LDIF files
      Throws:
      Exception
    • doDelete

      protected void doDelete(File wkdir) throws IOException
      Deletes the Eve working directory.
      Parameters:
      wkdir - the directory to delete
      Throws:
      IOException - if the directory cannot be deleted
    • setContexts

      protected void setContexts(String user, String passwd) throws Exception
      Sets the contexts for this base class. 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
      Throws:
      NamingException - if there is a failure of any kind
      Exception
    • setContexts

      protected void setContexts(Hashtable<String,Object> env) throws Exception
      Sets the contexts of this class taking into account the extras and overrides properties.
      Parameters:
      env - an environment to use while setting up the system root.
      Throws:
      NamingException - if there is a failure of any kind
      Exception
    • tearDown

      public void tearDown() throws Exception
      Sets the system context root to null.
      Throws:
      Exception
      See Also:
      • TestCase.tearDown()
    • importLdif

      protected void importLdif(InputStream inputStream) throws NamingException
      Imports the LDIF entries packaged with the Eve JNDI provider jar into the newly created system partition to prime it up for operation. Note that only ou=system entries will be added - entries for other partitions cannot be imported and will blow chunks.
      Throws:
      NamingException - if there are problems reading the ldif file and adding those entries to the system partition in attribute the input stream with the ldif
    • injectEntries

      protected void injectEntries(String ldif) throws Exception
      Inject an ldif String into the server. DN must be relative to the root.
      Parameters:
      ldif - the entries to inject
      Throws:
      NamingException - if the entries cannot be added
      Exception
    • createPartition

      protected org.apache.directory.server.core.partition.Partition createPartition(String partitionId, String partitionDn) throws Exception
      creates new JdbmPartition partition and registers for it defeault set of mappings using current directory service e.g. :
      addPartition("hybris", "dc=hybris,dc=de"); with optional indexed attributes values e.g. :
      addPartition("hybris", "dc=hybris,dc=de","objectClass", "dc");
      Throws:
      Exception
    • addIndex

      protected void addIndex(org.apache.directory.server.core.partition.Partition partition, String... attrs)
      Add a new set of index on the given attributes
      Parameters:
      partition - The partition on which we want to add index
      attrs - The list of attributes to index
    • tearDownLogger

      public static void tearDownLogger()