001: /*
002: * (c) Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP All
003: * rights reserved. [See end of file] $Id: TestXMLFeatures.java,v 1.35
004: * 2003/11/29 15:07:53 jeremy_carroll Exp $
005: */
006:
007: package com.hp.hpl.jena.rdf.arp.test;
008:
009: import java.util.ArrayList;
010:
011: import junit.framework.Test;
012: import junit.framework.TestCase;
013: import junit.framework.TestSuite;
014:
015: import org.xml.sax.Attributes;
016: import org.xml.sax.ErrorHandler;
017: import org.xml.sax.SAXException;
018: import org.xml.sax.SAXParseException;
019:
020: import com.hp.hpl.jena.rdf.arp.impl.XMLHandler;
021: import com.hp.hpl.jena.vocabulary.RDF;
022:
023: public class TestPropEltErrorMsg extends TestCase {
024:
025: static String rslts[] = {
026: null,
027: null,
028: "pT=L,",
029: "",
030: "pT=R,",
031: "",
032: "pT=C,",
033: "",
034: "t,",
035: "",
036: "pT=L,t,",
037: "On a property element, only one of the attributes rdf:parseType or rdf:type is permitted.\n",
038: "pT=R,t,",
039: "On a property element, only one of the attributes rdf:parseType or rdf:type is permitted.\n",
040: "pT=C,t,",
041: "On a property element, only one of the attributes rdf:parseType or rdf:type is permitted.\n",
042: "r,",
043: "",
044: "pT=L,r,",
045: "On a property element, only one of the attributes rdf:parseType or rdf:resource is permitted.\n",
046: "pT=R,r,",
047: "On a property element, only one of the attributes rdf:parseType or rdf:resource is permitted.\n",
048: "pT=C,r,",
049: "On a property element, only one of the attributes rdf:parseType or rdf:resource is permitted.\n",
050: "t,r,",
051: "",
052: "pT=L,t,r,",
053: "On a property element, the attribute rdf:parseType is incompatible with both the attribute rdf:type and the attribute rdf:resource.\n",
054: "pT=R,t,r,",
055: "On a property element, the attribute rdf:parseType is incompatible with both the attribute rdf:type and the attribute rdf:resource.\n",
056: "pT=C,t,r,",
057: "On a property element, the attribute rdf:parseType is incompatible with both the attribute rdf:type and the attribute rdf:resource.\n",
058: "p,",
059: "",
060: "pT=L,p,",
061: "The attribute rdf:parseType is not permitted with property attributes (eg:prop) on a property element.\n",
062: "pT=R,p,",
063: "The attribute rdf:parseType is not permitted with property attributes (eg:prop) on a property element.\n",
064: "pT=C,p,",
065: "The attribute rdf:parseType is not permitted with property attributes (eg:prop) on a property element.\n",
066: "t,p,",
067: "",
068: "pT=L,t,p,",
069: "On a property element, the attribute rdf:parseType is incompatible with both the attribute rdf:type and the property attributes (eg:prop).\n",
070: "pT=R,t,p,",
071: "On a property element, the attribute rdf:parseType is incompatible with both the attribute rdf:type and the property attributes (eg:prop).\n",
072: "pT=C,t,p,",
073: "On a property element, the attribute rdf:parseType is incompatible with both the attribute rdf:type and the property attributes (eg:prop).\n",
074: "r,p,",
075: "",
076: "pT=L,r,p,",
077: "On a property element, the attribute rdf:parseType is incompatible with the property attributes (eg:prop) and the attribute rdf:resource.\n",
078: "pT=R,r,p,",
079: "On a property element, the attribute rdf:parseType is incompatible with the property attributes (eg:prop) and the attribute rdf:resource.\n",
080: "pT=C,r,p,",
081: "On a property element, the attribute rdf:parseType is incompatible with the property attributes (eg:prop) and the attribute rdf:resource.\n",
082: "t,r,p,",
083: "",
084: "pT=L,t,r,p,",
085: "On a property element, the attribute rdf:parseType is incompatible with each of the attribute rdf:type, the property attributes (eg:prop) and the attribute rdf:resource.\n",
086: "pT=R,t,r,p,",
087: "On a property element, the attribute rdf:parseType is incompatible with each of the attribute rdf:type, the property attributes (eg:prop) and the attribute rdf:resource.\n",
088: "pT=C,t,r,p,",
089: "On a property element, the attribute rdf:parseType is incompatible with each of the attribute rdf:type, the property attributes (eg:prop) and the attribute rdf:resource.\n",
090: "n,",
091: "",
092: "pT=L,n,",
093: "On a property element, only one of the attributes rdf:parseType or rdf:nodeID is permitted.\n",
094: "pT=R,n,",
095: "On a property element, only one of the attributes rdf:parseType or rdf:nodeID is permitted.\n",
096: "pT=C,n,",
097: "On a property element, only one of the attributes rdf:parseType or rdf:nodeID is permitted.\n",
098: "t,n,",
099: "",
100: "pT=L,t,n,",
101: "On a property element, the attribute rdf:parseType is incompatible with both the attribute rdf:type and the attribute rdf:nodeID.\n",
102: "pT=R,t,n,",
103: "On a property element, the attribute rdf:parseType is incompatible with both the attribute rdf:type and the attribute rdf:nodeID.\n",
104: "pT=C,t,n,",
105: "On a property element, the attribute rdf:parseType is incompatible with both the attribute rdf:type and the attribute rdf:nodeID.\n",
106: "r,n,",
107: "On a property element, only one of the attributes rdf:nodeID or rdf:resource is permitted.\n",
108: "pT=L,r,n,",
109: "On a property element, only one of the attributes rdf:parseType, rdf:nodeID or rdf:resource is permitted.\n",
110: "pT=R,r,n,",
111: "On a property element, only one of the attributes rdf:parseType, rdf:nodeID or rdf:resource is permitted.\n",
112: "pT=C,r,n,",
113: "On a property element, only one of the attributes rdf:parseType, rdf:nodeID or rdf:resource is permitted.\n",
114: "t,r,n,",
115: "On a property element, only one of the attributes rdf:nodeID or rdf:resource is permitted.\n",
116: "pT=L,t,r,n,",
117: "On a property element, the attribute rdf:parseType is incompatible with both the attribute rdf:type and the mutually incompatible attributes rdf:nodeID and rdf:resource.\n",
118: "pT=R,t,r,n,",
119: "On a property element, the attribute rdf:parseType is incompatible with both the attribute rdf:type and the mutually incompatible attributes rdf:nodeID and rdf:resource.\n",
120: "pT=C,t,r,n,",
121: "On a property element, the attribute rdf:parseType is incompatible with both the attribute rdf:type and the mutually incompatible attributes rdf:nodeID and rdf:resource.\n",
122: "p,n,",
123: "",
124: "pT=L,p,n,",
125: "On a property element, the attribute rdf:parseType is incompatible with the property attributes (eg:prop) and the attribute rdf:nodeID.\n",
126: "pT=R,p,n,",
127: "On a property element, the attribute rdf:parseType is incompatible with the property attributes (eg:prop) and the attribute rdf:nodeID.\n",
128: "pT=C,p,n,",
129: "On a property element, the attribute rdf:parseType is incompatible with the property attributes (eg:prop) and the attribute rdf:nodeID.\n",
130: "t,p,n,",
131: "",
132: "pT=L,t,p,n,",
133: "On a property element, the attribute rdf:parseType is incompatible with each of the attribute rdf:type, the property attributes (eg:prop) and the attribute rdf:nodeID.\n",
134: "pT=R,t,p,n,",
135: "On a property element, the attribute rdf:parseType is incompatible with each of the attribute rdf:type, the property attributes (eg:prop) and the attribute rdf:nodeID.\n",
136: "pT=C,t,p,n,",
137: "On a property element, the attribute rdf:parseType is incompatible with each of the attribute rdf:type, the property attributes (eg:prop) and the attribute rdf:nodeID.\n",
138: "r,p,n,",
139: "On a property element, only one of the attributes rdf:nodeID or rdf:resource is permitted.\n",
140: "pT=L,r,p,n,",
141: "On a property element, the attribute rdf:parseType is incompatible with the property attributes (eg:prop) and the mutually incompatible attributes rdf:nodeID and rdf:resource.\n",
142: "pT=R,r,p,n,",
143: "On a property element, the attribute rdf:parseType is incompatible with the property attributes (eg:prop) and the mutually incompatible attributes rdf:nodeID and rdf:resource.\n",
144: "pT=C,r,p,n,",
145: "On a property element, the attribute rdf:parseType is incompatible with the property attributes (eg:prop) and the mutually incompatible attributes rdf:nodeID and rdf:resource.\n",
146: "t,r,p,n,",
147: "On a property element, only one of the attributes rdf:nodeID or rdf:resource is permitted.\n",
148: "pT=L,t,r,p,n,",
149: "On a property element, the attribute rdf:parseType is incompatible with each of the attribute rdf:type, the property attributes (eg:prop) and the mutually incompatible attributes rdf:nodeID and rdf:resource.\n",
150: "pT=R,t,r,p,n,",
151: "On a property element, the attribute rdf:parseType is incompatible with each of the attribute rdf:type, the property attributes (eg:prop) and the mutually incompatible attributes rdf:nodeID and rdf:resource.\n",
152: "pT=C,t,r,p,n,",
153: "On a property element, the attribute rdf:parseType is incompatible with each of the attribute rdf:type, the property attributes (eg:prop) and the mutually incompatible attributes rdf:nodeID and rdf:resource.\n",
154: "d,",
155: "",
156: "pT=L,d,",
157: "On a property element, only one of the attributes rdf:parseType or rdf:datatype is permitted.\n",
158: "pT=R,d,",
159: "On a property element, only one of the attributes rdf:parseType or rdf:datatype is permitted.\n",
160: "pT=C,d,",
161: "On a property element, only one of the attributes rdf:parseType or rdf:datatype is permitted.\n",
162: "t,d,",
163: "On a property element, only one of the attributes rdf:datatype or rdf:type is permitted.\n",
164: "pT=L,t,d,",
165: "On a property element, only one of the attributes rdf:parseType, rdf:datatype or rdf:type is permitted.\n",
166: "pT=R,t,d,",
167: "On a property element, only one of the attributes rdf:parseType, rdf:datatype or rdf:type is permitted.\n",
168: "pT=C,t,d,",
169: "On a property element, only one of the attributes rdf:parseType, rdf:datatype or rdf:type is permitted.\n",
170: "r,d,",
171: "On a property element, only one of the attributes rdf:datatype or rdf:resource is permitted.\n",
172: "pT=L,r,d,",
173: "On a property element, only one of the attributes rdf:parseType, rdf:datatype or rdf:resource is permitted.\n",
174: "pT=R,r,d,",
175: "On a property element, only one of the attributes rdf:parseType, rdf:datatype or rdf:resource is permitted.\n",
176: "pT=C,r,d,",
177: "On a property element, only one of the attributes rdf:parseType, rdf:datatype or rdf:resource is permitted.\n",
178: "t,r,d,",
179: "On a property element, the attribute rdf:datatype is incompatible with both the attribute rdf:type and the attribute rdf:resource.\n",
180: "pT=L,t,r,d,",
181: "On a property element, the mutually incompatible attributes rdf:datatype and rdf:parseType are incompatible with both the attribute rdf:type and the attribute rdf:resource.\n",
182: "pT=R,t,r,d,",
183: "On a property element, the mutually incompatible attributes rdf:datatype and rdf:parseType are incompatible with both the attribute rdf:type and the attribute rdf:resource.\n",
184: "pT=C,t,r,d,",
185: "On a property element, the mutually incompatible attributes rdf:datatype and rdf:parseType are incompatible with both the attribute rdf:type and the attribute rdf:resource.\n",
186: "p,d,",
187: "The attribute rdf:datatype is not permitted with property attributes (eg:prop) on a property element.\n",
188: "pT=L,p,d,",
189: "On a property element, only one of the rdf:parseType or rdf:datatype attributes or property attributes (eg:prop) is permitted.\n",
190: "pT=R,p,d,",
191: "On a property element, only one of the rdf:parseType or rdf:datatype attributes or property attributes (eg:prop) is permitted.\n",
192: "pT=C,p,d,",
193: "On a property element, only one of the rdf:parseType or rdf:datatype attributes or property attributes (eg:prop) is permitted.\n",
194: "t,p,d,",
195: "On a property element, the attribute rdf:datatype is incompatible with both the attribute rdf:type and the property attributes (eg:prop).\n",
196: "pT=L,t,p,d,",
197: "On a property element, the mutually incompatible attributes rdf:datatype and rdf:parseType are incompatible with both the attribute rdf:type and the property attributes (eg:prop).\n",
198: "pT=R,t,p,d,",
199: "On a property element, the mutually incompatible attributes rdf:datatype and rdf:parseType are incompatible with both the attribute rdf:type and the property attributes (eg:prop).\n",
200: "pT=C,t,p,d,",
201: "On a property element, the mutually incompatible attributes rdf:datatype and rdf:parseType are incompatible with both the attribute rdf:type and the property attributes (eg:prop).\n",
202: "r,p,d,",
203: "On a property element, the attribute rdf:datatype is incompatible with the property attributes (eg:prop) and the attribute rdf:resource.\n",
204: "pT=L,r,p,d,",
205: "On a property element, the mutually incompatible attributes rdf:datatype and rdf:parseType are incompatible with the property attributes (eg:prop) and the attribute rdf:resource.\n",
206: "pT=R,r,p,d,",
207: "On a property element, the mutually incompatible attributes rdf:datatype and rdf:parseType are incompatible with the property attributes (eg:prop) and the attribute rdf:resource.\n",
208: "pT=C,r,p,d,",
209: "On a property element, the mutually incompatible attributes rdf:datatype and rdf:parseType are incompatible with the property attributes (eg:prop) and the attribute rdf:resource.\n",
210: "t,r,p,d,",
211: "On a property element, the attribute rdf:datatype is incompatible with each of the attribute rdf:type, the property attributes (eg:prop) and the attribute rdf:resource.\n",
212: "pT=L,t,r,p,d,",
213: "On a property element, the mutually incompatible attributes rdf:datatype and rdf:parseType are incompatible with each of the attribute rdf:type, the property attributes (eg:prop) and the attribute rdf:resource.\n",
214: "pT=R,t,r,p,d,",
215: "On a property element, the mutually incompatible attributes rdf:datatype and rdf:parseType are incompatible with each of the attribute rdf:type, the property attributes (eg:prop) and the attribute rdf:resource.\n",
216: "pT=C,t,r,p,d,",
217: "On a property element, the mutually incompatible attributes rdf:datatype and rdf:parseType are incompatible with each of the attribute rdf:type, the property attributes (eg:prop) and the attribute rdf:resource.\n",
218: "n,d,",
219: "On a property element, only one of the attributes rdf:datatype or rdf:nodeID is permitted.\n",
220: "pT=L,n,d,",
221: "On a property element, only one of the attributes rdf:parseType, rdf:datatype or rdf:nodeID is permitted.\n",
222: "pT=R,n,d,",
223: "On a property element, only one of the attributes rdf:parseType, rdf:datatype or rdf:nodeID is permitted.\n",
224: "pT=C,n,d,",
225: "On a property element, only one of the attributes rdf:parseType, rdf:datatype or rdf:nodeID is permitted.\n",
226: "t,n,d,",
227: "On a property element, the attribute rdf:datatype is incompatible with both the attribute rdf:type and the attribute rdf:nodeID.\n",
228: "pT=L,t,n,d,",
229: "On a property element, the mutually incompatible attributes rdf:datatype and rdf:parseType are incompatible with both the attribute rdf:type and the attribute rdf:nodeID.\n",
230: "pT=R,t,n,d,",
231: "On a property element, the mutually incompatible attributes rdf:datatype and rdf:parseType are incompatible with both the attribute rdf:type and the attribute rdf:nodeID.\n",
232: "pT=C,t,n,d,",
233: "On a property element, the mutually incompatible attributes rdf:datatype and rdf:parseType are incompatible with both the attribute rdf:type and the attribute rdf:nodeID.\n",
234: "r,n,d,",
235: "On a property element, only one of the attributes rdf:datatype, rdf:nodeID or rdf:resource is permitted.\n",
236: "pT=L,r,n,d,",
237: "On a property element, only one of the attributes rdf:parseType, rdf:datatype, rdf:nodeID or rdf:resource is permitted.\n",
238: "pT=R,r,n,d,",
239: "On a property element, only one of the attributes rdf:parseType, rdf:datatype, rdf:nodeID or rdf:resource is permitted.\n",
240: "pT=C,r,n,d,",
241: "On a property element, only one of the attributes rdf:parseType, rdf:datatype, rdf:nodeID or rdf:resource is permitted.\n",
242: "t,r,n,d,",
243: "On a property element, the attribute rdf:datatype is incompatible with both the attribute rdf:type and the mutually incompatible attributes rdf:nodeID and rdf:resource.\n",
244: "pT=L,t,r,n,d,",
245: "On a property element, the mutually incompatible attributes rdf:datatype and rdf:parseType are incompatible with both the attribute rdf:type and the mutually incompatible attributes rdf:nodeID and rdf:resource.\n",
246: "pT=R,t,r,n,d,",
247: "On a property element, the mutually incompatible attributes rdf:datatype and rdf:parseType are incompatible with both the attribute rdf:type and the mutually incompatible attributes rdf:nodeID and rdf:resource.\n",
248: "pT=C,t,r,n,d,",
249: "On a property element, the mutually incompatible attributes rdf:datatype and rdf:parseType are incompatible with both the attribute rdf:type and the mutually incompatible attributes rdf:nodeID and rdf:resource.\n",
250: "p,n,d,",
251: "On a property element, the attribute rdf:datatype is incompatible with the property attributes (eg:prop) and the attribute rdf:nodeID.\n",
252: "pT=L,p,n,d,",
253: "On a property element, the mutually incompatible attributes rdf:datatype and rdf:parseType are incompatible with the property attributes (eg:prop) and the attribute rdf:nodeID.\n",
254: "pT=R,p,n,d,",
255: "On a property element, the mutually incompatible attributes rdf:datatype and rdf:parseType are incompatible with the property attributes (eg:prop) and the attribute rdf:nodeID.\n",
256: "pT=C,p,n,d,",
257: "On a property element, the mutually incompatible attributes rdf:datatype and rdf:parseType are incompatible with the property attributes (eg:prop) and the attribute rdf:nodeID.\n",
258: "t,p,n,d,",
259: "On a property element, the attribute rdf:datatype is incompatible with each of the attribute rdf:type, the property attributes (eg:prop) and the attribute rdf:nodeID.\n",
260: "pT=L,t,p,n,d,",
261: "On a property element, the mutually incompatible attributes rdf:datatype and rdf:parseType are incompatible with each of the attribute rdf:type, the property attributes (eg:prop) and the attribute rdf:nodeID.\n",
262: "pT=R,t,p,n,d,",
263: "On a property element, the mutually incompatible attributes rdf:datatype and rdf:parseType are incompatible with each of the attribute rdf:type, the property attributes (eg:prop) and the attribute rdf:nodeID.\n",
264: "pT=C,t,p,n,d,",
265: "On a property element, the mutually incompatible attributes rdf:datatype and rdf:parseType are incompatible with each of the attribute rdf:type, the property attributes (eg:prop) and the attribute rdf:nodeID.\n",
266: "r,p,n,d,",
267: "On a property element, the attribute rdf:datatype is incompatible with the property attributes (eg:prop) and the mutually incompatible attributes rdf:nodeID and rdf:resource.\n",
268: "pT=L,r,p,n,d,",
269: "On a property element, the mutually incompatible attributes rdf:datatype and rdf:parseType are incompatible with the property attributes (eg:prop) and the mutually incompatible attributes rdf:nodeID and rdf:resource.\n",
270: "pT=R,r,p,n,d,",
271: "On a property element, the mutually incompatible attributes rdf:datatype and rdf:parseType are incompatible with the property attributes (eg:prop) and the mutually incompatible attributes rdf:nodeID and rdf:resource.\n",
272: "pT=C,r,p,n,d,",
273: "On a property element, the mutually incompatible attributes rdf:datatype and rdf:parseType are incompatible with the property attributes (eg:prop) and the mutually incompatible attributes rdf:nodeID and rdf:resource.\n",
274: "t,r,p,n,d,",
275: "On a property element, the attribute rdf:datatype is incompatible with each of the attribute rdf:type, the property attributes (eg:prop) and the mutually incompatible attributes rdf:nodeID and rdf:resource.\n",
276: "pT=L,t,r,p,n,d,",
277: "On a property element, the mutually incompatible attributes rdf:datatype and rdf:parseType are incompatible with each of the attribute rdf:type, the property attributes (eg:prop) and the mutually incompatible attributes rdf:nodeID and rdf:resource.\n",
278: "pT=R,t,r,p,n,d,",
279: "On a property element, the mutually incompatible attributes rdf:datatype and rdf:parseType are incompatible with each of the attribute rdf:type, the property attributes (eg:prop) and the mutually incompatible attributes rdf:nodeID and rdf:resource.\n",
280: "pT=C,t,r,p,n,d,",
281: "On a property element, the mutually incompatible attributes rdf:datatype and rdf:parseType are incompatible with each of the attribute rdf:type, the property attributes (eg:prop) and the mutually incompatible attributes rdf:nodeID and rdf:resource.\n", };
282:
283: static private class Att {
284: private final String prefix;
285: private final String localName;
286: private final String value;
287:
288: Att(String p, String n, String v) {
289: prefix = p;
290: localName = n;
291: value = v;
292: }
293:
294: String getURI() {
295: return prefix.equals("rdf") ? RDF.getURI()
296: : "http://example.org/";
297: }
298:
299: public String getValue() {
300: return value;
301: }
302:
303: public String getQName() {
304: return prefix + ":" + localName;
305: }
306:
307: public String getLocalName() {
308: return localName;
309: }
310: }
311:
312: static private class Atts implements Attributes {
313: ArrayList atts = new ArrayList();
314:
315: public int getLength() {
316: return atts.size();
317: }
318:
319: public String getURI(int index) {
320: return ((Att) atts.get(index)).getURI();
321: }
322:
323: public String getLocalName(int index) {
324: return ((Att) atts.get(index)).getLocalName();
325: }
326:
327: public String getQName(int index) {
328: return ((Att) atts.get(index)).getQName();
329: }
330:
331: public String getType(int index) {
332: return null;
333: }
334:
335: public String getValue(int index) {
336: return ((Att) atts.get(index)).getValue();
337: }
338:
339: public int getIndex(String uri, String localName) {
340: return -1;
341: }
342:
343: public int getIndex(String qName) {
344: return -1;
345: }
346:
347: public String getType(String uri, String localName) {
348: return null;
349: }
350:
351: public String getType(String qName) {
352: return null;
353: }
354:
355: public String getValue(String uri, String localName) {
356: return null;
357: }
358:
359: public String getValue(String qName) {
360: return null;
361: }
362:
363: public void add(Att att) {
364: atts.add(att);
365: }
366:
367: }
368:
369: final Atts testAtts;
370: final int n;
371:
372: public TestPropEltErrorMsg(String name, Atts atts, int i) {
373: super (name);
374: testAtts = atts;
375: n = i;
376: }
377:
378: public String toString() {
379: return getName();
380: }
381:
382: public static Test suite() {
383: TestSuite s = new TestSuite();
384: s.setName("ARP Property Element Error Messages");
385: for (int i = 1; i < 128; i++) {
386: Atts atts = new Atts();
387: StringBuffer name = new StringBuffer();
388: switch (i & 3) {
389: case 0:
390: break;
391: case 1:
392: atts.add(new Att("rdf", "parseType", "Literal"));
393: name.append("pT=L,");
394: break;
395: case 2:
396: atts.add(new Att("rdf", "parseType", "Resource"));
397: name.append("pT=R,");
398: break;
399: case 3:
400: atts.add(new Att("rdf", "parseType", "Collection"));
401: name.append("pT=C,");
402: break;
403: }
404: if ((i & 4) == 4) {
405: atts.add(new Att("rdf", "type", "foo"));
406: name.append("t,");
407: }
408: if ((i & 8) == 8) {
409: atts.add(new Att("rdf", "resource", "foo"));
410: name.append("r,");
411: }
412: if ((i & 16) == 16) {
413: atts.add(new Att("eg", "prop", "foo"));
414: name.append("p,");
415: }
416: if ((i & 32) == 32) {
417: atts.add(new Att("rdf", "nodeID", "foo"));
418: name.append("n,");
419: }
420: if ((i & 64) == 64) {
421: atts.add(new Att("rdf", "datatype", "foo"));
422: name.append("d,");
423: }
424: s
425: .addTest(new TestPropEltErrorMsg(name.toString(),
426: atts, i));
427:
428: }
429: return s;
430: }
431:
432: protected void runTest() {
433: Attributes noAtts = new Atts();
434: final StringBuffer buf = new StringBuffer();
435: XMLHandler arp = new XMLHandler();
436: arp.getHandlers().setErrorHandler(new ErrorHandler() {
437:
438: public void warning(SAXParseException exception) {
439: buf.append(exception.getMessage());
440: buf.append("\n");
441: }
442:
443: public void error(SAXParseException e) {
444: warning(e);
445: }
446:
447: public void fatalError(SAXParseException e) {
448: warning(e);
449: }
450:
451: });
452: try {
453: arp.initParse("http://example.org/", "");
454: arp.startElement(RDF.getURI(), "RDF", "rdf:RDF", noAtts);
455: arp.startElement(RDF.getURI(), "Description",
456: "rdf:Description", noAtts);
457: arp.startElement(RDF.getURI(), "value", "rdf:value",
458: testAtts);
459: } catch (SAXException e) {
460:
461: }
462:
463: // System.err.println("===");
464:
465: // System.err.println("\""+getName()+"\",");
466:
467: // System.err.println("---");
468: String contents = buf.toString();
469:
470: // System.err.println("\""+(contents.length()>7?contents.substring(7).replace("\n","\\n"):"")+"\",");
471: assertEquals("test data muddled", rslts[n * 2], getName());
472: assertTrue("error message has changed.", contents
473: .endsWith(rslts[n * 2 + 1]));
474: contents = null;
475: }
476:
477: }
478: /*
479: * (c) Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP All
480: * rights reserved.
481: *
482: * Redistribution and use in source and binary forms, with or without
483: * modification, are permitted provided that the following conditions are met: 1.
484: * Redistributions of source code must retain the above copyright notice, this
485: * list of conditions and the following disclaimer. 2. Redistributions in
486: * binary form must reproduce the above copyright notice, this list of
487: * conditions and the following disclaimer in the documentation and/or other
488: * materials provided with the distribution. 3. The name of the author may not
489: * be used to endorse or promote products derived from this software without
490: * specific prior written permission.
491: *
492: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
493: * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
494: * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
495: * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
496: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
497: * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
498: * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
499: * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
500: * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
501: * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
502: *
503: * $Id: TestPropEltErrorMsg.java,v 1.6 2008/01/02 12:06:50 andy_seaborne Exp $
504: */
|