KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > message > TestMessageSerialization


1 /*
2  * Copyright 2002-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.message;
18
19 import junit.framework.TestCase;
20 import org.apache.axis.Message;
21 import org.apache.axis.message.MimeHeaders;
22
23 import java.io.ByteArrayOutputStream JavaDoc;
24 import java.io.ObjectOutputStream JavaDoc;
25 import java.io.ObjectInputStream JavaDoc;
26 import java.io.ByteArrayInputStream JavaDoc;
27
28 /**
29  * Test serializability of org.apache.axis.Message
30  *
31  * @author Davanum Srinivas (dims@yahoo.com)
32  */

33 public class TestMessageSerialization extends TestCase {
34
35     public TestMessageSerialization(String JavaDoc name) {
36         super(name);
37     }
38
39     public void test1() throws Exception JavaDoc {
40         String JavaDoc messageText = "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" soap:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">"
41             + "<soap:Header>"
42             + "</soap:Header> "
43             + "<soap:Body> "
44             + "</soap:Body>"
45             + "</soap:Envelope>";
46         Message message = new Message(messageText);
47         ByteArrayOutputStream JavaDoc ostream = new ByteArrayOutputStream JavaDoc();
48         ObjectOutputStream JavaDoc os = new ObjectOutputStream JavaDoc(ostream);
49         os.writeObject(message);
50         ostream.flush();
51         
52         ObjectInputStream JavaDoc ois = new ObjectInputStream JavaDoc(new ByteArrayInputStream JavaDoc(ostream.toByteArray()));
53         Message m2 = (Message) ois.readObject();
54     }
55 }
56
Popular Tags