KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > deployment > impl > TargetServerTest


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.deployment.impl;
21
22 import junit.framework.*;
23 import org.netbeans.junit.*;
24 import java.util.*;
25 import java.io.*;
26 import org.netbeans.modules.j2ee.deployment.execution.DeploymentTarget;
27 import org.netbeans.modules.j2ee.deployment.impl.*;
28 import javax.enterprise.deploy.spi.*;
29 import org.netbeans.tests.j2eeserver.plugin.jsr88.DepManager;
30 import org.netbeans.modules.j2ee.deployment.impl.ui.*;
31
32 /**
33  *
34  * @author nn136682
35  */

36 public class TargetServerTest extends NbTestCase {
37
38     public TargetServerTest(java.lang.String JavaDoc testName) {
39         super(testName);
40     }
41     
42     public static Test suite() {
43         TestSuite suite = new NbTestSuite(TargetServerTest.class);
44         //suite.addTest(new TargetServerTest("testDistributeSuccess"));
45
//suite.addTest(new TargetServerTest("testDistributeFailed"));
46
//suite.addTest(new TargetServerTest("testRedeploySuccess"));
47
//suite.addTest(new TargetServerTest("testRedeployFailed"));
48
//suite.addTest(new TargetServerTest("testDeployWhenServerDown"));
49
//suite.addTest(new TargetServerTest("testDeployWhenStartServerFailed"));
50
return suite;
51     }
52
53     ServerString server;
54     ServerString getSuiteTargetServer() {
55         return getTargetServer(null);
56     }
57     ServerString getTargetServer(String JavaDoc name){
58         if (server != null)
59             return server;
60
61         ServerRegistry registry = ServerRegistry.getInstance();
62         String JavaDoc url = "fooservice:TargetServerTest";
63         if (name != null)
64             url += "_"+name;
65         try {
66             registry.addInstance(url, "user", "password", "TestInstance");
67         } catch (IOException ioe) { throw new RuntimeException JavaDoc(ioe); }
68         
69         server = new ServerString(registry.getServerInstance(url).getServerTarget("Target 1"));
70         return server;
71     }
72         
73     /** Test of processLastTargetModules method, of class org.netbeans.modules.j2ee.deployment.impl.TargetServer. */
74     /*
75     public void testDistributeSuccess() {
76         System.out.println("testDistributeSuccess");
77         
78         ServerInstance instance = getSuiteTargetServer().getServerInstance();
79         DepManager dm = (DepManager) instance.getDeploymentManager();
80         boolean started = instance.start();
81         if (! started || dm.getState() != DepManager.RUNNING)
82             fail("Failed to start: state="+dm.getState());
83         try {Thread.sleep(2000); } catch(Exception e) {}
84         TargetModule[] modules = getSuiteDeployTarget().getTargetModules();
85         assertTrue(modules == null || modules.length == 0);
86         DeploymentTarget dt = getSuiteDeployTarget();
87         ServerExecutor.instance().deploy(dt);
88         //FIXME: this.assertTrue(dm.hasDistributed(dt.getTargetModules()[0].getId()));
89     }
90     
91     // Precondtion: testDistributeSuccess
92     public void testRedeploySuccess() {
93         System.out.println("testRedeploySuccess");
94         DepManager dm = (DepManager) getSuiteTargetServer().getServerInstance().getDeploymentManager();
95         //FIXME: this.assertFalse(dm.hasRedeployed(getSuiteDeployTarget().getTargetModules()[0].toString()));
96         ServerExecutor.instance().deploy(getSuiteDeployTarget());
97         //FIXME: this.assertTrue(dm.hasRedeployed(getSuiteDeployTarget().getTargetModules()[0].toString()));
98     }
99     */

100     
101     /*public void testNoChangesRedeploy() {
102         System.out.println("testRedeployFailed");
103         
104         // Add your test code below by replacing the default call to fail.
105         fail("The test case is empty.");
106     }*/

107     
108     /*public void testDistributeFailed() {
109         System.out.println("testDistributeFailed");
110         
111         // Add your test code below by replacing the default call to fail.
112         fail("The test case is empty.");
113     }*/

114     
115     /*public void testDeployWhenServerDown() {
116         System.out.println("testDeployWhenServerDown");
117         // Make sure server is down
118         
119         // deploy or redeploy
120         
121         // make sure server is up
122         fail("The test case is empty.");
123     }*/

124     
125     /*public void testDeployWhenStartServerFailed() {
126         System.out.println("testDeployWhenStartServerFailed");
127         
128         // Add your test code below by replacing the default call to fail.
129         fail("The test case is empty.");
130     }*/

131     
132     public void testWebContextRoot() {
133         
134     }
135     
136 }
137
Popular Tags