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 17package org.apache.harmony.tests.org.xml.sax.ext; 18 19import junit.framework.TestCase; 20 21import org.xml.sax.SAXException; 22import org.xml.sax.ext.DefaultHandler2; 23 24import java.io.IOException; 25 26public class DefaultHandler2Test extends TestCase { 27 28 private DefaultHandler2 h = new DefaultHandler2(); 29 30 public void testDefaultHandler2() { 31 new DefaultHandler2(); 32 } 33 34 public void testStartCDATA() { 35 try { 36 h.startCDATA(); 37 } catch (SAXException e) { 38 throw new RuntimeException("Unexpected exception", e); 39 } 40 } 41 42 public void testEndCDATA() { 43 try { 44 h.endCDATA(); 45 } catch (SAXException e) { 46 throw new RuntimeException("Unexpected exception", e); 47 } 48 } 49 50 public void testStartDTD() { 51 try { 52 h.startDTD("name", "publicId", "systemId"); 53 } catch (SAXException e) { 54 throw new RuntimeException("Unexpected exception", e); 55 } 56 } 57 58 public void testEndDTD() { 59 try { 60 h.endDTD(); 61 } catch (SAXException e) { 62 throw new RuntimeException("Unexpected exception", e); 63 } 64 } 65 66 public void testStartEntity() { 67 try { 68 h.startEntity("name"); 69 } catch (SAXException e) { 70 throw new RuntimeException("Unexpected exception", e); 71 } 72 } 73 74 public void testEndEntity() { 75 try { 76 h.endEntity("name"); 77 } catch (SAXException e) { 78 throw new RuntimeException("Unexpected exception", e); 79 } 80 } 81 82 public void testComment() { 83 try { 84 h.comment("<!-- Comment -->".toCharArray(), 0, 15); 85 } catch (SAXException e) { 86 throw new RuntimeException("Unexpected exception", e); 87 } 88 } 89 90 public void testAttributeDecl() { 91 try { 92 h.attributeDecl("eName", "aName", "type", "mode", "value"); 93 } catch (SAXException e) { 94 throw new RuntimeException("Unexpected exception", e); 95 } 96 } 97 98 public void testElementDecl() { 99 try { 100 h.elementDecl("name", "model"); 101 } catch (SAXException e) { 102 throw new RuntimeException("Unexpected exception", e); 103 } 104 } 105 106 public void testExternalEntityDecl() { 107 try { 108 h.externalEntityDecl("name", "publicId", "systemId"); 109 } catch (SAXException e) { 110 throw new RuntimeException("Unexpected exception", e); 111 } 112 } 113 114 public void testInternalEntityDecl() { 115 try { 116 h.internalEntityDecl("name", "value"); 117 } catch (SAXException e) { 118 throw new RuntimeException("Unexpected exception", e); 119 } 120 } 121 122 public void testGetExternalSubset() { 123 try { 124 assertNull(h.getExternalSubset("name", "http://some.uri")); 125 } catch (SAXException e) { 126 throw new RuntimeException("Unexpected exception", e); 127 } catch (IOException e) { 128 throw new RuntimeException("Unexpected exception", e); 129 } 130 } 131 132 public void testResolveEntityStringString() { 133 try { 134 assertNull(h.resolveEntity("publicId", "systemId")); 135 } catch (SAXException e) { 136 throw new RuntimeException("Unexpected exception", e); 137 } catch (IOException e) { 138 throw new RuntimeException("Unexpected exception", e); 139 } 140 } 141 142 public void testResolveEntityStringStringStringString() { 143 try { 144 assertNull(h.resolveEntity("name", "publicId", "http://some.uri", 145 "systemId")); 146 } catch (SAXException e) { 147 throw new RuntimeException("Unexpected exception", e); 148 } catch (IOException e) { 149 throw new RuntimeException("Unexpected exception", e); 150 } 151 } 152 153} 154