private static void cpSubsystemConfig(XmlGenerator gen, Config config) {
        CPSubsystemConfig cpSubsystemConfig = config.getCPSubsystemConfig();
        gen.open("cp-subsystem")
                .node("cp-member-count", cpSubsystemConfig.getCPMemberCount())
                .node("group-size", cpSubsystemConfig.getGroupSize())
                .node("session-time-to-live-seconds", cpSubsystemConfig.getSessionTimeToLiveSeconds())
                .node("session-heartbeat-interval-seconds", cpSubsystemConfig.getSessionHeartbeatIntervalSeconds())
                .node("missing-cp-member-auto-removal-seconds", cpSubsystemConfig.getMissingCPMemberAutoRemovalSeconds())
                .node("fail-on-indeterminate-operation-state", cpSubsystemConfig.isFailOnIndeterminateOperationState())
                .node("persistence-enabled", cpSubsystemConfig.isPersistenceEnabled())
                .node("base-dir", cpSubsystemConfig.getBaseDir().getAbsolutePath())
                .node("data-load-timeout-seconds", cpSubsystemConfig.getDataLoadTimeoutSeconds())
                .node("cp-member-priority", cpSubsystemConfig.getCPMemberPriority())
                .node("map-limit", cpSubsystemConfig.getCPMapLimit());

        RaftAlgorithmConfig raftAlgorithmConfig = cpSubsystemConfig.getRaftAlgorithmConfig();
        gen.open("raft-algorithm")
                .node("leader-election-timeout-in-millis", raftAlgorithmConfig.getLeaderElectionTimeoutInMillis())
                .node("leader-heartbeat-period-in-millis", raftAlgorithmConfig.getLeaderHeartbeatPeriodInMillis())
                .node("max-missed-leader-heartbeat-count", raftAlgorithmConfig.getMaxMissedLeaderHeartbeatCount())
                .node("append-request-max-entry-count", raftAlgorithmConfig.getAppendRequestMaxEntryCount())
                .node("commit-index-advance-count-to-snapshot", raftAlgorithmConfig.getCommitIndexAdvanceCountToSnapshot())
                .node("uncommitted-entry-count-to-reject-new-appends",
                        raftAlgorithmConfig.getUncommittedEntryCountToRejectNewAppends())
                .node("append-request-backoff-timeout-in-millis", raftAlgorithmConfig.getAppendRequestBackoffTimeoutInMillis())
                .close();

        gen.open("semaphores");

        for (SemaphoreConfig semaphoreConfig : cpSubsystemConfig.getSemaphoreConfigs().values()) {
            gen.open("semaphore")
                    .node("name", semaphoreConfig.getName())
                    .node("jdk-compatible", semaphoreConfig.isJDKCompatible())
                    .node("initial-permits", semaphoreConfig.getInitialPermits())
                    .close();
        }

        gen.close().open("locks");

        for (FencedLockConfig lockConfig : cpSubsystemConfig.getLockConfigs().values()) {
            gen.open("fenced-lock")
                    .node("name", lockConfig.getName())
                    .node("lock-acquire-limit", lockConfig.getLockAcquireLimit())
                    .close();
        }

        gen.close().open("maps");

        for (CPMapConfig cpMapConfig : cpSubsystemConfig.getCpMapConfigs().values()) {
            gen.open("map")
               .node("name", cpMapConfig.getName())
               .node("max-size-mb", cpMapConfig.getMaxSizeMb())
               .close();
        }

        gen.close().close();
    }
@Test
    public void testCPSubsystemConfig() {
        Config config = new Config();

        config.getCPSubsystemConfig()
                .setCPMemberCount(10)
                .setGroupSize(5)
                .setSessionTimeToLiveSeconds(15)
                .setSessionHeartbeatIntervalSeconds(3)
                .setMissingCPMemberAutoRemovalSeconds(120)
                .setFailOnIndeterminateOperationState(true)
                .setPersistenceEnabled(true)
                .setBaseDir(new File("/custom-dir"))
                .setCPMemberPriority(-1);

        config.getCPSubsystemConfig()
                .getRaftAlgorithmConfig()
                .setLeaderElectionTimeoutInMillis(500)
                .setLeaderHeartbeatPeriodInMillis(100)
                .setMaxMissedLeaderHeartbeatCount(10)
                .setAppendRequestMaxEntryCount(25)
                .setAppendRequestMaxEntryCount(250)
                .setUncommittedEntryCountToRejectNewAppends(75)
                .setAppendRequestBackoffTimeoutInMillis(50);

        config.getCPSubsystemConfig()
                .addSemaphoreConfig(new SemaphoreConfig("sem1", true, 1))
                .addSemaphoreConfig(new SemaphoreConfig("sem2", false, 2));

        config.getCPSubsystemConfig()
                .addLockConfig(new FencedLockConfig("lock1", 1))
                .addLockConfig(new FencedLockConfig("lock1", 2));

        config.getCPSubsystemConfig()
              .addCPMapConfig(new CPMapConfig("map1", 50))
              .addCPMapConfig(new CPMapConfig("map2", 25));

        config.getCPSubsystemConfig().setCPMapLimit(30);

        CPSubsystemConfig generatedConfig = getNewConfigViaXMLGenerator(config).getCPSubsystemConfig();
        assertTrue(generatedConfig + " should be compatible with " + config.getCPSubsystemConfig(),
                new CPSubsystemConfigChecker().check(config.getCPSubsystemConfig(), generatedConfig));
    }