Search in sources :

Example 16 with Patten

use of org.wso2.ballerinalang.compiler.packaging.Patten in project ballerina by ballerina-lang.

the class PattenTest method testBalExpansion.

@Test
public void testBalExpansion() {
    Converter<String> mock = mockResolver("project-dir", null, null, s -> Stream.of(s + " > dir1 > x.bal", s + " > y.bal", s + " > dir2 > dir3 > f.bal"));
    Patten subject = new Patten(Patten.WILDCARD_SOURCE);
    List<String> strings = subject.convert(mock).collect(Collectors.toList());
    Assert.assertEquals(strings, Arrays.asList("project-dir > dir1 > x.bal", "project-dir > y.bal", "project-dir > dir2 > dir3 > f.bal"));
}
Also used : Patten(org.wso2.ballerinalang.compiler.packaging.Patten) Test(org.testng.annotations.Test)

Example 17 with Patten

use of org.wso2.ballerinalang.compiler.packaging.Patten in project ballerina by ballerina-lang.

the class PattenTest method testSiblingPath.

@Test
public void testSiblingPath() {
    Patten subject = new Patten(path("first", "second", "third-a"));
    Patten result = subject.sibling(path("third-b"));
    Assert.assertEquals("$/first/second/third-b", result.toString());
}
Also used : Patten(org.wso2.ballerinalang.compiler.packaging.Patten) Test(org.testng.annotations.Test)

Example 18 with Patten

use of org.wso2.ballerinalang.compiler.packaging.Patten in project ballerina by ballerina-lang.

the class PattenTest method testLazy.

/**
 * Disabled because it fails in JVM 8
 * See: https://bugs.openjdk.java.net/browse/JDK-8075939
 */
@Test(enabled = false)
public void testLazy() {
    Converter<String> mock = mockResolver("root-dir", null, s -> Stream.concat(Stream.of("", ""), Stream.generate(() -> {
        Assert.fail("method called. Hence not lazy.");
        return "";
    })), null);
    Patten subject = new Patten(Patten.WILDCARD_DIR);
    List<String> strings = subject.convert(mock).limit(1).collect(Collectors.toList());
    Assert.assertTrue(strings.isEmpty());
}
Also used : Patten(org.wso2.ballerinalang.compiler.packaging.Patten) Test(org.testng.annotations.Test)

Example 19 with Patten

use of org.wso2.ballerinalang.compiler.packaging.Patten in project ballerina by ballerina-lang.

the class RepoTest method testProjectObjRepo.

@Test
public void testProjectObjRepo() {
    PackageID pkg = newPackageID("my_org", "my.pkg", "1.2.3");
    ObjRepo subject = new ObjRepo((PathConverter) null);
    Patten patten = subject.calculate(pkg);
    Assert.assertEquals(patten.toString(), "$/repo/my_org/my.pkg/1.2.3/obj/my.pkg.balo");
}
Also used : PackageID(org.ballerinalang.model.elements.PackageID) ObjRepo(org.wso2.ballerinalang.compiler.packaging.repo.ObjRepo) Patten(org.wso2.ballerinalang.compiler.packaging.Patten) Test(org.testng.annotations.Test)

Example 20 with Patten

use of org.wso2.ballerinalang.compiler.packaging.Patten in project ballerina by ballerina-lang.

the class RepoTest method testSystemOrgIsReserved.

@Test
public void testSystemOrgIsReserved() {
    PackageID pkg = newPackageID("ballerina", "any.pkg", "10.2.3");
    Repo subject = new NonSysRepo<String>(null) {

        @Override
        public Patten calculateNonSysPkg(PackageID pkg) {
            Assert.fail("Tried to calculate path for system packages");
            return null;
        }
    };
    Patten patten = subject.calculate(pkg);
    Assert.assertEquals(patten, Patten.NULL);
}
Also used : ObjRepo(org.wso2.ballerinalang.compiler.packaging.repo.ObjRepo) ProjectSourceRepo(org.wso2.ballerinalang.compiler.packaging.repo.ProjectSourceRepo) HomeRepo(org.wso2.ballerinalang.compiler.packaging.repo.HomeRepo) Repo(org.wso2.ballerinalang.compiler.packaging.repo.Repo) CacheRepo(org.wso2.ballerinalang.compiler.packaging.repo.CacheRepo) NonSysRepo(org.wso2.ballerinalang.compiler.packaging.repo.NonSysRepo) PackageID(org.ballerinalang.model.elements.PackageID) NonSysRepo(org.wso2.ballerinalang.compiler.packaging.repo.NonSysRepo) Patten(org.wso2.ballerinalang.compiler.packaging.Patten) Test(org.testng.annotations.Test)

Aggregations

Patten (org.wso2.ballerinalang.compiler.packaging.Patten)20 Test (org.testng.annotations.Test)16 PackageID (org.ballerinalang.model.elements.PackageID)6 Path (java.nio.file.Path)5 URI (java.net.URI)3 ProjectSourceRepo (org.wso2.ballerinalang.compiler.packaging.repo.ProjectSourceRepo)3 Repo (org.wso2.ballerinalang.compiler.packaging.repo.Repo)3 BLangCompilerException (org.ballerinalang.compiler.BLangCompilerException)2 PackageSourceEntry (org.ballerinalang.repository.PackageSourceEntry)2 Converter (org.wso2.ballerinalang.compiler.packaging.converters.Converter)2 PathConverter (org.wso2.ballerinalang.compiler.packaging.converters.PathConverter)2 CacheRepo (org.wso2.ballerinalang.compiler.packaging.repo.CacheRepo)2 HomeRepo (org.wso2.ballerinalang.compiler.packaging.repo.HomeRepo)2 ObjRepo (org.wso2.ballerinalang.compiler.packaging.repo.ObjRepo)2 RemoteRepo (org.wso2.ballerinalang.compiler.packaging.repo.RemoteRepo)2 IOException (java.io.IOException)1 URISyntaxException (java.net.URISyntaxException)1 MissingResourceException (java.util.MissingResourceException)1 URIConverter (org.wso2.ballerinalang.compiler.packaging.converters.URIConverter)1 JarRepo (org.wso2.ballerinalang.compiler.packaging.repo.JarRepo)1