KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > sun > test > WebModuleTest


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.j2ee.sun.test;
21
22 import java.io.File JavaDoc;
23 import javax.enterprise.deploy.shared.ModuleType JavaDoc;
24 import javax.enterprise.deploy.spi.TargetModuleID JavaDoc;
25 import org.netbeans.api.project.Project;
26 import org.netbeans.junit.NbTestCase;
27 import org.netbeans.junit.NbTestSuite;
28 import org.netbeans.modules.j2ee.deployment.impl.ServerInstance;
29 import org.netbeans.modules.j2ee.deployment.impl.ServerRegistry;
30
31 /**
32  *
33  * @author Michal Mocnak
34  */

35 public class WebModuleTest extends NbTestCase {
36     
37     private final int SLEEP = 10000;
38     static private Project p = null;
39     
40     public WebModuleTest(String JavaDoc testName) {
41         super(testName);
42     }
43     
44     public void deployWebModule() {
45         try {
46             // touch the index...
47
//
48
// File f = new File(Util.WEB_PROJECT_PATH+"/web/index.jsp");
49
// f.setLastModified((new java.util.Date()).getTime());
50
Util.deployModule(ModuleType.WAR, p, Util.WEB_PROJECT_NAME);
51         } catch(Exception JavaDoc e) {
52             e.printStackTrace();
53             fail(e.getMessage());
54         }
55     }
56     
57     public void undeployWebModule() {
58         try {
59             ServerInstance si = ServerRegistry.getInstance().getServerInstance(Util._URL);
60             TargetModuleID JavaDoc moduleID = Util.getModuleID(ModuleType.WAR, Util.WEB_PROJECT_NAME, si,false);
61             
62             if(moduleID == null)
63                 fail("isn't the web module supposed to be here???");
64             
65             Util.undeployModule(ModuleType.WAR, Util.WEB_PROJECT_PATH, Util.WEB_PROJECT_NAME, moduleID);
66         } catch(Exception JavaDoc e) {
67             e.printStackTrace();
68             fail(e.getMessage());
69         }
70     }
71     
72     public void openProject() {
73         p = (Project) Util.openProject(new java.io.File JavaDoc(Util.WEB_PROJECT_PATH));
74     }
75     
76     public void closeProject() {
77         Util.closeProject(Util.WEB_PROJECT_NAME);
78     }
79     
80     public static NbTestSuite suite() {
81         NbTestSuite suite = new NbTestSuite("WebModuleTest");
82         suite.addTest(new AddRemoveSjsasInstanceTest("addSjsasInstance"));
83         suite.addTest(new WebModuleTest("openProject"));
84         
85         // deploy, then redeploy 19 time
86
suite.addTest(new WebModuleTest("deployWebModule"));
87         suite.addTest(new WebModuleTest("deployWebModule"));
88         suite.addTest(new WebModuleTest("deployWebModule"));
89         suite.addTest(new WebModuleTest("deployWebModule"));
90         suite.addTest(new WebModuleTest("deployWebModule"));
91         suite.addTest(new WebModuleTest("deployWebModule"));
92         suite.addTest(new WebModuleTest("deployWebModule"));
93         suite.addTest(new WebModuleTest("deployWebModule"));
94         suite.addTest(new WebModuleTest("deployWebModule"));
95         suite.addTest(new WebModuleTest("deployWebModule"));
96         suite.addTest(new WebModuleTest("deployWebModule"));
97         suite.addTest(new WebModuleTest("deployWebModule"));
98         suite.addTest(new WebModuleTest("deployWebModule"));
99         suite.addTest(new WebModuleTest("deployWebModule"));
100         suite.addTest(new WebModuleTest("deployWebModule"));
101         suite.addTest(new WebModuleTest("deployWebModule"));
102         suite.addTest(new WebModuleTest("deployWebModule"));
103         suite.addTest(new WebModuleTest("deployWebModule"));
104         suite.addTest(new WebModuleTest("deployWebModule"));
105         suite.addTest(new WebModuleTest("deployWebModule"));
106         suite.addTest(new WebModuleTest("undeployWebModule"));
107         
108         // deploy+undeploy 20 times
109
suite.addTest(new WebModuleTest("deployWebModule"));
110         suite.addTest(new WebModuleTest("undeployWebModule"));
111         suite.addTest(new WebModuleTest("deployWebModule"));
112         suite.addTest(new WebModuleTest("undeployWebModule"));
113         suite.addTest(new WebModuleTest("deployWebModule"));
114         suite.addTest(new WebModuleTest("undeployWebModule"));
115         suite.addTest(new WebModuleTest("deployWebModule"));
116         suite.addTest(new WebModuleTest("undeployWebModule"));
117         suite.addTest(new WebModuleTest("deployWebModule"));
118         suite.addTest(new WebModuleTest("undeployWebModule"));
119         suite.addTest(new WebModuleTest("deployWebModule"));
120         suite.addTest(new WebModuleTest("undeployWebModule"));
121         suite.addTest(new WebModuleTest("deployWebModule"));
122         suite.addTest(new WebModuleTest("undeployWebModule"));
123         suite.addTest(new WebModuleTest("deployWebModule"));
124         suite.addTest(new WebModuleTest("undeployWebModule"));
125         suite.addTest(new WebModuleTest("deployWebModule"));
126         suite.addTest(new WebModuleTest("undeployWebModule"));
127         suite.addTest(new WebModuleTest("deployWebModule"));
128         suite.addTest(new WebModuleTest("undeployWebModule"));
129         suite.addTest(new WebModuleTest("deployWebModule"));
130         suite.addTest(new WebModuleTest("undeployWebModule"));
131         suite.addTest(new WebModuleTest("deployWebModule"));
132         suite.addTest(new WebModuleTest("undeployWebModule"));
133         suite.addTest(new WebModuleTest("deployWebModule"));
134         suite.addTest(new WebModuleTest("undeployWebModule"));
135         suite.addTest(new WebModuleTest("deployWebModule"));
136         suite.addTest(new WebModuleTest("undeployWebModule"));
137         suite.addTest(new WebModuleTest("deployWebModule"));
138         suite.addTest(new WebModuleTest("undeployWebModule"));
139         suite.addTest(new WebModuleTest("deployWebModule"));
140         suite.addTest(new WebModuleTest("undeployWebModule"));
141         suite.addTest(new WebModuleTest("deployWebModule"));
142         suite.addTest(new WebModuleTest("undeployWebModule"));
143         suite.addTest(new WebModuleTest("deployWebModule"));
144         suite.addTest(new WebModuleTest("undeployWebModule"));
145         suite.addTest(new WebModuleTest("deployWebModule"));
146         suite.addTest(new WebModuleTest("undeployWebModule"));
147         suite.addTest(new WebModuleTest("deployWebModule"));
148         suite.addTest(new WebModuleTest("undeployWebModule"));
149         suite.addTest(new WebModuleTest("closeProject"));
150         suite.addTest(new StartStopServerTest("stopServer"));
151         suite.addTest(new AddRemoveSjsasInstanceTest("removeSjsasInstance"));
152         return suite;
153     }
154 }
Popular Tags