Author: maartenc Date: Sun Jan 24 14:15:08 2010 New Revision: 902569 URL: http://svn.apache.org/viewvc?rev=902569&view=rev Log: FIX: add ability to programmatically change default resolver (IVY-1163) (thanks to Jason Trump)
Added: ant/ivy/core/trunk/test/java/org/apache/ivy/core/settings/IvySettingsTest.java (with props) Modified: ant/ivy/core/trunk/CHANGES.txt ant/ivy/core/trunk/src/java/org/apache/ivy/core/settings/IvySettings.java Modified: ant/ivy/core/trunk/CHANGES.txt URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/CHANGES.txt?rev=902569&r1=902568&r2=902569&view=diff ============================================================================== --- ant/ivy/core/trunk/CHANGES.txt (original) +++ ant/ivy/core/trunk/CHANGES.txt Sun Jan 24 14:15:08 2010 @@ -107,6 +107,7 @@ - IMPROVEMENT: Trace a message when a property file referenced from the settings doesn't exixts (IVY-1074) - IMPROVEMENT: use defaultconf in combination with defaultconfmapping (IVY-1135) (thanks to Jon Schneider) +- FIX: add ability to programmatically change default resolver (IVY-1163) (thanks to Jason Trump) - FIX: ivy.settings.dir space escaping problem (IVY-1162) - FIX: Ivy cannot parse alternate format for Maven MD5 files (IVY-1155) - FIX: Ivy does not close URL connection to ivy-report.xsl properly (IVY-1152) Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/core/settings/IvySettings.java URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/settings/IvySettings.java?rev=902569&r1=902568&r2=902569&view=diff ============================================================================== --- ant/ivy/core/trunk/src/java/org/apache/ivy/core/settings/IvySettings.java (original) +++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/settings/IvySettings.java Sun Jan 24 14:15:08 2010 @@ -723,6 +723,9 @@ public void setDefaultResolver(String resolverName) { checkResolverName(resolverName); + if (resolverName != null && !resolverName.equals(defaultResolverName)) { + defaultResolver = null; + } defaultResolverName = resolverName; } Added: ant/ivy/core/trunk/test/java/org/apache/ivy/core/settings/IvySettingsTest.java URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/core/settings/IvySettingsTest.java?rev=902569&view=auto ============================================================================== --- ant/ivy/core/trunk/test/java/org/apache/ivy/core/settings/IvySettingsTest.java (added) +++ ant/ivy/core/trunk/test/java/org/apache/ivy/core/settings/IvySettingsTest.java Sun Jan 24 14:15:08 2010 @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.ivy.core.settings; + +import java.io.IOException; +import java.text.ParseException; + +import junit.framework.TestCase; + +import org.apache.ivy.Ivy; +import org.apache.ivy.plugins.resolver.DependencyResolver; + +public class IvySettingsTest extends TestCase { + + 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()); + } + +} Propchange: ant/ivy/core/trunk/test/java/org/apache/ivy/core/settings/IvySettingsTest.java ------------------------------------------------------------------------------ svn:mime-type = text/plain