You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ivy-commits@incubator.apache.org by xa...@apache.org on 2007/10/27 13:56:01 UTC

svn commit: r589100 - in /incubator/ivy/core/trunk: CHANGES.txt src/java/org/apache/ivy/plugins/resolver/IvyRepResolver.java test/java/org/apache/ivy/plugins/resolver/IvyRepResolverTest.java

Author: xavier
Date: Sat Oct 27 06:56:01 2007
New Revision: 589100

URL: http://svn.apache.org/viewvc?rev=589100&view=rev
Log:
IMPROVEMENT: Make the root attribute in the ivyrep resolver mandatory (IVY-625)

Modified:
    incubator/ivy/core/trunk/CHANGES.txt
    incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/IvyRepResolver.java
    incubator/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/IvyRepResolverTest.java

Modified: incubator/ivy/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/CHANGES.txt?rev=589100&r1=589099&r2=589100&view=diff
==============================================================================
--- incubator/ivy/core/trunk/CHANGES.txt (original)
+++ incubator/ivy/core/trunk/CHANGES.txt Sat Oct 27 06:56:01 2007
@@ -70,6 +70,7 @@
 - IMPROVEMENT: Support *(private) and *(public) in the confs parameter of the resolve (IVY-588)
 - IMPROVEMENT: replace * by *(public) when resolving inline (IVY-589)
 - IMPROVEMENT: Improvements on hello ivy example (IVY-626) (with contribution from Jacob Grydholt Jensen)
+- IMPROVEMENT: Make the root attribute in the ivyrep resolver mandatory (IVY-625)
 
 - REFACTORING: Extract a settings interface for the different engines
 

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/IvyRepResolver.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/IvyRepResolver.java?rev=589100&r1=589099&r2=589100&view=diff
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/IvyRepResolver.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/IvyRepResolver.java Sat Oct 27 06:56:01 2007
@@ -99,8 +99,10 @@
                 if (root != null) {
                     ivyroot = root;
                 } else {
-                    settings.configureRepositories(true);
-                    ivyroot = settings.getVariable("ivy.ivyrep.default.ivy.root");
+                    throw new IllegalStateException(
+                        "ivyroot is mandatory on IvyRepResolver. " 
+                        + "Make sure to set it in your settings, before setting ivypattern "
+                        + "if you wish to set ivypattern too.");
                 }
             }
             if (ivypattern == null) {

Modified: incubator/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/IvyRepResolverTest.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/IvyRepResolverTest.java?rev=589100&r1=589099&r2=589100&view=diff
==============================================================================
--- incubator/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/IvyRepResolverTest.java (original)
+++ incubator/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/IvyRepResolverTest.java Sat Oct 27 06:56:01 2007
@@ -48,8 +48,6 @@
  * 
  */
 public class IvyRepResolverTest extends TestCase {
-    // remote.test
-
     private IvySettings _settings;
 
     private ResolveEngine _engine;
@@ -97,24 +95,44 @@
         assertEquals("http://www.ibiblio.org/mymaven/[module]/jars/[artifact]-[revision].jar", l
                 .get(0));
     }
-
-    public void testIvyRep() throws Exception {
+    
+    public void testMandatoryRoot() throws Exception {
+        // IVY-625: should fail if no ivyroot specified
         IvyRepResolver resolver = new IvyRepResolver();
         resolver.setName("test");
         resolver.setSettings(_settings);
-        assertEquals("test", resolver.getName());
 
         ModuleRevisionId mrid = ModuleRevisionId.newInstance("apache", "commons-cli", "1.0");
+        try {
+            resolver.getDependency(new DefaultDependencyDescriptor(mrid, false), _data);
+            fail("using ivyrep resolver without ivyroot should raise an exception");
+        } catch (IllegalStateException ex) {
+            assertTrue(
+                "exception thrown when using ivyrep with no ivyroot should talk about the root", 
+                ex.getMessage().indexOf("ivyroot") != -1);
+        }
+    }
+
+    public void testIvyRepWithLocalURL() throws Exception {
+        IvyRepResolver resolver = new IvyRepResolver();
+        String rootpath = new File("test/repositories/1").getAbsolutePath();
+
+        resolver.setName("testLocal");
+        resolver.setIvyroot("file:" + rootpath);
+        resolver.setIvypattern("[organisation]/[module]/ivys/ivy-[revision].xml");
+        resolver.setArtroot("file:"+rootpath);
+        resolver.setArtpattern("[organisation]/[module]/jars/[artifact]-[revision].[ext]");
+        resolver.setSettings(_settings);
+
+        ModuleRevisionId mrid = ModuleRevisionId.newInstance("org1", "mod1.1", "1.0");
         ResolvedModuleRevision rmr = resolver.getDependency(new DefaultDependencyDescriptor(mrid,
                 false), _data);
         assertNotNull(rmr);
-        assertEquals(mrid, rmr.getId());
-        assertEquals(2, rmr.getDescriptor().getDependencies().length);
 
         DefaultArtifact artifact = new DefaultArtifact(mrid, rmr.getPublicationDate(),
-                "commons-cli", "jar", "jar");
+            "mod1.1", "jar", "jar");
         DownloadReport report = resolver.download(new Artifact[] {artifact}, new DownloadOptions(
-                _settings, _cache));
+            _settings, _cache));
         assertNotNull(report);
 
         assertEquals(1, report.getArtifactsReports().length);
@@ -137,43 +155,5 @@
 
         assertEquals(artifact, ar.getArtifact());
         assertEquals(DownloadStatus.NO, ar.getDownloadStatus());
-    }
-
-    /*
-     * Tests IvyRepResolver with a root path given as 'file:/path_to_root'
-     */
-    public void testIvyRepLocalURL() throws Exception {
-        IvyRepResolver resolver = new IvyRepResolver();
-        String rootpath = new File("test/repositories/1").getAbsolutePath();
-
-        resolver.setName("testLocal");
-        resolver.setIvyroot("file:" + rootpath);
-        resolver.setIvypattern("[organisation]/[module]/ivys/ivy-[revision].xml");
-        resolver.setSettings(_settings);
-
-        ModuleRevisionId mrid = ModuleRevisionId.newInstance("org1", "mod1.1", "1.0");
-        ResolvedModuleRevision rmr = resolver.getDependency(new DefaultDependencyDescriptor(mrid,
-                false), _data);
-        assertNotNull(rmr);
-    }
-
-    public void testListing() {
-        IvyRepResolver resolver = new IvyRepResolver();
-        resolver.setName("test");
-        resolver.setSettings(_settings);
-
-        OrganisationEntry[] orgs = resolver.listOrganisations();
-        ResolverTestHelper.assertOrganisationEntriesContains(resolver, new String[] {"hibernate",
-                "apache"}, orgs);
-
-        OrganisationEntry org = ResolverTestHelper.getEntry(orgs, "apache");
-        ModuleEntry[] mods = resolver.listModules(org);
-        ResolverTestHelper.assertModuleEntriesContains(resolver, org, new String[] {
-                "commons-logging", "commons-lang"}, mods);
-
-        ModuleEntry mod = ResolverTestHelper.getEntry(mods, "commons-logging");
-        RevisionEntry[] revs = resolver.listRevisions(mod);
-        ResolverTestHelper.assertRevisionEntriesContains(resolver, mod, new String[] {"1.0",
-                "1.0.2", "1.0.3", "1.0.4"}, revs);
     }
 }