1 26 27 package org.objectweb.ccm.simple; 28 29 32 public class Install 33 { 34 37 public static void 38 main(String [] args) 39 throws Exception 40 { 41 System.out.println("INSTALL: Initializing the ORB..."); 43 44 49 args = org.objectweb.ccm.CORBA.TheORB.initialize(args); 51 52 org.objectweb.ccm.Components.Runtime.init(); 54 55 org.omg.CORBA.ORB orb = org.objectweb.ccm.CORBA.TheORB.getORB(); 57 58 System.out.println("INSTALL: Obtaining the Name Service..."); 60 org.omg.CORBA.Object obj = orb.resolve_initial_references("NameService"); 61 org.omg.CosNaming.NamingContext nc = org.omg.CosNaming.NamingContextHelper.narrow(obj); 62 63 System.out.println("INSTALL: Obtaining the Component Server..."); 65 org.omg.CosNaming.NameComponent [] ncomp = new org.omg.CosNaming.NameComponent [1]; 66 ncomp[0] = new org.omg.CosNaming.NameComponent ("ComponentServer", ""); 67 obj = nc.resolve(ncomp); 68 org.objectweb.ccm.Deployment.Server server = org.objectweb.ccm.Deployment.ServerHelper.narrow(obj); 69 70 org.omg.Components.Deployment.ComponentServer server_cs = server.provide_component_server(); 72 org.omg.Components.Deployment.ComponentInstallation server_inst = server.provide_install(); 73 74 System.out.println("INSTALL: Installing the archive..."); 76 String demoPath = null; 78 try 79 { 80 demoPath = new java.io.File (".").getCanonicalPath()+ java.io.File.separator ; 81 } 82 catch(Exception e) 83 { 84 e.printStackTrace(); 85 } 86 87 server_inst.install("simple", demoPath + "./archives/simple.jar"); 88 89 System.out.println("INSTALL: Creating a container..."); 91 org.omg.Components.Deployment.Container server_cont = 92 server_cs.create_container(new org.omg.Components.ConfigValue[0]); 93 94 System.out.println("INSTALL: Instantiating the home..."); 96 org.omg.Components.CCMHome h = null; 97 98 org.omg.Components.ConfigValue[] config = new org.omg.Components.ConfigValue[0]; 99 100 try 101 { 102 System.out.println("INSTALL: Call install_home with a correct home executor entry point..."); 103 h = server_cont.install_home("simple", 104 "org.objectweb.ccm.simple.ServerHomeImpl.create_home", 105 config); 106 System.out.println("INSTALL: Home installed correctly."); 107 } 108 catch (Exception exc) 109 { 110 System.out.println("INSTALL: ERROR: " + exc.getMessage() + " was thrown!!!"); 111 System.exit(-1); 112 } 113 114 try 115 { 116 System.out.println("\nINSTALL: Call install_home with an unknown implementation id...\n"); 117 118 h = server_cont.install_home("unknown_uuid", 119 "org.objectweb.ccm.simple.ServerHomeImpl.create_home", 120 config); 121 122 System.out.println("\nINSTALL: ERROR: Components::Deployment::UnknownImplId must be thrown!!!"); 123 System.exit(-1); 124 } 125 catch (org.omg.Components.Deployment.UnknownImplId exc) 126 { 127 System.out.println("\nINSTALL: OK " + exc.getMessage() + " was thrown."); 128 } 129 130 try 131 { 132 System.out.println("\nINSTALL: Call install_home with an unknown home executor entry point...\n"); 133 134 h = server_cont.install_home("simple", 135 "UnknownClass.create_home", 136 config); 137 138 System.out.println("\nINSTALL: ERROR: Components::Deployment::ImplEntryPointNotFound must be thrown!!!"); 139 System.exit(-1); 140 } 141 catch (org.omg.Components.Deployment.ImplEntryPointNotFound exc) 142 { 143 System.out.println("\nINSTALL: OK " + exc.getMessage() + " was thrown."); 144 } 145 146 try 147 { 148 System.out.println("\nINSTALL: Call install_home with an unknown home executor entry point...\n"); 149 150 h = server_cont.install_home("simple", 151 "org.objectweb.ccm.simple.ServerHomeImpl.unknown_method", 152 config); 153 154 System.out.println("\nINSTALL: ERROR: Components::Deployment::ImplEntryPointNotFound must be thrown!!!"); 155 System.exit(-1); 156 } 157 catch (org.omg.Components.Deployment.ImplEntryPointNotFound exc) 158 { 159 System.out.println("\nINSTALL: OK " + exc.getMessage() + " was thrown."); 160 } 161 162 try 163 { 164 System.out.println("\nINSTALL: Call install_home with an existing home executor entry point but invalid signature...\n"); 165 166 h = server_cont.install_home("simple", 167 "org.objectweb.ccm.simple.ServerHomeImpl.create_home_private", 168 config); 169 170 System.out.println("\nINSTALL: ERROR: Components::Deployment::ImplEntryPointNotFound must be thrown!!!"); 171 System.exit(-1); 172 } 173 catch (org.omg.Components.Deployment.ImplEntryPointNotFound exc) 174 { 175 System.out.println("\nINSTALL: OK " + exc.getMessage() + " was thrown."); 176 } 177 178 try 179 { 180 System.out.println("\nINSTALL: Call install_home with an existing home executor entry point but invalid signature...\n"); 181 182 h = server_cont.install_home("simple", 183 "org.objectweb.ccm.simple.ServerHomeImpl.create_home_not_static", 184 config); 185 186 System.out.println("\nINSTALL: ERROR: Components::Deployment::ImplEntryPointNotFound must be thrown!!!"); 187 System.exit(-1); 188 } 189 catch (org.omg.Components.Deployment.ImplEntryPointNotFound exc) 190 { 191 System.out.println("\nINSTALL: OK " + exc.getMessage() + " was thrown."); 192 } 193 194 try 195 { 196 System.out.println("\nINSTALL: Call install_home with an existing home executor entry point but invalid signature...\n"); 197 198 h = server_cont.install_home("simple", 199 "org.objectweb.ccm.simple.ServerHomeImpl.create_home_with_invalid_return_type", 200 config); 201 202 System.out.println("\nINSTALL: ERROR: Components::Deployment::ImplEntryPointNotFound must be thrown!!!"); 203 System.exit(-1); 204 } 205 catch (org.omg.Components.Deployment.ImplEntryPointNotFound exc) 206 { 207 System.out.println("\nINSTALL: OK " + exc.getMessage() + " was thrown."); 208 } 209 210 try 211 { 212 System.out.println("\nINSTALL: Call install_home with an existing home executor entry point but invalid signature...\n"); 213 214 h = server_cont.install_home("simple", 215 "org.objectweb.ccm.simple.ServerHomeImpl.create_home_with_parameter", 216 config); 217 218 System.out.println("\nINSTALL: ERROR: Components::Deployment::ImplEntryPointNotFound must be thrown!!!"); 219 System.exit(-1); 220 } 221 catch (org.omg.Components.Deployment.ImplEntryPointNotFound exc) 222 { 223 System.out.println("\nINSTALL: OK " + exc.getMessage() + " was thrown."); 224 } 225 226 try 227 { 228 System.out.println("\nINSTALL: Call install_home with an existing home executor entry point function but thrown an exception...\n"); 229 230 h = server_cont.install_home("simple", 231 "org.objectweb.ccm.simple.ServerHomeImpl.create_home_thrown_an_exception", 232 config); 233 234 System.out.println("\nINSTALL: ERROR: Components::Deployment::Installation must be thrown!!!"); 235 System.exit(-1); 236 } 237 catch (org.omg.Components.Deployment.InstallationFailure exc) 238 { 239 System.out.println("\nINSTALL: OK " + exc.getMessage() + " was thrown."); 240 } 241 242 config = new org.omg.Components.ConfigValue[1]; 243 config[0] = new org.objectweb.ccm.Components.ConfigValueImpl(); 244 config[0].name = "home_script"; 245 config[0].value = orb.create_any(); 246 247 try 248 { 249 System.out.println("\nINSTALL: Call install_home with an empty 'home_script' configuration value..."); 250 config[0].value.insert_string(""); 251 h = server_cont.install_home("simple", 252 "org.objectweb.ccm.simple.ServerHomeImpl.create_home", 253 config); 254 System.out.println("\nINSTALL: ERROR: Components::Deployment::InstallationFailure must be thrown!!!"); 255 System.exit(-1); 256 } 257 catch (org.omg.Components.Deployment.InstallationFailure exc) 258 { 259 System.out.println("\nINSTALL: OK " + exc.getMessage() + " was thrown."); 260 } 261 262 try 263 { 264 System.out.println("\nINSTALL: Call install_home with an invalid type for the 'home_script' configuration value..."); 265 config[0].value.insert_long(10); 266 h = server_cont.install_home("simple", 267 "org.objectweb.ccm.simple.ServerHomeImpl.create_home", 268 config); 269 System.out.println("\nINSTALL: ERROR: Components::Deployment::InvalidConfiguration must be thrown!!!"); 270 System.exit(-1); 271 } 272 catch (org.omg.Components.Deployment.InvalidConfiguration exc) 273 { 274 System.out.println("\nINSTALL: OK " + exc.getMessage() + " was thrown."); 275 } 276 277 try 278 { 279 System.out.println("\nINSTALL: Call install_home with an invalid value for the 'home_script' configuration value..."); 280 config[0].value.insert_string("invalid script"); 281 h = server_cont.install_home("simple", 282 "org.objectweb.ccm.simple.ServerHomeImpl.create_home", 283 config); 284 System.out.println("\nINSTALL: ERROR: Components::Deployment::InvalidConfiguration must be thrown!!!"); 285 System.exit(-1); 286 } 287 catch (org.omg.Components.Deployment.InvalidConfiguration exc) 288 { 289 System.out.println("\nINSTALL: OK " + exc.getMessage() + " was thrown."); 290 } 291 292 System.out.println("\nINSTALL: All install_home tests were OK."); 293 System.exit(0); 294 } 295 } 296 297 298 299 300 301 302 | Popular Tags |