use of java.util.jar.JarInputStream in project drools by kiegroup.
the class VerifierMapBackedClassLoaderTest method testCheckResources.
@Test
public void testCheckResources() throws Exception {
ArrayList<JarInputStream> jarInputStreams = new ArrayList<JarInputStream>();
jarInputStreams.add(new JarInputStream(Verifier.class.getResourceAsStream("model.jar")));
VerifierMapBackedClassLoader verifierMapBackedClassLoader = new VerifierMapBackedClassLoader(jarInputStreams);
assertNotNull(verifierMapBackedClassLoader.getStore().containsKey("org.test.Person"));
assertNotNull(verifierMapBackedClassLoader.getStore().containsKey("org.test.Rambo"));
assertNotNull(verifierMapBackedClassLoader.getStore().containsKey("org.test.Pet"));
}
use of java.util.jar.JarInputStream in project Payara by payara.
the class HTTPInputArchive method entryNames.
/**
* Returns a collection containing the names of all entries in the
* archive.
*
* @return
* @throws IOException
*/
private synchronized Collection<String> entryNames() throws IOException {
if (cachedEntryNames == null) {
/*
* We have to build the cache first.
*/
cachedEntryNames = new ArrayList<String>();
final JarInputStream jis = new JarInputStream(archiveURL.openStream());
JarEntry entry;
try {
while ((entry = jis.getNextJarEntry()) != null) {
cachedEntryNames.add(entry.getName());
}
} finally {
jis.close();
}
}
return cachedEntryNames;
}
use of java.util.jar.JarInputStream in project drools by kiegroup.
the class VerifierTest method testFactTypesFromJar.
@Test
public void testFactTypesFromJar() {
VerifierBuilder vBuilder = VerifierBuilderFactory.newVerifierBuilder();
// Check that the builder works.
assertFalse(vBuilder.hasErrors());
assertEquals(0, vBuilder.getErrors().size());
Verifier verifier = vBuilder.newVerifier();
try {
JarInputStream jar = new JarInputStream(this.getClass().getResourceAsStream("model.jar"));
verifier.addObjectModel(jar);
} catch (IOException e) {
fail(e.getMessage());
}
verifier.addResourcesToVerify(new ClassPathResource("imports.drl", Verifier.class), ResourceType.DRL);
assertFalse(verifier.hasErrors());
assertEquals(0, verifier.getErrors().size());
boolean works = verifier.fireAnalysis();
assertTrue(works);
VerifierReport result = verifier.getResult();
Collection<ObjectType> objectTypes = result.getVerifierData().getAll(VerifierComponentType.OBJECT_TYPE);
assertNotNull(objectTypes);
assertEquals(3, objectTypes.size());
Collection<Field> fields = result.getVerifierData().getAll(VerifierComponentType.FIELD);
assertNotNull(fields);
assertEquals(10, fields.size());
}
use of java.util.jar.JarInputStream in project Payara by payara.
the class Archivist method performOptionalPkgDependenciesCheck.
/**
* Perform Optional packages dependencies checking on an archive
*/
public boolean performOptionalPkgDependenciesCheck(ReadableArchive archive) throws IOException {
boolean dependenciesSatisfied = true;
Manifest m = archive.getManifest();
if (m != null) {
dependenciesSatisfied = InstalledLibrariesResolver.resolveDependencies(m, archive.getURI().getSchemeSpecificPart());
}
// now check my libraries.
Vector<String> libs = getLibraries(archive);
if (libs != null) {
for (String libUri : libs) {
JarInputStream jis = null;
try {
jis = new JarInputStream(archive.getEntry(libUri));
m = jis.getManifest();
if (m != null) {
if (!InstalledLibrariesResolver.resolveDependencies(m, libUri)) {
dependenciesSatisfied = false;
}
}
} finally {
if (jis != null)
jis.close();
}
}
}
return dependenciesSatisfied;
}
use of java.util.jar.JarInputStream in project Payara by payara.
the class JarFile method setupEntryCertificates.
void setupEntryCertificates(JarEntry entry) {
// happening that often.
try {
JarInputStream inputStream = new JarInputStream(getData().getInputStream(ResourceAccess.ONCE));
try {
java.util.jar.JarEntry certEntry = inputStream.getNextJarEntry();
while (certEntry != null) {
inputStream.closeEntry();
if (entry.getName().equals(certEntry.getName())) {
setCertificates(entry, certEntry);
}
setCertificates(getJarEntry(certEntry.getName()), certEntry);
certEntry = inputStream.getNextJarEntry();
}
} finally {
inputStream.close();
}
} catch (IOException ex) {
throw new IllegalStateException(ex);
}
}
Aggregations