ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hi...@apache.org
Subject svn commit: r1026174 - in /ant/ivy/core/trunk: ./ test/java/org/apache/ivy/core/resolve/ test/repositories/1/usecacheonly/ test/repositories/1/usecacheonly/mod1/ test/repositories/1/usecacheonly/mod1/ivys/ test/repositories/1/usecacheonly/mod1/jars/ te...
Date Thu, 21 Oct 2010 23:03:33 GMT
Author: hibou
Date: Thu Oct 21 23:03:32 2010
New Revision: 1026174

URL: http://svn.apache.org/viewvc?rev=1026174&view=rev
Log:
IVY-1227: here are the unit test for useCacheOnly

Added:
    ant/ivy/core/trunk/test/repositories/1/usecacheonly/
    ant/ivy/core/trunk/test/repositories/1/usecacheonly/mod1/
    ant/ivy/core/trunk/test/repositories/1/usecacheonly/mod1/ivys/
    ant/ivy/core/trunk/test/repositories/1/usecacheonly/mod1/ivys/ivy-1.0.xml
    ant/ivy/core/trunk/test/repositories/1/usecacheonly/mod1/jars/
    ant/ivy/core/trunk/test/repositories/1/usecacheonly/mod1/jars/mod1-1.0.jar
    ant/ivy/core/trunk/test/repositories/1/usecacheonly/mod2/
    ant/ivy/core/trunk/test/repositories/1/usecacheonly/mod2/ivys/
    ant/ivy/core/trunk/test/repositories/1/usecacheonly/mod2/ivys/ivy-1.0.xml
    ant/ivy/core/trunk/test/repositories/1/usecacheonly/mod2/jars/
    ant/ivy/core/trunk/test/repositories/1/usecacheonly/mod2/jars/mod2-1.0.jar
Modified:
    ant/ivy/core/trunk/CHANGES.txt
    ant/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ResolveTest.java

Modified: ant/ivy/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/CHANGES.txt?rev=1026174&r1=1026173&r2=1026174&view=diff
==============================================================================
--- ant/ivy/core/trunk/CHANGES.txt (original)
+++ ant/ivy/core/trunk/CHANGES.txt Thu Oct 21 23:03:32 2010
@@ -118,6 +118,7 @@ for detailed view of each issue, please 
 - FIX: Couldn't authenticate against sites having the same address as the proxy server (IVY-1234)
 - FIX: OutOfMemoryError when uploading large files using commons-httpclient (IVY-1197) (thanks
to Torkild U. Resheim)
 - FIX: Only the last dependency descriptor is taken into account on the same module (IVY-1240)
+- FIX: UseCacheOnly doesn't respect the cache configuration in the ivysettings (IVY-1227)
 
    2.2.0
 =====================================

Modified: ant/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ResolveTest.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ResolveTest.java?rev=1026174&r1=1026173&r2=1026174&view=diff
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ResolveTest.java (original)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ResolveTest.java Thu Oct 21 23:03:32
2010
@@ -18,6 +18,8 @@
 package org.apache.ivy.core.resolve;
 
 import java.io.File;
+import java.io.IOException;
+import java.net.URL;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -57,6 +59,8 @@ import org.apache.ivy.plugins.circular.W
 import org.apache.ivy.plugins.conflict.StrictConflictException;
 import org.apache.ivy.plugins.matcher.ExactPatternMatcher;
 import org.apache.ivy.plugins.parser.xml.XmlModuleDescriptorParser;
+import org.apache.ivy.plugins.repository.AbstractRepository;
+import org.apache.ivy.plugins.repository.Resource;
 import org.apache.ivy.plugins.resolver.BasicResolver;
 import org.apache.ivy.plugins.resolver.DependencyResolver;
 import org.apache.ivy.plugins.resolver.DualResolver;
@@ -76,6 +80,7 @@ public class ResolveTest extends TestCas
 
     private File cache;
     private File deliverDir;
+    private File workDir;
 
     public ResolveTest() {
     }
@@ -88,6 +93,9 @@ public class ResolveTest extends TestCas
         deliverDir = new File("build/test/deliver");
         deliverDir.mkdirs();
 
+        workDir = new File("build/test/work");
+        workDir.mkdirs();
+
         ivy = Ivy.newInstance();
         ivy.configure(new File("test/repositories/ivysettings.xml"));
     }
@@ -99,6 +107,7 @@ public class ResolveTest extends TestCas
     protected void tearDown() throws Exception {
         CacheCleaner.deleteDir(cache);
         FileUtil.forceDelete(deliverDir);
+        FileUtil.forceDelete(workDir);
     }
 
     public void testResolveWithRetainingArtifactName() throws Exception {
@@ -5205,4 +5214,62 @@ public class ResolveTest extends TestCas
         ivy.deliver(pubrev, deliveryPattern, dopts);
     }
 
