#154 - Introduce XMLUnit to make sure we can build on Java 6 and 7.

Using XMLUnit's Diff to guard against minor changes in the default rendering of XML between Java 6 and 7.
This commit is contained in:
Oliver Gierke
2014-02-27 07:47:31 +01:00
parent f9f7b5bc68
commit 4ad5dd7136
3 changed files with 25 additions and 6 deletions

View File

@@ -238,6 +238,13 @@
<version>2.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>xmlunit</groupId>
<artifactId>xmlunit</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
</dependencies>

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012 the original author or authors.
* Copyright 2012-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,6 +27,7 @@ import javax.xml.bind.annotation.XmlRootElement;
import org.codehaus.jackson.annotate.JsonAutoDetect;
import org.codehaus.jackson.annotate.JsonAutoDetect.Visibility;
import org.custommonkey.xmlunit.Diff;
import org.junit.Test;
/**
@@ -54,6 +55,7 @@ public class ResourceIntegrationTest extends AbstractMarshallingIntegrationTest
/**
* @see #124
* @see #154
*/
@Test
public void marshalsResourceToXml() throws Exception {
@@ -71,7 +73,7 @@ public class ResourceIntegrationTest extends AbstractMarshallingIntegrationTest
Marshaller marshaller = context.createMarshaller();
marshaller.marshal(resource, writer);
assertThat(writer.toString(), is(XML_REFERENCE));
assertThat(new Diff(XML_REFERENCE, writer.toString()).similar(), is(true));
}
/**

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013 the original author or authors.
* Copyright 2013-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,6 +33,7 @@ import javax.xml.bind.Unmarshaller;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.map.SerializationConfig.Feature;
import org.custommonkey.xmlunit.Diff;
import org.junit.Before;
import org.junit.Test;
import org.springframework.core.io.ClassPathResource;
@@ -71,7 +72,6 @@ public class VndErrorsMarshallingTest {
}
@Before
@SuppressWarnings("deprecation")
public void setUp() throws Exception {
jackson1Mapper = new ObjectMapper();
@@ -92,26 +92,36 @@ public class VndErrorsMarshallingTest {
errors = new VndErrors(error, error, error);
}
/**
* @see #62
*/
@Test
public void jackson1Marshalling() throws Exception {
assertThat(jackson1Mapper.writeValueAsString(errors), is(jsonReference));
}
/**
* @see #62
*/
@Test
public void jackson2Marshalling() throws Exception {
assertThat(jackson2Mapper.writeValueAsString(errors), is(json2Reference));
}
/**
* @see #62, #154
*/
@Test
public void jaxbMarshalling() throws Exception {
Writer writer = new StringWriter();
marshaller.marshal(errors, writer);
assertThat(writer.toString(), is(xmlReference));
assertThat(new Diff(xmlReference, writer.toString()).similar(), is(true));
}
/**
* @see #93, #94
* @see #62, #93, #94
*/
@Test
public void jackson1UnMarshalling() throws Exception {