KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > functional > TestMessageSample


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.message.TestMsg;
24
25
26 /** Test the message sample code.
27  */

28 public class TestMessageSample extends TestCase {
29     static Log log =
30             LogFactory.getLog(TestMessageSample.class.getName());
31
32     public TestMessageSample(String JavaDoc name) {
33         super(name);
34     }
35     
36     public void doTestDeploy() throws Exception JavaDoc {
37         String JavaDoc[] args = { "samples/message/deploy.wsdd" };
38         AdminClient.main(args);
39     }
40     
41     public void doTestMessage() throws Exception JavaDoc {
42         String JavaDoc[] args = { };
43         String JavaDoc res = (new TestMsg()).doit(args);
44         String JavaDoc expected="Res elem[0]=<ns1:e1 xmlns:ns1=\"urn:foo\">Hello</ns1:e1>"
45                         +"Res elem[1]=<ns2:e1 xmlns:ns2=\"urn:foo\">World</ns2:e1>"
46                         +"Res elem[2]=<ns3:e3 xmlns:ns3=\"urn:foo\">"
47                         +"<![CDATA["
48                         +"Text with\n\tImportant <b> whitespace </b> and tags! "
49                         +"]]>"
50                         +"</ns3:e3>";
51         assertEquals("test result elements", expected, res);
52     }
53     
54     public void doTestUndeploy () throws Exception JavaDoc {
55         String JavaDoc[] args = { "samples/message/undeploy.wsdd" };
56         AdminClient.main(args);
57     }
58
59     public static void main(String JavaDoc args[]) throws Exception JavaDoc {
60         TestMessageSample tester = new TestMessageSample("tester");
61         tester.testMessageService();
62     }
63
64     public void testMessageService () throws Exception JavaDoc {
65         try {
66             log.info("Testing message sample.");
67             log.info("Testing deployment...");
68             doTestDeploy();
69             log.info("Testing service...");
70             doTestMessage();
71             doTestUndeploy();
72             log.info("Test complete.");
73         }
74         catch( Exception JavaDoc e ) {
75             e.printStackTrace();
76             throw new Exception JavaDoc("Fault returned from test: "+e);
77         }
78     }
79     
80 }
81
82
83
Popular Tags