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.ext;
19 import dalvik.annotation.TestLevel;
20 import dalvik.annotation.TestTargetClass;
21 import dalvik.annotation.TestTargetNew;
23 import junit.framework.TestCase;
25 import org.xml.sax.SAXException;
26 import org.xml.sax.ext.DefaultHandler2;
28 import java.io.IOException;
30 @TestTargetClass(DefaultHandler2.class)
31 public class DefaultHandler2Test extends TestCase {
33 private DefaultHandler2 h = new DefaultHandler2();
36 level = TestLevel.COMPLETE,
37 method = "DefaultHandler2",
40 public void testDefaultHandler2() {
41 new DefaultHandler2();
45 level = TestLevel.COMPLETE,
46 method = "startCDATA",
49 public void testStartCDATA() {
52 } catch (SAXException e) {
53 throw new RuntimeException("Unexpected exception", e);
58 level = TestLevel.COMPLETE,
62 public void testEndCDATA() {
65 } catch (SAXException e) {
66 throw new RuntimeException("Unexpected exception", e);
71 level = TestLevel.COMPLETE,
73 args = { String.class, String.class, String.class }
75 public void testStartDTD() {
77 h.startDTD("name", "publicId", "systemId");
78 } catch (SAXException e) {
79 throw new RuntimeException("Unexpected exception", e);
84 level = TestLevel.COMPLETE,
88 public void testEndDTD() {
91 } catch (SAXException e) {
92 throw new RuntimeException("Unexpected exception", e);
97 level = TestLevel.COMPLETE,
98 method = "startEntity",
99 args = { String.class }
101 public void testStartEntity() {
103 h.startEntity("name");
104 } catch (SAXException e) {
105 throw new RuntimeException("Unexpected exception", e);
110 level = TestLevel.COMPLETE,
111 method = "endEntity",
112 args = { String.class }
114 public void testEndEntity() {
117 } catch (SAXException e) {
118 throw new RuntimeException("Unexpected exception", e);
123 level = TestLevel.COMPLETE,
125 args = { char[].class, int.class, int.class }
127 public void testComment() {
129 h.comment("<!-- Comment -->".toCharArray(), 0, 15);
130 } catch (SAXException e) {
131 throw new RuntimeException("Unexpected exception", e);
136 level = TestLevel.COMPLETE,
137 method = "attributeDecl",
138 args = { String.class, String.class, String.class, String.class,
141 public void testAttributeDecl() {
143 h.attributeDecl("eName", "aName", "type", "mode", "value");
144 } catch (SAXException e) {
145 throw new RuntimeException("Unexpected exception", e);
150 level = TestLevel.COMPLETE,
151 method = "elementDecl",
152 args = { String.class, String.class }
154 public void testElementDecl() {
156 h.elementDecl("name", "model");
157 } catch (SAXException e) {
158 throw new RuntimeException("Unexpected exception", e);
163 level = TestLevel.COMPLETE,
164 method = "externalEntityDecl",
165 args = { String.class, String.class, String.class }
167 public void testExternalEntityDecl() {
169 h.externalEntityDecl("name", "publicId", "systemId");
170 } catch (SAXException e) {
171 throw new RuntimeException("Unexpected exception", e);
176 level = TestLevel.COMPLETE,
177 method = "internalEntityDecl",
178 args = { String.class, String.class }
180 public void testInternalEntityDecl() {
182 h.internalEntityDecl("name", "value");
183 } catch (SAXException e) {
184 throw new RuntimeException("Unexpected exception", e);
189 level = TestLevel.COMPLETE,
190 method = "getExternalSubset",
191 args = { String.class, String.class }
193 public void testGetExternalSubset() {
195 assertNull(h.getExternalSubset("name", "http://some.uri"));
196 } catch (SAXException e) {
197 throw new RuntimeException("Unexpected exception", e);
198 } catch (IOException e) {
199 throw new RuntimeException("Unexpected exception", e);
204 level = TestLevel.COMPLETE,
205 method = "resolveEntity",
206 args = { String.class, String.class }
208 public void testResolveEntityStringString() {
210 assertNull(h.resolveEntity("publicId", "systemId"));
211 } catch (SAXException e) {
212 throw new RuntimeException("Unexpected exception", e);
213 } catch (IOException e) {
214 throw new RuntimeException("Unexpected exception", e);
219 level = TestLevel.COMPLETE,
220 method = "resolveEntity",
221 args = { String.class, String.class, String.class, String.class }
223 public void testResolveEntityStringStringStringString() {
225 assertNull(h.resolveEntity("name", "publicId", "http://some.uri",
227 } catch (SAXException e) {
228 throw new RuntimeException("Unexpected exception", e);
229 } catch (IOException e) {
230 throw new RuntimeException("Unexpected exception", e);