1 package org.jacorb.test.poa; 2 3 22 23 import junit.framework.*; 24 import junit.extensions.TestSetup; 25 import org.jacorb.test.common.ORBSetup; 26 import org.jacorb.poa.util.ByteArrayKey; 27 28 29 35 public class ByteArrayKeyTest extends TestCase 36 { 37 40 private static org.omg.CORBA.ORB orb = null; 41 42 43 44 49 public ByteArrayKeyTest (String name) 50 { 51 super (name); 52 } 53 54 55 60 public static Test suite () 61 { 62 TestSuite suite = new TestSuite ("ByteArrayKey Test"); 63 Setup setup = new Setup( suite ); 64 ORBSetup osetup = new ORBSetup( setup ); 65 66 suite.addTest (new ByteArrayKeyTest ("testKey1")); 67 suite.addTest (new ByteArrayKeyTest ("testKey2")); 68 69 return osetup; 70 } 71 72 73 76 public void testKey1 () 77 { 78 ByteArrayKey bk = new ByteArrayKey( (byte[])null ); 79 80 try 81 { 82 bk.toString(); 83 bk.getBytes(); 84 bk.hashCode(); 85 86 if( System.identityHashCode( bk.toString() ) != 87 System.identityHashCode( bk.toString() ) ) 88 { 89 fail( "Different Strings returned on toString" ); 90 } 91 } 92 catch( Exception e ) 93 { 94 fail( "Caught exception processing ByteArrayKey" ); 95 } 96 } 97 98 99 102 public void testKey2 () 103 { 104 ByteArrayKey bk = new ByteArrayKey( ( "bytearraykeytest" ).getBytes() ); 105 106 try 107 { 108 bk.toString(); 109 bk.getBytes(); 110 bk.hashCode(); 111 112 if( System.identityHashCode( bk.toString() ) != 113 System.identityHashCode( bk.toString() ) ) 114 { 115 fail( "Different Strings returned on toString" ); 116 } 117 } 118 catch( Exception e ) 119 { 120 fail( "Caught exception processing ByteArrayKey" ); 121 } 122 } 123 124 125 128 private static class Setup extends TestSetup 129 { 130 135 public Setup (Test test) 136 { 137 super (test); 138 } 139 140 143 protected void setUp () 144 { 145 org.omg.CORBA.Object obj = null; 146 147 orb = ORBSetup.getORB (); 148 } 149 150 153 protected void tearDown () 154 { 155 } 156 } 157 } 158 | Popular Tags |