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.io.InputStream; 21 import java.io.InputStreamReader; 22 23 import org.wsmo.factory.Factory; 24 import org.wsmo.service.Goal; 25 import org.wsmo.service.WebService; 26 import org.wsmo.validator.WsmlValidator; 27 28 /** 29 * Checks if WSML Web Service and Goals are valid and checks the error messages 30 * if not. 31 * 32 * <pre> 33 * Created on Aug 17, 2006 34 * Committed by $Author: nathaliest $ 35 * $Source$, 36 * </pre> 37 * 38 * @author nathalie.steinmetz@deri.org 39 * @version $Revision: 1804 $ $Date: 2006-08-17 17:58:57 +0300 (Thu, 17 Aug 2006) $ 40 */ 41 public class ValidatorWSandGoalTests extends ValidatorTestCase { 42 43 WebService webService = null; 44 Goal goal = null; 45 46 /** 47 * This test submits a valid wsml-rule web service to the validator and 48 * asserts that the validator recognizes the file as valid. 49 * 50 * Only the capability axioms are checked for validity. 51 */ 52 public void testValidWebService()throws Exception { 53 // read test file and parse it 54 InputStream is = this.getClass().getClassLoader().getResourceAsStream( 55 "test/wsmo4j/validator/travelWebServiceB.wsml"); 56 assertNotNull(is); 57 // assuming first topentity in file is an ontology 58 webService = (WebService)parser.parse(new InputStreamReader(is))[0]; 59 60 WsmlValidator w = Factory.createWsmlValidator(null); 61 boolean b = w.isValid(webService, "http://www.wsmo.org/wsml/wsml-syntax/wsml-flight", errors, warnings); 62 // printWarning(warnings); 63 // printError(errors); 64 assertTrue(b); 65 } 66 67 /** 68 * This test submits an invalid wsml-flight web service to the validator and 69 * asserts that the validator recognizes the file as valid. 70 * 71 * Only the capability axioms are checked for validity. 72 */ 73 public void testInvalidWebService()throws Exception { 74 // read test file and parse it 75 InputStream is = this.getClass().getClassLoader().getResourceAsStream( 76 "test/wsmo4j/validator/travelWebServiceA.wsml"); 77 assertNotNull(is); 78 // assuming first topentity in file is an ontology 79 webService = (WebService)parser.parse(new InputStreamReader(is))[0]; 80 81 WsmlValidator w = Factory.createWsmlValidator(null); 82 boolean b = w.isValid(webService, "http://www.wsmo.org/wsml/wsml-syntax/wsml-flight", errors, warnings); 83 // printWarning(warnings); 84 // printError(errors); 85 assertFalse(b); 86 } 87 88 /** 89 * This test submits a valid wsml-flight goal to the validator and 90 * asserts that the validator recognizes the file as valid. 91 * 92 * Only the capability axioms are checked for validity. 93 */ 94 public void testValidGoal()throws Exception { 95 // read test file and parse it 96 InputStream is = this.getClass().getClassLoader().getResourceAsStream( 97 "test/wsmo4j/validator/travelGoal.wsml"); 98 assertNotNull(is); 99 // assuming first topentity in file is an ontology 100 goal = (Goal)parser.parse(new InputStreamReader(is))[0]; 101 102 WsmlValidator w = Factory.createWsmlValidator(null); 103 boolean b = w.isValid(goal, "http://www.wsmo.org/wsml/wsml-syntax/wsml-flight", errors, warnings); 104 // printWarning(warnings); 105 // printError(errors); 106 assertTrue(b); 107 } 108 109 /** 110 * This test submits an invalid wsml-flight goal to the validator and 111 * asserts that the validator recognizes the file as valid. 112 * 113 * Only the capability axioms are checked for validity. 114 */ 115 public void testInvalidGoal()throws Exception { 116 // read test file and parse it 117 InputStream is = this.getClass().getClassLoader().getResourceAsStream( 118 "test/wsmo4j/validator/travelGoal.wsml"); 119 assertNotNull(is); 120 // assuming first topentity in file is an ontology 121 goal = (Goal)parser.parse(new InputStreamReader(is))[0]; 122 123 WsmlValidator w = Factory.createWsmlValidator(null); 124 boolean b = w.isValid(goal, "http://www.wsmo.org/wsml/wsml-syntax/wsml-core", errors, warnings); 125 // printWarning(warnings); 126 // printError(errors); 127 assertFalse(b); 128 } 129 130 } 131 /* 132 *$Log$ 133 *Revision 1.1 2006/08/17 14:58:57 nathaliest 134 *added test for validation of capability axioms in webservices and goals 135 * 136 * 137 */