Search in sources :

Example 26 with ArtifactContext

use of org.eclipse.ceylon.cmr.api.ArtifactContext in project ceylon by eclipse.

the class SmokeTestCase method testSimpleOSGi.

@Test
public void testSimpleOSGi() throws Exception {
    RepositoryManager manager = getRepositoryManager();
    ArtifactContext context = new ArtifactContext(null, "org.osgi.ceylon.simple", "1.0", ArtifactContext.JAR);
    try {
        Manifest manifest = mockManifest("1.0");
        manifest.getMainAttributes().putValue("Require-Bundle", "moduletest;bundle-version=0.1");
        manager.putArtifact(context, mockJar("foo", "bar".getBytes(), manifest));
        File file = manager.getArtifact(context);
        Assert.assertNotNull(file);
    } finally {
        manager.removeArtifact(context);
    }
}
Also used : RepositoryManager(org.eclipse.ceylon.cmr.api.RepositoryManager) SimpleRepositoryManager(org.eclipse.ceylon.cmr.impl.SimpleRepositoryManager) ArtifactContext(org.eclipse.ceylon.cmr.api.ArtifactContext) Manifest(java.util.jar.Manifest) File(java.io.File) Test(org.junit.Test)

Example 27 with ArtifactContext

use of org.eclipse.ceylon.cmr.api.ArtifactContext in project ceylon by eclipse.

the class SmokeTestCase method testGetMultipleCached.

@Test
public void testGetMultipleCached() throws Exception {
    RepositoryManagerBuilder builder = getRepositoryManagerBuilder(false, 60000, java.net.Proxy.NO_PROXY);
    CmrRepository[] externalRepos = builder.repositoryBuilder().buildRepository(Constants.REPO_URL_CEYLON);
    for (CmrRepository repo : externalRepos) {
        builder.addRepository(repo);
    }
    RepositoryManager manager = builder.buildRepository();
    ArtifactContext artifact1 = new ArtifactContext(null, "ceylon.json", "1.0.0", ArtifactContext.CAR, ArtifactContext.SCRIPTS_ZIPPED, ArtifactContext.JS);
    List<ArtifactResult> json1 = manager.getArtifactResults(artifact1);
    Assert.assertNotNull("Module 'ceylon.json-1.0.0' not found", json1);
    Assert.assertEquals("Expected two artifacts for 'ceylon.json-1.0.0'", 2, json1.size());
    File root = new File(manager.getRepositories().get(1).getDisplayString());
    File missing = new File(root, "ceylon/json/1.0.0/ceylon.json-1.0.0.scripts.zip.missing");
    Assert.assertTrue("Marker file .missing not found", missing.exists());
    ArtifactContext artifact2 = new ArtifactContext(null, "ceylon.json", "1.0.0", ArtifactContext.CAR, ArtifactContext.SCRIPTS_ZIPPED, ArtifactContext.SRC);
    List<ArtifactResult> json2 = manager.getArtifactResults(artifact2);
    Assert.assertNotNull("Module 'ceylon.json-1.0.0' not found", json2);
    Assert.assertEquals("Expected two artifacts for 'ceylon.json-1.0.0'", 2, json2.size());
}
Also used : RepositoryManagerBuilder(org.eclipse.ceylon.cmr.api.RepositoryManagerBuilder) RepositoryManager(org.eclipse.ceylon.cmr.api.RepositoryManager) SimpleRepositoryManager(org.eclipse.ceylon.cmr.impl.SimpleRepositoryManager) ArtifactContext(org.eclipse.ceylon.cmr.api.ArtifactContext) CmrRepository(org.eclipse.ceylon.cmr.api.CmrRepository) File(java.io.File) ArtifactResult(org.eclipse.ceylon.model.cmr.ArtifactResult) Test(org.junit.Test)

Example 28 with ArtifactContext

use of org.eclipse.ceylon.cmr.api.ArtifactContext in project ceylon by eclipse.

the class SmokeTestCase method testOptionalOSGi.

@Test
public void testOptionalOSGi() throws Exception {
    RepositoryManager manager = getRepositoryManager();
    ArtifactContext context = new ArtifactContext(null, "org.osgi.ceylon.optional", "1.0", ArtifactContext.JAR);
    try {
        Manifest manifest = mockManifest("1.0");
        manifest.getMainAttributes().putValue("Require-Bundle", "moduletest;resolution:=optional;bundle-version=0.1");
        manager.putArtifact(context, mockJar("foo", "bar".getBytes(), manifest));
        ArtifactResult result = manager.getArtifactResult(context);
        Assert.assertNotNull(result);
        Assert.assertNotNull(result.dependencies());
        Assert.assertEquals(1, result.dependencies().size());
        ArtifactResult dep1 = result.dependencies().get(0);
        Assert.assertNotNull(dep1);
        Assert.assertTrue(dep1.optional());
    } finally {
        manager.removeArtifact(context);
    }
}
Also used : RepositoryManager(org.eclipse.ceylon.cmr.api.RepositoryManager) SimpleRepositoryManager(org.eclipse.ceylon.cmr.impl.SimpleRepositoryManager) ArtifactContext(org.eclipse.ceylon.cmr.api.ArtifactContext) Manifest(java.util.jar.Manifest) ArtifactResult(org.eclipse.ceylon.model.cmr.ArtifactResult) Test(org.junit.Test)

