1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.springframework.oxm.xmlbeans;
17
18 import junit.framework.TestCase;
19 import org.apache.xmlbeans.XMLStreamValidationException;
20 import org.apache.xmlbeans.XmlError;
21 import org.apache.xmlbeans.XmlException;
22 import org.xml.sax.SAXException;
23
24 public class XmlBeansUtilsTest extends TestCase {
25
26 public void testConvertXMLStreamValidationException() {
27 assertTrue("Invalid exception conversion", XmlBeansUtils.convertXmlBeansException(
28 new XMLStreamValidationException(XmlError.forMessage("")),
29 true) instanceof XmlBeansValidationFailureException);
30
31 }
32
33 public void testConvertXmlException() {
34 assertTrue("Invalid exception conversion", XmlBeansUtils
35 .convertXmlBeansException(new XmlException(""), true) instanceof XmlBeansMarshallingFailureException);
36 assertTrue("Invalid exception conversion", XmlBeansUtils.convertXmlBeansException(new XmlException(""),
37 false) instanceof XmlBeansUnmarshallingFailureException);
38 }
39
40 public void testConvertSAXException() {
41 assertTrue("Invalid exception conversion", XmlBeansUtils
42 .convertXmlBeansException(new SAXException(""), true) instanceof XmlBeansMarshallingFailureException);
43 assertTrue("Invalid exception conversion", XmlBeansUtils.convertXmlBeansException(new SAXException(""),
44 false) instanceof XmlBeansUnmarshallingFailureException);
45 }
46
47 public void testFallbackException() {
48 assertTrue("Invalid exception conversion",
49 XmlBeansUtils.convertXmlBeansException(new Exception(""), false) instanceof XmlBeansSystemException);
50
51 }
52
53 }