001 package org.apache.maven.repository.metadata; 002 003 import org.apache.maven.repository.metadata.GraphConflictResolutionPolicy; 004 import org.apache.maven.repository.metadata.MetadataGraphEdge; 005 import org.codehaus.plexus.PlexusTestCase; 006 007 /** 008 * 009 * @author <a href="mailto:oleg@codehaus.org">Oleg Gusakov</a> 010 * 011 */ 012 013 public class DefaultGraphConflictResolutionPolicyTest 014 extends PlexusTestCase 015 { 016 GraphConflictResolutionPolicy policy; 017 MetadataGraphEdge e1; 018 MetadataGraphEdge e2; 019 MetadataGraphEdge e3; 020 //------------------------------------------------------------------------------------------ 021 @Override 022 protected void setUp() throws Exception 023 { 024 super.setUp(); 025 policy = (GraphConflictResolutionPolicy) lookup( GraphConflictResolutionPolicy.ROLE, "default" ); 026 e1 = new MetadataGraphEdge( "1.1", true, null, null, 2, 1 ); 027 e2 = new MetadataGraphEdge( "1.2", true, null, null, 3, 2 ); 028 e3 = new MetadataGraphEdge( "1.2", true, null, null, 2, 3 ); 029 } 030 //------------------------------------------------------------------------------------------ 031 public void testDefaultPolicy() 032 throws Exception 033 { 034 MetadataGraphEdge res; 035 036 res = policy.apply( e1, e2 ); 037 assertEquals( "Wrong depth edge selected", "1.1", res.getVersion() ); 038 039 res = policy.apply( e1, e3 ); 040 assertEquals( "Wrong version edge selected", "1.2", res.getVersion() ); 041 } 042 //------------------------------------------------------------------------------------------ 043 //------------------------------------------------------------------------------------------ 044 }