Skip to content

Commit 749bee4

Browse files
committed
Polish tests
1 parent df83196 commit 749bee4

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

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

Lines changed: 10 additions & 4 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
@@ -273,4 +279,4 @@ public int hashCode() {
273279
}
274280
}
275281

276-
}
282+
}

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: 9 additions & 2 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;
@@ -56,6 +57,7 @@
5657

5758
/**
5859
* @author Arjen Poutsma
60+
* @author Rossen Stoyanchev
5961
*/
6062
public class SourceHttpMessageConverterTests {
6163

@@ -226,8 +228,13 @@ public void readStAXSourceExternal() throws Exception {
226228
streamReader.next();
227229
String s = streamReader.getLocalName();
228230
assertEquals("root", s);
229-
s = streamReader.getElementText();
230-
assertNotEquals("Foo Bar", s);
231+
try {
232+
s = streamReader.getElementText();
233+
assertNotEquals("Foo Bar", s);
234+
}
235+
catch (XMLStreamException ex) {
236+
// Some parsers raise a parse exception
237+
}
231238
streamReader.close();
232239
}
233240

0 commit comments

Comments
 (0)