@Test public void testGetJvmByWorker() { Jvm mockJvm = mock(Jvm.class); when(mockJvm.getJvmName()).thenReturn("jvm-localhost-3"); when(mockJvm.getHostName()).thenReturn("localhost"); when(mockJvm.getHttpPort()).thenReturn(9120); when(mockJvm.getHttpsPort()).thenReturn(9121); when(mockJvm.getAjpPort()).thenReturn(9122); when(mockJvmService.getJvms()).thenReturn(Collections.singletonList(mockJvm)); String jvmName = balancerManagerXmlParser.findJvmNameByWorker("https: assertEquals("jvm-localhost-3", jvmName); jvmName = balancerManagerXmlParser.findJvmNameByWorker("http: assertEquals("jvm-localhost-3", jvmName); jvmName = balancerManagerXmlParser.findJvmNameByWorker("ajp: assertEquals("jvm-localhost-3", jvmName); }
String findJvmNameByWorker(final String worker) { LOGGER.info("Entering findJvmNameByWorker"); List<Jvm> jvms = jvmService.getJvms(); String jvmName = ""; for (Jvm jvm : jvms) { String jvmUrl; if (worker.indexOf("https") != -1) { jvmUrl = "https: } else if (worker.indexOf("http") != -1) { jvmUrl = "http: } else if (worker.indexOf("ajp") != -1) { jvmUrl = "ajp: } else { return ""; } if (worker.toLowerCase(Locale.US).indexOf(jvmUrl.toLowerCase(Locale.US)) != -1) { jvmName = jvm.getJvmName(); break; } } LOGGER.info(jvmName); return jvmName; }
BalancerManagerXmlParser { String findJvmNameByWorker(final String worker) { LOGGER.info("Entering findJvmNameByWorker"); List<Jvm> jvms = jvmService.getJvms(); String jvmName = ""; for (Jvm jvm : jvms) { String jvmUrl; if (worker.indexOf("https") != -1) { jvmUrl = "https: } else if (worker.indexOf("http") != -1) { jvmUrl = "http: } else if (worker.indexOf("ajp") != -1) { jvmUrl = "ajp: } else { return ""; } if (worker.toLowerCase(Locale.US).indexOf(jvmUrl.toLowerCase(Locale.US)) != -1) { jvmName = jvm.getJvmName(); break; } } LOGGER.info(jvmName); return jvmName; } }
BalancerManagerXmlParser { String findJvmNameByWorker(final String worker) { LOGGER.info("Entering findJvmNameByWorker"); List<Jvm> jvms = jvmService.getJvms(); String jvmName = ""; for (Jvm jvm : jvms) { String jvmUrl; if (worker.indexOf("https") != -1) { jvmUrl = "https: } else if (worker.indexOf("http") != -1) { jvmUrl = "http: } else if (worker.indexOf("ajp") != -1) { jvmUrl = "ajp: } else { return ""; } if (worker.toLowerCase(Locale.US).indexOf(jvmUrl.toLowerCase(Locale.US)) != -1) { jvmName = jvm.getJvmName(); break; } } LOGGER.info(jvmName); return jvmName; } BalancerManagerXmlParser(JvmService jvmService); }
BalancerManagerXmlParser { String findJvmNameByWorker(final String worker) { LOGGER.info("Entering findJvmNameByWorker"); List<Jvm> jvms = jvmService.getJvms(); String jvmName = ""; for (Jvm jvm : jvms) { String jvmUrl; if (worker.indexOf("https") != -1) { jvmUrl = "https: } else if (worker.indexOf("http") != -1) { jvmUrl = "http: } else if (worker.indexOf("ajp") != -1) { jvmUrl = "ajp: } else { return ""; } if (worker.toLowerCase(Locale.US).indexOf(jvmUrl.toLowerCase(Locale.US)) != -1) { jvmName = jvm.getJvmName(); break; } } LOGGER.info(jvmName); return jvmName; } BalancerManagerXmlParser(JvmService jvmService); Map<String, String> getWorkers(final Manager manager, final String balancerName); Map<String, String> getJvmWorkerByName(final Manager manager, final String balancerName, final String jvmName); }
BalancerManagerXmlParser { String findJvmNameByWorker(final String worker) { LOGGER.info("Entering findJvmNameByWorker"); List<Jvm> jvms = jvmService.getJvms(); String jvmName = ""; for (Jvm jvm : jvms) { String jvmUrl; if (worker.indexOf("https") != -1) { jvmUrl = "https: } else if (worker.indexOf("http") != -1) { jvmUrl = "http: } else if (worker.indexOf("ajp") != -1) { jvmUrl = "ajp: } else { return ""; } if (worker.toLowerCase(Locale.US).indexOf(jvmUrl.toLowerCase(Locale.US)) != -1) { jvmName = jvm.getJvmName(); break; } } LOGGER.info(jvmName); return jvmName; } BalancerManagerXmlParser(JvmService jvmService); Map<String, String> getWorkers(final Manager manager, final String balancerName); Map<String, String> getJvmWorkerByName(final Manager manager, final String balancerName, final String jvmName);  }