Search in sources :

Example 6 with GraalEdition

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

the class GraalEditionListTest method testParseRelease20CatalogProperty.

/**
 * Checks that GraalVM 20.x style single property is parsed properly. Multiple SoftwareChannel
 * Sources should be created, but just one Edition, the default one.
 *
 * @throws Exception
 */
@Test
public void testParseRelease20CatalogProperty() throws Exception {
    loadReleaseFile("release20ce.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(1, eds.size());
    GraalEdition ge = eds.get(0);
    assertSame(list.getDefaultEdition(), ge);
    assertEquals("Expected ce edition", "ce", ge.getId());
    assertEquals("Label from graal caps should be capitalized", "CE", ge.getDisplayName());
}
Also used : GraalEdition(org.graalvm.component.installer.model.GraalEdition) Test(org.junit.Test)

Example 7 with GraalEdition

use of org.graalvm.component.installer.model.GraalEdition 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 GraalEdition

use of org.graalvm.component.installer.model.GraalEdition 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 GraalEdition

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

the class GraalEditionListTest method testEmptyReleaseInitializesOK.

@Test
public void testEmptyReleaseInitializesOK() throws Exception {
    loadReleaseFile("emptyRelease.properties");
    storage.graalInfo.put(CommonConstants.CAP_EDITION, "ee");
    GraalEditionList list = new GraalEditionList(this, this, getLocalRegistry());
    GraalEdition ge = list.getDefaultEdition();
    assertNotNull(ge);
    assertEquals("ee", ge.getId());
    assertEquals(0, ge.getSoftwareSources().size());
}
Also used : GraalEdition(org.graalvm.component.installer.model.GraalEdition) Test(org.junit.Test)

Example 10 with GraalEdition

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

the class GraalEditionList method getEdition.

/**
 * Gets an edition with the specified ID. Throws an exception, if that edition does not exist.
 *
 * @param id edition id. "" or null means default edition.
 * @return edition instance
 * @throws FailedOperationException if no such edition is configured.
 */
public GraalEdition getEdition(String id) {
    if (id == null || "".equals(id)) {
        return getDefaultEdition();
    } else {
        init();
        GraalEdition e = editionMap.get(id.toLowerCase(Locale.ENGLISH));
        if (e == null) {
            throw feedback.failure("ERR_NoSuchEdition", null, id);
        }
        return e;
    }
}
Also used : GraalEdition(org.graalvm.component.installer.model.GraalEdition)

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