Search in sources :

Example 6 with EventManager

use of org.apache.ivy.core.event.EventManager in project ant-ivy by apache.

the class JarResolverTest method setUp.

@Before
public void setUp() {
    settings = new IvySettings();
    engine = new ResolveEngine(settings, new EventManager(), new SortEngine(settings));
    cache = new File("build/cache");
    data = new ResolveData(engine, new ResolveOptions());
    cache.mkdirs();
    settings.setDefaultCache(cache);
    cacheManager = (DefaultRepositoryCacheManager) settings.getDefaultRepositoryCacheManager();
}
Also used : ResolveEngine(org.apache.ivy.core.resolve.ResolveEngine) SortEngine(org.apache.ivy.core.sort.SortEngine) ResolveData(org.apache.ivy.core.resolve.ResolveData) EventManager(org.apache.ivy.core.event.EventManager) IvySettings(org.apache.ivy.core.settings.IvySettings) File(java.io.File) ResolveOptions(org.apache.ivy.core.resolve.ResolveOptions) Before(org.junit.Before)

Example 7 with EventManager

use of org.apache.ivy.core.event.EventManager in project ant-ivy by apache.

the class Maven2LocalTest method setUp.

@Before
public void setUp() {
    settings = new IvySettings();
    engine = new ResolveEngine(settings, new EventManager(), new SortEngine(settings));
    cache = new File("build/cache");
    data = new ResolveData(engine, new ResolveOptions());
    cache.mkdirs();
    settings.setDefaultCache(cache);
}
Also used : ResolveEngine(org.apache.ivy.core.resolve.ResolveEngine) SortEngine(org.apache.ivy.core.sort.SortEngine) ResolveData(org.apache.ivy.core.resolve.ResolveData) EventManager(org.apache.ivy.core.event.EventManager) IvySettings(org.apache.ivy.core.settings.IvySettings) File(java.io.File) ResolveOptions(org.apache.ivy.core.resolve.ResolveOptions) Before(org.junit.Before)

Example 8 with EventManager

use of org.apache.ivy.core.event.EventManager in project ant-ivy by apache.

the class URLResolverTest method setUp.

@Before
public void setUp() {
    settings = new IvySettings();
    engine = new ResolveEngine(settings, new EventManager(), new SortEngine(settings));
    data = new ResolveData(engine, new ResolveOptions());
    TestHelper.createCache();
    settings.setDefaultCache(TestHelper.cache);
}
Also used : ResolveEngine(org.apache.ivy.core.resolve.ResolveEngine) SortEngine(org.apache.ivy.core.sort.SortEngine) ResolveData(org.apache.ivy.core.resolve.ResolveData) EventManager(org.apache.ivy.core.event.EventManager) IvySettings(org.apache.ivy.core.settings.IvySettings) ResolveOptions(org.apache.ivy.core.resolve.ResolveOptions) Before(org.junit.Before)

Example 9 with EventManager

use of org.apache.ivy.core.event.EventManager in project ant-ivy by apache.

the class PublishEngineTest method testAtomicity.

