Package de.hybris.platform.ldap.jalo
Class AbstractLDAPTest
java.lang.Object
de.hybris.platform.ldap.jalo.AbstractLDAPTest
- Direct Known Subclasses:
AbstractEmbeddedLDAPTest,AbstractRemoteLDAPTest
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.apache.directory.server.core.DirectoryServiceprotected org.apache.directory.server.ldap.LdapServerprotected org.apache.directory.server.core.CoreSessionthe context root for the rootDSEprotected LdapContextthe context root for the schemaprotected LdapContextthe context root for the system partition -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidAdd a new set of index on the given attributesprotected voidconfigure here test specific data ,load LDIF filesprotected voidconfigureLdapServer(org.apache.directory.server.ldap.LdapServer ldapServer) register some dynamic mappingsprotected abstract org.apache.directory.server.core.partition.Partitionprepare partition , be aware at this methodDirectoryServiceis not started yet so no session will be availableprotected org.apache.directory.server.core.partition.PartitioncreatePartition(String partitionId, String partitionDn) creates newJdbmPartitionpartition and registers for it defeault set of mappings using current directory service e.g.protected voidDeletes the Eve working directory.protected Stringprotected Stringprotected abstract Stringldap host domain name/IPprotected Stringprotected abstract intport to listen ldap for either embedded or externalprotected LdapContextCommon code to get an initial context via a simple bind to the server over the wire using the SUN JNDI LDAP provider.protected LdapContextgetWiredContext(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 Fileconfigure custom working directory hereprotected voidimportLdif(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 voidinjectEntries(String ldif) Inject an ldif String into the server.protected booleanflag whether to delete database files for each test or notprotected booleanprotected 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 voidsetContexts(String user, String passwd) Sets the contexts for this base class.protected voidsetContexts(Hashtable<String, Object> env) Sets the contexts of this class taking into account the extras and overrides properties.voidsetUp()Get's the initial context factory for the provider's ou=system context root.voidtearDown()Sets the system context root to null.static voidprotected voidverify(org.apache.directory.shared.ldap.ldif.LdifEntry entry) Verifies that an entry exists in the directory with the specified attributes.
-
Field Details
-
sysRoot
the context root for the system partition -
rootDSE
protected org.apache.directory.server.core.CoreSession rootDSEthe context root for the rootDSE -
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
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
- Returns:
- the ldapCredenetial
-
getLDAPPassword
- Returns:
- the ldapPassword
-
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 failsException
-
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 loadverifyEntries- 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 failsException
-
getWiredContext
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 contactedException
-
getWiredContext
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 aspassword- the password of the bind principal- Returns:
- an LDAP context as the the administrator to the rootDSE
- Throws:
NamingException- if the server cannot be contactedException
-
setUp
Get's the initial context factory for the provider's ou=system context root.- Throws:
Exception- See Also:
-
TestCase.setUp()
-
getWorkingDirectory
configure custom working directory here -
configurePartition
protected abstract org.apache.directory.server.core.partition.Partition configurePartition() throws Exceptionprepare partition , be aware at this methodDirectoryServiceis 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
configure here test specific data ,load LDIF files- Throws:
Exception
-
doDelete
Deletes the Eve working directory.- Parameters:
wkdir- the directory to delete- Throws:
IOException- if the directory cannot be deleted
-
setContexts
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 userpasswd- the password of the user- Throws:
NamingException- if there is a failure of any kindException
-
setContexts
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 kindException
-
tearDown
Sets the system context root to null.- Throws:
Exception- See Also:
-
TestCase.tearDown()
-
importLdif
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
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 addedException
-
createPartition
protected org.apache.directory.server.core.partition.Partition createPartition(String partitionId, String partitionDn) throws Exception creates newJdbmPartitionpartition 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 indexattrs- The list of attributes to index
-
tearDownLogger
public static void tearDownLogger()
-