use of org.jboss.vfs.TempFileProvider in project jersey by jersey.
the class VFSSchemeResourceFinderTest method testClassEnumeration.
/**
* Test case for JERSEY-2197, JERSEY-2175.
*/
@Test
public void testClassEnumeration() throws Exception {
// Count actual entries.
int actualEntries = 0;
try (JarFile jarFile = new JarFile(jaxRsApiPath)) {
final Enumeration<JarEntry> entries = jarFile.entries();
while (entries.hasMoreElements()) {
final JarEntry entry = entries.nextElement();
if (entry.getName().endsWith(".class")) {
actualEntries++;
}
}
}
// Scan entries using VFS scanner.
final VirtualFile mountDir = VFS.getChild("content");
ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
try (TempFileProvider provider = TempFileProvider.create("test", executor, false);
Closeable mount = VFS.mountZip(VFS.getChild(jaxRsApiPath), mountDir, provider)) {
ResourceFinder finder = new VfsSchemeResourceFinderFactory().create(new URI(mountDir.toURI().toString() + "/javax/ws/rs"), true);
int scannedEntryCount = 0;
while (finder.hasNext()) {
// Fetch next entry.
finder.next();
try (InputStream classStream = finder.open()) {
scannedEntryCount++;
}
}
assertThat("Failed to enumerate all contents of javax.ws.rs-api.", scannedEntryCount, equalTo(actualEntries));
} finally {
executor.shutdownNow();
}
}
use of org.jboss.vfs.TempFileProvider in project wildfly by wildfly.
the class JdrTestCase method recursiveMount.
public static List<Closeable> recursiveMount(VirtualFile file) throws IOException {
TempFileProvider provider = TempFileProvider.create("test", Executors.newSingleThreadScheduledExecutor());
ArrayList<Closeable> mounts = new ArrayList<Closeable>();
if (!file.isDirectory() && file.getName().matches("^.*\\.([EeWwJj][Aa][Rr]|[Zz][Ii][Pp])$")) {
mounts.add(VFS.mountZip(file, file, provider));
}
if (file.isDirectory()) {
for (VirtualFile child : file.getChildren()) {
mounts.addAll(recursiveMount(child));
}
}
return mounts;
}
Aggregations