1   /*
2   wsmo4j - a WSMO API and Reference Implementation
3   
4   Copyright (c) 2005, University of Innsbruck, Austria
5   
6   This library is free software; you can redistribute it and/or modify it under
7   the terms of the GNU Lesser General Public License as published by the Free
8   Software Foundation; either version 2.1 of the License, or (at your option)
9   any later version.
10  This library is distributed in the hope that it will be useful, but WITHOUT
11  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12  FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13  details.
14  You should have received a copy of the GNU Lesser General Public License along
15  with this library; if not, write to the Free Software Foundation, Inc.,
16  59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  */
18  package test.wsmo4j.validator;
19  
20  import java.util.List;
21  import java.util.Vector;
22  
23  import org.deri.wsmo4j.validator.WsmlValidatorImpl;
24  import org.omwg.logicalexpression.LogicalExpression;
25  import org.wsmo.common.WSML;
26  import org.wsmo.validator.ValidationError;
27  import org.wsmo.validator.ValidationWarning;
28  import org.wsmo.validator.WsmlValidator;
29  
30  /**
31   * This unit test class is meant to show up bugs in the 
32   * validator that need to be fixed.
33   * 
34   * <pre>
35   * Created on Sep 19, 2006
36   * Committed by $Author: morcen $
37   * $Source$,
38   * </pre>
39   * 
40   * @author nathalie.steinmetz@deri.org
41   * @version $Revision: 1946 $ $Date: 2007-04-02 15:13:28 +0300 (Mon, 02 Apr 2007) $
42   */
43  public class BugTests extends ValidatorTestCase {
44  
45  	LogicalExpression logExpr = null;
46  	
47  	List <ValidationError> errors = new Vector <ValidationError> ();
48  	
49  	List <ValidationWarning> warnings = new Vector <ValidationWarning>();
50  	
51  	WsmlValidator validator = new WsmlValidatorImpl();
52  	
53  	/* ---------------------- DL Bugs -----------------------*/
54  	
55  	/**
56  	 * In the following logical expression, ?x and ?y are not connected. 
57  	 */
58  	public void testUnConnectedGraphInWSMLDL() throws Exception {
59  		errors.clear();
60  		logExpr = leFactory.createLogicalExpression(
61  				"?x[attr hasValue ?y] implies ?w[attr2 hasValue ?z].", 
62  				ontology);
63  		boolean valid = validator.isValid(logExpr, WSML.WSML_DL, errors, warnings);
64  //		printError(errors);
65  		assertFalse(valid);	
66  	}
67  	
68  	/**
69  	 * In the following logical expression, the left and the right side of the 
70  	 * implication have no common root variable.
71  	 */
72  	public void testNoRootVariableInWSMLDL() throws Exception {
73  		errors.clear();
74  		logExpr = leFactory.createLogicalExpression(
75  				"?x memberOf A implies ?y memberOf B and ?z[C hasValue ?y].", 
76  				ontology);
77  		boolean valid = validator.isValid(logExpr, WSML.WSML_DL, errors, warnings);
78  //		printError(errors);
79  		assertFalse(valid);	
80  	}
81  	
82  	/**
83  	 * In the following logical expression, the universal truth is used.
84  	 */
85  	public void testUseOfBooleanInWSMLDL() throws Exception {
86  		errors.clear();
87  		logExpr = leFactory.createLogicalExpression(
88  				"?x memberOf Person implies true.", 
89  				ontology);
90  		boolean valid = validator.isValid(logExpr, WSML.WSML_DL, errors, warnings);
91  //		printError(errors);
92  		assertTrue(valid);	
93  	}
94  	
95  	/**
96  	 * In the following logical expression, a built-in atom is used.
97  	 */
98  	public void testBuiltInInWSMLDL() throws Exception {
99  			errors.clear();
100 		logExpr = leFactory.createLogicalExpression("?x = ?y and ?x memberOf Animal " +
101 				"implies ?y memberOf Human.", ontology);
102 		boolean valid = validator.isValid(logExpr, WSML.WSML_DL, errors, warnings);
103 //		printError(errors);
104 		assertFalse(valid);	
105 	}
106 	
107 //	/**
108 //	 * The following logical expression contains a "=" in the head of the formula, 
109 //	 * but applying the following splitting rule transfers the "=" into the body, 
110 //	 * so that this should be allowed.
111 //	 * 
112 //	 * A implies B  is transformed to B :- A.
113 //	 */
114 //	public void testSplittingInWSMLFlight() throws Exception {
115 //		errors.clear();
116 ////		logExpr = leFactory.createLogicalExpression(
117 ////				"?x[hasAgeInYears hasValue ?y] and ?days=(10*365) " +
118 ////				"implies ?x[hasAgeInDays hasValue ?days]", ontology);
119 //		logExpr = leFactory.createLogicalExpression(
120 //				"?x memberOf Human or ?x memberOf Animal implies " +
121 //				"?x memberOf Mammal", ontology);
122 //		boolean valid = validator.isValid(logExpr, WSML.WSML_FLIGHT, errors, warnings);
123 //		printError(errors);
124 //		assertTrue(valid);	
125 //	}
126 	
127 }
128 /*
129  * $Log$
130  * Revision 1.6  2007/04/02 12:13:23  morcen
131  * Generics support added to wsmo-api, wsmo4j and wsmo-test
132  *
133  * Revision 1.5  2007/02/23 10:44:23  nathaliest
134  * changed test
135  *
136  * Revision 1.4  2006/10/05 13:09:28  nathaliest
137  * fixed metamodelling bug
138  *
139  * Revision 1.3  2006/09/28 15:59:02  nathaliest
140  * *** empty log message ***
141  *
142  * Revision 1.2  2006/09/28 13:11:34  nathaliest
143  * added utility method to geet root variable of valid WSML-DL formula and added corresponding tests
144  *
145  * Revision 1.1  2006/09/20 14:39:07  nathaliest
146  * tests for bugs, fixed ones and such ones that need to be fixed
147  *
148  * 
149  */