Search in sources :

Example 26 with ComponentInfo

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

the class InstallerTest method testUninstallComponentWithUserROFiles.

@Test
public void testUninstallComponentWithUserROFiles() throws Exception {
    if (System.getProperty("os.name").toLowerCase().contains("windows")) {
        return;
    }
    setupComponentInstall("trufflerubyWork.jar");
    installer.setPermissions(loader.loadPermissions());
    installer.setSymlinks(loader.loadSymlinks());
    // install
    installer.install();
    ComponentInfo savedInfo = installer.getComponentInfo();
    Path langPath = targetPath.resolve(SystemUtils.fromCommonString("jre/languages/ruby"));
    Path roPath = langPath.resolve(SystemUtils.fromCommonString("doc/user"));
    // and add a new file to that dir:
    Path uf = roPath.resolve(SystemUtils.fileName("userFile.txt"));
    Files.write(uf, Arrays.asList("This file", "Should vanish"));
    Files.setPosixFilePermissions(uf, PosixFilePermissions.fromString("r--r-----"));
    Files.setPosixFilePermissions(roPath, PosixFilePermissions.fromString("r-xr-xr-x"));
    // now uninstall, fileName a new installer.
    Uninstaller uninstaller = new Uninstaller(fb(), fileOps, savedInfo, registry);
    uninstaller.setInstallPath(targetPath);
    uninstaller.uninstallContent();
    assertFalse("All files should be removed after uninstall", Files.list(targetPath).findAny().isPresent());
}
Also used : Path(java.nio.file.Path) ComponentInfo(org.graalvm.component.installer.model.ComponentInfo) Test(org.junit.Test)

Example 27 with ComponentInfo

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

the class ListTest method testListSpecifiedComponents.

/**
 * Tests that 'list' will print matching components.
 */
@Test
public void testListSpecifiedComponents() throws Exception {
    storage.installed.add(new ComponentInfo("org.graalvm.R", "FastR", Version.fromString("1.0.0")));
    storage.installed.add(new ComponentInfo("org.graalvm.ruby", "Ruby", Version.fromString("1.0.0")));
    storage.installed.add(new ComponentInfo("org.graalvm.python", "Python", Version.fromString("1.0.0")));
    ListInstalledCommand inst = new ListInstalledCommand() {

        @Override
        boolean process() {
            super.process();
            // block the actual print
            return false;
        }
    };
    textParams.add("ruby");
    textParams.add("r");
    textParams.add("python");
    inst.init(this, this);
    inst.execute();
    Set<String> found = new HashSet<>();
    assertEquals(3, inst.getComponents().size());
    for (ComponentInfo ci : inst.getComponents()) {
        assertTrue(found.add(ci.getId().toLowerCase()));
    }
    assertTrue(found.contains("org.graalvm.r"));
    assertTrue(found.contains("org.graalvm.ruby"));
    assertTrue(found.contains("org.graalvm.python"));
}
Also used : ComponentInfo(org.graalvm.component.installer.model.ComponentInfo) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 28 with ComponentInfo

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

the class UninstallTest method setupComponentsWithDeps.

private void setupComponentsWithDeps() throws Exception {
    storage.graalInfo.put(CommonConstants.CAP_GRAALVM_VERSION, "19.3-dev");
    Path catalogFile = dataFile("cataloginstallDeps.properties");
    RemoteCatalogDownloader downloader = new RemoteCatalogDownloader(this, this, catalogFile.toUri().toURL());
    componentCatalog = new CatalogContents(this, downloader.getStorage(), getLocalRegistry());
    ComponentInfo ruby = componentCatalog.findComponent("org.graalvm.ruby");
    ComponentInfo fastr = componentCatalog.findComponent("org.graalvm.r");
    Set<ComponentInfo> deps = new HashSet<>();
    componentCatalog.findDependencies(ruby, true, null, deps);
    componentCatalog.findDependencies(fastr, true, null, deps);
    deps.add(ruby);
    deps.add(fastr);
    storage.installed.addAll(deps);
    deps.forEach((ci) -> ci.setInfoPath(""));
}
Also used : Path(java.nio.file.Path) CatalogContents(org.graalvm.component.installer.model.CatalogContents) RemoteCatalogDownloader(org.graalvm.component.installer.remote.RemoteCatalogDownloader) ComponentInfo(org.graalvm.component.installer.model.ComponentInfo) HashSet(java.util.HashSet)

Example 29 with ComponentInfo

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

the class UninstallTest method testUninstallLibraryFailure.

/**
 * Schedules uninstallation of a library. One component should become broken.
 */
@Test
public void testUninstallLibraryFailure() throws Exception {
    setupComponentsWithDeps();
    UninstallCommand uc = new UninstallCommand();
    uc.init(this, this.withBundle(UninstallCommand.class));
    textParams.add("org.graalvm.native-image");
    uc.prepareUninstall();
    assertFalse(uc.getBrokenDependencies().isEmpty());
    assertEquals(1, uc.getUninstallComponents().size());
    ComponentInfo nimage = localRegistry.findComponent("org.graalvm.native-image");
    ComponentInfo ruby = localRegistry.findComponent("org.graalvm.ruby");
    assertSame(nimage, uc.getUninstallComponents().iterator().next());
    Collection<ComponentInfo> broken = uc.getBrokenDependencies().get(nimage);
    assertNotNull(broken);
    assertSame(ruby, broken.iterator().next());
    exception.expect(FailedOperationException.class);
    exception.expectMessage("UNINSTALL_BreakDependenciesTerminate");
    uc.checkBrokenDependencies();
}
Also used : ComponentInfo(org.graalvm.component.installer.model.ComponentInfo) Test(org.junit.Test)

Example 30 with ComponentInfo

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

the class DirectoryStorageTest method testGraalVMCoreComponentRegular.

@Test
public void testGraalVMCoreComponentRegular() throws Exception {
    Files.copy(dataFile("release_simple.properties"), graalVMPath.resolve("release"));
    Set<ComponentInfo> infos = storage.loadComponentMetadata(BundleConstants.GRAAL_COMPONENT_ID);
    assertEquals(1, infos.size());
    ComponentInfo ci = infos.iterator().next();
    assertFalse(ci.isNativeComponent());
}
Also used : 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