Example 29 with ArtifactContext

use of org.eclipse.ceylon.cmr.api.ArtifactContext in project ceylon by eclipse.

the class SmokeTestCase method testPropertiesGet.

@Test
public void testPropertiesGet() throws Exception {
    RepositoryManagerBuilder builder = getRepositoryManagerBuilder(false, 60000, java.net.Proxy.NO_PROXY);
    RepositoryBuilder rb = builder.repositoryBuilder();
    CmrRepository[] repositories = rb.buildRepository(Constants.REPO_URL_CEYLON);
    for (CmrRepository repo : repositories) {
        builder.addRepository(repo);
    }
    RepositoryManager manager = builder.buildRepository();
    ArtifactContext context = new ArtifactContext(null, "io.undertow.core", "1.0.0.Alpha1-9fdfd5f766", ArtifactContext.JAR);
    try {
        File artifact = manager.getArtifact(context);
        Assert.assertNotNull(artifact);
        File mp = new File(artifact.getParent(), ArtifactContext.MODULE_PROPERTIES);
        Assert.assertNotNull(mp.exists());
    } finally {
        manager.removeArtifact(context);
    }
}
Also used : RepositoryManagerBuilder(org.eclipse.ceylon.cmr.api.RepositoryManagerBuilder) RepositoryBuilder(org.eclipse.ceylon.cmr.api.RepositoryBuilder) RepositoryManager(org.eclipse.ceylon.cmr.api.RepositoryManager) SimpleRepositoryManager(org.eclipse.ceylon.cmr.impl.SimpleRepositoryManager) ArtifactContext(org.eclipse.ceylon.cmr.api.ArtifactContext) CmrRepository(org.eclipse.ceylon.cmr.api.CmrRepository) File(java.io.File) Test(org.junit.Test)

Example 30 with ArtifactContext

use of org.eclipse.ceylon.cmr.api.ArtifactContext in project ceylon by eclipse.

the class JarUtils method publish.

public static void publish(File outputFile, File sha1File, ArtifactContext context, RepositoryManager repoManager, Logger log) {
    try {
        context.setForceOperation(true);
        // In putting we're effectively renaming
        repoManager.putArtifact(context, outputFile);
        ArtifactContext sha1Context = context.getSha1Context();
        sha1Context.setForceOperation(true);
        repoManager.putArtifact(sha1Context, sha1File);
    } catch (RuntimeException x) {
        log.error("Failed to write module to repository: " + x.getMessage());
        // fatal errors go all the way up but don't print anything if we logged an error
        throw x;
    } finally {
        // now cleanup
        outputFile.delete();
        sha1File.delete();
    }
}
Also used : ArtifactContext(org.eclipse.ceylon.cmr.api.ArtifactContext)

Aggregations

ArtifactContext (org.eclipse.ceylon.cmr.api.ArtifactContext)62 File (java.io.File)33 ArtifactResult (org.eclipse.ceylon.model.cmr.ArtifactResult)25 RepositoryManager (org.eclipse.ceylon.cmr.api.RepositoryManager)22 Test (org.junit.Test)20 SimpleRepositoryManager (org.eclipse.ceylon.cmr.impl.SimpleRepositoryManager)17 IOException (java.io.IOException)13 CmrRepository (org.eclipse.ceylon.cmr.api.CmrRepository)9 MavenArtifactContext (org.eclipse.ceylon.cmr.api.MavenArtifactContext)7 ModuleSpec (org.eclipse.ceylon.common.ModuleSpec)6 ArrayList (java.util.ArrayList)5 RepositoryManagerBuilder (org.eclipse.ceylon.cmr.api.RepositoryManagerBuilder)5 Manifest (java.util.jar.Manifest)4 ModuleVersionDetails (org.eclipse.ceylon.cmr.api.ModuleVersionDetails)4 Module (org.eclipse.ceylon.model.typechecker.model.Module)4 ByteArrayInputStream (java.io.ByteArrayInputStream)3 FileWriter (java.io.FileWriter)3 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 Map (java.util.Map)3