1 package org.jacorb.test.bugs.bug272; 2 3 import junit.framework.*; 4 5 import org.omg.CORBA.*; 6 7 13 public class TestCase extends junit.framework.TestCase 14 { 15 public TestCase (String name) 16 { 17 super (name); 18 } 19 20 public static Test suite() 21 { 22 TestSuite suite = new TestSuite ("bug 272 byte array in Any"); 23 24 suite.addTest (new TestCase ("test_Any_byte_array_1")); 25 suite.addTest (new TestCase ("test_Any_byte_array_3999")); 26 suite.addTest (new TestCase ("test_Any_byte_array_4000")); 27 suite.addTest (new TestCase ("test_Any_byte_array_4001")); 28 suite.addTest (new TestCase ("test_Any_byte_array_40123")); 29 30 return suite; 31 } 32 33 37 public void test_Any_byte_array_1() 38 { 39 do_Any_byte_array (1); 40 } 41 42 47 public void test_Any_byte_array_3999() 48 { 49 do_Any_byte_array (3999); 50 } 51 52 57 public void test_Any_byte_array_4000() 58 { 59 do_Any_byte_array (4000); 60 } 61 62 67 public void test_Any_byte_array_4001() 68 { 69 do_Any_byte_array (4001); 70 } 71 72 77 public void test_Any_byte_array_40123() 78 { 79 do_Any_byte_array (40123); 80 } 81 82 private void do_Any_byte_array (int length) 83 { 84 ORB orb = ORB.init(); 85 Any a = orb.create_any(); 86 87 byte[] b = new byte[length]; 88 for (int i=0; i<b.length; i++) b[i] = (byte)(i % 256); 89 90 OctetSeqHelper.insert( a, b ); 91 92 byte[] result = OctetSeqHelper.extract( a ); 93 94 assertTrue ( "arrays are the same", b != result); 95 assertEquals( "wrong length of resulting array: ", b.length, result.length ); 96 97 for (int i=0; i<result.length; i++) 98 assertEquals( "wrong array element at index " + i, b[i], result[i] ); 99 } 100 101 } 102 | Popular Tags |