01: /*
02: * (c) Copyright 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
03: * [See end of file]
04: */
05:
06: package com.hp.hpl.jena.rdf.arp.states.test;
07:
08: import java.util.HashMap;
09:
10: import junit.framework.Assert;
11:
12: import com.hp.hpl.jena.rdf.arp.impl.ANode;
13: import com.hp.hpl.jena.rdf.arp.impl.Taint;
14: import com.hp.hpl.jena.rdf.arp.impl.XMLHandler;
15:
16: class TestHandler extends XMLHandler {
17: public void wrong(String msg) {
18: wrong = true;
19: if (failOnWarning)
20: Assert.fail("unexpected warning: " + msg);
21: }
22:
23: public void warning(Taint taintMe, int i, String s) {
24: if (i < 100)
25: return;
26: wrong = true;
27: if (failOnWarning)
28: Assert.fail("unexpected warning: " + s);
29: }
30:
31: public void endLocalScope(ANode v) {
32: scope++;
33: }
34:
35: public void triple(ANode s, ANode p, ANode o) {
36: triples++;
37: }
38:
39: boolean wrong;
40: int triples;
41: int scope;
42: boolean failOnWarning;
43:
44: public void clear(boolean failOnWarning_) {
45: wrong = false;
46: triples = 0;
47: scope = 0;
48: this .failOnWarning = failOnWarning_;
49: idsUsed = new HashMap();
50: idsUsedCount = 0;
51: }
52:
53: public String info() {
54: return wrong ? "?"
55: : ((triples == 0 ? "" : ("T" + triples)) + (scope == 0 ? ""
56: : (" E" + scope)));
57: }
58:
59: public void check(EventRecord r) {
60: r.initCounts();
61: Assert.assertEquals("triple count", r.triples, triples);
62: Assert.assertEquals("end bnode scope count", r.scope, scope);
63:
64: }
65: }
66:
67: /*
68: * (c) Copyright 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
69: * All rights reserved.
70: *
71: * Redistribution and use in source and binary forms, with or without
72: * modification, are permitted provided that the following conditions
73: * are met:
74: * 1. Redistributions of source code must retain the above copyright
75: * notice, this list of conditions and the following disclaimer.
76: * 2. Redistributions in binary form must reproduce the above copyright
77: * notice, this list of conditions and the following disclaimer in the
78: * documentation and/or other materials provided with the distribution.
79: * 3. The name of the author may not be used to endorse or promote products
80: * derived from this software without specific prior written permission.
81: *
82: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
83: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
84: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
85: * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
86: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
87: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
88: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
89: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
90: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
91: * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
92: */
|