Search in sources :

Example 11 with XMLContext

use of org.hibernate.cfg.annotations.reflection.XMLContext in project hibernate-orm by hibernate.

the class XMLContextTest method testAll.

@Test
public void testAll() throws Exception {
    final XMLHelper xmlHelper = new XMLHelper(ClassLoaderServiceTestingImpl.INSTANCE);
    final XMLContext context = new XMLContext(ClassLoaderAccessTestingImpl.INSTANCE);
    InputStream is = ClassLoaderServiceTestingImpl.INSTANCE.locateResourceStream("org/hibernate/test/annotations/reflection/orm.xml");
    Assert.assertNotNull("ORM.xml not found", is);
    final ErrorLogger errorLogger = new ErrorLogger();
    final SAXReader saxReader = xmlHelper.createSAXReader(errorLogger, EJB3DTDEntityResolver.INSTANCE);
    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 );
        }
    }
    Assert.assertFalse(errorLogger.hasErrors());
    context.addDocument(doc);
}
Also used : InputSource(org.xml.sax.InputSource) SAXNotSupportedException(org.xml.sax.SAXNotSupportedException) XMLContext(org.hibernate.cfg.annotations.reflection.XMLContext) BufferedInputStream(java.io.BufferedInputStream) BufferedInputStream(java.io.BufferedInputStream) InputStream(java.io.InputStream) SAXReader(org.dom4j.io.SAXReader) IOException(java.io.IOException) XMLHelper(org.hibernate.internal.util.xml.XMLHelper) ErrorLogger(org.hibernate.internal.util.xml.ErrorLogger) Test(org.junit.Test)

Example 12 with XMLContext

use of org.hibernate.cfg.annotations.reflection.XMLContext in project hibernate-orm by hibernate.

the class Ejb3XmlTestCase method getReader.

protected JPAOverriddenAnnotationReader getReader(Class<?> entityClass, String fieldName, String ormResourceName) throws Exception {
    AnnotatedElement el = getAnnotatedElement(entityClass, fieldName);
    XMLContext xmlContext = getContext(ormResourceName);
    return new JPAOverriddenAnnotationReader(el, xmlContext, ClassLoaderAccessTestingImpl.INSTANCE);
}
Also used : XMLContext(org.hibernate.cfg.annotations.reflection.XMLContext) AnnotatedElement(java.lang.reflect.AnnotatedElement) JPAOverriddenAnnotationReader(org.hibernate.cfg.annotations.reflection.JPAOverriddenAnnotationReader)

Example 13 with XMLContext

use of org.hibernate.cfg.annotations.reflection.XMLContext in project hibernate-orm by hibernate.

the class Ejb3XmlTestCase method getContext.

protected XMLContext getContext(InputStream is) throws Exception {
    XMLContext xmlContext = new XMLContext(ClassLoaderAccessTestingImpl.INSTANCE);
    Document doc = new SAXReader().read(is);
    xmlContext.addDocument(doc);
    return xmlContext;
}
Also used : XMLContext(org.hibernate.cfg.annotations.reflection.XMLContext) SAXReader(org.dom4j.io.SAXReader) Document(org.dom4j.Document)

Aggregations

XMLContext (org.hibernate.cfg.annotations.reflection.XMLContext)13 JPAOverriddenAnnotationReader (org.hibernate.cfg.annotations.reflection.JPAOverriddenAnnotationReader)10 Test (org.junit.Test)10 Field (java.lang.reflect.Field)5 PrimaryKeyJoinColumns (javax.persistence.PrimaryKeyJoinColumns)4 Method (java.lang.reflect.Method)3 DiscriminatorColumn (javax.persistence.DiscriminatorColumn)3 JoinTable (javax.persistence.JoinTable)3 MappedSuperclass (javax.persistence.MappedSuperclass)3 PrimaryKeyJoinColumn (javax.persistence.PrimaryKeyJoinColumn)3 SequenceGenerator (javax.persistence.SequenceGenerator)3 SAXReader (org.dom4j.io.SAXReader)3 BufferedInputStream (java.io.BufferedInputStream)2 InputStream (java.io.InputStream)2 AttributeOverrides (javax.persistence.AttributeOverrides)2 Basic (javax.persistence.Basic)2 Entity (javax.persistence.Entity)2 IdClass (javax.persistence.IdClass)2 Inheritance (javax.persistence.Inheritance)2 JoinColumns (javax.persistence.JoinColumns)2