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