KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > functional > TestFaultsSample


1 /*
2  * Copyright 2001-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package test.functional;
18
19 import junit.framework.TestCase;
20 import org.apache.axis.client.AdminClient;
21 import org.apache.axis.components.logger.LogFactory;
22 import org.apache.commons.logging.Log;
23 import samples.faults.EmployeeClient;
24
25
26
27 /** Test the faults sample code.
28  */

29 public class TestFaultsSample extends TestCase {
30     static Log log =
31             LogFactory.getLog(TestFaultsSample.class.getName());
32
33     public TestFaultsSample(String JavaDoc name) {
34         super(name);
35     }
36     
37     public void doTestDeploy () throws Exception JavaDoc {
38         String JavaDoc[] args = { "samples/faults/deploy.wsdd" };
39         AdminClient.main(args);
40     }
41     
42     public void doTest1 () throws Exception JavaDoc {
43         String JavaDoc[] args = { "#001" };
44         EmployeeClient.main(args);
45     }
46     
47     public void doTest2 () throws Exception JavaDoc {
48         String JavaDoc[] args = { "#002" };
49         try {
50             EmployeeClient.main(args);
51         } catch (samples.faults.NoSuchEmployeeFault nsef) {
52             return;
53         }
54         fail("Should not reach here");
55     }
56
57     public void testFaultsService () throws Exception JavaDoc {
58         try {
59             log.info("Testing faults sample.");
60             log.info("Testing deployment...");
61             doTestDeploy();
62             log.info("Testing service...");
63             doTest1();
64             doTest2();
65             log.info("Test complete.");
66         }
67         catch( Exception JavaDoc e ) {
68             e.printStackTrace();
69             throw new Exception JavaDoc("Fault returned from test: "+e);
70         }
71     }
72
73     public static void main(String JavaDoc[] args) throws Exception JavaDoc {
74         TestFaultsSample tester = new TestFaultsSample("test");
75         tester.testFaultsService();
76     }
77 }
78
79
Popular Tags