OptionsAndArgs { public String toAgentArg() { StringBuilder arg = new StringBuilder(); for (Map.Entry<String,String> entry : options.entrySet()) { String key = entry.getKey(); if (!key.equals("quiet") && !key.equals("verbose")) { arg.append(key).append("=").append(EscapeUtil.escape(entry.getValue(),EscapeUtil.CSV_ESCAPE,",")).append(","); } } return arg.length() > 0 ? arg.substring(0,arg.length() - 1) : ""; } OptionsAndArgs(Set<String> pCommands, String ... pArgs); String toAgentArg(); String getPid(); Pattern getProcessPattern(); String getCommand(); List<String> getExtraArgs(); boolean isQuiet(); String getPort(); boolean isVerbose(); boolean needsVm(); String getJarFilePath(); String getJarFileName(); static File lookupJarFile();  }
@Test public void listArgs() { String DN1 = "CN=adminuser, C=XX, O=Default Company Ltd"; String DN2 = "CN=Max Mustermann, C=DE, O=Volkswagen"; OptionsAndArgs o = opts("--clientPrincipal",DN1,"--clientPrincipal",DN2); assertTrue(o.toAgentArg().contains(EscapeUtil.escape(DN1,EscapeUtil.CSV_ESCAPE,","))); assertTrue(o.toAgentArg().contains(EscapeUtil.escape(DN2,EscapeUtil.CSV_ESCAPE,","))); assertTrue(o.toAgentArg().contains("clientPrincipal")); assertTrue(o.toAgentArg().contains("clientPrincipal.1")); assertFalse(o.toAgentArg().contains("clientPrincipal.0")); assertFalse(o.toAgentArg().contains("clientPrincipal.2")); }