static 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! Reuse any cache with existing name.
        String ehCacheName = "apiman-" + partitionName + "-ehcache-testing";
        if (!ehCacheManager.cacheExists(ehCacheName)) {
            ehCacheManager.addCache(ehCacheName);
            ehCacheManager.clearAll();
        }
        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"));

        // The test framework may leave the partition there (albeit empty). Find and reuse, else create.
        boolean partitionAlreadyExists = false;
        for (Partition servicePartition : service.getPartitions()) {
            if (servicePartition.getId().equals("apiman")) {
                partition = (JdbmPartition) servicePartition;
                partitionAlreadyExists = true;
            }
        }
        if (!partitionAlreadyExists) {
            service.addPartition(partition);
        }

        // Inject the foo root entry if it does not already exist
        // Between runs, this may be empty.
        try {
            service.getAdminSession().lookup(partition.getSuffixDn());
        } catch (Exception lnnfe) {
            fixLNNFE(service);
        }

        return partition;
    }
Initialise the LDAP server with basic test setup.
gateway/platforms/vertx3/vertx3/src/test/java/io/apiman/gateway/platforms/vertx3/components/ldap/LdapTestMixin.java