Search in sources :

Example 16 with CatalogContents

use of org.graalvm.component.installer.model.CatalogContents in project graal by oracle.

the class UpgradeTest method testUpgradeRespectsTargetCatalogURLs.

/**
 * The target GraalVM installation may have configured the catalog URLs differently. When
 * installing components or dependencies to the target, the target's URLs / release file
 * settings should be respected.
 *
 * @throws Exception
 */
@Test
public void testUpgradeRespectsTargetCatalogURLs() throws Exception {
    URL u = new URL("test://catalog-19.3.properties");
    Handler.bind(u.toString(), dataFile("../repo/catalog-19.3.properties").toUri().toURL());
    initVersion("1.0.0.0", "../repo/catalog-19.3.properties");
    ComponentInfo ci = new ComponentInfo("org.graalvm.r", "Installed R", "1.0.0.0");
    storage.installed.add(ci);
    UpgradeCommand cmd = new UpgradeCommand();
    cmd.init(this, this);
    ComponentInfo graalInfo = cmd.configureProcess();
    boolean installed = cmd.getProcess().installGraalCore(graalInfo);
    assertTrue(installed);
    factory = new CatalogFactory() {

        @Override
        public ComponentCatalog createComponentCatalog(CommandInput in) {
            RemoteCatalogDownloader dnl = new RemoteCatalogDownloader(in, UpgradeTest.this, (String) null);
            return new CatalogContents(UpgradeTest.this, dnl.getStorage(), in.getLocalRegistry());
        }

        @Override
        public List<GraalEdition> listEditions(ComponentRegistry targetGraalVM) {
            return Collections.emptyList();
        }
    };
    InstallTrampoline targetInstall = new InstallTrampoline();
    cmd.getProcess().configureInstallCommand(targetInstall);
    targetInstall.executionInit();
    targetInstall.prepareInstallation();
    // verify the URL from the target installation was visited.
    assertTrue(Handler.isVisited(u));
}
Also used : ComponentCatalog(org.graalvm.component.installer.ComponentCatalog) URL(java.net.URL) CommandInput(org.graalvm.component.installer.CommandInput) ComponentRegistry(org.graalvm.component.installer.model.ComponentRegistry) CatalogContents(org.graalvm.component.installer.model.CatalogContents) RemoteCatalogDownloader(org.graalvm.component.installer.remote.RemoteCatalogDownloader) List(java.util.List) ComponentInfo(org.graalvm.component.installer.model.ComponentInfo) Test(org.junit.Test)

Example 17 with CatalogContents

use of org.graalvm.component.installer.model.CatalogContents in project graal by oracle.

the class DirectoryCatalogProviderTest method testDifferentRequirementsFiltered.

@Test
public void testDifferentRequirementsFiltered() throws Exception {
    Path testData = dataFile("dir1");
    DirectoryCatalogProvider prov = new DirectoryCatalogProvider(testData, this);
    Set<String> ids = prov.listComponentIDs();
    assertEquals(2, ids.size());
    // typo is there...
    Collection<ComponentInfo> infos = prov.loadComponentMetadata("org.graavm.ruby");
    assertEquals(2, infos.size());
    CatalogContents contents = new CatalogContents(this, prov, getLocalRegistry());
    Version.Match m = getLocalRegistry().getGraalVersion().match(Version.Match.Type.INSTALLABLE);
    // check that the JDK11 component gets removed
    Collection<ComponentInfo> catInfos = contents.loadComponents("org.graavm.ruby", m, false);
    assertEquals(1, catInfos.size());
    ComponentInfo ci = catInfos.iterator().next();
    assertEquals(testData.resolve("ruby.jar").toUri().toURL(), ci.getRemoteURL());
}
Also used : Path(java.nio.file.Path) Version(org.graalvm.component.installer.Version) CatalogContents(org.graalvm.component.installer.model.CatalogContents) ComponentInfo(org.graalvm.component.installer.model.ComponentInfo) Test(org.junit.Test)

Example 18 with CatalogContents

use of org.graalvm.component.installer.model.CatalogContents in project graal by oracle.

the class DirectoryCatalogProviderTest method testSpecificJavaPresent.

