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:
19: package org.mandarax.kernel.validation;
20:
21: import org.mandarax.kernel.*;
22: import org.mandarax.util.logging.LogCategories;
23:
24: import java.util.*;
25:
26: /**
27: * A simple validator component.
28: * For more sophisticated validators, one of the (GUI) junit runners can be used.
29: * @author <A HREF="mailto:j.b.dietrich@massey.ac.nz">Jens Dietrich</A>
30: * @version 3.4 <7 March 05>
31: * @since 3.4
32: */
33: public class SimpleValidator implements LogCategories {
34:
35: /**
36: * Constructor.
37: */
38: public SimpleValidator() {
39: super ();
40: }
41:
42: /**
43: * Validate a knowledge base.
44: * @param kb a knowledge base
45: * @return a boolean (true iff validation succeeds)
46: */
47: public void validate(KnowledgeBase kb) throws Exception {
48: Iterator iter = kb.testcases();
49: while (iter.hasNext()) {
50: TestCase tc = (TestCase) iter.next();
51: tc.prepare();
52: tc.execute();
53: LOG_VALIDATION.info("Validation succeeded for test case "
54: + tc);
55: tc.release();
56: }
57: LOG_VALIDATION.info("Validation of " + kb + " succeeded");
58: }
59:
60: }
|