1 package org.objectweb.petals.tools.ant; 2 3 import java.io.File ; 4 import java.io.IOException ; 5 6 import org.objectweb.petals.tools.ant.InstallSharedLibTask; 7 import org.objectweb.petals.tools.ant.ListSharedLibraryTask; 8 import org.objectweb.petals.tools.ant.UninstallSharedLibTask; 9 import org.objectweb.petals.tools.ant.util.ServerUtil; 10 11 import junit.framework.TestCase; 12 13 18 public class SharedLibrariesTasksTest extends TestCase { 19 20 23 private static int port = 9988; 24 25 public void setUp() throws Exception { 26 ServerUtil.start(port); 27 } 28 29 public void tearDown() throws IOException { 30 ServerUtil.stop(); 31 } 32 33 37 public void testExceptionFileNull() { 38 UninstallSharedLibTask uninstallSharedLibTask = new UninstallSharedLibTask(); 39 uninstallSharedLibTask.setPort("" + port); 40 try { 41 uninstallSharedLibTask.execute(); 42 fail(); 43 } catch (Exception e) { 44 45 } 46 } 47 48 52 public void testExceptionNameNull() { 53 InstallSharedLibTask installSharedLibTask = new InstallSharedLibTask(); 54 installSharedLibTask.setPort("" + port); 55 try { 56 installSharedLibTask.execute(); 57 fail(); 58 } catch (Exception e) { 59 60 } 61 } 62 63 67 public void testExceptionServerJMX() { 68 String baseDir = this.getClass().getResource(".").toString(); 69 baseDir = baseDir.substring(0, baseDir.indexOf("target")); 70 baseDir = baseDir.substring(baseDir.indexOf(":")+1); 71 InstallSharedLibTask installSharedLibTask = new InstallSharedLibTask(); 72 installSharedLibTask.setFile("file:" + baseDir + "src" + File.separator 73 + "test-data" + File.separator + "sa.zip"); 74 installSharedLibTask.setPort("" + port); 75 try { 76 tearDown(); 77 installSharedLibTask.execute(); 78 fail(); 79 } catch (Exception e) { 80 81 } 82 } 83 84 87 public void testExceptionServerJMX1() { 88 testInstall(); 89 UninstallSharedLibTask uninstallSharedLibTask = new UninstallSharedLibTask(); 90 uninstallSharedLibTask.setName("foo003"); 91 uninstallSharedLibTask.setPort("" + port); 92 try { 93 tearDown(); 94 uninstallSharedLibTask.execute(); 95 } catch (Exception e) { 96 97 } 98 } 99 100 105 public void testInstall() { 106 String baseDir = this.getClass().getResource(".").toString(); 107 baseDir = baseDir.substring(0, baseDir.indexOf("target")); 108 baseDir = baseDir.substring(baseDir.indexOf(":")+1); 109 InstallSharedLibTask installSharedLibTask = new InstallSharedLibTask(); 110 installSharedLibTask.setFile("file:" + baseDir + "src" + File.separator 111 + "test-data" + File.separator + "sa.zip"); 112 installSharedLibTask.setPort("" + port); 113 installSharedLibTask.execute(); 114 } 115 116 119 public void testList() { 120 testInstall(); 121 ListSharedLibraryTask listSharedLibraryTask = new ListSharedLibraryTask(); 122 listSharedLibraryTask.setPort("" + port); 123 try { 127 listSharedLibraryTask.execute(); 128 fail(); 129 } catch (Exception e) { 130 } 131 } 132 133 136 public void testUninstall() { 137 testInstall(); 138 UninstallSharedLibTask uninstallSharedLibTask = new UninstallSharedLibTask(); 139 uninstallSharedLibTask.setName("foo003"); 140 uninstallSharedLibTask.setPort("" + port); 141 uninstallSharedLibTask.execute(); 142 } 143 144 } 145 | Popular Tags |