OSDN Git Service

original
[gb-231r1-is01/Gingerbread_2.3.3_r1_IS01.git] / libcore / luni / src / test / java / tests / api / org / xml / sax / ext / DefaultHandler2Test.java
1 /*
2  * Copyright (C) 2007 The Android Open Source Project
3  *
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
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
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
17 package tests.api.org.xml.sax.ext;
18
19 import dalvik.annotation.TestLevel;
20 import dalvik.annotation.TestTargetClass;
21 import dalvik.annotation.TestTargetNew;
22
23 import junit.framework.TestCase;
24
25 import org.xml.sax.SAXException;
26 import org.xml.sax.ext.DefaultHandler2;
27
28 import java.io.IOException;
29
30 @TestTargetClass(DefaultHandler2.class)
31 public class DefaultHandler2Test extends TestCase {
32
33     private DefaultHandler2 h = new DefaultHandler2();
34
35     @TestTargetNew(
36         level = TestLevel.COMPLETE,
37         method = "DefaultHandler2",
38         args = { }
39     )
40     public void testDefaultHandler2() {
41         new DefaultHandler2();
42     }
43
44     @TestTargetNew(
45         level = TestLevel.COMPLETE,
46         method = "startCDATA",
47         args = { }
48     )
49     public void testStartCDATA() {
50         try {
51             h.startCDATA();
52         } catch (SAXException e) {
53             throw new RuntimeException("Unexpected exception", e);
54         }
55     }
56
57     @TestTargetNew(
58         level = TestLevel.COMPLETE,
59         method = "endCDATA",
60         args = { }
61     )
62     public void testEndCDATA() {
63         try {
64             h.endCDATA();
65         } catch (SAXException e) {
66             throw new RuntimeException("Unexpected exception", e);
67         }
68     }
69
70     @TestTargetNew(
71         level = TestLevel.COMPLETE,
72         method = "startDTD",
73         args = { String.class, String.class, String.class }
74     )
75     public void testStartDTD() {
76         try {
77             h.startDTD("name", "publicId", "systemId");
78         } catch (SAXException e) {
79             throw new RuntimeException("Unexpected exception", e);
80         }
81     }
82
83     @TestTargetNew(
84         level = TestLevel.COMPLETE,
85         method = "endDTD",
86         args = { }
87     )
88     public void testEndDTD() {
89         try {
90             h.endDTD();
91         } catch (SAXException e) {
92             throw new RuntimeException("Unexpected exception", e);
93         }
94     }
95
96     @TestTargetNew(
97         level = TestLevel.COMPLETE,
98         method = "startEntity",
99         args = { String.class }
100     )
101     public void testStartEntity() {
102         try {
103             h.startEntity("name");
104         } catch (SAXException e) {
105             throw new RuntimeException("Unexpected exception", e);
106         }
107     }
108
109     @TestTargetNew(
110         level = TestLevel.COMPLETE,
111         method = "endEntity",
112         args = { String.class }
113     )
114     public void testEndEntity() {
115         try {
116             h.endEntity("name");
117         } catch (SAXException e) {
118             throw new RuntimeException("Unexpected exception", e);
119         }
120     }
121
122     @TestTargetNew(
123         level = TestLevel.COMPLETE,
124         method = "comment",
125         args = { char[].class, int.class, int.class }
126     )
127     public void testComment() {
128         try {
129             h.comment("<!-- Comment -->".toCharArray(), 0, 15);
130         } catch (SAXException e) {
131             throw new RuntimeException("Unexpected exception", e);
132         }
133     }
134
135     @TestTargetNew(
136         level = TestLevel.COMPLETE,
137         method = "attributeDecl",
138         args = { String.class, String.class, String.class, String.class,
139                  String.class }
140     )
141     public void testAttributeDecl() {
142         try {
143             h.attributeDecl("eName", "aName", "type", "mode", "value");
144         } catch (SAXException e) {
145             throw new RuntimeException("Unexpected exception", e);
146         }
147     }
148
149     @TestTargetNew(
150         level = TestLevel.COMPLETE,
151         method = "elementDecl",
152         args = { String.class, String.class }
153     )
154     public void testElementDecl() {
155         try {
156             h.elementDecl("name", "model");
157         } catch (SAXException e) {
158             throw new RuntimeException("Unexpected exception", e);
159         }
160     }
161
162     @TestTargetNew(
163         level = TestLevel.COMPLETE,
164         method = "externalEntityDecl",
165         args = { String.class, String.class, String.class }
166     )
167     public void testExternalEntityDecl() {
168         try {
169             h.externalEntityDecl("name", "publicId", "systemId");
170         } catch (SAXException e) {
171             throw new RuntimeException("Unexpected exception", e);
172         }
173     }
174
175     @TestTargetNew(
176         level = TestLevel.COMPLETE,
177         method = "internalEntityDecl",
178         args = { String.class, String.class }
179     )
180     public void testInternalEntityDecl() {
181         try {
182             h.internalEntityDecl("name", "value");
183         } catch (SAXException e) {
184             throw new RuntimeException("Unexpected exception", e);
185         }
186     }
187
188     @TestTargetNew(
189         level = TestLevel.COMPLETE,
190         method = "getExternalSubset",
191         args = { String.class, String.class }
192     )
193     public void testGetExternalSubset() {
194         try {
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);
200         }
201     }
202
203     @TestTargetNew(
204         level = TestLevel.COMPLETE,
205         method = "resolveEntity",
206         args = { String.class, String.class }
207     )
208     public void testResolveEntityStringString() {
209         try {
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);
215         }
216     }
217
218     @TestTargetNew(
219         level = TestLevel.COMPLETE,
220         method = "resolveEntity",
221         args = { String.class, String.class, String.class, String.class }
222     )
223     public void testResolveEntityStringStringStringString() {
224         try {
225             assertNull(h.resolveEntity("name", "publicId", "http://some.uri",
226                     "systemId"));
227         } catch (SAXException e) {
228             throw new RuntimeException("Unexpected exception", e);
229         } catch (IOException e) {
230             throw new RuntimeException("Unexpected exception", e);
231         }
232     }
233
234 }