test serialization to and from jdom documents
This commit is contained in:
parent
c47ec5fa9e
commit
b015f3ae0c
2 changed files with 36 additions and 0 deletions
6
pom.xml
6
pom.xml
|
@ -76,6 +76,12 @@
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>xmlunit</groupId>
|
||||||
|
<artifactId>xmlunit</artifactId>
|
||||||
|
<version>1.6</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -6,9 +6,18 @@ import java.io.File;
|
||||||
import java.io.ObjectInputStream;
|
import java.io.ObjectInputStream;
|
||||||
import java.io.ObjectOutputStream;
|
import java.io.ObjectOutputStream;
|
||||||
|
|
||||||
|
import org.custommonkey.xmlunit.Diff;
|
||||||
|
import org.custommonkey.xmlunit.ElementNameAndAttributeQualifier;
|
||||||
|
import org.custommonkey.xmlunit.XMLAssert;
|
||||||
|
import org.custommonkey.xmlunit.XMLUnit;
|
||||||
|
import org.jdom2.Document;
|
||||||
|
import org.jdom2.output.Format;
|
||||||
|
import org.jdom2.output.XMLOutputter;
|
||||||
|
|
||||||
import com.rometools.rome.feed.WireFeed;
|
import com.rometools.rome.feed.WireFeed;
|
||||||
import com.rometools.rome.feed.synd.SyndFeed;
|
import com.rometools.rome.feed.synd.SyndFeed;
|
||||||
import com.rometools.rome.feed.synd.SyndFeedImpl;
|
import com.rometools.rome.feed.synd.SyndFeedImpl;
|
||||||
|
import com.rometools.rome.io.WireFeedOutput;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -64,6 +73,27 @@ public abstract class FeedOpsTest extends FeedTest {
|
||||||
assertTrue(feed1.equals(feed2));
|
assertTrue(feed1.equals(feed2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 1.5
|
||||||
|
public void testWireFeedJDOMSerialization() throws Exception {
|
||||||
|
Document inputDoc = getCachedJDomDoc();
|
||||||
|
|
||||||
|
final WireFeed feed = getCachedWireFeed();
|
||||||
|
WireFeedOutput output = new WireFeedOutput();
|
||||||
|
Document outputDoc = output.outputJDom(feed);
|
||||||
|
|
||||||
|
XMLOutputter outputter = new XMLOutputter(Format.getCompactFormat());
|
||||||
|
String inputString = outputter.outputString(inputDoc);
|
||||||
|
String outputString = outputter.outputString(outputDoc);
|
||||||
|
|
||||||
|
XMLUnit.setIgnoreWhitespace(true);
|
||||||
|
XMLUnit.setIgnoreAttributeOrder(true);
|
||||||
|
Diff diff = XMLUnit.compareXML(inputString, outputString);
|
||||||
|
// ignore elements order
|
||||||
|
diff.overrideElementQualifier(new ElementNameAndAttributeQualifier());
|
||||||
|
|
||||||
|
XMLAssert.assertXMLEqual(diff, true);
|
||||||
|
}
|
||||||
|
|
||||||
// 1.6
|
// 1.6
|
||||||
public void testWireFeedSyndFeedConversion() throws Exception {
|
public void testWireFeedSyndFeedConversion() throws Exception {
|
||||||
final SyndFeed sFeed1 = getCachedSyndFeed();
|
final SyndFeed sFeed1 = getCachedSyndFeed();
|
||||||
|
|
Loading…
Reference in a new issue