Search in sources :

Example 76 with Ivy

use of org.apache.ivy.Ivy in project ant-ivy by apache.

the class InstallTest method testLatestDependenciesDummyDefaultResolver.

@Test
public void testLatestDependenciesDummyDefaultResolver() throws Exception {
    Ivy ivy = Ivy.newInstance();
    ivy.configure(new File("test/repositories/ivysettings-dummydefaultresolver.xml"));
    ivy.install(ModuleRevisionId.newInstance("org1", "mod1.4", "1.0.1"), "test", "install", new InstallOptions());
    assertTrue(new File("build/test/install/org1/mod1.4/ivy-1.0.1.xml").exists());
    assertTrue(new File("build/test/install/org1/mod1.1/ivy-2.0.xml").exists());
    assertTrue(new File("build/test/install/org1/mod1.1/mod1.1-2.0.jar").exists());
    assertTrue(new File("build/test/install/org1/mod1.2/ivy-2.2.xml").exists());
    assertTrue(new File("build/test/install/org1/mod1.2/mod1.2-2.2.jar").exists());
}
Also used : Ivy(org.apache.ivy.Ivy) File(java.io.File) Test(org.junit.Test)

Example 77 with Ivy

use of org.apache.ivy.Ivy in project ant-ivy by apache.

the class IvyTaskTest method testDefaultSettings.

@Test
public void testDefaultSettings() throws MalformedURLException {
    Project p = TestHelper.newProject();
    p.setBasedir("test/repositories");
    p.setProperty("myproperty", "myvalue");
    IvyTask task = new IvyTask() {

        public void doExecute() throws BuildException {
        }
    };
    task.setProject(p);
    Ivy ivy = task.getIvyInstance();
    assertNotNull(ivy);
    IvySettings settings = ivy.getSettings();
    assertNotNull(settings);
    assertEquals(new File("test/repositories/build/cache").getAbsoluteFile(), settings.getDefaultCache());
    // The next test doesn't always works on windows (mix C: and c: drive)
    assertEquals(new File("test/repositories/ivysettings.xml").getAbsolutePath().toUpperCase(), new File(settings.getVariables().getVariable("ivy.settings.file")).getAbsolutePath().toUpperCase());
    assertEquals(new File("test/repositories/ivysettings.xml").toURI().toURL().toExternalForm().toUpperCase(), settings.getVariables().getVariable("ivy.settings.url").toUpperCase());
    assertEquals(new File("test/repositories").getAbsolutePath().toUpperCase(), settings.getVariables().getVariable("ivy.settings.dir").toUpperCase());
    assertEquals("myvalue", settings.getVariables().getVariable("myproperty"));
}
Also used : Project(org.apache.tools.ant.Project) IvySettings(org.apache.ivy.core.settings.IvySettings) Ivy(org.apache.ivy.Ivy) File(java.io.File) Test(org.junit.Test)

Example 78 with Ivy

use of org.apache.ivy.Ivy in project ant-ivy by apache.

the class IvyVarTest method testSimple.

@Test
public void testSimple() {
    IvyVar task = new IvyVar();
    task.setProject(TestHelper.newProject());
    task.setName("mytest");
    task.setValue("myvalue");
    task.execute();
    Ivy ivy = task.getIvyInstance();
    assertNotNull(ivy);
    assertEquals("myvalue", ivy.getVariable("mytest"));
}
Also used : Ivy(org.apache.ivy.Ivy) Test(org.junit.Test)

Example 79 with Ivy

use of org.apache.ivy.Ivy in project ant-ivy by apache.

the class IvyVarTest method testPrefix.

@Test
public void testPrefix() {
    IvyVar task = new IvyVar();
    task.setProject(TestHelper.newProject());
    task.setName("mytest");
    task.setValue("myvalue");
    task.setPrefix("myprefix");
    task.execute();
    Ivy ivy = task.getIvyInstance();
    assertNotNull(ivy);
    assertEquals("myvalue", ivy.getVariable("myprefix.mytest"));
}
Also used : Ivy(org.apache.ivy.Ivy) Test(org.junit.Test)

Example 80 with Ivy

use of org.apache.ivy.Ivy in project ant-ivy by apache.

the class IvyVarTest method testURLPrefix.

@Test
public void testURLPrefix() {
    IvyVar task = new IvyVar();
    task.setProject(TestHelper.newProject());
    task.setUrl(IvyVarTest.class.getResource("vartest.properties").toExternalForm());
    task.setPrefix("myprefix.");
    task.execute();
    Ivy ivy = task.getIvyInstance();
    assertNotNull(ivy);
    assertEquals("myvalue1", ivy.getVariable("myprefix.mytest1"));
    assertEquals("myvalue2", ivy.getVariable("myprefix.mytest2"));
}
Also used : Ivy(org.apache.ivy.Ivy) Test(org.junit.Test)

Aggregations

Ivy (org.apache.ivy.Ivy)169 File (java.io.File)147 Test (org.junit.Test)137 ResolveReport (org.apache.ivy.core.report.ResolveReport)102 JarFile (java.util.jar.JarFile)100 ConfigurationResolveReport (org.apache.ivy.core.report.ConfigurationResolveReport)97 ModuleRevisionId (org.apache.ivy.core.module.id.ModuleRevisionId)40 IvySettings (org.apache.ivy.core.settings.IvySettings)26 ModuleDescriptor (org.apache.ivy.core.module.descriptor.ModuleDescriptor)23 BuildException (org.apache.tools.ant.BuildException)17 Before (org.junit.Before)12 HashMap (java.util.HashMap)9 DependencyResolver (org.apache.ivy.plugins.resolver.DependencyResolver)8 RepositoryCacheManager (org.apache.ivy.core.cache.RepositoryCacheManager)6 ResolveOptions (org.apache.ivy.core.resolve.ResolveOptions)6 DefaultRepositoryCacheManager (org.apache.ivy.core.cache.DefaultRepositoryCacheManager)5 ModuleId (org.apache.ivy.core.module.id.ModuleId)5 IOException (java.io.IOException)4 ParseException (java.text.ParseException)4 Date (java.util.Date)4