Search in sources :

Example 41 with ComponentInfo

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

the class DirectoryStorageTest method testExplicitCoreMetadata.

/**
 * Checks that the core component registration is loaded, if present.
 */
@Test
public void testExplicitCoreMetadata() throws Exception {
    Files.copy(dataFile("release_simple.properties"), graalVMPath.resolve("release"));
    Files.copy(dataFile("graalvmcore.properties"), registryPath.resolve(BundleConstants.GRAAL_COMPONENT_ID + ".component"));
    Set<ComponentInfo> loaded = storage.loadComponentMetadata(BundleConstants.GRAAL_COMPONENT_ID);
    assertEquals(1, loaded.size());
    ComponentInfo ci = loaded.iterator().next();
    assertNotNull(ci);
    assertEquals(StabilityLevel.Experimental, ci.getStability());
    assertFalse(ci.isNativeComponent());
    assertEquals(DistributionType.BUNDLED, ci.getDistributionType());
}
Also used : ComponentInfo(org.graalvm.component.installer.model.ComponentInfo) Test(org.junit.Test)

Example 42 with ComponentInfo

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

the class DirectoryStorageTest method testStabilityLevelSaved.

/**
 * Checks that the 'stability level' is saved to the registry.
 */
@Test
public void testStabilityLevelSaved() throws Exception {
    ComponentInfo info = new ComponentInfo("x", "y", "2.0");
    info.setStability(StabilityLevel.Experimental_Earlyadopter);
    storage.saveComponent(info);
    Properties props = new Properties();
    try (InputStream is = Files.newInputStream(registryPath.resolve("x.component"))) {
        props.load(is);
    }
    // check the -Level was saved, and corresponds to the enum's text
    String p = props.getProperty(BundleConstants.BUNDLE_STABILITY2);
    assertEquals(StabilityLevel.Experimental_Earlyadopter.toString(), p);
    assertNull(props.getProperty(BundleConstants.BUNDLE_STABILITY));
    // recreate the storage:
    storage = new DirectoryStorage(this, registryPath, graalVMPath);
    // the default assumed by most test data.
    storage.setJavaVersion("8");
    Set<ComponentInfo> loaded = storage.loadComponentMetadata("x");
    assertEquals(1, loaded.size());
    ComponentInfo compare = loaded.iterator().next();
    assertEquals(info.getStability(), compare.getStability());
}
Also used : InputStream(java.io.InputStream) ComponentInfo(org.graalvm.component.installer.model.ComponentInfo) Properties(java.util.Properties) Test(org.junit.Test)

Example 43 with ComponentInfo

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

the class UpgradeTest method testInstallWithoutCoreUpgrade.

/**
 * Checks installation without core , even though the user has specified the version. Simulates
 * "gu install ruby" on 1.0.1.0 installation which ought to install 1.0.1.1
 */
@Test
public void testInstallWithoutCoreUpgrade() throws Exception {
    initVersion("1.0.1.0");
    ComponentInfo ci = new ComponentInfo("org.graalvm.ruby", "Installed Ruby", "1.0.1.0");
    storage.installed.add(ci);
    helper.resetExistingComponents();
    ComponentInfo info = helper.findGraalVersion(Version.fromString("1.0.1").match(Version.Match.Type.COMPATIBLE));
    assertNotNull(info);
    boolean inst = helper.installGraalCore(info);
    assertFalse(inst);
}
Also used : ComponentInfo(org.graalvm.component.installer.model.ComponentInfo) Test(org.junit.Test)

Example 44 with ComponentInfo

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

the class UpgradeTest method testInstallIntoExistingRelease.

/**
 * Fails on non-empty directory.
 */
@Test
public void testInstallIntoExistingRelease() throws Exception {
    initVersion("1.0.0.0");
    ComponentInfo ci = new ComponentInfo("org.graalvm.ruby", "Installed Ruby", "1.0.0.0");
    storage.installed.add(ci);
    textParams.add("ruby");
    UpgradeCommand cmd = new UpgradeCommand();
    cmd.init(this, this);
    helper = cmd.getProcess();
    ComponentInfo info = cmd.configureProcess();
    Path p = getGraalHomePath().normalize();
    Path ndir = graalVMDirectory(p, "1.0.1");
    Files.createDirectories(ndir);
    Files.write(ndir.resolve("some-content"), Arrays.asList("Fail"));
    Path toCopy = dataFile("../persist/release_simple.properties");
    Files.copy(toCopy, ndir.resolve("release"));
    exception.expect(FailedOperationException.class);
    exception.expectMessage("UPGRADE_TargetExistsContainsGraalVM");
    helper.prepareInstall(info);
}
Also used : Path(java.nio.file.Path) ComponentInfo(org.graalvm.component.installer.model.ComponentInfo) Test(org.junit.Test)

Example 45 with ComponentInfo

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

the class UpgradeTest method testInstallIntoExistingNonempty.

/**
 * Fails on non-empty directory.
 */
@Test
public void testInstallIntoExistingNonempty() throws Exception {
    initVersion("1.0.0.0");
    ComponentInfo ci = new ComponentInfo("org.graalvm.ruby", "Installed Ruby", "1.0.0.0");
    storage.installed.add(ci);
    textParams.add("ruby");
    UpgradeCommand cmd = new UpgradeCommand();
    cmd.init(this, this);
    helper = cmd.getProcess();
    ComponentInfo info = cmd.configureProcess();
    Path p = getGraalHomePath().normalize();
    Path ndir = graalVMDirectory(p, "1.0.1");
    Files.createDirectories(ndir);
    Files.write(ndir.resolve("some-content"), Arrays.asList("Fail"));
    exception.expect(FailedOperationException.class);
    exception.expectMessage("UPGRADE_TargetExistsNotEmpty");
    helper.prepareInstall(info);
}
Also used : Path(java.nio.file.Path) ComponentInfo(org.graalvm.component.installer.model.ComponentInfo) Test(org.junit.Test)

Aggregations

ComponentInfo (org.graalvm.component.installer.model.ComponentInfo)149 Test (org.junit.Test)94 Path (java.nio.file.Path)36 Version (org.graalvm.component.installer.Version)28 HashSet (java.util.HashSet)20 ArrayList (java.util.ArrayList)19 ComponentParam (org.graalvm.component.installer.ComponentParam)19 IOException (java.io.IOException)13 URL (java.net.URL)11 MetadataLoader (org.graalvm.component.installer.persist.MetadataLoader)10 InputStream (java.io.InputStream)9 HashMap (java.util.HashMap)9 Collection (java.util.Collection)8 List (java.util.List)8 Properties (java.util.Properties)8 Map (java.util.Map)7 Set (java.util.Set)7 Collections (java.util.Collections)6 FailedOperationException (org.graalvm.component.installer.FailedOperationException)6 SystemUtils (org.graalvm.component.installer.SystemUtils)6