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; 24 import java.io.ObjectOutputStream; 25 import java.io.ObjectInputStream; 26 import java.io.ByteArrayInputStream; 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 name) { 36 super(name); 37 } 38 39 public void test1() throws Exception { 40 String 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 ostream = new ByteArrayOutputStream(); 48 ObjectOutputStream os = new ObjectOutputStream(ostream); 49 os.writeObject(message); 50 ostream.flush(); 51 52 ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(ostream.toByteArray())); 53 Message m2 = (Message) ois.readObject(); 54 } 55 } 56