/**
*
* Copyright 2004 Protique Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
**/
package org.activemq.transport.xstream;
import org.activemq.io.WireFormat;
import org.activemq.io.util.ByteArray;
import org.activemq.message.ActiveMQMessage;
import org.activemq.test.WireFormatTestSupport;
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.StaxDriver;
import com.thoughtworks.xstream.io.xml.QNameMap;
/**
* @version $Revision$
*/
public class XStreamWireFormatTest extends WireFormatTestSupport {
public void testViewXStreamXML() throws Exception {
writeMessageAsXml(createMessage());
writeMessageAsXml(createObjectMessage());
writeMessageAsXml(createMapMessage());
}
public void testXStreamIssue() throws Exception {
XStream xstream = new XStream();
ByteArray byteArray = new ByteArray(new byte[0]);
String byteArrayXml = xstream.toXML(byteArray);
System.out.println("Created byte XML: " + byteArrayXml);
// The next line leads to an error
ByteArray byteArray2 = (ByteArray) xstream.fromXML(byteArrayXml);
}
protected void writeMessageAsXml(ActiveMQMessage message) {
String xml = getXStreamWireFormat().toString(message);
System.out.println(message.getClass().getName() + " as XML is:");
System.out.println(xml);
}
protected XStreamWireFormat getXStreamWireFormat() {
return (XStreamWireFormat) wireFormat;
}
protected WireFormat createWireFormat() {
return new XStreamWireFormat();
}
}