@Test
public void testSpecificJavaPresent() throws Exception {
    storage.graalInfo.put(CommonConstants.CAP_JAVA_VERSION, "11");
    Path testData = dataFile("dir1");
    DirectoryCatalogProvider prov = new DirectoryCatalogProvider(testData, this);
    Set<String> ids = prov.listComponentIDs();
    assertEquals(2, ids.size());
    // typo is there...
    Collection<ComponentInfo> infos = prov.loadComponentMetadata("org.graavm.ruby");
    assertEquals(2, infos.size());
    CatalogContents contents = new CatalogContents(this, prov, getLocalRegistry());
    Version.Match m = getLocalRegistry().getGraalVersion().match(Version.Match.Type.INSTALLABLE);
    // both Ruby should pass: ruby.jar has no jdk restriction
    Collection<ComponentInfo> catInfos = contents.loadComponents("org.graavm.ruby", m, false);
    assertEquals(2, catInfos.size());
    Set<URL> urls = new HashSet<>(Arrays.asList(testData.resolve("ruby.jar").toUri().toURL(), testData.resolve("ruby-11.jar").toUri().toURL()));
    Iterator<ComponentInfo> itC = catInfos.iterator();
    ComponentInfo ci = itC.next();
    assertTrue(urls.remove(ci.getRemoteURL()));
    ci = itC.next();
    assertTrue(urls.remove(ci.getRemoteURL()));
}
Also used : Path(java.nio.file.Path) URL(java.net.URL) Version(org.graalvm.component.installer.Version) CatalogContents(org.graalvm.component.installer.model.CatalogContents) ComponentInfo(org.graalvm.component.installer.model.ComponentInfo) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 19 with CatalogContents

use of org.graalvm.component.installer.model.CatalogContents in project graal by oracle.

the class CatalogCompatTest method openCatalog.

ComponentCatalog openCatalog(SoftwareChannel ch, Version v) throws IOException {
    ComponentCatalog cc = new CatalogContents(this, ch.getStorage(), getLocalRegistry(), v);
    cc.getComponentIDs();
    return cc;
}
Also used : ComponentCatalog(org.graalvm.component.installer.ComponentCatalog) CatalogContents(org.graalvm.component.installer.model.CatalogContents)

Example 20 with CatalogContents

use of org.graalvm.component.installer.model.CatalogContents in project graal by oracle.

the class CatalogInstallTest method setupCatalog2.

private void setupCatalog2(String rel) throws IOException {
    Path p = dataFile(rel);
    URL u = p.toUri().toURL();
    downloader = new RemoteCatalogDownloader(this, this, u);
    this.registry = new CatalogContents(this, downloader.getStorage(), getLocalRegistry());
}
Also used : Path(java.nio.file.Path) CatalogContents(org.graalvm.component.installer.model.CatalogContents) RemoteCatalogDownloader(org.graalvm.component.installer.remote.RemoteCatalogDownloader) URL(java.net.URL)

Aggregations

CatalogContents (org.graalvm.component.installer.model.CatalogContents)21 RemoteCatalogDownloader (org.graalvm.component.installer.remote.RemoteCatalogDownloader)11 Path (java.nio.file.Path)9 URL (java.net.URL)8 ComponentCatalog (org.graalvm.component.installer.ComponentCatalog)7 ComponentInfo (org.graalvm.component.installer.model.ComponentInfo)6 Version (org.graalvm.component.installer.Version)5 ComponentRegistry (org.graalvm.component.installer.model.ComponentRegistry)5 CatalogIterable (org.graalvm.component.installer.remote.CatalogIterable)5 Test (org.junit.Test)5 List (java.util.List)4 CommandInput (org.graalvm.component.installer.CommandInput)4 HashSet (java.util.HashSet)3 RemotePropertiesStorage (org.graalvm.component.installer.remote.RemotePropertiesStorage)2 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 ComponentParam (org.graalvm.component.installer.ComponentParam)1 FileIterable (org.graalvm.component.installer.FileIterable)1 SoftwareChannelSource (org.graalvm.component.installer.SoftwareChannelSource)1