Java Code Examples for org.apache.ivy.Ivy#configureDefault()

The following examples show how to use org.apache.ivy.Ivy#configureDefault() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultRepositoryCacheManagerTest.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {
    File f = File.createTempFile("ivycache", ".dir");
    ivy = new Ivy();
    ivy.configureDefault();
    ivy.getLoggerEngine().setDefaultLogger(new DefaultMessageLogger(Message.MSG_DEBUG));
    IvyContext.pushNewContext().setIvy(ivy);

    IvySettings settings = ivy.getSettings();
    f.delete(); // we want to use the file as a directory, so we delete the file itself
    cacheManager = new DefaultRepositoryCacheManager();
    cacheManager.setSettings(settings);
    cacheManager.setBasedir(f);

    artifact = createArtifact("org", "module", "rev", "name", "type", "ext");

    Artifact originArtifact = createArtifact("org", "module", "rev", "name", "pom.original",
        "pom");
    origin = new ArtifactOrigin(originArtifact, true, "file:/some/where.pom");

    cacheManager.saveArtifactOrigin(originArtifact, origin);
    cacheManager.saveArtifactOrigin(artifact, origin);
}
 
Example 2
Source File: IvySettingsTest.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
@Test
public void testChangeDefaultResolver() throws ParseException, IOException {
    Ivy ivy = new Ivy();
    ivy.configureDefault();

    IvySettings settings = ivy.getSettings();
    DependencyResolver defaultResolver = settings.getDefaultResolver();

    assertNotNull(defaultResolver);
    assertEquals("default", defaultResolver.getName());
    assertSame("default resolver cached", defaultResolver, settings.getDefaultResolver());

    settings.setDefaultResolver("public");
    DependencyResolver newDefault = settings.getDefaultResolver();
    assertNotNull(newDefault);
    assertNotSame("default resolver has changed", defaultResolver, newDefault);
    assertEquals("resolver changed successfully", "public", newDefault.getName());
}
 
Example 3
Source File: ConfigureTest.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
@Test
public void testDefault() throws ParseException, IOException {
    Ivy ivy = new Ivy();
    ivy.configureDefault();

    IvySettings settings = ivy.getSettings();
    assertNotNull(settings.getDefaultResolver());

    DependencyResolver publicResolver = settings.getResolver("public");
    assertNotNull(publicResolver);
    assertTrue(publicResolver instanceof IBiblioResolver);
    IBiblioResolver ibiblio = (IBiblioResolver) publicResolver;
    assertTrue(ibiblio.isM2compatible());
}
 
Example 4
Source File: IvySettingsTest.java    From ant-ivy with Apache License 2.0 4 votes vote down vote up
@Test
public void testVariables() throws Exception {
    Ivy ivy = new Ivy();
    ivy.configureDefault();
    IvySettings settings = ivy.getSettings();

    // test set
    assertNull(settings.getVariable("foo"));
    settings.setVariable("foo", "bar", false, null, null);
    assertEquals("bar", settings.getVariable("foo"));

    // test no override
    settings.setVariable("foo", "wrong", false, null, null);
    assertEquals("bar", settings.getVariable("foo"));

    // test override
    settings.setVariable("foo", "right", true, null, null);
    assertEquals("right", settings.getVariable("foo"));

    // test ifset no exist
    assertNull(settings.getVariable("bar"));
    settings.setVariable("bar", "foo", true, "noexist", null);
    assertNull(settings.getVariable("bar"));

    // test ifset exist
    settings.setVariable("bar", "foo", true, "foo", null);
    assertEquals("foo", settings.getVariable("bar"));

    // test unlessset exist
    assertNull(settings.getVariable("thing"));
    settings.setVariable("thing", "foo", true, null, "foo");
    assertNull(settings.getVariable("thing"));

    // test unlessset noexist
    settings.setVariable("thing", "foo", true, null, "noexist");
    assertEquals("foo", settings.getVariable("thing"));

    // test ifset no exist and unlessset exist
    assertNull(settings.getVariable("ivy"));
    settings.setVariable("ivy", "rocks", true, "noexist", "foo");
    assertNull(settings.getVariable("ivy"));

    // test ifset no exist and unlessset no exist
    settings.setVariable("ivy", "rocks", true, "noexist", "noexist");
    assertNull(settings.getVariable("ivy"));

    // test ifset exist and unlessset exist
    settings.setVariable("ivy", "rocks", true, "foo", "foo");
    assertNull(settings.getVariable("ivy"));

    // test ifset exist and unlessset no exist
    settings.setVariable("ivy", "rocks", true, "foo", "noexist");
    assertEquals("rocks", settings.getVariable("ivy"));
}