View Javadoc

1   package org.apache.maven.archiva.model;
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 junit.framework.TestCase;
23  
24  /**
25   * DependencyScopeTest 
26   *
27   * @version $Id: DependencyScopeTest.java 718864 2008-11-19 06:33:35Z brett $
28   */
29  public class DependencyScopeTest
30      extends TestCase
31  {
32      public void testIsWithinScope()
33      {
34          // Test on blank / empty desired scopes.
35          assertFalse( DependencyScope.isWithinScope( "compile", null ) );
36          assertFalse( DependencyScope.isWithinScope( "test", null ) );
37          assertFalse( DependencyScope.isWithinScope( "runtime", null ) );
38          assertFalse( DependencyScope.isWithinScope( "provided", null ) );
39          assertFalse( DependencyScope.isWithinScope( "compile", "" ) );
40          assertFalse( DependencyScope.isWithinScope( "test", "" ) );
41          assertFalse( DependencyScope.isWithinScope( "runtime", "" ) );
42          assertFalse( DependencyScope.isWithinScope( "provided", "" ) );
43  
44          // Tests on blank / empty actual scopes.
45          assertTrue( DependencyScope.isWithinScope( "", DependencyScope.COMPILE ) );
46          assertTrue( DependencyScope.isWithinScope( null, DependencyScope.COMPILE ) );
47          assertTrue( DependencyScope.isWithinScope( "", DependencyScope.TEST ) );
48          assertTrue( DependencyScope.isWithinScope( null, DependencyScope.TEST ) );
49          assertFalse( DependencyScope.isWithinScope( "", DependencyScope.PROVIDED ) );
50          assertFalse( DependencyScope.isWithinScope( null, DependencyScope.PROVIDED ) );
51          assertFalse( DependencyScope.isWithinScope( "", DependencyScope.RUNTIME ) );
52          assertFalse( DependencyScope.isWithinScope( null, DependencyScope.RUNTIME ) );
53  
54          // Tests on compile desired scopes.
55          assertTrue( DependencyScope.isWithinScope( "compile", DependencyScope.COMPILE ) );
56          assertFalse( DependencyScope.isWithinScope( "test", DependencyScope.COMPILE ) );
57  
58          // Tests on test desired scopes.
59          assertTrue( DependencyScope.isWithinScope( "compile", DependencyScope.TEST ) );
60          assertTrue( DependencyScope.isWithinScope( "test", DependencyScope.TEST ) );
61  
62          // Tests on oddball scopes.
63          assertFalse( DependencyScope.isWithinScope( "compile", DependencyScope.PROVIDED ) );
64          assertFalse( DependencyScope.isWithinScope( "test", DependencyScope.PROVIDED ) );
65          assertTrue( DependencyScope.isWithinScope( "provided", DependencyScope.PROVIDED ) );
66  
67          assertFalse( DependencyScope.isWithinScope( "compile", DependencyScope.RUNTIME ) );
68          assertFalse( DependencyScope.isWithinScope( "test", DependencyScope.RUNTIME ) );
69          assertTrue( DependencyScope.isWithinScope( "provided", DependencyScope.RUNTIME ) );
70          assertTrue( DependencyScope.isWithinScope( "runtime", DependencyScope.RUNTIME ) );
71      }
72  }