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