1 /* 2 * Copyright 2001-2004 (C) MetaStuff, Ltd. All Rights Reserved. 3 * 4 * This software is open source. 5 * See the bottom of this file for the licence. 6 * 7 * $Id: TestValidation.java,v 1.6 2004/06/25 08:03:47 maartenc Exp $ 8 */ 9 10 package org.dom4j; 11 12 import junit.framework.Test; 13 import junit.framework.TestSuite; 14 import junit.textui.TestRunner; 15 16 import org.dom4j.io.SAXReader; 17 import org.xml.sax.SAXException; 18 19 /*** A test harness for validation when using SAXReader 20 * 21 * @author <a href="mailto:jstrachan@apache.org">James Strachan</a> 22 * @version $Revision: 1.6 $ 23 */ 24 public class TestValidation extends AbstractTestCase { 25 26 public static void main( String[] args ) { 27 TestRunner.run( suite() ); 28 } 29 30 public static Test suite() { 31 return new TestSuite( TestValidation.class ); 32 } 33 34 public TestValidation(String name) { 35 super(name); 36 } 37 38 // Test case(s) 39 //------------------------------------------------------------------------- 40 public void testValidation() throws Exception { 41 try { 42 SAXReader reader = new SAXReader("org.dom4j.io.aelfred2.SAXDriver", true); 43 reader.read("test"); 44 fail(); 45 } catch (DocumentException e) { 46 ; // internal parser is non validating, so OK 47 } 48 } 49 } 50 51 52 53 54 /* 55 * Redistribution and use of this software and associated documentation 56 * ("Software"), with or without modification, are permitted provided 57 * that the following conditions are met: 58 * 59 * 1. Redistributions of source code must retain copyright 60 * statements and notices. Redistributions must also contain a 61 * copy of this document. 62 * 63 * 2. Redistributions in binary form must reproduce the 64 * above copyright notice, this list of conditions and the 65 * following disclaimer in the documentation and/or other 66 * materials provided with the distribution. 67 * 68 * 3. The name "DOM4J" must not be used to endorse or promote 69 * products derived from this Software without prior written 70 * permission of MetaStuff, Ltd. For written permission, 71 * please contact dom4j-info@metastuff.com. 72 * 73 * 4. Products derived from this Software may not be called "DOM4J" 74 * nor may "DOM4J" appear in their names without prior written 75 * permission of MetaStuff, Ltd. DOM4J is a registered 76 * trademark of MetaStuff, Ltd. 77 * 78 * 5. Due credit should be given to the DOM4J Project - 79 * http://www.dom4j.org 80 * 81 * THIS SOFTWARE IS PROVIDED BY METASTUFF, LTD. AND CONTRIBUTORS 82 * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT 83 * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 84 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 85 * METASTUFF, LTD. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 86 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 87 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 88 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 89 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 90 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 91 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 92 * OF THE POSSIBILITY OF SUCH DAMAGE. 93 * 94 * Copyright 2001-2004 (C) MetaStuff, Ltd. All Rights Reserved. 95 * 96 * $Id: TestValidation.java,v 1.6 2004/06/25 08:03:47 maartenc Exp $ 97 */