001: /*
002: * Copyright (C) 1999-2004 <A href="http://www-ist.massey.ac.nz/JBDietrich" target="_top">Jens Dietrich</a>
003: *
004: * This library is free software; you can redistribute it and/or
005: * modify it under the terms of the GNU Lesser General Public
006: * License as published by the Free Software Foundation; either
007: * version 2 of the License, or (at your option) any later version.
008: *
009: * This library is distributed in the hope that it will be useful,
010: * but WITHOUT ANY WARRANTY; without even the implied warranty of
011: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012: * Lesser General Public License for more details.
013: *
014: * You should have received a copy of the GNU Lesser General Public
015: * License along with this library; if not, write to the Free Software
016: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
017: */
018: package test.org.mandarax.reference;
019:
020: import junit.framework.Test;
021: import junit.framework.TestSuite;
022:
023: import org.apache.log4j.BasicConfigurator;
024:
025: /**
026: * Defines a test suite for all tests testing the resolution inference engine.
027: * The engine is tested together with both knowledge bases, KnowledgeBase and
028: * AdvancedKnowledgeBase.
029: * @see org.mandarax.reference.ResolutionInferenceEngine
030: * @see org.mandarax.reference.KnowledgeBase
031: * @see org.mandarax.reference.AdvancedKnowledgeBase
032: * @author <A href="http://www-ist.massey.ac.nz/JBDietrich" target="_top">Jens Dietrich</A>
033: * @version 3.4 <7 March 05>
034: * @since 1.2
035: */
036: public class ResolutionInferenceEngineTests {
037:
038: /**
039: * Launch the test suite. See TestRunner for interpretation
040: * of command line parameters.
041: * @see test.org.mandarax.testsupport.TestRunner
042: * @param args parameters
043: */
044: public static void main(String[] args) {
045: // first init log4j
046: BasicConfigurator.configure();
047: test.org.mandarax.testsupport.TestRunner.run(
048: ResolutionInferenceEngineTests.class, args);
049: }
050:
051: /**
052: * Get the test suite.
053: * @return the test suite
054: */
055: public static Test suite() {
056: TestSuite suite = new TestSuite(
057: "Test cases for the mandarax reference implementation(s) of a resolution inference engine");
058:
059: // testing all inference engine / knowledge base combinations
060: addIETests4OneResult(
061: suite,
062: KnowledgeBaseFactory.ORG_MANDARAX_REFERENCE_KNOWLEDGE_BASE,
063: InferenceEngineFactory.ORG_MANDARAX_REFERENCE_RESOLUTION_INFERENCE_ENGINE);
064: addIETests4OneResult(
065: suite,
066: KnowledgeBaseFactory.ORG_MANDARAX_REFERENCE_ADVANCED_KNOWLEDGE_BASE,
067: InferenceEngineFactory.ORG_MANDARAX_REFERENCE_RESOLUTION_INFERENCE_ENGINE);
068: addIETests4OneResult(
069: suite,
070: KnowledgeBaseFactory.ORG_MANDARAX_REFERENCE_KNOWLEDGE_BASE,
071: InferenceEngineFactory.ORG_MANDARAX_REFERENCE_RESOLUTION_INFERENCE_ENGINE2);
072: addIETests4OneResult(
073: suite,
074: KnowledgeBaseFactory.ORG_MANDARAX_REFERENCE_ADVANCED_KNOWLEDGE_BASE,
075: InferenceEngineFactory.ORG_MANDARAX_REFERENCE_RESOLUTION_INFERENCE_ENGINE2);
076: addIETests4OneResult(
077: suite,
078: KnowledgeBaseFactory.ORG_MANDARAX_REFERENCE_KNOWLEDGE_BASE,
079: InferenceEngineFactory.ORG_MANDARAX_REFERENCE_RESOLUTION_INFERENCE_ENGINE3);
080: addIETests4OneResult(
081: suite,
082: KnowledgeBaseFactory.ORG_MANDARAX_REFERENCE_ADVANCED_KNOWLEDGE_BASE,
083: InferenceEngineFactory.ORG_MANDARAX_REFERENCE_RESOLUTION_INFERENCE_ENGINE3);
084: addIETests4OneResult(
085: suite,
086: KnowledgeBaseFactory.ORG_MANDARAX_REFERENCE_KNOWLEDGE_BASE,
087: InferenceEngineFactory.ORG_MANDARAX_REFERENCE_RESOLUTION_INFERENCE_ENGINE4);
088: addIETests4OneResult(
089: suite,
090: KnowledgeBaseFactory.ORG_MANDARAX_REFERENCE_ADVANCED_KNOWLEDGE_BASE,
091: InferenceEngineFactory.ORG_MANDARAX_REFERENCE_RESOLUTION_INFERENCE_ENGINE4);
092:
093: addIETests4MultipleResults(
094: suite,
095: KnowledgeBaseFactory.ORG_MANDARAX_REFERENCE_KNOWLEDGE_BASE,
096: InferenceEngineFactory.ORG_MANDARAX_REFERENCE_RESOLUTION_INFERENCE_ENGINE2);
097: addIETests4MultipleResults(
098: suite,
099: KnowledgeBaseFactory.ORG_MANDARAX_REFERENCE_ADVANCED_KNOWLEDGE_BASE,
100: InferenceEngineFactory.ORG_MANDARAX_REFERENCE_RESOLUTION_INFERENCE_ENGINE2);
101: addIETests4MultipleResults(
102: suite,
103: KnowledgeBaseFactory.ORG_MANDARAX_REFERENCE_KNOWLEDGE_BASE,
104: InferenceEngineFactory.ORG_MANDARAX_REFERENCE_RESOLUTION_INFERENCE_ENGINE3);
105: addIETests4MultipleResults(
106: suite,
107: KnowledgeBaseFactory.ORG_MANDARAX_REFERENCE_ADVANCED_KNOWLEDGE_BASE,
108: InferenceEngineFactory.ORG_MANDARAX_REFERENCE_RESOLUTION_INFERENCE_ENGINE3);
109: addIETests4MultipleResults(
110: suite,
111: KnowledgeBaseFactory.ORG_MANDARAX_REFERENCE_KNOWLEDGE_BASE,
112: InferenceEngineFactory.ORG_MANDARAX_REFERENCE_RESOLUTION_INFERENCE_ENGINE4);
113: addIETests4MultipleResults(
114: suite,
115: KnowledgeBaseFactory.ORG_MANDARAX_REFERENCE_ADVANCED_KNOWLEDGE_BASE,
116: InferenceEngineFactory.ORG_MANDARAX_REFERENCE_RESOLUTION_INFERENCE_ENGINE4);
117:
118: return suite;
119: }
120:
121: /**
122: * Add tests for the combination knowledge base/ inference engine to a test suite.
123: * @param suite a test suite
124: * @param kbFact a knowledge base factory
125: * @param ieFact an inference engine factory
126: */
127: private static void addIETests4OneResult(TestSuite suite,
128: KnowledgeBaseFactory kbFact, InferenceEngineFactory ieFact) {
129: suite.addTest(new TestInferenceEngine1(kbFact.createKB(),
130: ieFact.createIE()));
131: suite.addTest(new TestInferenceEngine2(kbFact.createKB(),
132: ieFact.createIE()));
133: suite.addTest(new TestInferenceEngine3(kbFact.createKB(),
134: ieFact.createIE()));
135: suite.addTest(new TestInferenceEngine4(kbFact.createKB(),
136: ieFact.createIE()));
137: suite.addTest(new TestInferenceEngine5(kbFact.createKB(),
138: ieFact.createIE()));
139: suite.addTest(new TestInferenceEngine6(kbFact.createKB(),
140: ieFact.createIE()));
141: suite.addTest(new TestInferenceEngine7(kbFact.createKB(),
142: ieFact.createIE()));
143: suite.addTest(new TestInferenceEngine8(kbFact.createKB(),
144: ieFact.createIE()));
145: suite.addTest(new TestInferenceEngine9(kbFact.createKB(),
146: ieFact.createIE()));
147: suite.addTest(new TestInferenceEngine10(kbFact.createKB(),
148: ieFact.createIE()));
149: suite.addTest(new TestInferenceEngine11(kbFact.createKB(),
150: ieFact.createIE()));
151: suite.addTest(new TestInferenceEngine12(kbFact.createKB(),
152: ieFact.createIE()));
153: suite.addTest(new TestInferenceEngine13(kbFact.createKB(),
154: ieFact.createIE()));
155: suite.addTest(new TestInferenceEngine14(kbFact.createKB(),
156: ieFact.createIE()));
157: suite.addTest(new TestInferenceEngine15(kbFact.createKB(),
158: ieFact.createIE()));
159: suite.addTest(new TestInferenceEngine16(kbFact.createKB(),
160: ieFact.createIE()));
161: suite.addTest(new TestInferenceEngine17(kbFact.createKB(),
162: ieFact.createIE()));
163: suite.addTest(new TestResultSet1(kbFact.createKB(), ieFact
164: .createIE()));
165: suite.addTest(new TestResultSet2(kbFact.createKB(), ieFact
166: .createIE()));
167: suite.addTest(new TestResultSet3(kbFact.createKB(), ieFact
168: .createIE()));
169: suite.addTest(new TestResultSet4(kbFact.createKB(), ieFact
170: .createIE()));
171: suite.addTest(new TestResultSet5(kbFact.createKB(), ieFact
172: .createIE()));
173: suite.addTest(new TestResultSet6(kbFact.createKB(), ieFact
174: .createIE()));
175: suite.addTest(new TestResultSet7(kbFact.createKB(), ieFact
176: .createIE()));
177:
178: // new in 3.3
179: suite.addTest(new TestRecursion1("test1", kbFact.createKB(),
180: ieFact.createIE()));
181: suite.addTest(new TestRecursion1("test2", kbFact.createKB(),
182: ieFact.createIE()));
183: suite.addTest(new TestRecursion1("test3", kbFact.createKB(),
184: ieFact.createIE()));
185: suite.addTest(new TestRecursion1("test4", kbFact.createKB(),
186: ieFact.createIE()));
187: suite.addTest(new TestRecursion1("test5", kbFact.createKB(),
188: ieFact.createIE()));
189: suite.addTest(new TestRecursion1("test6", kbFact.createKB(),
190: ieFact.createIE()));
191: suite.addTest(new TestRecursion1("test7", kbFact.createKB(),
192: ieFact.createIE()));
193:
194: // new in 3.3.1
195: // suite.addTest(new TestComplexTerm("testComplexTerm1",kbFact.createKB(),ieFact.createIE())); WARNING: this is not supported by current IE implementations (Jens, March 05) !!
196: suite.addTest(new TestComplexTerm("testComplexTerm2", kbFact
197: .createKB(), ieFact.createIE()));
198: suite.addTest(new TestComplexTerm("testComplexTerm3", kbFact
199: .createKB(), ieFact.createIE()));
200:
201: }
202:
203: /**
204: * Add tests for the combination knowledge base/ inference engine to a test suite.
205: * @param suite a test suite
206: * @param kbFact a knowledge base factory
207: * @param ieFact an inference engine factory
208: */
209: private static void addIETests4MultipleResults(TestSuite suite,
210: KnowledgeBaseFactory kbFact, InferenceEngineFactory ieFact) {
211: suite.addTest(new TestInferenceEngine4MultipleResults1(kbFact
212: .createKB(), ieFact.createIE()));
213: suite.addTest(new TestInferenceEngine4MultipleResults2(kbFact
214: .createKB(), ieFact.createIE()));
215: suite.addTest(new TestInferenceEngine4MultipleResults3(kbFact
216: .createKB(), ieFact.createIE()));
217: suite.addTest(new TestInferenceEngine4MultipleResults4(kbFact
218: .createKB(), ieFact.createIE()));
219:
220: }
221:
222: }
|