Skip to content
Browse files

Minor modifications in XOM converters

Changed XmmToByteArray to XomToString converter and fixed @since in javadoc.

Issue #AXON-232 Fixed
  • Loading branch information...
1 parent e30919b commit fd65af3fbff0c3e26b8fe1c9eb933f8d29bd5b00 @abuijze abuijze committed
View
2 core/src/main/java/org/axonframework/serializer/xml/InputStreamToXomConverter.java
@@ -31,7 +31,7 @@
* formatted XML.
*
* @author Jochen Munz
- * @since 2.1.2
+ * @since 2.2
*/
public class InputStreamToXomConverter extends AbstractContentTypeConverter<InputStream, Document> {
View
5 core/src/main/java/org/axonframework/serializer/xml/XStreamSerializer.java
@@ -24,7 +24,6 @@
import org.axonframework.serializer.ConverterFactory;
import org.axonframework.serializer.RevisionResolver;
import org.axonframework.serializer.SerializedObject;
-import org.dom4j.Document;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
@@ -141,7 +140,7 @@ public Object doDeserialize(SerializedObject serializedObject, XStream xStream)
if("nu.xom.Document".equals(serializedObject.getContentType().getName())) {
return xStream.unmarshal(new XomReader((nu.xom.Document) serializedObject.getData()));
}
- InputStream serializedData = (InputStream) convert(serializedObject.getContentType(), InputStream.class,
+ InputStream serializedData = convert(serializedObject.getContentType(), InputStream.class,
serializedObject.getData());
return xStream.fromXML(new InputStreamReader(serializedData, getCharset()));
}
@@ -150,7 +149,7 @@ public Object doDeserialize(SerializedObject serializedObject, XStream xStream)
protected void registerConverters(ChainingConverterFactory converterFactory) {
converterFactory.registerConverter(Dom4JToByteArrayConverter.class);
converterFactory.registerConverter(InputStreamToDom4jConverter.class);
- converterFactory.registerConverter(XomToByteArrayConverter.class);
+ converterFactory.registerConverter(XomToStringConverter.class);
converterFactory.registerConverter(InputStreamToXomConverter.class);
}
}
View
18 ...rializer/xml/XomToByteArrayConverter.java → .../serializer/xml/XomToStringConverter.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2012. Axon Framework
+ * Copyright (c) 2010-2014. Axon Framework
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,17 +17,15 @@
package org.axonframework.serializer.xml;
import nu.xom.Document;
-import org.axonframework.common.io.IOUtils;
import org.axonframework.serializer.AbstractContentTypeConverter;
/**
- * Converter that converts XOM Document instances to a byte array. The Document is written as XML string, and
- * converted to bytes using the UTF-8 character set.
+ * Converter that converts XOM Document instances to a String. The Document is written as XML string.
*
* @author Jochen Munz
- * @since 2.1.2
+ * @since 2.2
*/
-public class XomToByteArrayConverter extends AbstractContentTypeConverter<Document, byte[]> {
+public class XomToStringConverter extends AbstractContentTypeConverter<Document, String> {
@Override
public Class<Document> expectedSourceType() {
@@ -35,12 +33,12 @@
}
@Override
- public Class<byte[]> targetType() {
- return byte[].class;
+ public Class<String> targetType() {
+ return String.class;
}
@Override
- public byte[] convert(Document original) {
- return original.toXML().getBytes(IOUtils.UTF8);
+ public String convert(Document original) {
+ return original.toXML();
}
}
View
14 ...izer/xml/XomToByteArrayConverterTest.java → ...ializer/xml/XomToStringConverterTest.java
@@ -29,21 +29,21 @@
/**
* @author Jochen Munz
*/
-public class XomToByteArrayConverterTest {
+public class XomToStringConverterTest {
- private XomToByteArrayConverter testSubject;
+ private XomToStringConverter testSubject;
private SimpleSerializedType serializedType;
@Before
public void setUp() throws Exception {
- testSubject = new XomToByteArrayConverter();
+ testSubject = new XomToStringConverter();
serializedType = new SimpleSerializedType("custom", "0");
}
@Test
public void testCanConvert() {
assertEquals(Document.class, testSubject.expectedSourceType());
- assertEquals(byte[].class, testSubject.targetType());
+ assertEquals(String.class, testSubject.targetType());
}
@Test
@@ -53,11 +53,11 @@ public void testConvert() throws Exception {
SimpleSerializedObject<Document> original = new SimpleSerializedObject<Document>(doc,
Document.class,
serializedType);
- SerializedObject<byte[]> actual = testSubject.convert(original);
+ SerializedObject<String> actual = testSubject.convert(original);
assertNotNull(actual);
- assertNotNull(actual.getData());
- String actualString = new String(actual.getData());
+ String actualString = actual.getData();
+ assertNotNull(actualString);
assertTrue("Wrong output: " + actualString, actualString.contains("rootElement"));
}

0 comments on commit fd65af3

Please sign in to comment.
Something went wrong with that request. Please try again.