01: /*
02: * Copyright 2005 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
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(
28: "Invalid exception conversion",
29: XmlBeansUtils.convertXmlBeansException(
30: new XMLStreamValidationException(XmlError
31: .forMessage("")), true) instanceof XmlBeansValidationFailureException);
32:
33: }
34:
35: public void testConvertXmlException() {
36: assertTrue(
37: "Invalid exception conversion",
38: XmlBeansUtils.convertXmlBeansException(
39: new XmlException(""), true) instanceof XmlBeansMarshallingFailureException);
40: assertTrue(
41: "Invalid exception conversion",
42: XmlBeansUtils.convertXmlBeansException(
43: new XmlException(""), false) instanceof XmlBeansUnmarshallingFailureException);
44: }
45:
46: public void testConvertSAXException() {
47: assertTrue(
48: "Invalid exception conversion",
49: XmlBeansUtils.convertXmlBeansException(
50: new SAXException(""), true) instanceof XmlBeansMarshallingFailureException);
51: assertTrue(
52: "Invalid exception conversion",
53: XmlBeansUtils.convertXmlBeansException(
54: new SAXException(""), false) instanceof XmlBeansUnmarshallingFailureException);
55: }
56:
57: public void testFallbackException() {
58: assertTrue(
59: "Invalid exception conversion",
60: XmlBeansUtils.convertXmlBeansException(
61: new Exception(""), false) instanceof XmlBeansSystemException);
62:
63: }
64:
65: }
|