1 package org.jacorb.test.bugs.bug344; 2 3 22 23 import junit.framework.*; 24 import junit.extensions.TestSetup; 25 import org.jacorb.test.common.ORBSetup; 26 import org.jacorb.test.orb.BasicServerImpl; 27 import org.omg.PortableServer.POA ; 28 import org.omg.PortableServer.POAHelper ; 29 import org.omg.CORBA.Policy ; 30 31 32 39 public class TestCase extends junit.framework.TestCase 40 { 41 44 private static org.omg.CORBA.ORB orb = null; 45 46 47 52 public TestCase (String name) 53 { 54 super (name); 55 } 56 57 58 63 public static Test suite () 64 { 65 TestSuite suite = new TestSuite ("bug 344 POA activation/deactivation"); 66 Setup setup = new Setup( suite ); 67 ORBSetup osetup = new ORBSetup( setup ); 68 69 suite.addTest (new TestCase ("testActivateDeactivate1")); 70 suite.addTest (new TestCase ("testActivateDeactivate2")); 71 suite.addTest (new TestCase ("testActivateDeactivate3")); 72 73 return osetup; 74 } 75 76 77 82 public void testActivateDeactivate1 () 83 { 84 try 85 { 86 POA poa = POAHelper.narrow(orb.resolve_initial_references("RootPOA")); 87 88 poa.the_POAManager().activate(); 89 90 BasicServerImpl soi = new BasicServerImpl(); 91 92 for (int count=0;count<100;count++) 93 { 94 poa.activate_object( soi); 96 poa.deactivate_object(poa.servant_to_id(soi)); 98 } 99 } 100 catch( Exception e ) 101 { 102 fail( "unexpected exception: " + e ); 103 } 104 } 105 106 107 111 public void testActivateDeactivate2 () 112 { 113 try 114 { 115 POA poa = POAHelper.narrow(orb.resolve_initial_references("RootPOA")); 116 117 poa.the_POAManager().activate(); 118 119 BasicServerImpl soi = new BasicServerImpl(); 120 121 byte []id = poa.servant_to_id( soi ); 123 124 for (int count=0;count<100;count++) 125 { 126 poa.deactivate_object(id); 127 poa.activate_object_with_id(id, soi); 128 } 129 } 130 catch( Exception e ) 131 { 132 fail( "unexpected exception: " + e ); 133 } 134 } 135 136 137 141 public void testActivateDeactivate3 () 142 { 143 try 144 { 145 POA rootPoa = POAHelper.narrow(orb.resolve_initial_references("RootPOA")); 146 147 Policy policies[] = new Policy [3]; 149 policies[0] = rootPoa.create_id_assignment_policy( 150 org.omg.PortableServer.IdAssignmentPolicyValue.SYSTEM_ID); 151 policies[1] = rootPoa.create_id_uniqueness_policy( 152 org.omg.PortableServer.IdUniquenessPolicyValue.MULTIPLE_ID); 153 policies[2] = rootPoa.create_servant_retention_policy( 154 org.omg.PortableServer.ServantRetentionPolicyValue.RETAIN); 155 156 POA poa = rootPoa.create_POA("system_id", rootPoa.the_POAManager(), policies); 157 158 BasicServerImpl soi = new BasicServerImpl(); 159 160 byte [] id = poa.activate_object(soi); 161 162 for (int count=0;count<100;count++) 163 { 164 poa.deactivate_object(id); 165 poa.activate_object_with_id( id, soi); 166 } 167 } 168 catch( Exception e ) 169 { 170 e.printStackTrace(); 171 fail( "unexpected exception: " + e ); 172 } 173 } 174 175 176 177 180 private static class Setup extends TestSetup 181 { 182 187 public Setup (Test test) 188 { 189 super (test); 190 } 191 192 195 protected void setUp () 196 { 197 org.omg.CORBA.Object obj = null; 198 199 orb = ORBSetup.getORB (); 200 } 201 202 205 protected void tearDown () 206 { 207 } 208 } 209 } 210 | Popular Tags |