Search in sources :

Example 6 with SoftwareChannelSource

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

the class GraalEditionListTest method testParseRelease20MultiCatalogDefs.

/**
 * Checks multi-property definition parsing from the release file. The default property may be
 * present, but will be ignored.
 *
 * @throws Exception
 */
@Test
public void testParseRelease20MultiCatalogDefs() throws Exception {
    // this one contains multiple
    loadReleaseFile("release20ceWithEE.properties");
    storage.graalInfo.put(CommonConstants.CAP_EDITION, "ce");
    GraalEditionList list = new GraalEditionList(this, this, getLocalRegistry());
    list.setDefaultCatalogSpec(storage.graalInfo.get(CommonConstants.RELEASE_CATALOG_KEY));
    List<GraalEdition> eds = list.editions();
    assertFalse(eds.isEmpty());
    assertEquals(2, eds.size());
    GraalEdition ge = eds.get(0);
    assertSame(list.getDefaultEdition(), ge);
    assertEquals("Expected ce edition to be the default/installed", "ce", ge.getId());
    assertEquals("Label from graal caps should be capitalized", "CE", ge.getDisplayName());
    List<SoftwareChannelSource> sources = ge.getSoftwareSources();
    assertEquals("CE edition has single source", 1, sources.size());
    ge = eds.get(1);
    assertEquals("Enterprise Edition must be present", "ee", ge.getId());
    assertEquals("Enterprise label should be parsed out", "Enterprise Edition", ge.getDisplayName());
    sources = ge.getSoftwareSources();
    assertEquals("EE has more sources", 2, sources.size());
    assertEquals("Expected decreasing priority", 2, sources.get(1).getPriority());
    assertSame(ge, list.getEdition("ee"));
}
Also used : GraalEdition(org.graalvm.component.installer.model.GraalEdition) SoftwareChannelSource(org.graalvm.component.installer.SoftwareChannelSource) Test(org.junit.Test)

Example 7 with SoftwareChannelSource

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

the class GraalEditionListTest method testCheck21MultipleEditions.

@Test
public void testCheck21MultipleEditions() throws Exception {
    loadReleaseFile("release21ceWithEE.properties");
    storage.graalInfo.put(CommonConstants.CAP_EDITION, "ce");
    GraalEditionList list = new GraalEditionList(this, this, getLocalRegistry());
    list.setDefaultCatalogSpec(storage.graalInfo.get(CommonConstants.RELEASE_CATALOG_KEY));
    List<GraalEdition> eds = list.editions();
    assertEquals(2, eds.size());
    assertSame(list.getDefaultEdition(), eds.get(0));
    assertSame(list.getDefaultEdition(), list.getEdition(""));
    GraalEdition ge = list.getEdition("ce");
    assertSame(list.getDefaultEdition(), ge);
    assertSame(list.getEdition(""), ge);
    assertFalse("CE".equalsIgnoreCase(ge.getDisplayName()));
    List<SoftwareChannelSource> sources = ge.getSoftwareSources();
    assertEquals(2, sources.size());
    assertNotNull(sources.get(0).getLabel());
    assertTrue(sources.get(0).getLabel().contains("CE 8"));
    assertNotNull(sources.get(1).getLabel());
    assertTrue(sources.get(1).getLabel().contains("CE 11"));
    // check lowercasing
    ge = list.getEdition("eE");
    sources = ge.getSoftwareSources();
    assertEquals(3, sources.size());
    assertFalse("EE".equalsIgnoreCase(ge.getDisplayName()));
    String u = sources.get(0).getLocationURL();
    assertTrue(u.startsWith("gds:"));
    assertTrue(sources.get(0).getLabel().contains("GDS"));
    u = sources.get(1).getLocationURL();
    assertTrue(u.contains("java8.properties"));
    assertTrue(sources.get(1).getLabel().contains("Github"));
    assertEquals("valueY", sources.get(1).getParameter("paramx"));
    u = sources.get(2).getLocationURL();
    assertTrue(u.contains("ee-extras"));
    assertTrue(sources.get(2).getLabel().contains("experimental"));
}
Also used : GraalEdition(org.graalvm.component.installer.model.GraalEdition) SoftwareChannelSource(org.graalvm.component.installer.SoftwareChannelSource) Test(org.junit.Test)

Example 8 with SoftwareChannelSource

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

the class GraalEditionListTest method testCheckUserUserOverride20.

/**
 * Check function of the 'override' switch: the catalog software sources from Graal-20 release
 * file should be ignored.
 *
 * @throws Exception
 */
