KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > functional > TestJAXRPCSamples


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.jaxrpc.GetInfo;
24 import samples.jaxrpc.GetQuote1;
25
26
27 /**
28  * Test the JAX-RPC compliance samples.
29  */

30 public class TestJAXRPCSamples extends TestCase {
31     static Log log = LogFactory.getLog(TestJAXRPCSamples.class.getName());
32
33     public TestJAXRPCSamples(String JavaDoc name) {
34         super(name);
35     } // ctor
36

37     public void doTestDeploy() throws Exception JavaDoc {
38         String JavaDoc[] args = {"samples/stock/deploy.wsdd"};
39         AdminClient.main(args);
40     } // doTestDeploy
41

42     public void doTestGetQuoteXXX() throws Exception JavaDoc {
43         String JavaDoc[] args = {"-uuser1", "-wpass1", "XXX"};
44         float val = new GetQuote1().getQuote1(args);
45         assertEquals("Stock price is not the expected 55.25 +/- 0.01", val,
46                 55.25, 0.01);
47     } // doTestGetQuoteXXX
48

49     public void doTestGetQuoteMain() throws Exception JavaDoc {
50         String JavaDoc[] args = {"-uuser1", "-wpass1", "XXX"};
51         GetQuote1.main(args);
52     } // doTestGetQuoteMain
53

54     public void doTestUndeploy() throws Exception JavaDoc {
55         String JavaDoc[] args = {"samples/stock/undeploy.wsdd"};
56         AdminClient.main(args);
57     } // doTestStockNoAction
58

59 // public void testGetQuote() throws Exception {
60
// try {
61
// log.info("Testing JAX-RPC GetQuote1 sample.");
62
// log.info("Testing deployment...");
63
// doTestDeploy();
64
// log.info("Testing service...");
65
// doTestGetQuoteXXX();
66
// doTestGetQuoteMain();
67
// log.info("Testing undeployment...");
68
// doTestUndeploy();
69
// log.info("Test complete.");
70
// }
71
// catch (Throwable t) {
72
// t.printStackTrace();
73
// throw new Exception("Fault returned from test: " + t);
74
// }
75
// } // testGetQuote
76

77     public void testGetInfo() throws Exception JavaDoc {
78         try {
79             log.info("Testing JAX-RPC GetInfo sample.");
80             log.info("Testing deployment...");
81             doTestDeploy();
82             log.info("Testing service...");
83             String JavaDoc[] args = {"-uuser3", "-wpass3", "IBM", "symbol"};
84             GetInfo.main(args);
85             args = new String JavaDoc[] {"-uuser3", "-wpass3", "MACR", "name"};
86             GetInfo.main(args);
87             args = new String JavaDoc[] {"-uuser3", "-wpass3", "CSCO", "address"};
88             GetInfo.main(args);
89             log.info("Testing undeployment...");
90             doTestUndeploy();
91             log.info("Test complete.");
92         }
93         catch (Throwable JavaDoc t) {
94             t.printStackTrace();
95             throw new Exception JavaDoc("Fault returned from test: " + t);
96         }
97     } // testGetInfo
98

99     public void testHello() throws Exception JavaDoc {
100         try {
101             log.info("Testing JAX-RPC hello sample.");
102             samples.jaxrpc.hello.HelloClient.main(new String JavaDoc[]{});
103             log.info("Test complete.");
104         }
105         catch (Throwable JavaDoc t) {
106             t.printStackTrace();
107             throw new Exception JavaDoc("Fault returned from test: " + t);
108         }
109     }
110
111     public void testAddress() throws Exception JavaDoc {
112         try {
113             log.info("Testing JAX-RPC Address sample.");
114             samples.jaxrpc.address.AddressClient.main(new String JavaDoc[]{});
115             log.info("Test complete.");
116         }
117         catch (Throwable JavaDoc t) {
118             t.printStackTrace();
119             throw new Exception JavaDoc("Fault returned from test: " + t);
120         }
121     }
122
123     public static void main(String JavaDoc args[]) throws Exception JavaDoc {
124         TestJAXRPCSamples tester = new TestJAXRPCSamples("tester");
125         tester.testHello();
126         tester.testAddress();
127     } // main
128
}
129
130
131
Popular Tags