Search in sources :

Example 31 with ComponentInfo

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

the class DirectoryStorageTest method testLicensesDecativated.

/**
 * Checks that license management is disabled, that is no license is reported as accepted even
 * if the data (by some miracle) exist.
 */
@Test
public void testLicensesDecativated() throws Exception {
    copyDir("list1", registryPath);
    ComponentInfo info = loadLastComponent("fastr");
    Path p = registryPath.resolve(SystemUtils.fromCommonString("licenses/cafebabe.accepted/org.graalvm.fastr"));
    Files.createDirectories(p.getParent());
    Files.write(p, Arrays.asList("ahoj"));
    assertNull(storage.licenseAccepted(info, "cafebabe"));
}
Also used : Path(java.nio.file.Path) ComponentInfo(org.graalvm.component.installer.model.ComponentInfo) Test(org.junit.Test)

Example 32 with ComponentInfo

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

the class DirectoryStorageTest method testSaveComponent.

@Test
public void testSaveComponent() throws Exception {
    ComponentInfo info = new ComponentInfo("x", "y", "2.0");
    info.addRequiredValue("a", "b");
    Path p = registryPath.resolve(SystemUtils.fileName("x.component"));
    assertFalse(Files.exists(p));
    storage.saveComponent(info);
    assertTrue(Files.exists(p));
    List<String> lines = Files.readAllLines(p).stream().filter((l) -> !l.startsWith("#")).collect(Collectors.toList());
    List<String> golden = Files.readAllLines(dataFile("golden-save-component.properties")).stream().filter((l) -> !l.startsWith("#")).collect(Collectors.toList());
    golden.sort(String.CASE_INSENSITIVE_ORDER);
    lines.sort(String.CASE_INSENSITIVE_ORDER);
    assertEquals(golden, lines);
}
Also used : Path(java.nio.file.Path) Arrays(java.util.Arrays) CommandTestBase(org.graalvm.component.installer.CommandTestBase) BeforeClass(org.junit.BeforeClass) PosixFileAttributeView(java.nio.file.attribute.PosixFileAttributeView) HashMap(java.util.HashMap) StandardCopyOption(java.nio.file.StandardCopyOption) MessageFormat(java.text.MessageFormat) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) PosixFilePermissions(java.nio.file.attribute.PosixFilePermissions) BundleConstants(org.graalvm.component.installer.BundleConstants) TestName(org.junit.rules.TestName) Map(java.util.Map) After(org.junit.After) Assume(org.junit.Assume) Path(java.nio.file.Path) ExpectedException(org.junit.rules.ExpectedException) Before(org.junit.Before) Version(org.graalvm.component.installer.Version) AfterClass(org.junit.AfterClass) Properties(java.util.Properties) Files(java.nio.file.Files) CommonConstants(org.graalvm.component.installer.CommonConstants) Assert.assertNotNull(org.junit.Assert.assertNotNull) Collection(java.util.Collection) StabilityLevel(org.graalvm.component.installer.model.StabilityLevel) Assert.assertTrue(org.junit.Assert.assertTrue) Set(java.util.Set) IOException(java.io.IOException) Test(org.junit.Test) ComponentInfo(org.graalvm.component.installer.model.ComponentInfo) Collectors(java.util.stream.Collectors) FailedOperationException(org.graalvm.component.installer.FailedOperationException) SystemUtils(org.graalvm.component.installer.SystemUtils) List(java.util.List) DistributionType(org.graalvm.component.installer.model.DistributionType) Assert.assertNull(org.junit.Assert.assertNull) Rule(org.junit.Rule) Assert.assertFalse(org.junit.Assert.assertFalse) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals) TemporaryFolder(org.junit.rules.TemporaryFolder) InputStream(java.io.InputStream) ComponentInfo(org.graalvm.component.installer.model.ComponentInfo) Test(org.junit.Test)

Example 33 with ComponentInfo

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

the class DirectoryStorageTest method testLoadComponentMetadata2.

/**
 * Test of loadComponentMetadata method, of class RegistryStorage.
 */
