You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by xa...@apache.org on 2007/12/02 20:49:58 UTC

svn commit: r600364 - in /ant/ivy/core/trunk: src/java/org/apache/ivy/core/module/id/ test/java/org/apache/ivy/ test/java/org/apache/ivy/plugins/conflict/ test/repositories/latest-compatible/

Author: xavier
Date: Sun Dec  2 11:49:57 2007
New Revision: 600364

URL: http://svn.apache.org/viewvc?rev=600364&view=rev
Log:
introduce TestFixture useful to set up a repository from very simple text description, and use this for LatestCompatibleConflictManagerTest

Added:
    ant/ivy/core/trunk/test/java/org/apache/ivy/TestFixture.java   (with props)
Removed:
    ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/conflict/ivy-latest-compatible-1.xml
    ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/conflict/ivy-latest-compatible-2.xml
    ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/conflict/ivy-latest-compatible-3.xml
    ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/conflict/ivy-latest-compatible-4.xml
    ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/conflict/ivy-latest-compatible-5.xml
    ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/conflict/ivy-latest-compatible-6.xml
    ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/conflict/ivy-latest-compatible-7.xml
    ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/conflict/ivy-latest-compatible-conflict.xml
    ant/ivy/core/trunk/test/repositories/latest-compatible/
Modified:
    ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ModuleRevisionId.java
    ant/ivy/core/trunk/test/java/org/apache/ivy/TestHelper.java
    ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/conflict/LatestCompatibleConflictManagerTest.java

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ModuleRevisionId.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ModuleRevisionId.java?rev=600364&r1=600363&r2=600364&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ModuleRevisionId.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ModuleRevisionId.java Sun Dec  2 11:49:57 2007
@@ -41,12 +41,26 @@
     private static final String STRICT_CHARS_PATTERN = "[a-zA-Z0-9\\-/\\._+=]";
     private static final String REV_STRICT_CHARS_PATTERN 
         = "[a-zA-Z0-9\\-/\\._+=,\\[\\]\\{\\}\\(\\):@]";
-    private static final Pattern MRID_PATTERN = 
+
+    /**
+     * Pattern to use to matched mrid text representation.
+     * @see #parse(String)
+     */
+    public static final Pattern MRID_PATTERN = 
         Pattern.compile(
             "(" + STRICT_CHARS_PATTERN + "*)" 
             + "#(" + STRICT_CHARS_PATTERN + "+)" 
             + "(?:#(" + STRICT_CHARS_PATTERN + "+))?" 
             + ";(" + REV_STRICT_CHARS_PATTERN + "+)");
