Search in sources :

Example 36 with ComponentInfo

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

the class DirectoryStorageTest method testKnowsNativeComponent.

@Test
public void testKnowsNativeComponent() throws Exception {
    copyDir("list3", registryPath);
    Collection<String> ids = storage.listComponentIDs();
    assertTrue(ids.contains("fastr"));
    assertTrue(ids.contains("ruby"));
    Set<ComponentInfo> cis = storage.loadComponentMetadata("ruby");
    assertEquals(1, cis.size());
    ComponentInfo ci = cis.iterator().next();
    assertTrue(ci.isNativeComponent());
}
Also used : ComponentInfo(org.graalvm.component.installer.model.ComponentInfo) Test(org.junit.Test)

Example 37 with ComponentInfo

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

the class DirectoryStorageTest method testLoadComponentMetadata.

/**
 * Test of loadComponentMetadata method, of class RegistryStorage.
 */
@Test
public void testLoadComponentMetadata() throws Exception {
    copyDir("list1", registryPath);
    ComponentInfo info = loadLastComponent("fastr");
    assertEquals("org.graalvm.fastr", info.getId());
    assertEquals("1.0", info.getVersionString());
    assertEquals("0.32", info.getRequiredGraalValues().get("graalvm_version"));
}
Also used : ComponentInfo(org.graalvm.component.installer.model.ComponentInfo) Test(org.junit.Test)

Example 38 with ComponentInfo

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

the class DirectoryStorageTest method testCheckedAcceptedURLLicense.

/**
 * Acceptance test must use transliteration, too.
 *
 * @throws Exception
 */
@Test
public void testCheckedAcceptedURLLicense() throws Exception {
    String urlString = "http://acme.org/license.txt";
    copyDir("list1", registryPath);
    ComponentInfo info = loadLastComponent("fastr");
    enableLicensesForTesting();
    storage.recordLicenseAccepted(info, urlString, "This is a dummy license", null);
    assertNotNull(storage.licenseAccepted(info, urlString));
}
Also used : ComponentInfo(org.graalvm.component.installer.model.ComponentInfo) Test(org.junit.Test)

Example 39 with ComponentInfo

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

the class DirectoryStorageTest method testLicensesNotRecorded.

/**
 * Checks that no license is recorded, as the feature must be disabled.
 */
@Test
public void testLicensesNotRecorded() 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 40 with ComponentInfo

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

the class DirectoryStorageTest method saveComponentOptionalTags.

@Test
public void saveComponentOptionalTags() throws Exception {
    ComponentInfo info = new ComponentInfo("x", "y", "2.0");
    info.setPolyglotRebuild(true);
    info.addWorkingDirectories(Arrays.asList("jre/languages/test/scrap", "jre/lib/test/scrapdir"));
    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-optional.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