Package de.hybris.platform.ldap.jalo
Class AbstractLDAPTest
- java.lang.Object
-
- de.hybris.platform.ldap.jalo.AbstractLDAPTest
-
- Direct Known Subclasses:
AbstractEmbeddedLDAPTest
,AbstractRemoteLDAPTest
public abstract class AbstractLDAPTest extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description protected org.apache.directory.server.core.DirectoryService
directoryService
protected org.apache.directory.server.ldap.LdapServer
ldapServer
protected org.apache.directory.server.core.CoreSession
rootDSE
the context root for the rootDSEprotected javax.naming.ldap.LdapContext
schemaRoot
the context root for the schemaprotected javax.naming.ldap.LdapContext
sysRoot
the context root for the system partition
-
Constructor Summary
Constructors Constructor Description AbstractLDAPTest()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
addIndex(org.apache.directory.server.core.partition.Partition partition, java.lang.String... attrs)
Add a new set of index on the given attributesprotected void
configureLdapData()
configure here test specific data ,load LDIF filesprotected void
configureLdapServer(org.apache.directory.server.ldap.LdapServer ldapServer)
register some dynamic mappingsprotected abstract org.apache.directory.server.core.partition.Partition
configurePartition()
prepare partition , be aware at this methodDirectoryService
is not started yet so no session will be availableprotected org.apache.directory.server.core.partition.Partition
createPartition(java.lang.String partitionId, java.lang.String partitionDn)
creates newJdbmPartition
partition and registers for it defeault set of mappings using current directory service e.g.protected void
doDelete(java.io.File wkdir)
Deletes the Eve working directory.protected java.lang.String
getAuthenticationType()
protected java.lang.String
getLDAPCredenetial()
protected abstract java.lang.String
getLDAPHost()
ldap host domain name/IPprotected java.lang.String
getLDAPPassword()
protected abstract int
getLDAPPort()
port to listen ldap for either embedded or externalprotected javax.naming.ldap.LdapContext
getWiredContext()
Common code to get an initial context via a simple bind to the server over the wire using the SUN JNDI LDAP provider.protected javax.naming.ldap.LdapContext
getWiredContext(java.lang.String bindPrincipalDn, java.lang.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 java.io.File
getWorkingDirectory()
configure custom working directory hereprotected void
importLdif(java.io.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
injectEntries(java.lang.String ldif)
Inject an ldif String into the server.protected boolean
isDeleteLDAPServer()
flag whether to delete database files for each test or notprotected boolean
isEmbeddedLdap()
protected java.util.List<org.apache.directory.shared.ldap.ldif.LdifEntry>
loadLdif(java.io.InputStream inputStream, boolean verifyEntries)
Loads an LDIF from an input stream and adds the entries it congtains to the server.protected java.util.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(java.lang.String user, java.lang.String passwd)
Sets the contexts for this base class.protected void
setContexts(java.util.Hashtable<java.lang.String,java.lang.Object> env)
Sets the contexts of this class taking into account the extras and overrides properties.void
setUp()
Get's the initial context factory for the provider's ou=system context root.void
tearDown()
Sets the system context root to null.static void
tearDownLogger()
protected void
verify(org.apache.directory.shared.ldap.ldif.LdifEntry entry)
Verifies that an entry exists in the directory with the specified attributes.
-
-
-
Field Detail
-
sysRoot
protected javax.naming.ldap.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 javax.naming.ldap.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
-
-
Method Detail
-
getLDAPPort
protected abstract int getLDAPPort()
port to listen ldap for either embedded or external
-
getLDAPHost
protected abstract java.lang.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 java.lang.String getLDAPCredenetial()
- Returns:
- the ldapCredenetial
-
getLDAPPassword
protected java.lang.String getLDAPPassword()
- Returns:
- the ldapPassword
-
getAuthenticationType
protected java.lang.String getAuthenticationType()
- Returns:
- the authenticationType
-
loadTestLdif
protected java.util.List<org.apache.directory.shared.ldap.ldif.LdifEntry> loadTestLdif(boolean verifyEntries) throws java.lang.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:
javax.naming.NamingException
- of the load failsjava.lang.Exception
-
loadLdif
protected java.util.List<org.apache.directory.shared.ldap.ldif.LdifEntry> loadLdif(java.io.InputStream inputStream, boolean verifyEntries) throws java.lang.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:
javax.naming.NamingException
- of the load failsjava.lang.Exception
-
verify
protected void verify(org.apache.directory.shared.ldap.ldif.LdifEntry entry) throws java.lang.Exception
Verifies that an entry exists in the directory with the specified attributes.- Parameters:
entry
- the entry to verify- Throws:
javax.naming.NamingException
- if there are problems accessing the entryjava.lang.Exception
-
getWiredContext
protected javax.naming.ldap.LdapContext getWiredContext() throws java.lang.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:
javax.naming.NamingException
- if the server cannot be contactedjava.lang.Exception
-
getWiredContext
protected javax.naming.ldap.LdapContext getWiredContext(java.lang.String bindPrincipalDn, java.lang.String password) throws java.lang.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 aspassword
- the password of the bind principal- Returns:
- an LDAP context as the the administrator to the rootDSE
- Throws:
javax.naming.NamingException
- if the server cannot be contactedjava.lang.Exception
-
setUp
public void setUp() throws java.lang.Exception
Get's the initial context factory for the provider's ou=system context root.- Throws:
java.lang.Exception
- See Also:
TestCase.setUp()
-
getWorkingDirectory
protected java.io.File getWorkingDirectory()
configure custom working directory here
-
configurePartition
protected abstract org.apache.directory.server.core.partition.Partition configurePartition() throws java.lang.Exception
prepare partition , be aware at this methodDirectoryService
is not started yet so no session will be available- Throws:
java.lang.Exception
-
configureLdapServer
protected void configureLdapServer(org.apache.directory.server.ldap.LdapServer ldapServer) throws java.lang.Exception
register some dynamic mappings- Throws:
java.lang.Exception
-
configureLdapData
protected void configureLdapData() throws java.lang.Exception
configure here test specific data ,load LDIF files- Throws:
java.lang.Exception
-
doDelete
protected void doDelete(java.io.File wkdir) throws java.io.IOException
Deletes the Eve working directory.- Parameters:
wkdir
- the directory to delete- Throws:
java.io.IOException
- if the directory cannot be deleted
-
setContexts
protected void setContexts(java.lang.String user, java.lang.String passwd) throws java.lang.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 userpasswd
- the password of the user- Throws:
javax.naming.NamingException
- if there is a failure of any kindjava.lang.Exception
-
setContexts
protected void setContexts(java.util.Hashtable<java.lang.String,java.lang.Object> env) throws java.lang.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:
javax.naming.NamingException
- if there is a failure of any kindjava.lang.Exception
-
tearDown
public void tearDown() throws java.lang.Exception
Sets the system context root to null.- Throws:
java.lang.Exception
- See Also:
TestCase.tearDown()
-
importLdif
protected void importLdif(java.io.InputStream inputStream) throws javax.naming.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:
javax.naming.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(java.lang.String ldif) throws java.lang.Exception
Inject an ldif String into the server. DN must be relative to the root.- Parameters:
ldif
- the entries to inject- Throws:
javax.naming.NamingException
- if the entries cannot be addedjava.lang.Exception
-
createPartition
protected org.apache.directory.server.core.partition.Partition createPartition(java.lang.String partitionId, java.lang.String partitionDn) throws java.lang.Exception
creates newJdbmPartition
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:
java.lang.Exception
-
addIndex
protected void addIndex(org.apache.directory.server.core.partition.Partition partition, java.lang.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()
-
-