Search in sources :

Example 1 with DownloadURLParam

use of org.graalvm.component.installer.DownloadURLIterable.DownloadURLParam in project graal by oracle.

the class CommandTestBase method initURLComponent.

protected void initURLComponent(String relativeJar, String spec) throws IOException {
    clu = getClass().getResource(relativeJar);
    url = new URL(spec);
    Handler.bind(url.toString(), clu);
    File f = dataFile(relativeJar).toFile();
    JarFile jf = new JarFile(f, false);
    ComponentPackageLoader cpl = new JarMetaLoader(jf, this);
    info = cpl.getComponentInfo();
    // unknown in catalog metadata
    info.setLicensePath(null);
    info.setRemoteURL(url);
    param = rparam = new DownloadURLParam(url, spec, spec, this, false);
}
Also used : JarFile(java.util.jar.JarFile) DownloadURLParam(org.graalvm.component.installer.DownloadURLIterable.DownloadURLParam) JarFile(java.util.jar.JarFile) File(java.io.File) URL(java.net.URL) ComponentPackageLoader(org.graalvm.component.installer.persist.ComponentPackageLoader) JarMetaLoader(org.graalvm.component.installer.jar.JarMetaLoader)

Example 2 with DownloadURLParam

use of org.graalvm.component.installer.DownloadURLIterable.DownloadURLParam in project graal by oracle.

the class CatalogIterableTest method testDirectURLJarClosedAfterJar.

@Test
public void testDirectURLJarClosedAfterJar() throws Exception {
    addRemoteComponent("persist/data/truffleruby3.jar", "test://graalvm.io/download/truffleruby.zip", false);
    rparam = new DownloadURLParam(url, rparam.getDisplayName(), rparam.getSpecification(), this, false);
    components.add(param);
    JarArchive jf = (JarArchive) rparam.getArchive();
    assertNotNull(jf.getEntry("META-INF"));
    rparam.close();
    exception.expect(IllegalStateException.class);
    jf.getEntry("META-INF");
}
Also used : JarArchive(org.graalvm.component.installer.jar.JarArchive) DownloadURLParam(org.graalvm.component.installer.DownloadURLIterable.DownloadURLParam) Test(org.junit.Test)

Example 3 with DownloadURLParam

use of org.graalvm.component.installer.DownloadURLIterable.DownloadURLParam in project graal by oracle.

the class CatalogIterableTest method testDirectURLAccessedJustOnce.

@Test
public void testDirectURLAccessedJustOnce() throws Exception {
    addRemoteComponent("persist/data/truffleruby3.jar", "test://graalvm.io/download/truffleruby.zip", false);
    rparam = new DownloadURLParam(url, rparam.getDisplayName(), rparam.getSpecification(), this, false);
    components.add(param);
    URL remoteU = rparam.createMetaLoader().getComponentInfo().getRemoteURL();
    assertEquals(url, remoteU);
    assertTrue(Handler.isVisited(url));
    assertTrue(rparam.isComplete());
    Handler.clearVisited();
    Archive jf = rparam.getArchive();
    assertNotNull(jf);
    assertFalse(Handler.isVisited(url));
}
Also used : JarArchive(org.graalvm.component.installer.jar.JarArchive) DownloadURLParam(org.graalvm.component.installer.DownloadURLIterable.DownloadURLParam) URL(java.net.URL) Test(org.junit.Test)

Example 4 with DownloadURLParam

use of org.graalvm.component.installer.DownloadURLIterable.DownloadURLParam in project graal by oracle.

the class CatalogIterableTest method testMetaAccessesDirectURL.

@Test
public void testMetaAccessesDirectURL() throws Exception {
    addRemoteComponent("persist/data/truffleruby3.jar", "test://graalvm.io/download/truffleruby.zip", false);
    rparam = new DownloadURLParam(url, rparam.getDisplayName(), rparam.getSpecification(), this, false);
    components.add(param);
    URL remoteU = rparam.createMetaLoader().getComponentInfo().getRemoteURL();
    assertEquals(url, remoteU);
    assertTrue(Handler.isVisited(url));
    assertTrue(rparam.isComplete());
}
Also used : DownloadURLParam(org.graalvm.component.installer.DownloadURLIterable.DownloadURLParam) URL(java.net.URL) Test(org.junit.Test)

Example 5 with DownloadURLParam

use of org.graalvm.component.installer.DownloadURLIterable.DownloadURLParam in project graal by oracle.

the class CatalogIterableTest method testDirectURLJarClosedAfterMeta.

@Test
public void testDirectURLJarClosedAfterMeta() throws Exception {
    addRemoteComponent("persist/data/truffleruby3.jar", "test://graalvm.io/download/truffleruby.zip", false);
    rparam = new DownloadURLParam(url, rparam.getDisplayName(), rparam.getSpecification(), this, false);
    components.add(param);
    URL remoteU = rparam.createMetaLoader().getComponentInfo().getRemoteURL();
    assertEquals(url, remoteU);
    JarArchive jf = (JarArchive) rparam.getArchive();
    assertNotNull(jf.getEntry("META-INF"));
    rparam.close();
    exception.expect(IllegalStateException.class);
    jf.getEntry("META-INF");
}
Also used : JarArchive(org.graalvm.component.installer.jar.JarArchive) DownloadURLParam(org.graalvm.component.installer.DownloadURLIterable.DownloadURLParam) URL(java.net.URL) Test(org.junit.Test)

Aggregations

DownloadURLParam (org.graalvm.component.installer.DownloadURLIterable.DownloadURLParam)5 URL (java.net.URL)4 Test (org.junit.Test)4 JarArchive (org.graalvm.component.installer.jar.JarArchive)3 File (java.io.File)1 JarFile (java.util.jar.JarFile)1 JarMetaLoader (org.graalvm.component.installer.jar.JarMetaLoader)1 ComponentPackageLoader (org.graalvm.component.installer.persist.ComponentPackageLoader)1