Search in sources :

Example 51 with ComponentInfo

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

the class UpgradeTest method testRefuseUnsatisfiedCommandline.

/**
 * Checks "gu upgrade 1.1.0". Should fail because ruby is not available in 1.1.x
 */
@Test
public void testRefuseUnsatisfiedCommandline() throws Exception {
    initVersion("1.0.0.0");
    ComponentInfo ci = new ComponentInfo("org.graalvm.ruby", "Installed Ruby", "1.0.0.0");
    textParams.add("1.1.0");
    storage.installed.add(ci);
    exception.expect(FailedOperationException.class);
    exception.expectMessage("UPGRADE_ComponentsCannotMigrate");
    UpgradeCommand cmd = new UpgradeCommand();
    cmd.init(this, this);
    cmd.execute();
}
Also used : ComponentInfo(org.graalvm.component.installer.model.ComponentInfo) Test(org.junit.Test)

Example 52 with ComponentInfo

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

the class UpgradeTest method testRefuseUpgradeUnsatisfiedComponent.

@Test
public void testRefuseUpgradeUnsatisfiedComponent() throws Exception {
    exception.expect(FailedOperationException.class);
    exception.expectMessage("UPGRADE_ComponentsCannotMigrate");
    initVersion("1.0.0.0");
    ComponentInfo ci = new ComponentInfo("org.graalvm.ruby", "Installed Ruby", "1.0.0.0");
    storage.installed.add(ci);
    helper.resetExistingComponents();
    ComponentInfo info = helper.findGraalVersion(Version.fromString("1.1.0").match(Version.Match.Type.COMPATIBLE));
    assertNotNull(info);
}
Also used : ComponentInfo(org.graalvm.component.installer.model.ComponentInfo) Test(org.junit.Test)

Example 53 with ComponentInfo

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

the class DirectoryMetaLoader method loadPaths.

@Override
public void loadPaths() {
    ComponentInfo cinfo = getComponentInfo();
    Set<String> emptyDirectories = new HashSet<>();
    List<String> files = new ArrayList<>();
    try {
        Files.walk(rootDir).forEachOrdered((Path en) -> {
            String eName = SystemUtils.toCommonPath(en);
            if (eName.startsWith(META_INF_PATH)) {
                return;
            }
            int li = eName.lastIndexOf("/", Files.isDirectory(en) ? eName.length() - 2 : eName.length() - 1);
            if (li > 0) {
                emptyDirectories.remove(eName.substring(0, li + 1));
            }
            if (Files.isDirectory(en)) {
                // directory names always come first
                emptyDirectories.add(eName);
            } else {
                files.add(eName);
            }
        });
        addFiles(new ArrayList<>(emptyDirectories));
        // sort empty directories first
        Collections.sort(files);
        cinfo.addPaths(files);
        addFiles(files);
    } catch (IOException ex) {
        throw new UncheckedIOException(ex);
    }
}
Also used : Path(java.nio.file.Path) ArrayList(java.util.ArrayList) UncheckedIOException(java.io.UncheckedIOException) ComponentInfo(org.graalvm.component.installer.model.ComponentInfo) IOException(java.io.IOException) UncheckedIOException(java.io.UncheckedIOException) HashSet(java.util.HashSet)

Example 54 with ComponentInfo

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

the class DirectoryStorageTest method loadComponentFiles.

/**
 * Should strip whitespaces around.
 *
 * @throws Exception
 */
@Test
public void loadComponentFiles() throws Exception {
    copyDir("list1", registryPath);
    ComponentInfo info = loadLastComponent("fastr");
    storage.loadComponentFiles(info);
    List<String> paths = info.getPaths();
    assertEquals(Arrays.asList("bin/", "bin/R", "bin/Rscript"), paths.subList(0, 3));
}
Also used : ComponentInfo(org.graalvm.component.installer.model.ComponentInfo) Test(org.junit.Test)

Example 55 with ComponentInfo

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

the class DirectoryStorageTest method testGraalVMCoreComponentNative.

@Test
public void testGraalVMCoreComponentNative() throws Exception {
    // fake a release file
    Files.copy(dataFile("release_simple.properties"), graalVMPath.resolve("release"));
    Path meta = registryPath.resolve(BundleConstants.GRAAL_COMPONENT_ID + ".meta");
    // create the component storage, tag core component with .meta file
    Files.createFile(meta);
    Set<ComponentInfo> infos = storage.loadComponentMetadata(BundleConstants.GRAAL_COMPONENT_ID);
    assertEquals(1, infos.size());
    ComponentInfo ci = infos.iterator().next();
    assertTrue(ci.isNativeComponent());
}
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