KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > functional > TestElementSample


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.axis.transport.http.SimpleAxisWorker;
23 import org.apache.axis.utils.NetworkUtils;
24 import org.apache.commons.logging.Log;
25 import samples.encoding.TestElem;
26
27
28 /** Test the ElementService sample code.
29  */

30 public class TestElementSample extends TestCase {
31     static Log log =
32             LogFactory.getLog(TestElementSample.class.getName());
33
34     public TestElementSample(String JavaDoc name) {
35         super(name);
36     }
37     
38     public void doTestElement () throws Exception JavaDoc {
39         String JavaDoc thisHost = NetworkUtils.getLocalHostname();
40         String JavaDoc thisPort = System.getProperty("test.functional.ServicePort","8080");
41
42         String JavaDoc[] args = {thisHost,thisPort};
43         String JavaDoc xml = "<x:hello xmlns:x=\"urn:foo\">a string</x:hello>";
44         System.out.println("Sending : " + xml );
45         String JavaDoc res = TestElem.doit(args, xml);
46         System.out.println("Received: " + res );
47         assertEquals("TestElementSample.doit(): xml must match", res, xml);
48     }
49     
50     public void doTestDeploy () throws Exception JavaDoc {
51         String JavaDoc[] args = { "samples/encoding/deploy.wsdd" };
52         AdminClient.main(args);
53     }
54     
55     public void doTestUndeploy () throws Exception JavaDoc {
56         String JavaDoc[] args = { "samples/encoding/undeploy.wsdd" };
57         AdminClient.main(args);
58     }
59
60     public static void main(String JavaDoc args[]) throws Exception JavaDoc {
61         TestElementSample tester = new TestElementSample("tester");
62         tester.testElementService();
63     }
64
65     public void testElementService () throws Exception JavaDoc {
66         log.info("Testing element sample.");
67         log.info("Testing deployment...");
68         doTestDeploy();
69         log.info("Testing service...");
70         doTestElement();
71         log.info("Testing undeployment...");
72         doTestUndeploy();
73         log.info("Test complete.");
74     }
75 }
76
77
78
Popular Tags