org.apache.directory.server.core.annotations.ApplyLdifFiles Java Examples

The following examples show how to use org.apache.directory.server.core.annotations.ApplyLdifFiles. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DirectoryServiceBuilder.java    From wildfly-camel with Apache License 2.0 5 votes vote down vote up
public static SetupResult setupDirectoryService(Class<?> testClass) throws Exception {

        // Define a default class DS then
        DirectoryServiceFactory dsf = DefaultDirectoryServiceFactory.class.newInstance();

        SetupResult result = new SetupResult();
        result.directoryService = dsf.getDirectoryService();
        result.directoryService.getChangeLog().setEnabled(true);

        dsf.init("default" + UUID.randomUUID().toString());

        // Apply the class LDIFs
        ApplyLdifFiles applyLdifFiles = testClass.getAnnotation(ApplyLdifFiles.class);
        if (applyLdifFiles != null) {
            LOG.debug("Applying {} to {}", applyLdifFiles.value(), testClass.getName());
            DSAnnotationProcessor.injectLdifFiles(applyLdifFiles.clazz(), result.directoryService, applyLdifFiles.value());
        }

        // check if it has a LdapServerBuilder then use the DS created above
        CreateLdapServer ldapServerAnnotation = testClass.getAnnotation(CreateLdapServer.class);
        if (ldapServerAnnotation != null) {
            result.ldapServer = ServerAnnotationProcessor.instantiateLdapServer(ldapServerAnnotation, result.directoryService);
            result.ldapServer.setDirectoryService(result.directoryService);
            result.ldapServer.start();
        }

        // print out information which partition factory we use
        DirectoryServiceFactory dsFactory = DefaultDirectoryServiceFactory.class.newInstance();
        PartitionFactory partitionFactory = dsFactory.getPartitionFactory();
        LOG.debug("Using partition factory {}", partitionFactory.getClass().getSimpleName());

        return result;
    }