View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.maven.repository.legacy.resolver.conflict;
20  
21  import org.apache.maven.artifact.resolver.ResolutionNode;
22  
23  /**
24   * Tests <code>FarthestConflictResolver</code>.
25   *
26   * @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
27   * @see FarthestConflictResolver
28   */
29  public class FarthestConflictResolverTest extends AbstractConflictResolverTest {
30      // constructors -----------------------------------------------------------
31  
32      public FarthestConflictResolverTest() throws Exception {
33          super("farthest");
34      }
35  
36      // tests ------------------------------------------------------------------
37  
38      /**
39       * Tests that <code>a:2.0</code> wins in the scenario:
40       * <pre>
41       * a:1.0
42       * b:1.0 -&gt; a:2.0
43       * </pre>
44       */
45      public void testDepth() {
46          ResolutionNode a1n = createResolutionNode(a1);
47          ResolutionNode b1n = createResolutionNode(b1);
48          ResolutionNode a2n = createResolutionNode(a2, b1n);
49  
50          assertResolveConflict(a2n, a1n, a2n);
51      }
52  
53      /**
54       * Tests that <code>a:2.0</code> wins in the scenario:
55       * <pre>
56       * b:1.0 -&gt; a:2.0
57       * a:1.0
58       * </pre>
59       */
60      public void testDepthReversed() {
61          ResolutionNode b1n = createResolutionNode(b1);
62          ResolutionNode a2n = createResolutionNode(a2, b1n);
63          ResolutionNode a1n = createResolutionNode(a1);
64  
65          assertResolveConflict(a2n, a2n, a1n);
66      }
67  
68      /**
69       * Tests that <code>a:1.0</code> wins in the scenario:
70       * <pre>
71       * a:1.0
72       * a:2.0
73       * </pre>
74       */
75      public void testEqual() {
76          ResolutionNode a1n = createResolutionNode(a1);
77          ResolutionNode a2n = createResolutionNode(a2);
78  
79          assertResolveConflict(a1n, a1n, a2n);
80      }
81  
82      /**
83       * Tests that <code>a:2.0</code> wins in the scenario:
84       * <pre>
85       * a:2.0
86       * a:1.0
87       * </pre>
88       */
89      public void testEqualReversed() {
90          ResolutionNode a2n = createResolutionNode(a2);
91          ResolutionNode a1n = createResolutionNode(a1);
92  
93          assertResolveConflict(a2n, a2n, a1n);
94      }
95  }