@@ -1,10 +1,31 @@
//$Id$
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011 by Red Hat Inc and/or its affiliates or by
* third-party contributors as indicated by either @author tags or express
* copyright attribution statements applied by the authors. All
* third-party contributions are distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org .hibernate .test .annotations .reflection ;
import java .io .BufferedInputStream ;
import java .io .IOException ;
import java .io .InputStream ;
import java .util .ArrayList ;
import java .util .List ;
import org .dom4j .io .SAXReader ;
import org .junit .Assert ;
@@ -14,28 +35,29 @@
import org .hibernate .cfg .EJB3DTDEntityResolver ;
import org .hibernate .cfg .annotations .reflection .XMLContext ;
import org .hibernate .internal .util .xml .ErrorLogger ;
import org .hibernate .internal .util .xml .XMLHelper ;
/**
* @author Emmanuel Bernard
*/
public class XMLContextTest {
@ Test
@ Test
public void testAll () throws Exception {
XMLHelper xmlHelper = new XMLHelper ();
ClassLoader cl = Thread .currentThread ().getContextClassLoader ();
InputStream is = cl .getResourceAsStream (
"org/hibernate/test/annotations/reflection/orm.xml"
);
Assert .assertNotNull ( "ORM.xml not found" , is );
Assert .assertNotNull ( "ORM.xml not found" , is );
XMLContext context = new XMLContext ();
List errors = new ArrayList ();
SAXReader saxReader = xmlHelper .createSAXReader ( "XML InputStream" , errors , EJB3DTDEntityResolver .INSTANCE );
ErrorLogger errorLogger = new ErrorLogger ();
SAXReader saxReader = xmlHelper .createSAXReader ( errorLogger , EJB3DTDEntityResolver .INSTANCE );
//saxReader.setValidation( false );
try {
saxReader .setFeature ( "http://apache.org/xml/features/validation/schema" , true );
}
catch (SAXNotSupportedException e ) {
catch ( SAXNotSupportedException e ) {
saxReader .setValidation ( false );
}
org .dom4j .Document doc ;
@@ -47,11 +69,11 @@ public void testAll() throws Exception {
try {
is .close ();
}
catch (IOException ioe ) {
catch ( IOException ioe ) {
//log.warn( "Could not close input stream", ioe );
}
}
Assert .assertEquals ( 0 , errors . size () );
Assert .assertFalse ( errorLogger . hasErrors () );
context .addDocument ( doc );
}
}