+    public void testUseCacheOnly() throws Exception {
+        ResolveOptions option = getResolveOptions(new String[] {"*"}).setValidate(false);
+        URL url = new File("test/repositories/1/usecacheonly/mod1/ivys/ivy-1.0.xml").toURI()
+                .toURL();
+
+        // normal resolve, the file goes in the cache
+        ResolveReport report = ivy.resolve(url, option);
+        assertFalse(report.hasError());
+
+        option.setUseCacheOnly(true);
+
+        // use cache only, hit the cache
+        report = ivy.resolve(url, option);
+        assertFalse(report.hasError());
+
+        CacheCleaner.deleteDir(cache);
+        createCache();
+
+        // no more in the cache, missed
+        report = ivy.resolve(url, option);
+        assertTrue(report.hasError());
+
+        option.setUseCacheOnly(false);
+
+        // try with use origin: should fail as the cache is empty
+        ivy.getSettings().setDefaultUseOrigin(true);
+        option.setUseCacheOnly(true);
+        report = ivy.resolve(url, option);
+        assertTrue(report.hasError());
+
+        // populate the cache
+        option.setUseCacheOnly(false);
+        report = ivy.resolve(url, option);
+        assertFalse(report.hasError());
+
+        // use origin should now work
+        option.setUseCacheOnly(true);
+        report = ivy.resolve(url, option);
+        assertFalse(report.hasError());
+
+        // ensure that we hit only the cache and never try to hit in the repository
+        FileSystemResolver resolver = (FileSystemResolver) ivy.getSettings().getResolver("1");
+        resolver.setRepository(new AbstractRepository() {
+            public List list(String parent) throws IOException {
+                throw new UnsupportedOperationException();
+            }
+            
+            public Resource getResource(String source) throws IOException {
+                throw new UnsupportedOperationException();
+            }
+            
+            public void get(String source, File destination) throws IOException {
+                throw new UnsupportedOperationException();
+            }
+        });
+        report = ivy.resolve(url, option);
+        assertFalse(report.hasError());
+    }
 }

Added: ant/ivy/core/trunk/test/repositories/1/usecacheonly/mod1/ivys/ivy-1.0.xml
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/repositories/1/usecacheonly/mod1/ivys/ivy-1.0.xml?rev=1026174&view=auto
==============================================================================
--- ant/ivy/core/trunk/test/repositories/1/usecacheonly/mod1/ivys/ivy-1.0.xml (added)
+++ ant/ivy/core/trunk/test/repositories/1/usecacheonly/mod1/ivys/ivy-1.0.xml Thu Oct 21 23:03:32
2010
@@ -0,0 +1,27 @@
+<!--
+   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.    
+-->
+<ivy-module version="1.0">
+    <info organisation="usecacheonly" module="mod1" revision="1.0" />
+    <configurations>
+        <conf name="default" />
+    </configurations>
+    <dependencies>
+        <dependency org="usecacheonly" name="mod2" rev="1.0" />
+	</dependencies>
+</ivy-module>

Added: ant/ivy/core/trunk/test/repositories/1/usecacheonly/mod1/jars/mod1-1.0.jar
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/repositories/1/usecacheonly/mod1/jars/mod1-1.0.jar?rev=1026174&view=auto
==============================================================================
--- ant/ivy/core/trunk/test/repositories/1/usecacheonly/mod1/jars/mod1-1.0.jar (added)
+++ ant/ivy/core/trunk/test/repositories/1/usecacheonly/mod1/jars/mod1-1.0.jar Thu Oct 21
23:03:32 2010
@@ -0,0 +1 @@
+.
\ No newline at end of file

Added: ant/ivy/core/trunk/test/repositories/1/usecacheonly/mod2/ivys/ivy-1.0.xml
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/repositories/1/usecacheonly/mod2/ivys/ivy-1.0.xml?rev=1026174&view=auto
==============================================================================
--- ant/ivy/core/trunk/test/repositories/1/usecacheonly/mod2/ivys/ivy-1.0.xml (added)
+++ ant/ivy/core/trunk/test/repositories/1/usecacheonly/mod2/ivys/ivy-1.0.xml Thu Oct 21 23:03:32
2010
@@ -0,0 +1,26 @@
+<!--
+   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.    
+-->
+<ivy-module version="1.0">
+    <info organisation="usecacheonly" module="mod2" revision="1.0" />
+    <configurations>
+        <conf name="default" />
+    </configurations>
+    <dependencies>
+	</dependencies>
+</ivy-module>

Added: ant/ivy/core/trunk/test/repositories/1/usecacheonly/mod2/jars/mod2-1.0.jar
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/repositories/1/usecacheonly/mod2/jars/mod2-1.0.jar?rev=1026174&view=auto
==============================================================================
--- ant/ivy/core/trunk/test/repositories/1/usecacheonly/mod2/jars/mod2-1.0.jar (added)
+++ ant/ivy/core/trunk/test/repositories/1/usecacheonly/mod2/jars/mod2-1.0.jar Thu Oct 21
23:03:32 2010
@@ -0,0 +1 @@
+.
\ No newline at end of file



Mime
View raw message