@Test
public void testCheckUserUserOverride20() throws Exception {
    // this one contains multiple
    loadReleaseFile("release20ceWithEE.properties");
    storage.graalInfo.put(CommonConstants.CAP_EDITION, "ce");
    GraalEditionList list = new GraalEditionList(this, this, getLocalRegistry());
    list.setDefaultCatalogSpec(storage.graalInfo.get(CommonConstants.RELEASE_CATALOG_KEY));
    list.setOverrideCatalogSpec("http://somewhere/catalog.properties|http://somewhereElse/catalog.properties");
    List<GraalEdition> eds = list.editions();
    assertEquals(1, eds.size());
    GraalEdition ge = eds.get(0);
    assertEquals("Expected default edition", "ce", ge.getId());
    List<SoftwareChannelSource> sources = ge.getSoftwareSources();
    assertEquals("Expected 2 sources from override", 2, sources.size());
    assertTrue(sources.stream().allMatch(s -> s.getLocationURL().contains("somewhere")));
    assertEquals(2, sources.get(1).getPriority());
}
Also used : GraalEdition(org.graalvm.component.installer.model.GraalEdition) CommandTestBase(org.graalvm.component.installer.CommandTestBase) Properties(java.util.Properties) CommonConstants(org.graalvm.component.installer.CommonConstants) Assert.assertNotNull(org.junit.Assert.assertNotNull) Assert.assertTrue(org.junit.Assert.assertTrue) IOException(java.io.IOException) Test(org.junit.Test) FailedOperationException(org.graalvm.component.installer.FailedOperationException) Assert.assertSame(org.junit.Assert.assertSame) List(java.util.List) Assert.assertNull(org.junit.Assert.assertNull) GraalEdition(org.graalvm.component.installer.model.GraalEdition) Assert.assertFalse(org.junit.Assert.assertFalse) Assert.fail(org.junit.Assert.fail) SoftwareChannelSource(org.graalvm.component.installer.SoftwareChannelSource) Assert.assertEquals(org.junit.Assert.assertEquals) InputStream(java.io.InputStream) SoftwareChannelSource(org.graalvm.component.installer.SoftwareChannelSource) Test(org.junit.Test)

Example 9 with SoftwareChannelSource

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

the class RemoteCatalogDownloaderTest method testParseCatalogOverrideParameters.

@Test
public void testParseCatalogOverrideParameters() throws Exception {
    storage.graalInfo.put(CommonConstants.CAP_GRAALVM_VERSION, "0.33-dev");
    String url = "test://graalv.org/test/catalog.properties";
    String single = url + "?linux=a&macOS=a+b&windows=";
    RemoteCatalogDownloader d = new RemoteCatalogDownloader(this, this, single);
    List<SoftwareChannelSource> sources = d.getChannelSources();
    assertNotNull(sources);
    assertEquals(1, sources.size());
    SoftwareChannelSource src = sources.get(0);
    assertEquals(url, src.getLocationURL());
    assertEquals("a", src.getParameter("linux"));
    assertEquals("a b", src.getParameter("macOS"));
    assertEquals("", src.getParameter("windows"));
}
Also used : SoftwareChannelSource(org.graalvm.component.installer.SoftwareChannelSource) Test(org.junit.Test)

Example 10 with SoftwareChannelSource

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

the class MergeStorage method reportError.

private void reportError(Exception exc, SoftwareChannel errChannel) {
    if (exc == null) {
        return;
    }
    // the previous error is overwritten, so at least report it before it is
    // forgot:
    SoftwareChannelSource info = channelInfos.get(errChannel);
    String l = info.getLabel();
    if (l == null) {
        l = info.getLocationURL();
    }
    feedback.error("REMOTE_CannotLoadChannel", exc, l, exc.getLocalizedMessage());
}
Also used : SoftwareChannelSource(org.graalvm.component.installer.SoftwareChannelSource)

Aggregations

SoftwareChannelSource (org.graalvm.component.installer.SoftwareChannelSource)19 Test (org.junit.Test)10 GraalEdition (org.graalvm.component.installer.model.GraalEdition)8 URL (java.net.URL)6 Path (java.nio.file.Path)4 ArrayList (java.util.ArrayList)4 List (java.util.List)4 CommandInput (org.graalvm.component.installer.CommandInput)3 CommonConstants (org.graalvm.component.installer.CommonConstants)3 Feedback (org.graalvm.component.installer.Feedback)3 SoftwareChannel (org.graalvm.component.installer.SoftwareChannel)3 CatalogContents (org.graalvm.component.installer.model.CatalogContents)3 ComponentInfo (org.graalvm.component.installer.model.ComponentInfo)3 ComponentRegistry (org.graalvm.component.installer.model.ComponentRegistry)3 RemoteCatalogDownloader (org.graalvm.component.installer.remote.RemoteCatalogDownloader)3 Collections (java.util.Collections)2 Comparator (java.util.Comparator)2 HashMap (java.util.HashMap)2 Locale (java.util.Locale)2 Map (java.util.Map)2