001package org.apache.maven.repository.legacy.resolver.conflict;
002
003/*
004 * Licensed to the Apache Software Foundation (ASF) under one
005 * or more contributor license agreements.  See the NOTICE file
006 * distributed with this work for additional information
007 * regarding copyright ownership.  The ASF licenses this file
008 * to you under the Apache License, Version 2.0 (the
009 * "License"); you may not use this file except in compliance
010 * with the License.  You may obtain a copy of the License at
011 *
012 *  http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing,
015 * software distributed under the License is distributed on an
016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017 * KIND, either express or implied.  See the License for the
018 * specific language governing permissions and limitations
019 * under the License.
020 */
021
022import java.util.Collections;
023
024import org.apache.maven.artifact.resolver.ResolutionNode;
025import org.apache.maven.repository.legacy.resolver.conflict.FarthestConflictResolver;
026
027/**
028 * Tests <code>FarthestConflictResolver</code>.
029 *
030 * @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
031 * @see FarthestConflictResolver
032 */
033public class FarthestConflictResolverTest
034    extends AbstractConflictResolverTest
035{
036    // constructors -----------------------------------------------------------
037
038    public FarthestConflictResolverTest()
039        throws Exception
040    {
041        super("farthest");
042    }
043
044    // tests ------------------------------------------------------------------
045
046    /**
047     * Tests that <code>a:2.0</code> wins in the scenario:
048     * <pre>
049     * a:1.0
050     * b:1.0 -> a:2.0
051     * </pre>
052     */
053    public void testDepth()
054    {
055        ResolutionNode a1n = new ResolutionNode( a1, Collections.EMPTY_LIST );
056        ResolutionNode b1n = new ResolutionNode( b1, Collections.EMPTY_LIST );
057        ResolutionNode a2n = new ResolutionNode( a2, Collections.EMPTY_LIST, b1n );
058
059        assertResolveConflict( a2n, a1n, a2n );
060    }
061
062    /**
063     * Tests that <code>a:2.0</code> wins in the scenario:
064     * <pre>
065     * b:1.0 -> a:2.0
066     * a:1.0
067     * </pre>
068     */
069    public void testDepthReversed()
070    {
071        ResolutionNode b1n = new ResolutionNode( b1, Collections.EMPTY_LIST );
072        ResolutionNode a2n = new ResolutionNode( a2, Collections.EMPTY_LIST, b1n );
073        ResolutionNode a1n = new ResolutionNode( a1, Collections.EMPTY_LIST );
074
075        assertResolveConflict( a2n, a2n, a1n );
076    }
077
078    /**
079     * Tests that <code>a:1.0</code> wins in the scenario:
080     * <pre>
081     * a:1.0
082     * a:2.0
083     * </pre>
084     */
085    public void testEqual()
086    {
087        ResolutionNode a1n = new ResolutionNode( a1, Collections.EMPTY_LIST );
088        ResolutionNode a2n = new ResolutionNode( a2, Collections.EMPTY_LIST );
089
090        assertResolveConflict( a1n, a1n, a2n );
091    }
092
093    /**
094     * Tests that <code>a:2.0</code> wins in the scenario:
095     * <pre>
096     * a:2.0
097     * a:1.0
098     * </pre>
099     */
100    public void testEqualReversed()
101    {
102        ResolutionNode a2n = new ResolutionNode( a2, Collections.EMPTY_LIST );
103        ResolutionNode a1n = new ResolutionNode( a1, Collections.EMPTY_LIST );
104
105        assertResolveConflict( a2n, a2n, a1n );
106    }
107}