Search in sources :

Example 11 with GraalEdition

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

the class GraalEditionList method init.

void init() {
    if (defaultEdition != null) {
        return;
    }
    String defEditionId = targetGraal.getGraalCapabilities().get(CommonConstants.CAP_EDITION);
    if (isExplicitOverride()) {
        initSimple(defEditionId, overrideCatalogSpec);
        return;
    }
    List<SoftwareChannelSource> srcs = readChannelSources(defEditionId);
    if (srcs.isEmpty()) {
        // no source channels defined for the editionId
        srcs = readChannelSources(null);
    }
    if (srcs.isEmpty()) {
        initSimple(defEditionId, defaultCatalogSpec);
        return;
    }
    List<String> edList = listEditionsFromRelease();
    String label;
    List<SoftwareChannelSource> sources;
    if (edList.contains(defEditionId)) {
        edList.remove(defEditionId);
        label = getEditionLabel(defEditionId);
        sources = readChannelSources(defEditionId);
    } else if (!edList.remove("")) {
        throw new IllegalStateException("Malformed release file.");
    } else {
        label = getEditionLabel(null);
        sources = readChannelSources(null);
    }
    GraalEdition ge = new GraalEdition(defEditionId, label);
    ge.setSoftwareSources(sources);
    registerEdition(ge, true);
    for (String id : edList) {
        label = getEditionLabel(id);
        sources = readChannelSources(id);
        ge = new GraalEdition(id, label);
        ge.setSoftwareSources(sources);
        registerEdition(ge, false);
    }
}
Also used : GraalEdition(org.graalvm.component.installer.model.GraalEdition) SoftwareChannelSource(org.graalvm.component.installer.SoftwareChannelSource)

Example 12 with GraalEdition

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

the class GraalEditionList method initSimple.

/**
 * Performs single-property initialization.
 *
 * @param defEditionId default edition's ID, as it appears (or defaults) in the release file.
 * @param spec specification string.
 */
private void initSimple(String defEditionId, String spec) {
    parseSimpleSpecification(defEditionId, spec);
    if (editions.isEmpty()) {
        String label = getEditionLabel(defEditionId);
        GraalEdition ge = new GraalEdition(defEditionId, label);
        defaultEdition = ge;
        editions.add(ge);
    }
    foreignGraals.put(targetGraal, this);
    ensureDefaultDefined(defEditionId);
}
Also used : GraalEdition(org.graalvm.component.installer.model.GraalEdition)

Example 13 with GraalEdition

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

the class GraalEditionListTest method testParseRelease20EEWithLabel.

@Test
public void testParseRelease20EEWithLabel() throws Exception {
    // this one contains multiple
    loadReleaseFile("release20ee.properties");
    // substitute "ee", since that's what the DirectoryStorage does in presence of
    // 'vm-enterprise' now:
    storage.graalInfo.put(CommonConstants.CAP_EDITION, "ee");
    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(1, eds.size());
    GraalEdition ge = eds.get(0);
    assertSame(list.getDefaultEdition(), ge);
    assertEquals("Expected ee for vm-enterprise", "ee", ge.getId());
    assertEquals("Unqualified label should be picked up", "Enterprise Edition", ge.getDisplayName());
    List<SoftwareChannelSource> sources = ge.getSoftwareSources();
    assertEquals("Multiple software sources must be read", 3, sources.size());
    assertEquals("Expected decreasing priority", 2, sources.get(1).getPriority());
}
Also used : GraalEdition(org.graalvm.component.installer.model.GraalEdition) SoftwareChannelSource(org.graalvm.component.installer.SoftwareChannelSource) Test(org.junit.Test)

Example 14 with GraalEdition

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

the class GraalEditionListTest method checkOverrideCommon.

private void checkOverrideCommon() throws Exception {
    GraalEditionList list = new GraalEditionList(this, this, getLocalRegistry());
    list.setOverrideCatalogSpec("https://www.graalvm.org/component-catalog/graal-updater-component-catalog-java8x.properties");
    List<GraalEdition> eds = list.editions();
    assertEquals(1, eds.size());
    assertEquals(list.getDefaultEdition(), eds.get(0));
    GraalEdition ge = eds.get(0);
    assertEquals("ce", ge.getId());
    assertSame(ge, list.getEdition(null));
    List<SoftwareChannelSource> channels = ge.getSoftwareSources();
    assertEquals(1, channels.size());
    assertTrue(channels.get(0).getLocationURL().endsWith("java8x.properties"));
}
Also used : GraalEdition(org.graalvm.component.installer.model.GraalEdition) SoftwareChannelSource(org.graalvm.component.installer.SoftwareChannelSource)

Example 15 with GraalEdition

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

the class GraalEditionListTest method testCheck21MultipleProperties.

@Test
public void testCheck21MultipleProperties() throws Exception {
    loadReleaseFile("release21ce.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(1, eds.size());
    GraalEdition ge = eds.get(0);
    List<SoftwareChannelSource> sources = ge.getSoftwareSources();
    assertEquals("Expected default edition", "ce", ge.getId());
    assertEquals("Expected 2 sources from multiproperties", 2, sources.size());
}
Also used : GraalEdition(org.graalvm.component.installer.model.GraalEdition) SoftwareChannelSource(org.graalvm.component.installer.SoftwareChannelSource) Test(org.junit.Test)

Aggregations

GraalEdition (org.graalvm.component.installer.model.GraalEdition)15 SoftwareChannelSource (org.graalvm.component.installer.SoftwareChannelSource)7 Test (org.junit.Test)7 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 List (java.util.List)1 Properties (java.util.Properties)1 CommandTestBase (org.graalvm.component.installer.CommandTestBase)1 CommonConstants (org.graalvm.component.installer.CommonConstants)1 FailedOperationException (org.graalvm.component.installer.FailedOperationException)1 CatalogContents (org.graalvm.component.installer.model.CatalogContents)1 ComponentRegistry (org.graalvm.component.installer.model.ComponentRegistry)1 Assert.assertEquals (org.junit.Assert.assertEquals)1 Assert.assertFalse (org.junit.Assert.assertFalse)1 Assert.assertNotNull (org.junit.Assert.assertNotNull)1 Assert.assertNull (org.junit.Assert.assertNull)1 Assert.assertSame (org.junit.Assert.assertSame)1 Assert.assertTrue (org.junit.Assert.assertTrue)1 Assert.fail (org.junit.Assert.fail)1