KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > message > TestText


1 package test.message;
2
3 import junit.framework.TestCase;
4
5 import org.apache.axis.message.Text;
6
7 /**
8  * Test case for {@link Text}.
9  *
10  * @author Ian P. Springer
11  */

12 public class TestText extends TestCase
13 {
14
15     private static final String JavaDoc VANILLA = "vanilla";
16     private static final String JavaDoc CHOCOLATE = "chocolate";
17     private static final String JavaDoc NULL = null;
18
19     private Text vanillaText;
20     private Text chocolateText;
21     private Text nullText;
22     private Text vanillaText2;
23
24     protected void setUp() throws Exception JavaDoc
25     {
26         vanillaText = new org.apache.axis.message.Text( VANILLA );
27         vanillaText2 = new org.apache.axis.message.Text( VANILLA );
28         chocolateText = new org.apache.axis.message.Text( CHOCOLATE );
29         nullText = new org.apache.axis.message.Text( NULL );
30     }
31
32     /**
33      * Test for {@link org.apache.axis.message.Text#toString()}.
34      *
35      * @throws Exception on error
36      */

37     public void testToString() throws Exception JavaDoc
38     {
39         assertEquals( VANILLA, vanillaText.toString() );
40         assertEquals( NULL, nullText.toString() );
41     }
42
43     /**
44      * Test for {@link org.apache.axis.message.Text#hashCode()}.
45      *
46      * @throws Exception on error
47      */

48     public void testHashCode() throws Exception JavaDoc
49     {
50         assertEquals( VANILLA.hashCode(), vanillaText.hashCode() );
51         assertEquals( 0, nullText.hashCode() );
52     }
53
54     /**
55      * Test for {@link org.apache.axis.message.Text#equals(Object)}.
56      *
57      * @throws Exception on error
58      */

59     public void testEquals() throws Exception JavaDoc
60     {
61         assertEquals( vanillaText, vanillaText2 );
62         assertEquals( vanillaText2, vanillaText );
63         assertTrue( !vanillaText.equals( chocolateText ) );
64         assertTrue( !chocolateText.equals( vanillaText ) );
65         assertTrue( !vanillaText.equals( null ) );
66         assertTrue( !vanillaText.equals( VANILLA ) );
67     }
68
69 }
70
Popular Tags