@Test
public void testLoadComponentMetadata2() throws Exception {
    copyDir("list1", registryPath);
    ComponentInfo info = loadLastComponent("fastr-2");
    assertEquals("org.graalvm.fastr", info.getId());
    assertTrue(info.isPolyglotRebuild());
    assertTrue(info.getWorkingDirectories().contains("jre/languages/test/scrap"));
    assertTrue(info.getWorkingDirectories().contains("jre/lib/test/scrapdir"));
}
Also used : ComponentInfo(org.graalvm.component.installer.model.ComponentInfo) Test(org.junit.Test)

Example 34 with ComponentInfo

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

the class DirectoryStorageTest method testLoadProvidedCapabilities.

@Test
public void testLoadProvidedCapabilities() throws Exception {
    Path p = dataFile("data/core1.component");
    ComponentInfo info;
    try (InputStream is = Files.newInputStream(p)) {
        info = storage.loadMetadataFrom(is);
    }
    assertEquals("org.graalvm", info.getId());
    assertEquals(Version.fromString("1.0.1.0"), info.getProvidedValue("version", Version.class));
    assertEquals("ee", info.getProvidedValue("edition", String.class));
}
Also used : Path(java.nio.file.Path) Version(org.graalvm.component.installer.Version) InputStream(java.io.InputStream) ComponentInfo(org.graalvm.component.installer.model.ComponentInfo) Test(org.junit.Test)

Example 35 with ComponentInfo

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

the class DirectoryStorageTest method testSaveComponentWithCapabilities.

@Test
public void testSaveComponentWithCapabilities() throws Exception {
    ComponentInfo info = new ComponentInfo("x", "y", "2.0");
    info.provideValue("a", "foo");
    info.provideValue("v", Version.fromString("1.1.1"));
    Path p = registryPath.resolve(SystemUtils.fileName("x.component"));
    assertFalse(Files.exists(p));
    storage.saveComponent(info);
    assertTrue(Files.exists(p));
    List<String> lines = Files.readAllLines(p).stream().filter((l) -> !l.startsWith("#")).collect(Collectors.toList());
    List<String> golden = Files.readAllLines(dataFile("golden-save-component2.properties")).stream().filter((l) -> !l.startsWith("#")).collect(Collectors.toList());
    golden.sort(String.CASE_INSENSITIVE_ORDER);
    lines.sort(String.CASE_INSENSITIVE_ORDER);
    assertEquals(golden, lines);
}
Also used : Path(java.nio.file.Path) Arrays(java.util.Arrays) CommandTestBase(org.graalvm.component.installer.CommandTestBase) BeforeClass(org.junit.BeforeClass) PosixFileAttributeView(java.nio.file.attribute.PosixFileAttributeView) HashMap(java.util.HashMap) StandardCopyOption(java.nio.file.StandardCopyOption) MessageFormat(java.text.MessageFormat) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) PosixFilePermissions(java.nio.file.attribute.PosixFilePermissions) BundleConstants(org.graalvm.component.installer.BundleConstants) TestName(org.junit.rules.TestName) Map(java.util.Map) After(org.junit.After) Assume(org.junit.Assume) Path(java.nio.file.Path) ExpectedException(org.junit.rules.ExpectedException) Before(org.junit.Before) Version(org.graalvm.component.installer.Version) AfterClass(org.junit.AfterClass) Properties(java.util.Properties) Files(java.nio.file.Files) CommonConstants(org.graalvm.component.installer.CommonConstants) Assert.assertNotNull(org.junit.Assert.assertNotNull) Collection(java.util.Collection) StabilityLevel(org.graalvm.component.installer.model.StabilityLevel) Assert.assertTrue(org.junit.Assert.assertTrue) Set(java.util.Set) IOException(java.io.IOException) Test(org.junit.Test) ComponentInfo(org.graalvm.component.installer.model.ComponentInfo) Collectors(java.util.stream.Collectors) FailedOperationException(org.graalvm.component.installer.FailedOperationException) SystemUtils(org.graalvm.component.installer.SystemUtils) List(java.util.List) DistributionType(org.graalvm.component.installer.model.DistributionType) Assert.assertNull(org.junit.Assert.assertNull) Rule(org.junit.Rule) Assert.assertFalse(org.junit.Assert.assertFalse) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals) TemporaryFolder(org.junit.rules.TemporaryFolder) InputStream(java.io.InputStream) 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