Browse Source

Polish tests

pull/831/head
Rossen Stoyanchev 11 years ago
parent
commit
749bee4d58
  1. 14
      spring-web/src/test/java/org/springframework/http/converter/xml/Jaxb2CollectionHttpMessageConverterTests.java
  2. 1
      spring-web/src/test/java/org/springframework/http/converter/xml/Jaxb2RootElementHttpMessageConverterTests.java
  3. 11
      spring-web/src/test/java/org/springframework/http/converter/xml/SourceHttpMessageConverterTests.java

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

@ -43,6 +43,7 @@ import static org.junit.Assert.*; @@ -43,6 +43,7 @@ import static org.junit.Assert.*;
* Test fixture for {@link Jaxb2CollectionHttpMessageConverter}.
*
* @author Arjen Poutsma
* @author Rossen Stoyanchev
*/
@SuppressWarnings("unused")
public class Jaxb2CollectionHttpMessageConverterTests {
@ -151,9 +152,14 @@ public class Jaxb2CollectionHttpMessageConverterTests { @@ -151,9 +152,14 @@ public class Jaxb2CollectionHttpMessageConverterTests {
}
};
Collection<RootElement> result = converter.read(rootElementListType, null, inputMessage);
assertEquals(1, result.size());
assertEquals("", result.iterator().next().external);
try {
Collection<RootElement> result = converter.read(rootElementListType, null, inputMessage);
assertEquals(1, result.size());
assertEquals("", result.iterator().next().external);
}
catch (HttpMessageNotReadableException ex) {
// Some parsers raise an exception
}
}
@Test
@ -273,4 +279,4 @@ public class Jaxb2CollectionHttpMessageConverterTests { @@ -273,4 +279,4 @@ public class Jaxb2CollectionHttpMessageConverterTests {
}
}
}
}

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

@ -51,6 +51,7 @@ import static org.junit.Assert.assertTrue; @@ -51,6 +51,7 @@ import static org.junit.Assert.assertTrue;
*
* @author Arjen Poutsma
* @author Sebastien Deleuze
* @author Rossen Stoyanchev
*/
@SuppressWarnings("unused")
public class Jaxb2RootElementHttpMessageConverterTests {

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

@ -21,6 +21,7 @@ import java.io.InputStreamReader; @@ -21,6 +21,7 @@ import java.io.InputStreamReader;
import java.io.StringReader;
import java.nio.charset.Charset;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import javax.xml.transform.Source;
import javax.xml.transform.dom.DOMSource;
@ -56,6 +57,7 @@ import static org.junit.Assert.assertTrue; @@ -56,6 +57,7 @@ import static org.junit.Assert.assertTrue;
/**
* @author Arjen Poutsma
* @author Rossen Stoyanchev
*/
public class SourceHttpMessageConverterTests {
@ -226,8 +228,13 @@ public class SourceHttpMessageConverterTests { @@ -226,8 +228,13 @@ public class SourceHttpMessageConverterTests {
streamReader.next();
String s = streamReader.getLocalName();
assertEquals("root", s);
s = streamReader.getElementText();
assertNotEquals("Foo Bar", s);
try {
s = streamReader.getElementText();
assertNotEquals("Foo Bar", s);
}
catch (XMLStreamException ex) {
// Some parsers raise a parse exception
}
streamReader.close();
}

Loading…
Cancel
Save