1   package org.apache.maven.plugin.javadoc;
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 org.apache.maven.plugin.javadoc.options.Tag;
23  import org.codehaus.plexus.PlexusTestCase;
24  
25  /**
26   * @author <a href="mailto:oching@apache.org">Maria Odea Ching</a>
27   */
28  public class TagTest
29      extends PlexusTestCase
30  {
31      /**
32       * @see org.codehaus.plexus.PlexusTestCase#setUp()
33       */
34      protected void setUp()
35          throws Exception
36      {
37          super.setUp();
38      }
39  
40      /**
41       * @see org.codehaus.plexus.PlexusTestCase#tearDown()
42       */
43      protected void tearDown()
44          throws Exception
45      {
46          super.tearDown();
47      }
48  
49      /**
50       * Test when the specified object is not a Tag object
51       *
52       * @throws Exception
53       */
54      public void testNotEquals()
55          throws Exception
56      {
57          Tag tag = new Tag();
58          tag.setHead( "HEAD" );
59          tag.setName( "NAME" );
60          tag.setPlacement( "aop" );
61  
62          assertFalse( tag.equals( new String() ) );
63      }
64  
65      /**
66       * Test when the passed object is a Tag object
67       *
68       * @throws Exception
69       */
70      public void testEquals()
71          throws Exception
72      {
73          Tag tag = new Tag();
74          tag.setHead( "HEAD" );
75          tag.setName( "NAME" );
76          tag.setPlacement( "aop" );
77  
78          Tag equalTag = new Tag();
79          equalTag.setHead( "HEAD" );
80          equalTag.setName( "NAME" );
81          equalTag.setPlacement( "aop" );
82  
83          assertTrue( tag.equals( equalTag ) );
84      }
85  
86      /**
87       * Test hashCode method
88       *
89       * @throws Exception
90       */
91      public void testHashCode()
92          throws Exception
93      {
94          Tag tag = new Tag();
95          tag.setHead( "HEAD" );
96          tag.setName( "NAME" );
97  
98          assertEquals( tag.hashCode(), 90615520 );
99      }
100 
101     /**
102      * Test the toString method
103      *
104      * @throws Exception
105      */
106     public void testToString()
107         throws Exception
108     {
109         Tag tag = new Tag();
110         tag.setHead( "HEAD" );
111         tag.setName( "NAME" );
112 
113         assertTrue( tag.toString().indexOf( "HEAD" ) != -1 );
114         assertTrue( tag.toString().indexOf( "NAME" ) != -1 );
115     }
116 }