Search in sources :

Example 1 with DefaultRepository

use of org.eclipse.ceylon.cmr.impl.DefaultRepository in project ceylon by eclipse.

the class AbstractTest method getRepositoryManagerBuilder.

protected RepositoryManagerBuilder getRepositoryManagerBuilder(File root, boolean offline, int timeout, Proxy proxy, String overrideFileName) throws Exception {
    RepositoryManagerBuilder builder = new RepositoryManagerBuilder(temp.toFile(), log, offline, timeout, proxy, RepositoryManagerBuilder.parseOverrides(overrideFileName));
    builder.addRepository(new DefaultRepository(new FileContentStore(root).createRoot()));
    return builder;
}
Also used : RepositoryManagerBuilder(org.eclipse.ceylon.cmr.api.RepositoryManagerBuilder) DefaultRepository(org.eclipse.ceylon.cmr.impl.DefaultRepository) FileContentStore(org.eclipse.ceylon.cmr.impl.FileContentStore)

Example 2 with DefaultRepository

use of org.eclipse.ceylon.cmr.impl.DefaultRepository in project ceylon by eclipse.

the class HerdTestCase method getRepositoryManager.

private RepositoryManager getRepositoryManager(File root, boolean offline, int timeout, String apiVersion) throws Exception {
    RepositoryManagerBuilder builder = getRepositoryManagerBuilder(root, offline, timeout, java.net.Proxy.NO_PROXY);
    WebDAVContentStore rcs = new WebDAVContentStore(HERD_URL, log, false, 60000, java.net.Proxy.NO_PROXY, apiVersion);
    CmrRepository repo = new DefaultRepository(rcs.createRoot());
    return builder.addRepository(repo).buildRepository();
}
Also used : RepositoryManagerBuilder(org.eclipse.ceylon.cmr.api.RepositoryManagerBuilder) DefaultRepository(org.eclipse.ceylon.cmr.impl.DefaultRepository) CmrRepository(org.eclipse.ceylon.cmr.api.CmrRepository) WebDAVContentStore(org.eclipse.ceylon.cmr.webdav.WebDAVContentStore)

Example 3 with DefaultRepository

use of org.eclipse.ceylon.cmr.impl.DefaultRepository in project ceylon by eclipse.

the class CallbackTestCase method doTest.

protected void doTest(ArtifactContext context, TestArtifactCallback callback) throws Exception {
    String repoURL = "http://jboss-as7-modules-repository.googlecode.com/svn/trunk/ceylon";
    try {
        new URL(repoURL).openStream();
    } catch (Exception e) {
        log.error(String.format("Cannot connect to repo %s - %s", repoURL, e));
        // probably not on the internet?
        return;
    }
    RepositoryManagerBuilder builder = getRepositoryManagerBuilder(false, 60000, java.net.Proxy.NO_PROXY);
    RemoteContentStore rcs = new RemoteContentStore(repoURL, log, false, 60000, java.net.Proxy.NO_PROXY);
    CmrRepository repo = new DefaultRepository(rcs.createRoot());
    RepositoryManager manager = builder.addRepository(repo).buildRepository();
    try {
        File file = manager.getArtifact(context);
        Assert.assertNotNull(file);
        Assert.assertTrue(callback.size > 0);
        Assert.assertEquals(callback.size, callback.current);
    } catch (Exception re) {
        Assert.assertNotNull(callback.ts);
        Assert.assertNotNull(callback.err);
        Assert.assertEquals(callback.ts, callback.err.getMessage());
    } finally {
        manager.removeArtifact(null, name, version);
        // test if remove really works
        testSearchResults("org.eclipse.fizbiz", ModuleQuery.Type.JVM, new ModuleSearchResult.ModuleDetails[0]);
    }
}
Also used : RepositoryManagerBuilder(org.eclipse.ceylon.cmr.api.RepositoryManagerBuilder) DefaultRepository(org.eclipse.ceylon.cmr.impl.DefaultRepository) RepositoryManager(org.eclipse.ceylon.cmr.api.RepositoryManager) RemoteContentStore(org.eclipse.ceylon.cmr.impl.RemoteContentStore) CmrRepository(org.eclipse.ceylon.cmr.api.CmrRepository) File(java.io.File) ModuleSearchResult(org.eclipse.ceylon.cmr.api.ModuleSearchResult) URL(java.net.URL)

Example 4 with DefaultRepository

use of org.eclipse.ceylon.cmr.impl.DefaultRepository in project ceylon by eclipse.

the class SmokeTestCase method testRemoteContent.

