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 * @version $Id: FarthestConflictResolverTest.java 789077 2009-06-28 09:39:49Z jvanzyl $
32 * @see FarthestConflictResolver
33 */
34 public class FarthestConflictResolverTest
35 extends AbstractConflictResolverTest
36 {
37 // constructors -----------------------------------------------------------
38
39 public FarthestConflictResolverTest()
40 throws Exception
41 {
42 super("farthest");
43 }
44
45 // tests ------------------------------------------------------------------
46
47 /**
48 * Tests that <code>a:2.0</code> wins in the scenario:
49 * <pre>
50 * a:1.0
51 * b:1.0 -> a:2.0
52 * </pre>
53 */
54 public void testDepth()
55 {
56 ResolutionNode a1n = new ResolutionNode( a1, Collections.EMPTY_LIST );
57 ResolutionNode b1n = new ResolutionNode( b1, Collections.EMPTY_LIST );
58 ResolutionNode a2n = new ResolutionNode( a2, Collections.EMPTY_LIST, b1n );
59
60 assertResolveConflict( a2n, a1n, a2n );
61 }
62
63 /**
64 * Tests that <code>a:2.0</code> wins in the scenario:
65 * <pre>
66 * b:1.0 -> a:2.0
67 * a:1.0
68 * </pre>
69 */
70 public void testDepthReversed()
71 {
72 ResolutionNode b1n = new ResolutionNode( b1, Collections.EMPTY_LIST );
73 ResolutionNode a2n = new ResolutionNode( a2, Collections.EMPTY_LIST, b1n );
74 ResolutionNode a1n = new ResolutionNode( a1, Collections.EMPTY_LIST );
75
76 assertResolveConflict( a2n, a2n, a1n );
77 }
78
79 /**
80 * Tests that <code>a:1.0</code> wins in the scenario:
81 * <pre>
82 * a:1.0
83 * a:2.0
84 * </pre>
85 */
86 public void testEqual()
87 {
88 ResolutionNode a1n = new ResolutionNode( a1, Collections.EMPTY_LIST );
89 ResolutionNode a2n = new ResolutionNode( a2, Collections.EMPTY_LIST );
90
91 assertResolveConflict( a1n, a1n, a2n );
92 }
93
94 /**
95 * Tests that <code>a:2.0</code> wins in the scenario:
96 * <pre>
97 * a:2.0
98 * a:1.0
99 * </pre>
100 */
101 public void testEqualReversed()
102 {
103 ResolutionNode a2n = new ResolutionNode( a2, Collections.EMPTY_LIST );
104 ResolutionNode a1n = new ResolutionNode( a1, Collections.EMPTY_LIST );
105
106 assertResolveConflict( a2n, a2n, a1n );
107 }
108 }