ElasticConnectionPoolConfigurationPublisher implements ConnectionPoolConfigurationPublisher { Map<String, String> getLibraryVersion(Class<?> classLoadedWithURLClassLoader, Set<String> libraryNames) { ClassLoader cl = classLoadedWithURLClassLoader.getClassLoader(); Map<String, String> libraryVersionMapping = new HashMap<String, String>(); if (cl instanceof URLClassLoader) { @SuppressWarnings("resource") URLClassLoader uCl = (URLClassLoader) cl; URL urls[] = uCl.getURLs(); for (URL url : urls) { String fullNameWithVersion = url.toString().substring(url.toString().lastIndexOf('/')); if (fullNameWithVersion.length() > 4) { String nameWithVersion = fullNameWithVersion.substring(1, fullNameWithVersion.length() - 4); int idx = findVersionStartIndex(nameWithVersion); if (idx > 0) { String name = nameWithVersion.substring(0, idx - 1); if (libraryNames.contains(name)) { libraryVersionMapping.put(name, nameWithVersion.substring(idx)); } } } } } return libraryVersionMapping; } ElasticConnectionPoolConfigurationPublisher(String applicationName, String clusterName, String vip,
                                                       ConnectionPoolConfiguration config); @Override void publish();  }
@Test public void testLibraryVersion() { ElasticConnectionPoolConfigurationPublisher publisher = new ElasticConnectionPoolConfigurationPublisher("ClientApp", "dyno_cluster_1", "unit-test-vip", config); Map<String, String> versions = publisher.getLibraryVersion(this.getClass(), "dyno-core"); assertTrue(versions.size() == 1 || versions.size() == 0); }