directory-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Doan Tin Nghia <doting...@gmail.com>
Subject Re: apacheds unit tests cannot execute ldif update statements
Date Sat, 10 Sep 2016 10:30:24 GMT
I have a workaround as:

- Create custom directory service factory which be used when create a
directory service
e.g
@CreateDS(
          name = "SampleDS",
          factory = CustomDefaultDirectoryServiceFactory.class,
..

- Create own system schema ( copied from api-ldap-schema-data-*.jar and
modified some ldif files) and let API use it by setting:

 System.setProperty("schema.resource.location", schemaDirectory);


I would greatly appreciate if any other ideas.

Thanks

On Thu, Sep 8, 2016 at 8:12 AM, Doan Tin Nghia <dotinghia@gmail.com> wrote:

> Hi all,
>
> I am using
>
> -  api-ldap-client-api 1.0.0-RC1
> -  apacheds-core-integ, apacheds-server-integ (2.0.0-M23)
>
> and facing 2 issues when trying to apply LDIF update statements to
> embedded apacheds.
>
> 1. Both @ApplyLdifFiles and @ApplyLdifs  cannot execute the general format
> of LDIF update statements as:
>
> dn: m-oid=2.5.6.9, ou=objectclasses, cn=core, ou=schema
> changetype: modify
> delete: m-must
> m-must: member
> -
> add: m-may
> m-may: member
>
> Seems each operation must have 'dn' in the first line.
>
> 2. Modified entry will cause the entry deleted from schema registry(
>  SchemaObjectRegistry), e.g in my case
>
> *action 1:* modify groupOfNames
>
>     dn: m-oid=2.5.6.9, ou=objectclasses, cn=core, ou=schema
>     changetype: modify
>     delete: m-must
>      m-must: member
>
> *action 2:* add new object class that depend on  groupOfNames
>
> dn: m-oid=1.3.6.1.4.1.2552.2.2, ou=objectclasses, cn=Test, ou=schema
> objectclass: metaObjectClass
> objectclass: metaTop
> objectclass: top
> m-oid: 1.3.6.1.4.1.2552.2.2
> m-name: TestObjectClass
> m-description: Test Object class
> m-supObjectClass: groupOfNames
> m-must: givenName
>
>
> Then I got exception:
>
> Caused by: java.lang.NullPointerException: null
> at org.apache.directory.api.ldap.model.schema.registries.Defaul
> tSchemaObjectRegistry.unregister(DefaultSchemaObjectRegistry.java:302)
> at org.apache.directory.api.ldap.model.schema.registries.Defaul
> tObjectClassRegistry.unregister(DefaultObjectClassRegistry.java:190)
> at org.apache.directory.api.ldap.schema.manager.impl.DefaultSch
> emaManager.unregisterObjectClass(DefaultSchemaManager.java:2263)
> at org.apache.directory.server.core.api.schema.registries.synch
> ronizers.ObjectClassSynchronizer.modify(ObjectClassSynchronizer.java:80)
> at org.apache.directory.server.core.api.schema.registries.synch
> ronizers.RegistrySynchronizerAdaptor.modify(RegistrySynchron
> izerAdaptor.java:296)
> at org.apache.directory.server.core.api.schema.SchemaPartition.
> modify(SchemaPartition.java:400)
> at org.apache.directory.server.core.shared.partition.DefaultPar
> titionNexus.modify(DefaultPartitionNexus.java:491)
> at org.apache.directory.server.core.api.interceptor.BaseInterce
> ptor$1.modify(BaseInterceptor.java:170)
> at org.apache.directory.server.core.api.interceptor.BaseInterce
> ptor.next(BaseInterceptor.java:506)
> at org.apache.directory.server.core.journal.JournalInterceptor.
> modify(JournalInterceptor.java:229)
> at org.apache.directory.server.core.api.interceptor.BaseInterce
> ptor.next(BaseInterceptor.java:506)
> at org.apache.directory.server.core.changelog.ChangeLogIntercep
> tor.modify(ChangeLogInterceptor.java:222)
> at org.apache.directory.server.core.api.interceptor.BaseInterce
> ptor.next(BaseInterceptor.java:506)
> at org.apache.directory.server.core.trigger.TriggerInterceptor.
> modify(TriggerInterceptor.java:370)
> at org.apache.directory.server.core.api.interceptor.BaseInterce
> ptor.next(BaseInterceptor.java:506)
> at org.apache.directory.server.core.event.EventInterceptor.modi
> fy(EventInterceptor.java:282)
> at org.apache.directory.server.core.api.interceptor.BaseInterce
> ptor.next(BaseInterceptor.java:506)
> at org.apache.directory.server.core.subtree.SubentryInterceptor
> .modify(SubentryInterceptor.java:1220)
> at org.apache.directory.server.core.api.interceptor.BaseInterce
> ptor.next(BaseInterceptor.java:506)
> at org.apache.directory.server.core.collective.CollectiveAttrib
> uteInterceptor.modify(CollectiveAttributeInterceptor.java:165)
> at org.apache.directory.server.core.api.interceptor.BaseInterce
> ptor.next(BaseInterceptor.java:506)
> at org.apache.directory.server.core.operational.OperationalAttr
> ibuteInterceptor.modify(OperationalAttributeInterceptor.java:449)
> at org.apache.directory.server.core.api.interceptor.BaseInterce
> ptor.next(BaseInterceptor.java:506)
> at org.apache.directory.server.core.schema.SchemaInterceptor.mo
> dify(SchemaInterceptor.java:1206)
> at org.apache.directory.server.core.api.interceptor.BaseInterce
> ptor.next(BaseInterceptor.java:506)
> at org.apache.directory.server.core.exception.ExceptionIntercep
> tor.modify(ExceptionInterceptor.java:252)
> ....
>
> My java class is:
>
> RunWith(FrameworkRunner.class)
> @CreateLdapServer(transports = {
> @CreateTransport(port = 10489, protocol = "LDAP")
> })
>
> @CreateDS(
>         name = "LicenseServerDS",
>         enableChangeLog = false,
>         partitions =
>             {
>                 @CreatePartition(
>                     name = "myexample",
>                     suffix = "dc=myexample,dc=com",
>                     contextEntry = @ContextEntry(
>                         entryLdif =
>                         "dn: dc=myexample,dc=com\n" +
>                             "dc: myexample\n" +
>                             "objectClass: top\n" +
>                             "objectClass: domain\n\n"))
>         })
>
> @ApplyLdifs ( {
> "dn: m-oid=2.5.6.9, ou=objectclasses, cn=core, ou=schema",
> "changetype: modify",
> "delete: m-must",
> "m-must: member",
> "-"
> })
> @ApplyLdifFiles({
> "action2.ldif"
> })
>
> public class MyTest extends AbstractLdapTestUnit{
> @Test
>     public void testCreateDS() throws Exception
>     {
> SearchControls controls = new SearchControls();
>        controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
>        controls.setReturningAttributes( new String[]
>            { "+", "*" } );
>
>        NamingEnumeration<SearchResult> res = getRootContext( getService()
> ).search( "", "(ObjectClass=*)", controls );
>
>        assertTrue( res.hasMore() );
>
>        while ( res.hasMoreElements() )
>        {
>            SearchResult result = ( SearchResult ) res.next();
>
>            System.out.println( result.getName() );
>        }
>     }
> }
>
> Any help is appreciated. Thanks
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message