@Test
public void testRemoteContent() throws Exception {
    String repoURL = "http://jboss-as7-modules-repository.googlecode.com/svn/trunk/ceylon";
    try {
        new URL(repoURL).openStream();
    } catch (Exception e) {
        log.error(String.format("Cannot connect to repo %s - %s", repoURL, e));
        // probably not on the internet?
        return;
    }
    RepositoryManagerBuilder builder = getRepositoryManagerBuilder(false, 60000, java.net.Proxy.NO_PROXY);
    RemoteContentStore rcs = new RemoteContentStore(repoURL, log, false, 60000, java.net.Proxy.NO_PROXY);
    CmrRepository repo = new DefaultRepository(rcs.createRoot());
    RepositoryManager manager = builder.addRepository(repo).buildRepository();
    String name = "org.eclipse.fizbiz";
    String version = "1.0.0.Beta1";
    File file = null;
    File originFile = null;
    try {
        file = manager.getArtifact(null, name, version);
        Assert.assertNotNull(file);
        originFile = new File(file.getAbsolutePath() + ".origin");
        Assert.assertNotNull(originFile);
        try {
            String line;
            try (BufferedReader reader = new BufferedReader(new FileReader(originFile))) {
                line = reader.readLine();
            }
            assertEquals(repoURL, line);
        } catch (IOException ignored) {
        }
    } finally {
        manager.removeArtifact(null, name, version);
        // test if remove really works
        if (file != null)
            assertFalse(file.exists());
        if (originFile != null)
            assertFalse(originFile.exists());
        testSearchResults("org.eclipse.fizbiz", Type.JVM, new ModuleDetails[0]);
    }
}
Also used : RepositoryManagerBuilder(org.eclipse.ceylon.cmr.api.RepositoryManagerBuilder) DefaultRepository(org.eclipse.ceylon.cmr.impl.DefaultRepository) BufferedReader(java.io.BufferedReader) RepositoryManager(org.eclipse.ceylon.cmr.api.RepositoryManager) SimpleRepositoryManager(org.eclipse.ceylon.cmr.impl.SimpleRepositoryManager) FileReader(java.io.FileReader) RemoteContentStore(org.eclipse.ceylon.cmr.impl.RemoteContentStore) IOException(java.io.IOException) CmrRepository(org.eclipse.ceylon.cmr.api.CmrRepository) File(java.io.File) URL(java.net.URL) IOException(java.io.IOException) Test(org.junit.Test)

Example 5 with DefaultRepository

use of org.eclipse.ceylon.cmr.impl.DefaultRepository in project ceylon by eclipse.

the class SmokeTestCase method testExternalNodes.

@Test
public void testExternalNodes() throws Exception {
    RepositoryManagerBuilder builder = getRepositoryManagerBuilder(false, 60000, java.net.Proxy.NO_PROXY);
    InMemoryContentStore imcs = new InMemoryContentStore();
    OpenNode root = imcs.createRoot();
    CmrRepository repo = new DefaultRepository(root);
    RepositoryManager manager = builder.addRepository(repo).buildRepository();
    // a few impl details, feel free to remove/ignore this test
    String name = "org.eclipse.acme";
    String version = "1.0.0.CR1";
    ArtifactContext context = new ArtifactContext(null, name, version);
    // ignore with in-memory
    context.setIgnoreSHA(true);
    OpenNode parent = repo.createParent(context);
    parent.addContent(name + "-" + version + ArtifactContext.CAR, new ByteArrayInputStream("qwerty".getBytes()), context);
    try {
        File file = manager.getArtifact(context);
        Assert.assertNotNull("Failed to retrieve after put", file);
    } finally {
        manager.removeArtifact(null, name, version);
    }
}
Also used : RepositoryManagerBuilder(org.eclipse.ceylon.cmr.api.RepositoryManagerBuilder) DefaultRepository(org.eclipse.ceylon.cmr.impl.DefaultRepository) ByteArrayInputStream(java.io.ByteArrayInputStream) InMemoryContentStore(org.eclipse.ceylon.test.smoke.support.InMemoryContentStore) 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) OpenNode(org.eclipse.ceylon.cmr.spi.OpenNode) Test(org.junit.Test)

Aggregations

RepositoryManagerBuilder (org.eclipse.ceylon.cmr.api.RepositoryManagerBuilder)5 DefaultRepository (org.eclipse.ceylon.cmr.impl.DefaultRepository)5 CmrRepository (org.eclipse.ceylon.cmr.api.CmrRepository)4 File (java.io.File)3 RepositoryManager (org.eclipse.ceylon.cmr.api.RepositoryManager)3 URL (java.net.URL)2 RemoteContentStore (org.eclipse.ceylon.cmr.impl.RemoteContentStore)2 SimpleRepositoryManager (org.eclipse.ceylon.cmr.impl.SimpleRepositoryManager)2 Test (org.junit.Test)2 BufferedReader (java.io.BufferedReader)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 FileReader (java.io.FileReader)1 IOException (java.io.IOException)1 ArtifactContext (org.eclipse.ceylon.cmr.api.ArtifactContext)1 ModuleSearchResult (org.eclipse.ceylon.cmr.api.ModuleSearchResult)1 FileContentStore (org.eclipse.ceylon.cmr.impl.FileContentStore)1 OpenNode (org.eclipse.ceylon.cmr.spi.OpenNode)1 WebDAVContentStore (org.eclipse.ceylon.cmr.webdav.WebDAVContentStore)1 InMemoryContentStore (org.eclipse.ceylon.test.smoke.support.InMemoryContentStore)1