+    /**
+     * Same as MRID_PATTERN but using non capturing groups, useful to build larger regexp
+     */
+    public static final Pattern NON_CAPTURING_PATTERN = 
+        Pattern.compile(
+            "(?:" + STRICT_CHARS_PATTERN + "*)" 
+            + "#(?:" + STRICT_CHARS_PATTERN + "+)" 
+            + "(?:#(?:" + STRICT_CHARS_PATTERN + "+))?" 
+            + ";(?:" + REV_STRICT_CHARS_PATTERN + "+)");
 
     /**
      * Parses a module revision id text representation and returns a new {@link ModuleRevisionId}

Added: ant/ivy/core/trunk/test/java/org/apache/ivy/TestFixture.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/TestFixture.java?rev=600364&view=auto
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/TestFixture.java (added)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/TestFixture.java Sun Dec  2 11:49:57 2007
@@ -0,0 +1,124 @@
+/*
+ *  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;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor;
+import org.apache.ivy.core.module.id.ModuleRevisionId;
+import org.apache.ivy.core.report.ResolveReport;
+import org.apache.ivy.core.settings.IvySettings;
+import org.apache.ivy.plugins.repository.file.FileResource;
+import org.apache.ivy.plugins.resolver.DependencyResolver;
+import org.apache.ivy.plugins.resolver.util.ResolvedResource;
+
+/**
+ * Fixture easing the development of tests requiring to set up a simple repository with some
+ * modules, using micro ivy format to describe the repository. <br/> Example of use:
+ * 
+ * <pre>
+ * public class MyTest extends TestCase {
+ *     private TestFixture fixture;
+ * 
+ *     protected void setUp() throws Exception {
+ *         fixture = new TestFixture();
+ *         // additional setup here
+ *     }
+ * 
+ *     protected void tearDown() throws Exception {
+ *         fixture.clean();
+ *     }
+ *     
+ *     public void testXXX() throws Exception {
+ *        fixture
+ *            .addMD("#A;1-> { #B;[1.5,1.6] #C;2.5 }")
+ *            .addMD("#B;1.5->#D;2.0")
+ *            .addMD("#B;1.6->#D;2.0")
+ *            .addMD("#C;2.5->#D;[1.0,1.6]")
+ *            .addMD("#D;1.5").addMD("#D;1.6").addMD("#D;2.0")
+ *            .init();
+ *        ResolveReport r = fixture.resolve("#A;1");
+ *        // assertions go here
+ *     }
+ * }
+ * </pre>
+ */
+public class TestFixture {
+    
+    private Collection mds = new ArrayList();
+    private Ivy ivy;
+
+    public TestFixture() {
+        try {
+            this.ivy = new Ivy();
+            ivy.configureDefault();
+            TestHelper.loadTestSettings(ivy.getSettings());
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+    }
+    
+    public TestFixture addMD(String microIvy) {
+        mds.add(TestHelper.parseMicroIvyDescriptor(microIvy));
+        return this;
+    }
+    
+    public TestFixture init() throws IOException {
+        TestHelper.fillRepository(getTestRepository(), mds);
+        return this;
+    }
+
+    private DependencyResolver getTestRepository() {
+        return ivy.getSettings().getResolver("test");
+    }
+
+    public IvySettings getSettings() {
+        return ivy.getSettings();
+    }
+    
+    public Ivy getIvy() {
+        return ivy;
+    }
+    
+    public void clean() {
+        TestHelper.cleanTest();
+    }
+
+    public File getIvyFile(String mrid) {
+        ResolvedResource r = getTestRepository().findIvyFileRef(
+            new DefaultDependencyDescriptor(ModuleRevisionId.parse(mrid), false), 
+            TestHelper.newResolveData(getSettings()));
+        if (r == null) {
+            throw new IllegalStateException("module not found: "+mrid);
+        }
+        return ((FileResource) r.getResource()).getFile();
+    }
+
+    public ResolveReport resolve(String mrid) 
+            throws MalformedURLException, ParseException, IOException {
+        return ivy.resolve(
+            getIvyFile(mrid).toURL(),
+            TestHelper.newResolveOptions(getSettings()));
+    }
+    
+}

Propchange: ant/ivy/core/trunk/test/java/org/apache/ivy/TestFixture.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: ant/ivy/core/trunk/test/java/org/apache/ivy/TestHelper.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/TestHelper.java?rev=600364&r1=600363&r2=600364&view=diff
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/TestHelper.java (original)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/TestHelper.java Sun Dec  2 11:49:57 2007
@@ -18,15 +18,34 @@
 package org.apache.ivy;
 
 import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Date;
-import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 import junit.framework.Assert;
 
 import org.apache.ivy.core.cache.CacheManager;
+import org.apache.ivy.core.event.EventManager;
+import org.apache.ivy.core.module.descriptor.Artifact;
 import org.apache.ivy.core.module.descriptor.DefaultArtifact;
+import org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor;
+import org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor;
+import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
 import org.apache.ivy.core.module.id.ModuleRevisionId;
+import org.apache.ivy.core.resolve.ResolveData;
+import org.apache.ivy.core.resolve.ResolveEngine;
+import org.apache.ivy.core.resolve.ResolveOptions;
+import org.apache.ivy.core.settings.IvySettings;
+import org.apache.ivy.core.sort.SortEngine;
+import org.apache.ivy.plugins.parser.xml.XmlModuleDescriptorWriter;
+import org.apache.ivy.plugins.resolver.DependencyResolver;
+import org.apache.ivy.plugins.resolver.FileSystemResolver;
+import org.apache.ivy.util.FileUtil;
 
 public class TestHelper {
 
@@ -69,8 +88,8 @@
      * @return a collection of {@link ModuleRevisionId}
      */
     public static Collection parseMrids(String mrids) {
-        String[] m = mrids.split(", ");
-        Collection c = new HashSet();
+        String[] m = mrids.split(",?\\s+");
+        Collection c = new LinkedHashSet();
         for (int i = 0; i < m.length; i++) {
             c.add(ModuleRevisionId.parse(m[i]));
         }
@@ -88,5 +107,192 @@
     public static ModuleRevisionId[] parseMridsToArray(String mrids) {
         Collection parsedMrids = parseMrids(mrids);
         return (ModuleRevisionId[]) parsedMrids.toArray(new ModuleRevisionId[parsedMrids.size()]);
+    }
+    
+    /**
+     * Parses a string represenation of a module descriptor in micro ivy format.
+     * <p>
+     * Examples:
+     * <pre>
+     * #A;1
+     * </pre>
+     * <hr/>
+     * <pre>
+     * #A;2-> #B;[1.0,1.5]
+     * </pre>
+     * <hr/>
+     * <pre>
+     * #A;3-> { #B;[1.0,1.5] #C;[2.0,2.5] }
+     * </pre>
+     * </p>
+     * 
+     * @param microIvy the micro ivy description of the module descriptor
+     * @return the parsed module descriptor
+     */
+    public static ModuleDescriptor parseMicroIvyDescriptor(String microIvy) {
+        Pattern mridPattern = ModuleRevisionId.NON_CAPTURING_PATTERN;
+        Matcher m = mridPattern.matcher(microIvy);
+        if (m.matches()) {
+            return DefaultModuleDescriptor
+                .newBasicInstance(ModuleRevisionId.parse(microIvy), new Date());
+        }
+        
+        Pattern oneDependencyPattern = Pattern.compile(
+            "(" + mridPattern + ")\\s*->\\s*(" + mridPattern + ")");
+        m = oneDependencyPattern.matcher(microIvy);
+        if (m.matches()) {
+            DefaultModuleDescriptor md = DefaultModuleDescriptor
+                .newBasicInstance(ModuleRevisionId.parse(m.group(1)), new Date());
+            md.addDependency(new DefaultDependencyDescriptor(ModuleRevisionId.parse(m.group(2)), false));
+            return md;
+        }
+        
+        String p = "(" + mridPattern + ")\\s*->\\s*\\{\\s*((?:" 
+                    + mridPattern + ",?\\s+)*" + mridPattern + ")?\\s*\\}";
+        Pattern multipleDependenciesPattern = Pattern.compile(
+            p);
+        m = multipleDependenciesPattern.matcher(microIvy);
+        if (m.matches()) {
+            DefaultModuleDescriptor md = DefaultModuleDescriptor
+                .newBasicInstance(ModuleRevisionId.parse(m.group(1)), new Date());
+            String mrids = m.group(2);
+            if (mrids != null) {
+                Collection depMrids = parseMrids(mrids);
+                for (Iterator iter = depMrids.iterator(); iter.hasNext();) {
+                    ModuleRevisionId dep = (ModuleRevisionId) iter.next();
+                    md.addDependency(new DefaultDependencyDescriptor(dep, false));
+                }
+            }
+            return md;
+        }
+        throw new IllegalArgumentException("invalid micro ivy format: "+microIvy);
+    }
+    
+    /**
+     * Parses a collection of module descriptors in the micro ivy format, separated by double semi
+     * columns.
+     * 
+     * @param microIvy
+     *            the text representation of the collection of module descriptors
+     * @return the collection of module descriptors parsed
+     */
+    public static Collection/*<ModuleDescriptor>*/ parseMicroIvyDescriptors(String microIvy) {
+        String[] mds = microIvy.split("\\s*;;\\s*");
+        Collection r = new ArrayList();
+        for (int i = 0; i < mds.length; i++) {
+            r.add(parseMicroIvyDescriptor(mds[i]));
+        }
+        return r;
+    }
+    
+    /**
+     * Fills a repository with a set of module, using empty files for published artifacts.
+     * 
+     * @param resolver the resolver to use to publish the modules
+     * @param mds the descriptors of the modules to put in the repository
+     * @throws IOException if an IO problem occurs while filling the repository
+     */
+    public static void fillRepository(
+            DependencyResolver resolver, Collection/*<ModuleDescriptor>*/ mds) throws IOException {
+        File tmp = File.createTempFile("ivy", "tmp");
+        try {
+            for (Iterator iter = mds.iterator(); iter.hasNext();) {
+                boolean overwrite = false;
+                ModuleDescriptor md = (ModuleDescriptor) iter.next();
+                resolver.beginPublishTransaction(md.getModuleRevisionId(), overwrite);
+                boolean published = false;
+                try {
+                    XmlModuleDescriptorWriter.write(md, tmp);
+                    resolver.publish(md.getMetadataArtifact(), tmp, overwrite);
+                    tmp.delete();
+                    tmp.createNewFile();
+                    Artifact[] artifacts = md.getAllArtifacts();
+                    for (int i = 0; i < artifacts.length; i++) {
+                        resolver.publish(artifacts[i], tmp, overwrite);
+                    }
+                    resolver.commitPublishTransaction();
+                } finally {
+                    if (!published) {
+                        resolver.abortPublishTransaction();
+                    }
+                }
+            }
+        } finally {
+            tmp.delete();
+        }
+    }
+    
+    /**
+     * A file system resolver which can be used with the
+     * {@link #fillRepository(DependencyResolver, Collection)} method to create a test case of
+     * module descriptor.
+     * <p>
+     * When finished you should call {@link #cleanTestRepository()}
+     * </p>
+     */
+    public static FileSystemResolver newTestRepository() {
+        FileSystemResolver testRepository = new FileSystemResolver();
+        testRepository.setName("test");
+        testRepository.addIvyPattern(
+            "build/test/test-repo/[organisation]/[module]/[revision]/[artifact].[ext]");
+        testRepository.addArtifactPattern(
+            "build/test/test-repo/[organisation]/[module]/[revision]/[artifact].[ext]");
+        return testRepository;
+    }
+
+    /**
+     * Cleans up the test repository.
+     * @see #newTestRepository()
+     */
+    public static void cleanTestRepository() {
+        FileUtil.forceDelete(new File("build/test/test-repo"));
+    }
+    
+    /**
+     * Cleans up the test repository and cache.
+     * @see #newTestSettings()
+     */
+    public static void cleanTest() {
+        cleanTestRepository();
+        FileUtil.forceDelete(new File("build/test/cache"));
+    }
+    
+    /**
+     * Init a test resolver as default, useful combined with
+     * {@link #fillRepository(DependencyResolver, Collection)}.
+     * 
+     * @param settings
+     *            the settings to initialize
+     * @return test settings
+     */
+    public static IvySettings loadTestSettings(IvySettings settings) {
+        settings.setDefaultCache(new File("build/test/cache"));
+        settings.addResolver(newTestRepository());
+        settings.setDefaultResolver("test");
+        return settings;
+    }
+    
+    /**
+     * Create basic resolve data using the given settings
+     * 
+     * @param settings
+     *            the settings to use to create the resolve data
+     * @return basic resolve data useful for testing
+     */
+    public static ResolveData newResolveData(IvySettings settings) {
+        return new ResolveData(
+            new ResolveEngine(settings, new EventManager(), new SortEngine(settings)), 
+            newResolveOptions(settings));        
+    }
+
+    /**
+     * Create basic resolve options using the given settings
+     * 
+     * @param settings
+     *            the settings to use to create the resolve options
+     * @return the basic resolve options, useful for testing
+     */
+    public static ResolveOptions newResolveOptions(IvySettings settings) {
+        return new ResolveOptions().setCache(CacheManager.getInstance(settings));
     }
 }

Modified: ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/conflict/LatestCompatibleConflictManagerTest.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/conflict/LatestCompatibleConflictManagerTest.java?rev=600364&r1=600363&r2=600364&view=diff
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/conflict/LatestCompatibleConflictManagerTest.java (original)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/conflict/LatestCompatibleConflictManagerTest.java Sun Dec  2 11:49:57 2007
@@ -17,131 +17,134 @@
  */
 package org.apache.ivy.plugins.conflict;
 
-import java.io.File;
 import java.io.IOException;
 import java.text.ParseException;
 
 import junit.framework.TestCase;
 
 import org.apache.ivy.Ivy;
+import org.apache.ivy.TestFixture;
 import org.apache.ivy.TestHelper;
-import org.apache.ivy.core.cache.CacheManager;
 import org.apache.ivy.core.report.ConfigurationResolveReport;
 import org.apache.ivy.core.report.ResolveReport;
-import org.apache.ivy.core.resolve.ResolveOptions;
-import org.apache.ivy.util.DefaultMessageLogger;
-import org.apache.ivy.util.FileUtil;
-import org.apache.ivy.util.Message;
 
 public class LatestCompatibleConflictManagerTest extends TestCase {
-    private Ivy ivy;
+    private TestFixture fixture;
 
-    private File cache;
-    
     protected void setUp() throws Exception {
-        Message.setDefaultLogger(new DefaultMessageLogger(Message.MSG_DEBUG));
-        ivy = new Ivy();
-        ivy.configure(LatestCompatibleConflictManagerTest.class.getResource("ivysettings-latest-compatible.xml"));
-        cache = new File("build/cache");
-        cache.mkdirs();
+        fixture = new TestFixture();
+        LatestCompatibleConflictManager cm = new LatestCompatibleConflictManager();
+        fixture.getSettings().addConfigured(cm);
+        fixture.getSettings().setDefaultConflictManager(cm);
     }
 
     protected void tearDown() throws Exception {
-        FileUtil.forceDelete(cache);
+        fixture.clean();
     }
 
     public void testInitFromSettings() throws Exception {
+        Ivy ivy = new Ivy();
+        ivy.configure(LatestCompatibleConflictManagerTest
+            .class.getResource("ivysettings-latest-compatible.xml"));
         ConflictManager cm = ivy.getSettings().getDefaultConflictManager();
         assertTrue(cm instanceof LatestCompatibleConflictManager);
     }
 
     public void testCompatibilityResolve1() throws Exception {
-        /* Test data:
-            #A;1-> { #B;1.4 #C;[2.0,2.5] }
-            #B;1.4->#D;1.5
-            #C;2.5->#D;[1.0,1.6]
-         */
-        resolveAndAssert("ivy-latest-compatible-1.xml", "#B;1.4, #C;2.5, #D;1.5");
+        fixture
+            .addMD("#A;1-> { #B;1.4 #C;[2.0,2.5] }")
+            .addMD("#B;1.4->#D;1.5")
+            .addMD("#C;2.5->#D;[1.0,1.6]")
+            .addMD("#D;1.5").addMD("#D;1.6")
+            .init();
+        resolveAndAssert("#A;1", "#B;1.4, #C;2.5, #D;1.5");
     }
 
     public void testCompatibilityResolve2() throws Exception {
-        /* Test data:
-            #A;2-> { #B;[1.0,1.5] #C;[2.0,2.5] }
-            #B;1.4->#D;1.5
-            #B;1.5->#D;2.0
-            #C;2.5->#D;[1.0,1.6]
-         */
-        resolveAndAssert("ivy-latest-compatible-2.xml", "#B;1.4, #C;2.5, #D;1.5");
+        fixture
+            .addMD("#A;2-> { #B;[1.0,1.5] #C;[2.0,2.5] }")
+            .addMD("#B;1.4->#D;1.5")
+            .addMD("#B;1.5->#D;2.0")
+            .addMD("#C;2.5->#D;[1.0,1.6]")
+            .addMD("#D;1.5").addMD("#D;1.6").addMD("#D;2.0")
+            .init();
+        resolveAndAssert("#A;2", "#B;1.4, #C;2.5, #D;1.5");
     }
 
     public void testCompatibilityResolve3() throws Exception {
-        /* Test data:
-            #A;3-> { #B;[2.0,2.5] #C;[3.0,3.5] }
-            #B;2.3-> { #D;1.5 #E;1.0 }
-            #B;2.4-> { #D;1.5 #E;2.0 }
-            #B;2.5-> { #D;2.0 }
-            #C;3.4-> { #D;[1.0,1.6] #E;1.0 } 
-            #C;3.5-> { #D;[1.0,1.6] #E;1.9 } 
-         */
-        resolveAndAssert("ivy-latest-compatible-3.xml", "#B;2.3, #C;3.4, #D;1.5, #E;1.0");
+        fixture
+            .addMD("#A;3-> { #B;[2.0,2.5] #C;[3.0,3.5] }")
+            .addMD("#B;2.3-> { #D;1.5 #E;1.0 }")
+            .addMD("#B;2.4-> { #D;1.5 #E;2.0 }")
+            .addMD("#B;2.5-> { #D;2.0 }")
+            .addMD("#B;2.5-> { #D;2.0 }")
+            .addMD("#C;3.4-> { #D;[1.0,1.6] #E;1.0 }")
+            .addMD("#C;3.5-> { #D;[1.0,1.6] #E;1.9 }")
+            .addMD("#D;1.5").addMD("#D;1.6").addMD("#D;2.0")
+            .addMD("#E;1.0").addMD("#E;1.9").addMD("#E;2.0")
+            .init();
+        resolveAndAssert("#A;3", "#B;2.3, #C;3.4, #D;1.5, #E;1.0");
     }
 
     public void testCompatibilityResolve4() throws Exception {
-        /* Test data:
-            #A;4-> { #B;[1.0,1.5] #C;[2.0,2.5] #F;[1.0,1.1] }
-            #B;1.4->#D;1.5
-            #B;1.5->#D;2.0
-            #C;2.5->#D;[1.0,1.6]
-            #F;1.0->#D;1.5
-            #F;1.1->#D;1.6
-         */
-        resolveAndAssert("ivy-latest-compatible-4.xml", "#B;1.4, #C;2.5, #D;1.5, #F;1.0");
+        fixture
+            .addMD("#A;4-> { #B;[1.0,1.5] #C;[2.0,2.5] #F;[1.0,1.1] }")
+            .addMD("#B;1.4->#D;1.5")
+            .addMD("#B;1.5->#D;2.0")
+            .addMD("#C;2.5->#D;[1.0,1.6]")
+            .addMD("#F;1.0->#D;1.5")
+            .addMD("#F;1.1->#D;1.6")
+            .addMD("#D;1.5").addMD("#D;1.6").addMD("#D;2.0")
+            .init();
+        resolveAndAssert("#A;4", "#B;1.4, #C;2.5, #D;1.5, #F;1.0");
     }
 
     public void testCompatibilityResolve5() throws Exception {
-        /* Test data:
-            #A;5->{ #B;[1.0,1.5] #C;2.6 }
-            #B;1.3->{ }
-            #B;1.4->#D;1.5
-            #B;1.5->#D;2.0
-            #C;2.6->#D;1.6
-         */
-        resolveAndAssert("ivy-latest-compatible-5.xml", "#B;1.3, #C;2.6, #D;1.6");
+        fixture
+            .addMD("#A;5->{ #B;[1.0,1.5] #C;2.6 }")
+            .addMD("#B;1.3->{ }")
+            .addMD("#B;1.4->#D;1.5")
+            .addMD("#B;1.5->#D;2.0")
+            .addMD("#C;2.6->#D;1.6")
+            .addMD("#D;1.5").addMD("#D;1.6").addMD("#D;2.0")
+            .init();
+        resolveAndAssert("#A;5", "#B;1.3, #C;2.6, #D;1.6");
     }
 
     public void testCompatibilityResolve6() throws Exception {
-        /* Test data:
-            #A;6->{ #B;[3.0,3.5] #C;4.6 }
-            #B;3.4->#D;2.5
-            #B;3.5->#D;3.0
-            #C;4.6->#D;2.5
-            #D;3.0->#B;3.5 (circular dependency)
-            #D;2.5->#B;3.4 (circular dependency)
-         */
-        resolveAndAssert("ivy-latest-compatible-6.xml", "#B;3.4, #C;4.6, #D;2.5");
+        fixture
+            .addMD("#A;6->{ #B;[3.0,3.5] #C;4.6 }")
+            .addMD("#B;3.4->#D;2.5")
+            .addMD("#B;3.5->#D;3.0")
+            .addMD("#C;4.6->#D;2.5")
+            .addMD("#D;3.0->#B;3.5") // circular dependency
+            .addMD("#D;2.5->#B;3.4") // circular dependency
+            .addMD("#D;2.5").addMD("#D;3.0")
+            .init();
+        resolveAndAssert("#A;6", "#B;3.4, #C;4.6, #D;2.5");
     }
 
     public void testCompatibilityResolve7() throws Exception {
-        /* Test data: (same as 1, but with reverse dependencies order 
-            #A;7-> { #C;[2.0,2.5] #B;1.4 }
-            #B;1.4->#D;1.5
-            #C;2.5->#D;[1.0,1.6]
-         */
-        resolveAndAssert("ivy-latest-compatible-7.xml", "#B;1.4, #C;2.5, #D;1.5");
+        fixture
+            .addMD("#A;1-> { #C;[2.0,2.5] #B;1.4 }")
+            .addMD("#B;1.4->#D;1.5")
+            .addMD("#C;2.5->#D;[1.0,1.6]")
+            .addMD("#D;1.5").addMD("#D;1.6")
+            .init();
+        resolveAndAssert("#A;1", "#B;1.4, #C;2.5, #D;1.5");
     }
 
 
     public void testConflict() throws Exception {
-        /* Test data:
-            #A;conflict-> { #B;[1.5,1.6] #C;2.5 }
-            #B;1.5->#D;2.0
-            #B;1.6->#D;2.0
-            #C;2.5->#D;[1.0,1.6]
-         */
         try {
-            ivy.resolve(
-                LatestCompatibleConflictManagerTest.class.getResource("ivy-latest-compatible-conflict.xml"),
-                getResolveOptions());
+            fixture
+                .addMD("#A;conflict-> { #B;[1.5,1.6] #C;2.5 }")
+                .addMD("#B;1.5->#D;2.0")
+                .addMD("#B;1.6->#D;2.0")
+                .addMD("#C;2.5->#D;[1.0,1.6]")
+                .addMD("#D;1.5").addMD("#D;1.6").addMD("#D;2.0")
+                .init();
+            fixture.resolve("#A;conflict");
 
             fail("Resolve should have failed with a conflict");
         } catch (StrictConflictException e) {
@@ -149,20 +152,12 @@
         }
     }
 
-    private void resolveAndAssert(String ivyFile, String expectedModuleSet) 
+    private void resolveAndAssert(String mrid, String expectedModuleSet) 
         throws ParseException, IOException {
-        ResolveReport report = ivy.resolve(
-            LatestCompatibleConflictManagerTest.class.getResource(ivyFile),
-            getResolveOptions());
+        ResolveReport report = fixture.resolve(mrid);
         assertFalse(report.hasError());
         ConfigurationResolveReport defaultReport = report.getConfigurationReport("default");
         TestHelper.assertModuleRevisionIds(expectedModuleSet, 
             defaultReport.getModuleRevisionIds());
-    }
-    
-    private ResolveOptions getResolveOptions() {
-        return new ResolveOptions()
-                .setCache(CacheManager.getInstance(ivy.getSettings()))
-                .setValidate(false);
     }
 }