default JdbmPartition initLdapTestSetup(
         String partitionName,
         File targetDir,
         CacheManager ehCacheManager,
         DirectoryService service
    ) throws IOException, LdapException {

        JdbmPartition partition;
        if (!targetDir.isDirectory()) {
            throw new UncheckedIOException(
                 new IOException("Couldn't find maven target directory: " + targetDir));
        }
        File partitionDir = new File(targetDir, partitionName);
        if (partitionDir.exists()) {
            FileUtils.deleteDirectory(partitionDir);
        }
        partitionDir.mkdirs();

        // Requires EHCache!
        String ehCacheName = "apiman-" + partitionName + "-ehcache-testing";
        ehCacheManager.addCache(ehCacheName);
        Cache cache = ehCacheManager.getCache(ehCacheName);

        final SchemaManager schemaManager = new DefaultSchemaManager();
        final DnFactory defaultDnFactory = new DefaultDnFactory(schemaManager, cache);

        partition = new JdbmPartition(schemaManager, defaultDnFactory);
        partition.setId("apiman");
        partition.setPartitionPath(partitionDir.toURI());
        partition.setSchemaManager(service.getSchemaManager());
        partition.setSuffixDn(new Dn("o=apiman"));
        service.addPartition(partition);

        // Inject the foo root entry if it does not already exist
        try {
            service.getAdminSession().lookup(partition.getSuffixDn());
        } catch (Exception lnnfe) {
            Dn dn = new Dn("o=apiman");
            Entry entry = service.newEntry(dn);
            entry.add("objectClass", "top", "domain", "extensibleObject");
            entry.add("dc", "apiman");
            entry.add("cn", "o=apiman");
            service.getAdminSession().add(entry);
        }

        return partition;
    }
Initialise the LDAP server with basic test setup.
gateway/engine/policies/src/test/java/io/apiman/gateway/engine/policies/util/LdapTestMixin.java