View Javadoc
1   package org.apache.maven.plugin.war.util;
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  import org.apache.maven.model.Dependency;
24  
25  /**
26   * Test the WarUtils.
27   *
28   * @author Dennis Lundberg
29   * @version $Id: WarUtilsTest.html 935522 2015-01-08 20:15:45Z khmarbaise $
30   */
31  public class WarUtilsTest
32      extends TestCase
33  {
34      /**
35       * Test for MWAR-160.
36       */
37      public void testDependencyEquals()
38      {
39          Dependency firstDependency = new Dependency();
40          firstDependency.setGroupId( "1" );
41          firstDependency.setArtifactId( "a" );
42          Dependency secondDependency = new Dependency();
43          secondDependency.setGroupId( "2" );
44          secondDependency.setArtifactId( "b" );
45          Dependency thirdDependency = new Dependency();
46          thirdDependency.setGroupId( "1" );
47          thirdDependency.setArtifactId( "c" );
48          Dependency fourthDependency = new Dependency();
49          fourthDependency.setGroupId( "4" );
50          fourthDependency.setArtifactId( "a" );
51  
52          assertFalse( "dependencies 1:a and 2:b should not be equal", WarUtils.dependencyEquals( firstDependency,
53                                                                                                  secondDependency ) );
54          assertFalse( "dependencies 1:a and 1:c should not be equal", WarUtils.dependencyEquals( firstDependency,
55                                                                                                  thirdDependency ) );
56          assertFalse( "dependencies 1:a and 4:a should not be equal", WarUtils.dependencyEquals( firstDependency,
57                                                                                                  fourthDependency ) );
58          assertFalse( "dependencies 2:b and 1:c should not be equal", WarUtils.dependencyEquals( secondDependency,
59                                                                                                  thirdDependency ) );
60          assertFalse( "dependencies 2:b and 4:a should not be equal", WarUtils.dependencyEquals( secondDependency,
61                                                                                                  fourthDependency ) );
62          assertFalse( "dependencies 1:c and 4:a should not be equal", WarUtils.dependencyEquals( thirdDependency,
63                                                                                                  fourthDependency ) );
64      }
65  }