You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@axis.apache.org by ve...@apache.org on 2016/05/26 21:27:23 UTC
svn commit: r1745648 - in /axis/axis2/java/core/trunk/modules/fastinfoset:
pom.xml test/org/apache/axis2/fastinfoset/FastInfosetInputOutputTest.java
Author: veithen
Date: Thu May 26 21:27:23 2016
New Revision: 1745648
URL: http://svn.apache.org/viewvc?rev=1745648&view=rev
Log:
Simplify test case.
Modified:
axis/axis2/java/core/trunk/modules/fastinfoset/pom.xml
axis/axis2/java/core/trunk/modules/fastinfoset/test/org/apache/axis2/fastinfoset/FastInfosetInputOutputTest.java
Modified: axis/axis2/java/core/trunk/modules/fastinfoset/pom.xml
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/fastinfoset/pom.xml?rev=1745648&r1=1745647&r2=1745648&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/fastinfoset/pom.xml (original)
+++ axis/axis2/java/core/trunk/modules/fastinfoset/pom.xml Thu May 26 21:27:23 2016
@@ -101,9 +101,8 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>xmlunit</groupId>
- <artifactId>xmlunit</artifactId>
- <scope>test</scope>
+ <groupId>org.apache.ws.commons.axiom</groupId>
+ <artifactId>axiom-truth</artifactId>
</dependency>
</dependencies>
<url>http://axis.apache.org/axis2/java/core/</url>
Modified: axis/axis2/java/core/trunk/modules/fastinfoset/test/org/apache/axis2/fastinfoset/FastInfosetInputOutputTest.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/fastinfoset/test/org/apache/axis2/fastinfoset/FastInfosetInputOutputTest.java?rev=1745648&r1=1745647&r2=1745648&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/fastinfoset/test/org/apache/axis2/fastinfoset/FastInfosetInputOutputTest.java (original)
+++ axis/axis2/java/core/trunk/modules/fastinfoset/test/org/apache/axis2/fastinfoset/FastInfosetInputOutputTest.java Thu May 26 21:27:23 2016
@@ -21,20 +21,24 @@ package org.apache.axis2.fastinfoset;
import com.sun.xml.fastinfoset.stax.StAXDocumentParser;
import com.sun.xml.fastinfoset.stax.StAXDocumentSerializer;
+
+import org.apache.axiom.blob.Blobs;
+import org.apache.axiom.blob.MemoryBlob;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMXMLBuilderFactory;
import org.apache.axiom.om.OMXMLParserWrapper;
-import org.custommonkey.xmlunit.XMLTestCase;
+import org.junit.Test;
import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamWriter;
-import java.io.File;
+
+import static com.google.common.truth.Truth.assertAbout;
+import static org.apache.axiom.truth.xml.XMLTruth.xml;
+
import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.FileReader;
-import java.io.FileWriter;
+import java.io.OutputStream;
-public class FastInfosetInputOutputTest extends XMLTestCase {
+public class FastInfosetInputOutputTest {
/**
* This is to test how fast infoset interoperate with Axiom.
@@ -46,33 +50,27 @@ public class FastInfosetInputOutputTest
* <p/>
* Then the initial XML file and the last XML will be compared to see whether they are the same.
*/
+ @Test
public void testInputOutput() throws Exception {
String inputFile = "pom.xml";
- File outputFile = new File("target/output.xml");
- File tempFile = new File("target/test.bin");
- try {
- // first let's read the xml document in to Axiom
- OMElement element = OMXMLBuilderFactory.createOMBuilder(
- new FileInputStream(inputFile)).getDocumentElement();
-
- // output it using binary xml outputter
- XMLStreamWriter streamWriter = new StAXDocumentSerializer(new FileOutputStream(tempFile));
- streamWriter.writeStartDocument();
- element.serializeAndConsume(streamWriter);
- streamWriter.writeEndDocument();
-
- // now let's read the binary file in to Axiom
- XMLStreamReader streamReader = new StAXDocumentParser(new FileInputStream(tempFile));
- OMXMLParserWrapper builder = OMXMLBuilderFactory.createStAXOMBuilder(streamReader);
- builder.getDocumentElement().serialize(new FileWriter(outputFile));
-
- // let's see this is the same that we fed in to this test initially
- assertXMLEqual(new FileReader(inputFile), new FileReader(outputFile));
-
- } finally {
- if (outputFile.exists()) outputFile.delete();
- if (tempFile.exists()) tempFile.delete();
- }
+ // first let's read the xml document in to Axiom
+ OMElement element = OMXMLBuilderFactory.createOMBuilder(
+ new FileInputStream(inputFile)).getDocumentElement();
+
+ // output it using binary xml outputter
+ MemoryBlob blob = Blobs.createMemoryBlob();
+ OutputStream out = blob.getOutputStream();
+ XMLStreamWriter streamWriter = new StAXDocumentSerializer(out);
+ streamWriter.writeStartDocument();
+ element.serialize(streamWriter);
+ streamWriter.writeEndDocument();
+ out.close();
+
+ // now let's read the binary file in to Axiom
+ XMLStreamReader streamReader = new StAXDocumentParser(blob.getInputStream());
+ OMXMLParserWrapper builder = OMXMLBuilderFactory.createStAXOMBuilder(streamReader);
+
+ assertAbout(xml()).that(builder.getDocumentElement()).hasSameContentAs(element);
}
}