1 package org.jacorb.test.bugs.bug384; 2 3 22 23 import junit.framework.*; 24 25 import org.omg.CORBA.*; 26 import org.jacorb.test.common.*; 27 import org.omg.PortableServer.*; 28 29 30 37 38 public class TestCase 39 extends ClientServerTestCase 40 { 41 private org.omg.CORBA.Object testObject; 42 private org.omg.CORBA.Object localTestObject; 43 private POA poa; 44 private org.omg.CORBA.ORB orb; 45 46 public TestCase( String name, ClientServerSetup setup ) 47 { 48 super( name, setup ); 49 } 50 51 public void setUp() 52 { 53 testObject = setup.getServerObject(); 54 orb = org.omg.CORBA.ORB.init( new String [0], null); 55 try 56 { 57 poa = POAHelper.narrow( orb.resolve_initial_references("RootPOA")); 58 59 poa.the_POAManager().activate(); 60 61 localTestObject = 62 poa.servant_to_reference( new TestObjectImpl()); 63 } 64 catch( Exception e ) 65 { 66 e.printStackTrace(); 67 } 68 } 69 70 71 public static Test suite() 72 { 73 TestSuite suite = new TestSuite( "bug 384 wrong is_a results" ); 74 75 try 76 { 77 ClientServerSetup setup = 78 new ClientServerSetup( suite, 79 "org.jacorb.test.bugs.bug384.TestObjectImpl" ); 80 81 suite.addTest( new TestCase( "testNonLocalIsA", setup )); 82 suite.addTest( new TestCase( "testLocalIsA", setup )); 83 suite.addTest( new TestCase( "testMarshall", setup )); 84 85 return setup; 86 } 87 catch( Exception e ) 88 { 89 e.printStackTrace(); 90 } 91 return null; 92 } 93 94 public void testNonLocalIsA() 95 { 96 assertTrue( "Is_a incorrectly returns false for non-local object", 97 testObject._is_a( "IDL:org/jacorb/test/bugs/bug384/TestObject:1.0") ); 98 99 assertFalse( "Is_a incorrectly returns true for non-local object", 100 testObject._is_a( "IDL:omg.org/CosNaming/NamingContext:1.0" )); 101 } 102 103 public void testLocalIsA() 104 { 105 assertTrue( "Is_a incorrectly returns false for non-local object", 106 localTestObject._is_a( "IDL:org/jacorb/test/bugs/bug384/TestObject:1.0") ); 107 108 assertFalse( "Is_a incorrectly returns true for non-local object", 109 localTestObject._is_a( "IDL:omg.org/CosNaming/NamingContext:1.0" )); 110 } 111 112 public void testMarshall() 113 { 114 TestObject serverObj = TestObjectHelper.narrow( testObject ); 115 try 116 { 117 A[] result = serverObj.testMarshall(); 118 } 119 catch (Exception e) 120 { 121 fail( "Caught an exception " + e ); 122 } 123 } 124 125 126 public void tearDown() throws Exception 127 { 128 super.tearDown(); 129 orb.shutdown( true ); 130 } 131 132 133 public static void main( String [] args ) 134 { 135 junit.textui.TestRunner.run( TestCase.class ); 136 } 137 138 } 139 | Popular Tags |