KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > faults > FaultEncode


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 package test.faults;
17
18 import junit.framework.TestCase;
19 import org.apache.axis.AxisFault;
20 import org.apache.axis.Message;
21 import org.apache.axis.MessageContext;
22 import org.apache.axis.server.AxisServer;
23
24 /**
25  * This class tests Fault deserialization.
26  *
27  * @author Sam Ruby (rubys@us.ibm.com)
28  */

29
30 public class FaultEncode extends TestCase {
31     
32     public FaultEncode(String JavaDoc name) {
33         super(name);
34     } // ctor
35

36     public void testFault() throws Exception JavaDoc {
37         AxisFault fault = new AxisFault("<code>", "<string>", "<actor>", null);
38         fault.setFaultDetailString("<detail>");
39
40         AxisServer server = new AxisServer();
41         Message message = new Message(fault);
42         message.setMessageContext(new MessageContext(server));
43
44         String JavaDoc data = message.getSOAPPartAsString();
45         assertTrue("Fault code not encoded correctly",
46             data.indexOf("&lt;code&gt;")>=0);
47         assertTrue("Fault string not encoded correctly",
48             data.indexOf("&lt;string&gt;")>=0);
49         assertTrue("Fault actor not encoded correctly",
50             data.indexOf("&lt;actor&gt;")>=0);
51         assertTrue("Fault detail not encoded correctly",
52             data.indexOf("&lt;detail&gt;")>=0);
53         
54     } // testFault
55
}
56
Popular Tags