1 package org.jacorb.test.bugs.bug387; 2 3 22 23 import junit.framework.*; 24 25 import org.jacorb.test.common.*; 26 27 33 public class TestCase extends ClientServerTestCase 34 { 35 private TestInterface server = null; 36 37 public TestCase (String name, ClientServerSetup setup) 38 { 39 super (name, setup); 40 } 41 42 public void setUp() 43 { 44 server = (TestInterface)TestInterfaceHelper.narrow(setup.getServerObject()); 45 } 46 47 public static Test suite() 48 { 49 TestSuite suite = new TestSuite("bug 387 value box in struct in any"); 50 ClientServerSetup setup = 51 new ClientServerSetup(suite, 52 "org.jacorb.test.bugs.bug387.TestInterfaceImpl"); 53 54 suite.addTest(new TestCase("test_return_value", setup)); 55 suite.addTest(new TestCase("test_return_null", setup)); 56 suite.addTest(new TestCase("test_pass_value", setup)); 57 suite.addTest(new TestCase("test_pass_null", setup)); 58 suite.addTest(new TestCase("test_pass_unshared", setup)); 59 suite.addTest(new TestCase("test_pass_shared", setup)); 60 61 return setup; 62 } 63 64 public void test_return_value() 65 { 66 org.omg.CORBA.Any a = server.test_return_value(); 67 TestStruct t = TestStructHelper.extract(a); 68 assertEquals("STRINGTEST", t.name); 69 } 70 71 public void test_return_null() 72 { 73 org.omg.CORBA.Any a = server.test_return_null(); 74 TestStruct t = TestStructHelper.extract(a); 75 assertEquals(null, t.name); 76 } 77 78 public void test_pass_value() 79 { 80 org.omg.CORBA.Any a = setup.getClientOrb().create_any(); 81 TestStruct t = new TestStruct("STRINGTEST", null, 1); 82 TestStructHelper.insert(a, t); 83 boolean result = server.test_pass_value(a, "STRINGTEST"); 84 assertTrue(result); 85 } 86 87 public void test_pass_null() 88 { 89 org.omg.CORBA.Any a = setup.getClientOrb().create_any(); 90 TestStruct t = new TestStruct(null, null, 1); 91 TestStructHelper.insert(a, t); 92 boolean result = server.test_pass_null(a); 93 assertTrue(result); 94 } 95 96 public void test_pass_unshared() 97 { 98 org.omg.CORBA.Any a = setup.getClientOrb().create_any(); 99 String s1 = "hello"; 100 String s2 = new String (s1); 101 TestStruct t = new TestStruct(s1, s2, 1); 102 TestStructHelper.insert(a, t); 103 boolean result = server.test_pass_shared(a); 104 assertFalse(result); 105 } 106 107 public void test_pass_shared() 108 { 109 org.omg.CORBA.Any a = setup.getClientOrb().create_any(); 110 String s1 = "hello"; 111 String s2 = s1; 112 TestStruct t = new TestStruct(s1, s2, 1); 113 TestStructHelper.insert(a, t); 114 boolean result = server.test_pass_shared(a); 115 assertTrue(result); 116 } 117 } 118 | Popular Tags |