1 package org.objectweb.petals.tools.ant; 2 3 import java.io.File ; 4 import java.io.IOException ; 5 6 import junit.framework.TestCase; 7 8 import org.objectweb.petals.tools.ant.InstallComponentTask; 9 import org.objectweb.petals.tools.ant.ListBindingComponentsTask; 10 import org.objectweb.petals.tools.ant.ListServiceEnginesTask; 11 import org.objectweb.petals.tools.ant.ShutdownComponentTask; 12 import org.objectweb.petals.tools.ant.StartComponentTask; 13 import org.objectweb.petals.tools.ant.StopComponentTask; 14 import org.objectweb.petals.tools.ant.UninstallComponentTask; 15 import org.objectweb.petals.tools.ant.util.ServerUtil; 16 17 22 public class ComponentTasksTest extends TestCase { 23 24 27 private static int port = 9988; 28 29 public void setUp() throws Exception { 30 ServerUtil.start(port); 31 } 32 33 public void tearDown() throws IOException { 34 ServerUtil.stop(); 35 } 36 37 43 public void testExceptionCompoUnsinstalled() throws Exception { 44 testInstall(); 45 StartComponentTask startComponentTask = new StartComponentTask(); 46 startComponentTask.setPort("" + port); 47 startComponentTask.setName("uninstalledCompo"); 48 try { 49 startComponentTask.execute(); 50 fail(); 51 } catch (Exception e) { 52 53 } 54 } 55 56 60 public void testExceptionFileInvalid() { 61 InstallComponentTask installComponentTask = new InstallComponentTask(); 62 try { 63 installComponentTask.setFile("foo"); 64 installComponentTask.execute(); 65 fail(); 66 } catch (Exception e) { 67 } 68 } 69 70 74 public void testExceptionNameNotSet() { 75 InstallComponentTask installComponentTask = new InstallComponentTask(); 76 try { 77 installComponentTask.execute(); 78 fail(); 79 } catch (Exception e) { 80 } 81 } 82 83 89 public void testExceptionNameNull() throws Exception { 90 testInstall(); 91 StartComponentTask startComponentTask = new StartComponentTask(); 92 startComponentTask.setPort("" + port); 93 try { 94 startComponentTask.execute(); 95 fail(); 96 } catch (Exception e) { 97 98 } 99 } 100 101 107 public void testExceptionNameNull1() throws Exception { 108 testInstall(); 109 UninstallComponentTask uninstallComponentTask = new UninstallComponentTask(); 110 uninstallComponentTask.setPort("" + port); 111 try { 112 uninstallComponentTask.execute(); 113 fail(); 114 } catch (Exception e) { 115 116 } 117 } 118 119 125 public void testExceptionServerJMX2() throws Exception { 126 testInstall(); 127 StartComponentTask startComponentTask = new StartComponentTask(); 128 startComponentTask.setPort("" + port); 129 startComponentTask.setName("foo001"); 130 try { 131 tearDown(); 132 startComponentTask.execute(); 133 fail(); 134 } catch (Exception e) { 135 136 } 137 } 138 139 145 public void testExceptionServerJMX3() throws Exception { 146 testInstall(); 147 UninstallComponentTask uninstallComponentTask = new UninstallComponentTask(); 148 uninstallComponentTask.setPort("" + port); 149 uninstallComponentTask.setName("foo001"); 150 try { 151 tearDown(); 152 uninstallComponentTask.execute(); 153 fail(); 154 } catch (Exception e) { 155 156 } 157 } 158 159 163 public void testExceptionServerNotStarted() { 164 InstallComponentTask installComponentTask = new InstallComponentTask(); 165 try { 166 tearDown(); 167 installComponentTask.setFile("foo"); 168 installComponentTask.execute(); 169 fail(); 170 } catch (Exception e) { 171 } 172 } 173 174 180 public void testExceptionServiceAssemblyNotDeployed() throws Exception { 181 ListBindingComponentsTask listBindingComponentsTask = new ListBindingComponentsTask(); 182 listBindingComponentsTask.setPort("" + port); 183 listBindingComponentsTask.setServiceAssemblyName("foo"); 184 listBindingComponentsTask.setBindingComponentName("bar"); 185 testInstall(); 187 listBindingComponentsTask.execute(); 188 } 189 190 194 public void testExceptionStateInvalid() { 195 ListBindingComponentsTask listBindingComponentsTask = new ListBindingComponentsTask(); 196 listBindingComponentsTask.setPort("" + port); 197 listBindingComponentsTask.setState("fooState"); 198 try { 199 testInstall(); 200 listBindingComponentsTask.execute(); 201 fail(); 202 } catch (Exception e) { 203 } 204 } 205 206 210 public void testExceptionStateInvalid1() { 211 ListServiceEnginesTask listServiceEnginesTask = new ListServiceEnginesTask(); 212 listServiceEnginesTask.setPort("" + port); 213 listServiceEnginesTask.setState("InvalidState"); 214 try { 215 testInstall(); 216 listServiceEnginesTask.execute(); 217 fail(); 218 } catch (Exception e) { 219 } 220 } 221 222 229 public void testInstall() throws Exception { 230 String baseDir = this.getClass().getResource(".").toString(); 232 baseDir = baseDir.substring(0, baseDir.indexOf("target")); 233 baseDir = baseDir.substring(baseDir.indexOf(":")+1); 234 InstallComponentTask installComponentTask = new InstallComponentTask(); 235 installComponentTask.setFile("file:" + baseDir + "src" + File.separator 236 + "test-data" + File.separator + "clock.zip"); 237 installComponentTask.setPort("" + port); 238 installComponentTask.execute(); 239 } 240 241 246 public void testListBC() throws Exception { 247 testInstall(); 248 ListBindingComponentsTask listBindingComponentsTask = new ListBindingComponentsTask(); 249 listBindingComponentsTask.setPort("" + port); 250 listBindingComponentsTask.execute(); 251 } 252 253 256 public void testListSE() { 257 ListServiceEnginesTask listServiceEnginesTask = new ListServiceEnginesTask(); 258 listServiceEnginesTask.setPort("" + port); 259 listServiceEnginesTask.execute(); 260 } 261 262 267 public void testListSE1() throws Exception { 268 testInstall(); 269 ListServiceEnginesTask listServiceEnginesTask = new ListServiceEnginesTask(); 270 listServiceEnginesTask.setPort("" + port); 271 listServiceEnginesTask.setServiceAssemblyName("test"); 272 listServiceEnginesTask.setXmlOutput("test"); 273 listServiceEnginesTask.setServiceEngineName("bar"); 275 listServiceEnginesTask.execute(); 276 } 277 278 284 public void testListXMLOutput() throws Exception { 285 ListBindingComponentsTask listBindingComponentsTask = new ListBindingComponentsTask(); 286 listBindingComponentsTask.setPort("" + port); 287 listBindingComponentsTask.setXmlOutput("output"); 288 testInstall(); 289 listBindingComponentsTask.execute(); 290 } 291 292 297 public void testShutdown() throws Exception { 298 testInstall(); 299 ShutdownComponentTask shutdownComponentTask = new ShutdownComponentTask(); 300 shutdownComponentTask.setName("foo001"); 301 shutdownComponentTask.setPort("" + port); 302 shutdownComponentTask.execute(); 303 } 304 305 310 public void testStart() throws Exception { 311 testInstall(); 312 StartComponentTask startComponentTask = new StartComponentTask(); 313 startComponentTask.setName("foo001"); 314 startComponentTask.setPort("" + port); 315 startComponentTask.execute(); 316 } 317 318 323 public void testStop() throws Exception { 324 testInstall(); 325 StopComponentTask stopComponentTask = new StopComponentTask(); 326 stopComponentTask.setName("foo001"); 327 stopComponentTask.setPort("" + port); 328 stopComponentTask.execute(); 329 } 330 331 336 public void testUninstall() throws Exception { 337 testInstall(); 338 UninstallComponentTask uninstallComponentTask = new UninstallComponentTask(); 339 uninstallComponentTask.setName("foo001"); 340 uninstallComponentTask.setPort("" + port); 341 uninstallComponentTask.execute(); 342 } 343 344 349 public void testStart1() throws Exception { 350 testInstall(); 351 StartComponentTask startComponentTask = new StartComponentTask(); 352 startComponentTask.setName("foo001"); 353 startComponentTask.setPort("" + port); 354 startComponentTask.setHost("localhost"); 355 startComponentTask.setFailOnError("true"); 356 startComponentTask.setUsername(""); 357 startComponentTask.setPassword(""); 358 startComponentTask.execute(); 359 } 360 361 } | Popular Tags |