KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > petals > tools > ant > SharedLibrariesTasksTest


1 package org.objectweb.petals.tools.ant;
2
3 import java.io.File JavaDoc;
4 import java.io.IOException JavaDoc;
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 /**
14  * Test the shared libraries ant tasks
15  *
16  * @author ddesjardins - eBMWebsourcing
17  */

18 public class SharedLibrariesTasksTest extends TestCase {
19
20     /**
21      * Port of the JMX server
22      */

23     private static int port = 9988;
24
25     public void setUp() throws Exception JavaDoc {
26         ServerUtil.start(port);
27     }
28
29     public void tearDown() throws IOException JavaDoc {
30         ServerUtil.stop();
31     }
32
33     /**
34      * Test exception throwing
35      *
36      */

37     public void testExceptionFileNull() {
38         UninstallSharedLibTask uninstallSharedLibTask = new UninstallSharedLibTask();
39         uninstallSharedLibTask.setPort("" + port);
40         try {
41             uninstallSharedLibTask.execute();
42             fail();
43         } catch (Exception JavaDoc e) {
44
45         }
46     }
47
48     /**
49      * Test exception throwing
50      *
51      */

52     public void testExceptionNameNull() {
53         InstallSharedLibTask installSharedLibTask = new InstallSharedLibTask();
54         installSharedLibTask.setPort("" + port);
55         try {
56             installSharedLibTask.execute();
57             fail();
58         } catch (Exception JavaDoc e) {
59
60         }
61     }
62
63     /**
64      * Test exception throwing
65      *
66      */

67     public void testExceptionServerJMX() {
68         String JavaDoc 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 JavaDoc e) {
80
81         }
82     }
83
84     /**
85      * Test the shared library uninstallation task
86      */

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 JavaDoc e) {
96
97         }
98     }
99
100     /**
101      * Test the shared library installation task
102      *
103      * @throws Exception
104      */

105     public void testInstall() {
106         String JavaDoc 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     /**
117      * Test the shared library list task
118      */

119     public void testList() {
120         testInstall();
121         ListSharedLibraryTask listSharedLibraryTask = new ListSharedLibraryTask();
122         listSharedLibraryTask.setPort("" + port);
123 // listSharedLibraryTask.setComponentName("foo");
124
// listSharedLibraryTask.setSharedLibraryName("bar");
125
// listSharedLibraryTask.setXmlOutput("test");
126
try {
127             listSharedLibraryTask.execute();
128             fail();
129         } catch (Exception JavaDoc e) {
130         }
131     }
132
133     /**
134      * Test the shared library uninstallation task
135      */

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