View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a 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,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.maven.plugin.eclipse;
20  
21  import java.util.HashMap;
22  import java.util.Map;
23  
24  import junit.framework.TestCase;
25  
26  /**
27   * Tests the BuildCommand class.
28   * 
29   * @author <a href="mailto:kenneyw@neonics.com">Kenney Westerhof</a>
30   */
31  public class BuildCommandTest
32      extends TestCase
33  {
34      /**
35       * Tests various equalities for buildCommands, needed to remove duplicate build commands from <code>.project</code>.
36       */
37      public void testEquals()
38      {
39          BuildCommand b1 = new BuildCommand( "foobuilder", null, (Map) null );
40          BuildCommand b2 = new BuildCommand( "foobuilder", "", (Map) null );
41          assertEquals( false, b1.equals( b2 ) );
42          assertEquals( false, b2.equals( b1 ) );
43  
44          b2 = new BuildCommand( "foobuilder", null, (Map) null );
45          assertEquals( true, b1.equals( b2 ) );
46          assertEquals( true, b2.equals( b1 ) );
47  
48          b2 = new BuildCommand( "foobuilder", null, new HashMap() );
49          assertEquals( true, b1.equals( b2 ) );
50          assertEquals( true, b2.equals( b1 ) );
51  
52          Map m1 = new HashMap();
53          Map m2 = new HashMap();
54  
55          b1 = new BuildCommand( "foobuilder", null, m1 );
56          b2 = new BuildCommand( "foobuilder", null, m2 );
57          assertEquals( true, b1.equals( b2 ) );
58          assertEquals( true, b2.equals( b1 ) );
59  
60          m1.put( "arg1", "value1" );
61          m2.put( "arg1", "value1" );
62          b1 = new BuildCommand( "foobuilder", null, m1 );
63          b2 = new BuildCommand( "foobuilder", null, m2 );
64          assertEquals( true, b1.equals( b2 ) );
65          assertEquals( true, b2.equals( b1 ) );
66  
67          m2.put( "arg1", "foo" );
68          b1 = new BuildCommand( "foobuilder", null, m1 );
69          b2 = new BuildCommand( "foobuilder", null, m2 );
70          assertEquals( false, b1.equals( b2 ) );
71          assertEquals( false, b2.equals( b1 ) );
72      }
73  }