|
Hibernate example source code file (XMLContextTest.java)
The Hibernate XMLContextTest.java source code//$Id$ 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 junit.framework.TestCase; import org.dom4j.io.SAXReader; import org.hibernate.cfg.EJB3DTDEntityResolver; import org.hibernate.cfg.annotations.reflection.XMLContext; import org.hibernate.internal.util.xml.XMLHelper; import org.xml.sax.InputSource; import org.xml.sax.SAXNotSupportedException; /** * @author Emmanuel Bernard */ public class XMLContextTest extends TestCase { 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" ); assertNotNull( "ORM.xml not found", is ); XMLContext context = new XMLContext(); List errors = new ArrayList(); SAXReader saxReader = xmlHelper.createSAXReader( "XML InputStream", errors, EJB3DTDEntityResolver.INSTANCE ); //saxReader.setValidation( false ); try { saxReader.setFeature( "http://apache.org/xml/features/validation/schema", true ); } catch (SAXNotSupportedException e) { saxReader.setValidation( false ); } org.dom4j.Document doc; try { doc = saxReader .read( new InputSource( new BufferedInputStream( is ) ) ); } finally { try { is.close(); } catch (IOException ioe) { //log.warn( "Could not close input stream", ioe ); } } assertEquals( 0, errors.size() ); context.addDocument( doc ); } } Other Hibernate examples (source code examples)Here is a short list of links related to this Hibernate XMLContextTest.java source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.