001 package org.apache.maven.repository.metadata;
002
003 /*
004 * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
005 * agreements. See the NOTICE file distributed with this work for additional information regarding
006 * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance with the License. You may obtain a
008 * copy of the License at
009 *
010 * http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software distributed under the License
013 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
014 * or implied. See the License for the specific language governing permissions and limitations under
015 * the License.
016 */
017
018 import org.apache.maven.repository.metadata.GraphConflictResolutionPolicy;
019 import org.apache.maven.repository.metadata.MetadataGraphEdge;
020 import org.codehaus.plexus.PlexusTestCase;
021
022 /**
023 *
024 * @author <a href="mailto:oleg@codehaus.org">Oleg Gusakov</a>
025 *
026 */
027
028 public class DefaultGraphConflictResolutionPolicyTest
029 extends PlexusTestCase
030 {
031 GraphConflictResolutionPolicy policy;
032 MetadataGraphEdge e1;
033 MetadataGraphEdge e2;
034 MetadataGraphEdge e3;
035 //------------------------------------------------------------------------------------------
036 @Override
037 protected void setUp() throws Exception
038 {
039 super.setUp();
040 policy = (GraphConflictResolutionPolicy) lookup( GraphConflictResolutionPolicy.ROLE, "default" );
041 e1 = new MetadataGraphEdge( "1.1", true, null, null, 2, 1 );
042 e2 = new MetadataGraphEdge( "1.2", true, null, null, 3, 2 );
043 e3 = new MetadataGraphEdge( "1.2", true, null, null, 2, 3 );
044 }
045 //------------------------------------------------------------------------------------------
046 public void testDefaultPolicy()
047 throws Exception
048 {
049 MetadataGraphEdge res;
050
051 res = policy.apply( e1, e2 );
052 assertEquals( "Wrong depth edge selected", "1.1", res.getVersion() );
053
054 res = policy.apply( e1, e3 );
055 assertEquals( "Wrong version edge selected", "1.2", res.getVersion() );
056 }
057 //------------------------------------------------------------------------------------------
058 //------------------------------------------------------------------------------------------
059 }