2 * Copyright (C) 2007 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package tests.api.org.xml.sax;
19 import junit.framework.TestCase;
21 import org.xml.sax.SAXException;
22 import org.xml.sax.SAXParseException;
24 import dalvik.annotation.TestLevel;
25 import dalvik.annotation.TestTargetClass;
26 import dalvik.annotation.TestTargetNew;
28 @TestTargetClass(SAXException.class)
29 public class SAXExceptionTest extends TestCase {
31 public static final String ERR = "Houston, we have a problem";
34 level = TestLevel.COMPLETE,
35 method = "SAXException",
38 public void testSAXParseException() {
39 SAXException e = new SAXException();
41 assertNull(e.getMessage());
42 assertNull(e.getException());
46 level = TestLevel.COMPLETE,
47 method = "SAXException",
48 args = { String.class, Exception.class }
50 public void testSAXException_String_Exception() {
51 Exception c = new Exception();
54 SAXException e = new SAXException(ERR, c);
56 assertEquals(ERR, e.getMessage());
57 assertEquals(c, e.getException());
60 e = new SAXException(null, c);
62 assertNull(e.getMessage());
63 assertEquals(c, e.getException());
66 e = new SAXParseException(ERR, null);
68 assertEquals(ERR, e.getMessage());
69 assertNull(e.getException());
73 level = TestLevel.COMPLETE,
74 method = "SAXException",
75 args = { String.class }
77 public void testSAXException_String() {
79 SAXException e = new SAXException(ERR);
81 assertEquals(ERR, e.getMessage());
82 assertNull(e.getException());
85 e = new SAXException((String)null);
87 assertNull(e.getMessage());
88 assertNull(e.getException());
92 level = TestLevel.COMPLETE,
93 method = "SAXException",
94 args = { Exception.class }
96 public void testSAXException_Exception() {
97 Exception c = new Exception();
100 SAXException e = new SAXException(c);
102 assertNull(e.getMessage());
103 assertEquals(c, e.getException());
106 e = new SAXException((Exception)null);
108 assertNull(e.getMessage());
109 assertNull(e.getException());
113 level = TestLevel.COMPLETE,
117 public void testToString() {
119 SAXException e = new SAXException(ERR);
120 String s = e.toString();
122 assertTrue(s.contains(ERR));
125 e = new SAXException();
128 assertFalse(s.contains(ERR));