Skip to content

Commit c4e0f14

Browse files
committed
Polish tests
1 parent 38b8262 commit c4e0f14

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-7
lines changed

spring-web/src/test/java/org/springframework/http/converter/xml/Jaxb2CollectionHttpMessageConverterTests.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
* Test fixture for {@link Jaxb2CollectionHttpMessageConverter}.
4444
*
4545
* @author Arjen Poutsma
46+
* @author Rossen Stoyanchev
4647
*/
4748
@SuppressWarnings("unused")
4849
public class Jaxb2CollectionHttpMessageConverterTests {
@@ -151,9 +152,14 @@ protected XMLInputFactory createXmlInputFactory() {
151152
}
152153
};
153154

154-
Collection<RootElement> result = converter.read(rootElementListType, null, inputMessage);
155-
assertEquals(1, result.size());
156-
assertEquals("", result.iterator().next().external);
155+
try {
156+
Collection<RootElement> result = converter.read(rootElementListType, null, inputMessage);
157+
assertEquals(1, result.size());
158+
assertEquals("", result.iterator().next().external);
159+
}
160+
catch (HttpMessageNotReadableException ex) {
161+
// Some parsers raise an exception
162+
}
157163
}
158164

159165
@Test

spring-web/src/test/java/org/springframework/http/converter/xml/Jaxb2RootElementHttpMessageConverterTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
*
5252
* @author Arjen Poutsma
5353
* @author Sebastien Deleuze
54+
* @author Rossen Stoyanchev
5455
*/
5556
@SuppressWarnings("unused")
5657
public class Jaxb2RootElementHttpMessageConverterTests {

spring-web/src/test/java/org/springframework/http/converter/xml/SourceHttpMessageConverterTests.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.io.StringReader;
2222
import java.nio.charset.Charset;
2323
import javax.xml.parsers.DocumentBuilderFactory;
24+
import javax.xml.stream.XMLStreamException;
2425
import javax.xml.stream.XMLStreamReader;
2526
import javax.xml.transform.Source;
2627
import javax.xml.transform.dom.DOMSource;
@@ -49,13 +50,13 @@
4950

5051
import static org.custommonkey.xmlunit.XMLAssert.*;
5152
import static org.junit.Assert.assertEquals;
52-
import static org.junit.Assert.*;
53-
import static org.junit.Assert.assertTrue;
53+
import static org.junit.Assert.assertNotEquals;
5454

5555
// Do NOT statically import org.junit.Assert.*, since XMLAssert extends junit.framework.Assert
5656

5757
/**
5858
* @author Arjen Poutsma
59+
* @author Rossen Stoyanchev
5960
*/
6061
public class SourceHttpMessageConverterTests {
6162

@@ -226,8 +227,13 @@ public void readStAXSourceExternal() throws Exception {
226227
streamReader.next();
227228
String s = streamReader.getLocalName();
228229
assertEquals("root", s);
229-
s = streamReader.getElementText();
230-
assertNotEquals("Foo Bar", s);
230+
try {
231+
s = streamReader.getElementText();
232+
assertNotEquals("Foo Bar", s);
233+
}
234+
catch (XMLStreamException ex) {
235+
// Some parsers raise a parse exception
236+
}
231237
streamReader.close();
232238
}
233239

0 commit comments

Comments
 (0)