1 package org.apache.maven.repository.metadata;
2
3 /*
4 * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
5 * agreements. See the NOTICE file distributed with this work for additional information regarding
6 * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance with the License. You may obtain a
8 * 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, software distributed under the License
13 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
14 * or implied. See the License for the specific language governing permissions and limitations under
15 * the License.
16 */
17
18 import org.apache.maven.repository.metadata.GraphConflictResolutionPolicy;
19 import org.apache.maven.repository.metadata.MetadataGraphEdge;
20 import org.codehaus.plexus.PlexusTestCase;
21
22 /**
23 *
24 * @author <a href="mailto:oleg@codehaus.org">Oleg Gusakov</a>
25 *
26 */
27
28 public class DefaultGraphConflictResolutionPolicyTest
29 extends PlexusTestCase
30 {
31 GraphConflictResolutionPolicy policy;
32 MetadataGraphEdge e1;
33 MetadataGraphEdge e2;
34 MetadataGraphEdge e3;
35 //------------------------------------------------------------------------------------------
36 @Override
37 protected void setUp() throws Exception
38 {
39 super.setUp();
40 policy = (GraphConflictResolutionPolicy) lookup( GraphConflictResolutionPolicy.ROLE, "default" );
41 e1 = new MetadataGraphEdge( "1.1", true, null, null, 2, 1 );
42 e2 = new MetadataGraphEdge( "1.2", true, null, null, 3, 2 );
43 e3 = new MetadataGraphEdge( "1.2", true, null, null, 2, 3 );
44 }
45 //------------------------------------------------------------------------------------------
46 public void testDefaultPolicy()
47 throws Exception
48 {
49 MetadataGraphEdge res;
50
51 res = policy.apply( e1, e2 );
52 assertEquals( "Wrong depth edge selected", "1.1", res.getVersion() );
53
54 res = policy.apply( e1, e3 );
55 assertEquals( "Wrong version edge selected", "1.2", res.getVersion() );
56 }
57 //------------------------------------------------------------------------------------------
58 //------------------------------------------------------------------------------------------
59 }