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 org.apache.maven.artifact.resolver.ResolutionNode;
23
24 /**
25 * Tests <code>NewestConflictResolver</code>.
26 *
27 * @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
28 * @see NewestConflictResolver
29 */
30 public class NewestConflictResolverTest
31 extends AbstractConflictResolverTest
32 {
33 // constructors -----------------------------------------------------------
34
35 public NewestConflictResolverTest()
36 throws Exception
37 {
38 super("newest");
39 }
40
41 // tests ------------------------------------------------------------------
42
43 /**
44 * Tests that <code>a:2.0</code> wins in the scenario:
45 * <pre>
46 * a:1.0
47 * b:1.0 -> a:2.0
48 * </pre>
49 */
50 public void testDepth()
51 {
52 ResolutionNode a1n = createResolutionNode( a1 );
53 ResolutionNode b1n = createResolutionNode( b1 );
54 ResolutionNode a2n = createResolutionNode( a2, b1n );
55
56 assertResolveConflict( a2n, a1n, a2n );
57 }
58
59 /**
60 * Tests that <code>a:2.0</code> wins in the scenario:
61 * <pre>
62 * b:1.0 -> a:2.0
63 * a:1.0
64 * </pre>
65 */
66 public void testDepthReversed()
67 {
68 ResolutionNode b1n = createResolutionNode( b1 );
69 ResolutionNode a2n = createResolutionNode( a2, b1n );
70 ResolutionNode a1n = createResolutionNode( a1 );
71
72 assertResolveConflict( a2n, a2n, a1n );
73 }
74
75 /**
76 * Tests that <code>a:2.0</code> wins in the scenario:
77 * <pre>
78 * a:1.0
79 * a:2.0
80 * </pre>
81 */
82 public void testEqual()
83 {
84 ResolutionNode a1n = createResolutionNode( a1 );
85 ResolutionNode a2n = createResolutionNode( a2 );
86
87 assertResolveConflict( a2n, a1n, a2n );
88 }
89
90 /**
91 * Tests that <code>a:2.0</code> wins in the scenario:
92 * <pre>
93 * a:2.0
94 * a:1.0
95 * </pre>
96 */
97 public void testEqualReversed()
98 {
99 ResolutionNode a2n = createResolutionNode( a2 );
100 ResolutionNode a1n = createResolutionNode( a1 );
101
102 assertResolveConflict( a2n, a2n, a1n );
103 }
104 }