XMLCatalogSchemaManager { protected String[] listJarResources(URL dirURL, FilenameFilter filter) throws IOException, URISyntaxException { String[] files = new String[0]; String spec = dirURL.getFile(); int seperator = spec.indexOf("!/"); if (seperator == -1) { return files; } URL jarFileURL = new URL(spec.substring(0, seperator)); JarFile jarFile = new JarFile(jarFileURL.toURI().getPath()); Set<String> filesSet = new HashSet<String>(); try { Enumeration<JarEntry> entries = jarFile.entries(); while (entries.hasMoreElements()) { JarEntry entry = entries.nextElement(); if (entry.isDirectory()) { continue; } String entryName = entry.getName(); if (entryName.indexOf(schemaPath) > -1 && filter.accept(null, entryName)) { filesSet.add(entryName); } } } finally { jarFile.close(); } if (!filesSet.isEmpty()) { files = new String[filesSet.size()]; files = filesSet.toArray(files); } return files; } XMLCatalogSchemaManager(String schemaPath); void dropBaseSchema(Connection conn); void createBaseSchema(Connection conn); void upgradeBaseSchema(Connection conn, int currentVersion); boolean isInitialized(Connection conn); boolean isLoaded();  }
@Test @SetupPrepMethods(makeJDBCConnection=false) public void testListJarResources() throws Exception { XMLCatalogSchemaManager manager; Path jarPath; URL jarUrl; jarPath = createTestJar(); jarUrl = jarPath.toUri().toURL(); URLClassLoader classLoader = (URLClassLoader) ClassLoader.getSystemClassLoader(); Method addURLMethod = URLClassLoader.class.getDeclaredMethod("addURL", URL.class); addURLMethod.setAccessible(true); addURLMethod.invoke(classLoader, jarUrl); assertThat(classLoader.getURLs(), hasItemInArray(jarUrl)); manager = new XMLCatalogSchemaManager("schemas/jartest"); assertThat(manager.isLoaded(), is(true)); assertNotNull("Base Schema object cannot be null", manager.getCatalogStore().getSchema()); assertThat(manager.getCatalogStore().getSchema().getObjects(), not(empty())); }