1 package org.jacorb.test.bugs.bug401; 2 3 22 23 import junit.framework.*; 24 25 import java.io.*; 26 import org.omg.CORBA.*; 27 import org.omg.CORBA.portable.*; 28 import org.jacorb.test.common.*; 29 30 36 public class TestCase extends ClientServerTestCase 37 { 38 private AnyServer server = null; 39 40 public TestCase (String name, ClientServerSetup setup) 41 { 42 super (name, setup); 43 } 44 45 public void setUp() 46 { 47 server = (AnyServer)AnyServerHelper.narrow(setup.getServerObject()); 48 org.omg.CORBA_2_3.ORB orb = (org.omg.CORBA_2_3.ORB )setup.getClientOrb(); 49 orb.register_value_factory(AHelper.id(), new AFactory()); 50 orb.register_value_factory(BHelper.id(), new BFactory()); 51 } 52 53 public static Test suite() 54 { 55 TestSuite suite = new TestSuite("bug 401 values in anys"); 56 ClientServerSetup setup = 57 new ClientServerSetup(suite, 58 "org.jacorb.test.bugs.bug401.AnyServant"); 59 60 suite.addTest(new TestCase("test_getA", setup)); 61 suite.addTest(new TestCase("test_getB", setup)); 62 suite.addTest(new TestCase("test_getAB", setup)); 63 64 return setup; 65 } 66 67 public void test_getA() 68 { 69 Any aa = server.getAnyA(); 70 assertTrue ("expected TypeCode of A, got: " + aa.type().toString(), 71 aa.type().equivalent(AHelper.type())); 72 A a = AHelper.extract(aa); 73 assertEquals (0xAA, a.aa); 74 } 75 76 public void test_getB() 77 { 78 Any bb = server.getAnyB(); 79 assertTrue ("expected TypeCode of B, got: " + bb.type().toString(), 80 bb.type().equivalent(BHelper.type())); 81 B b = BHelper.extract(bb); 82 assertEquals (0xAA, b.aa); 83 assertEquals (0xBB, b.bb); 84 } 85 86 public void test_getAB() 87 { 88 Any[] ab = server.getAnyAB(); 89 assertTrue ("expected TypeCode of A, got: " + ab[0].type().toString(), 90 ab[0].type().equivalent(AHelper.type())); 91 assertTrue ("expected TypeCode of B, got: " + ab[1].type().toString(), 92 ab[1].type().equivalent(BHelper.type())); 93 A a = AHelper.extract(ab[0]); 94 B b = BHelper.extract(ab[1]); 95 assertEquals (0xAA, a.aa); 96 assertEquals (0xAA, b.aa); 97 assertEquals (0xBB, b.bb); 98 } 99 100 public static class AFactory implements ValueFactory 101 { 102 public Serializable read_value 103 (org.omg.CORBA_2_3.portable.InputStream is) 104 { 105 A a = new A(){}; 106 return is.read_value(a); 107 } 108 } 109 110 public static class BFactory implements ValueFactory 111 { 112 public Serializable read_value 113 (org.omg.CORBA_2_3.portable.InputStream is) 114 { 115 B b = new B(){}; 116 return is.read_value(b); 117 } 118 } 119 120 } 121 | Popular Tags |