01: /*
02: * Copyright (C) 1999-2004 <A href="http://www-ist.massey.ac.nz/JBDietrich" target="_top">Jens Dietrich</a>
03: *
04: * This library is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License as published by the Free Software Foundation; either
07: * version 2 of the License, or (at your option) any later version.
08: *
09: * This library is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: * Lesser General Public License for more details.
13: *
14: * You should have received a copy of the GNU Lesser General Public
15: * License along with this library; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17: */
18: package test.org.mandarax.reference;
19:
20: import org.mandarax.kernel.InferenceEngine;
21: import org.mandarax.kernel.InferenceException;
22: import org.mandarax.kernel.KnowledgeBase;
23: import org.mandarax.kernel.ResultSet;
24:
25: /**
26: * Test case for testing the ResultSet method <code>first()</code>.
27: * @author <A href="http://www-ist.massey.ac.nz/JBDietrich" target="_top">Jens Dietrich</A>
28: * @version 3.4 <7 March 05>
29: * @since 1.7
30: */
31: public class TestResultSet3 extends TestResultSet {
32:
33: /**
34: * Constructor.
35: * @param kb a new, uninitialized knowledge base that will be used
36: * @param ie the inference engine that will be tested
37: */
38: public TestResultSet3(KnowledgeBase kb, InferenceEngine ie) {
39: super (kb, ie);
40: }
41:
42: /**
43: * Get a description of this test case.
44: * This is used by the <code>org.mandarax.demo</code>
45: * package to display the test cases.
46: * @return a brief description of the test case
47: */
48: public String getDescription() {
49: return "Test ResultSet";
50: }
51:
52: /**
53: * Test the result set. Note that the result set is uninitialized (nothing has been fetched).
54: * @param rs the result set
55: * @return false if the test fails and true otherwise
56: */
57: public boolean testResultSet(ResultSet rs) {
58: try {
59: rs.first();
60: Person value = (Person) rs.getResult(Person.class, "x");
61: return (value != null && value.getName().equals(
62: this .getPersonName()));
63:
64: } catch (InferenceException x) {
65: System.err.println("Error running test case " + this );
66: x.printStackTrace();
67: }
68: return false;
69: }
70: }
|