@Test
public void testAtomicity() throws Exception {
    IvySettings settings = new IvySettings();
    final PublishEngine engine = new PublishEngine(settings, new EventManager());
    final int[] counter = new int[] { 0 };
    final DefaultModuleDescriptor md = DefaultModuleDescriptor.newDefaultInstance(ModuleRevisionId.parse("#A;1.0"));
    final FileSystemResolver resolver = new FileSystemResolver() {

        public void publish(Artifact artifact, File src, boolean overwrite) throws IOException {
            super.publish(artifact, src, overwrite);
            synchronized (PublishEngineTest.this) {
                counter[0]++;
            }
            sleepSilently(50);
            synchronized (PublishEngineTest.this) {
                counter[0]++;
            }
        }
    };
    resolver.setName("test");
    resolver.setSettings(settings);
    String publishRepoDir = new File("build/test/publish/repo").getAbsolutePath();
    resolver.addIvyPattern(publishRepoDir + "/[module]/[revision]/[artifact].[ext]");
    resolver.addArtifactPattern(publishRepoDir + "/[module]/[revision]/[artifact].[ext]");
    FileUtil.copy(new File("test/repositories/1/org1/mod1.1/jars/mod1.1-1.0.jar"), new File("build/test/publish/module/A.jar"), null);
    XmlModuleDescriptorWriter.write(md, new File("build/test/publish/module/ivy.xml"));
    resolveAndAssertNotFound(settings, resolver, "#A;latest.integration", "before publishing");
    // run publish asynchronously
    new Thread() {

        public void run() {
            try {
                engine.publish(md, Collections.singletonList("build/test/publish/module/[artifact].[ext]"), resolver, new PublishOptions().setSrcIvyPattern("build/test/publish/module/[artifact].[ext]"));
                synchronized (PublishEngineTest.this) {
                    counter[0]++;
                }
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
    }.start();
    while (true) {
        sleepSilently(5);
        synchronized (this) {
            if (counter[0] == 5) {
                break;
            } else if (counter[0] < 4) {
                resolveAndAssertNotFound(settings, resolver, "#A;latest.integration", "after " + (counter[0] / 2) + " artifacts published");
            }
        }
    }
    resolveAndAssertFound(settings, resolver, "#A;1.0");
}
Also used : EventManager(org.apache.ivy.core.event.EventManager) IvySettings(org.apache.ivy.core.settings.IvySettings) IOException(java.io.IOException) Artifact(org.apache.ivy.core.module.descriptor.Artifact) DefaultModuleDescriptor(org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor) File(java.io.File) FileSystemResolver(org.apache.ivy.plugins.resolver.FileSystemResolver) Test(org.junit.Test)

Example 10 with EventManager

use of org.apache.ivy.core.event.EventManager in project ant-ivy by apache.

the class RepositoryManagementEngineTest method setUp.

@Before
public void setUp() {
    fixture = new TestFixture();
    IvySettings settings = fixture.getSettings();
    repository = new RepositoryManagementEngine(settings, new SearchEngine(settings), new ResolveEngine(settings, new EventManager(), new SortEngine(settings)));
}
Also used : ResolveEngine(org.apache.ivy.core.resolve.ResolveEngine) SortEngine(org.apache.ivy.core.sort.SortEngine) SearchEngine(org.apache.ivy.core.search.SearchEngine) EventManager(org.apache.ivy.core.event.EventManager) IvySettings(org.apache.ivy.core.settings.IvySettings) TestFixture(org.apache.ivy.TestFixture) Before(org.junit.Before)

Aggregations

EventManager (org.apache.ivy.core.event.EventManager)19 ResolveEngine (org.apache.ivy.core.resolve.ResolveEngine)15 IvySettings (org.apache.ivy.core.settings.IvySettings)15 SortEngine (org.apache.ivy.core.sort.SortEngine)14 ResolveData (org.apache.ivy.core.resolve.ResolveData)13 ResolveOptions (org.apache.ivy.core.resolve.ResolveOptions)12 Before (org.junit.Before)12 File (java.io.File)7 IOException (java.io.IOException)2 CacheResourceOptions (org.apache.ivy.core.cache.CacheResourceOptions)2 ArtifactDownloadReport (org.apache.ivy.core.report.ArtifactDownloadReport)2 SearchEngine (org.apache.ivy.core.search.SearchEngine)2 Resource (org.apache.ivy.plugins.repository.Resource)2 URLResource (org.apache.ivy.plugins.repository.url.URLResource)2 MalformedURLException (java.net.MalformedURLException)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 URL (java.net.URL)1 TestFixture (org.apache.ivy.TestFixture)1 IvyAntSettings (org.apache.ivy.ant.IvyAntSettings)1