Package org.hibernate.reflection.java.xml

Examples of org.hibernate.reflection.java.xml.XMLContext


  public void testAll() throws Exception {
    XMLHelper xmlHelper = new XMLHelper();
    ClassLoader cl = Thread.currentThread().getContextClassLoader();
    InputStream is = cl.getResourceAsStream( "org/hibernate/test/reflection/java/xml/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 );
  }
View Full Code Here


  public JavaXFactory() {
    reset();
  }

  public void reset() {
    xmlContext = new XMLContext();
    xClasses.clear();
    packagesToXPackages.clear();
    xProperties.clear();
    xMethods.clear();
    defaults = null;
View Full Code Here

/**
* @author Emmanuel Bernard
*/
public class EJB3OverridenAnnotationReaderTest extends TestCase {
  public void testMappedSuperclassAnnotations() throws Exception {
    XMLContext context = buildContext( "org/hibernate/test/reflection/java/xml/metadata-complete.xml" );
    EJB3OverridenAnnotationReader reader = new EJB3OverridenAnnotationReader( Organization.class, context );
    assertTrue( reader.isAnnotationPresent( MappedSuperclass.class ) );
  }
View Full Code Here

    EJB3OverridenAnnotationReader reader = new EJB3OverridenAnnotationReader( Organization.class, context );
    assertTrue( reader.isAnnotationPresent( MappedSuperclass.class ) );
  }

  public void testEntityRelatedAnnotations() throws Exception {
    XMLContext context = buildContext( "org/hibernate/test/reflection/java/xml/orm.xml" );
    EJB3OverridenAnnotationReader reader = new EJB3OverridenAnnotationReader( Administration.class, context );
    assertNotNull( reader.getAnnotation( Entity.class ) );
    assertEquals(
        "Default value in xml entity should not override @Entity.name", "JavaAdministration",
        reader.getAnnotation( Entity.class ).name()
View Full Code Here

        "discriminator-column.length broken", 34, reader.getAnnotation( DiscriminatorColumn.class ).length()
    );
  }

  public void testEntityRelatedAnnotationsMetadataComplete() throws Exception {
    XMLContext context = buildContext( "org/hibernate/test/reflection/java/xml/metadata-complete.xml" );
    EJB3OverridenAnnotationReader reader = new EJB3OverridenAnnotationReader( Administration.class, context );
    assertNotNull( reader.getAnnotation( Entity.class ) );
    assertEquals(
        "Metadata complete should ignore java annotations", "", reader.getAnnotation( Entity.class ).name()
    );
View Full Code Here

    assertNull( reader.getAnnotation( SequenceGenerator.class ) );
    assertNull( reader.getAnnotation( TableGenerator.class ) );
  }

  public void testIdRelatedAnnotations() throws Exception {
    XMLContext context = buildContext( "org/hibernate/test/reflection/java/xml/orm.xml" );
    Method method = Administration.class.getDeclaredMethod( "getId" );
    EJB3OverridenAnnotationReader reader = new EJB3OverridenAnnotationReader( method, context );
    assertNull( reader.getAnnotation( Id.class ) );
    assertNull( reader.getAnnotation( Column.class ) );
    Field field = Administration.class.getDeclaredField( "id" );
View Full Code Here

    assertNotNull( reader.getAnnotation( AttributeOverrides.class ) );
    assertEquals( 1, reader.getAnnotation( AttributeOverrides.class ).value().length );
  }

  public void testBasicRelatedAnnotations() throws Exception {
    XMLContext context = buildContext( "org/hibernate/test/reflection/java/xml/metadata-complete.xml" );
    Field field = BusTrip.class.getDeclaredField( "status" );
    EJB3OverridenAnnotationReader reader = new EJB3OverridenAnnotationReader( field, context );
    assertNotNull( reader.getAnnotation( Enumerated.class ) );
    assertEquals( EnumType.STRING, reader.getAnnotation( Enumerated.class ).value() );
    assertEquals( false, reader.getAnnotation( Basic.class ).optional() );
View Full Code Here

    reader = new EJB3OverridenAnnotationReader( field, context );
    assertNotNull( reader.isAnnotationPresent( Basic.class ) );
  }

  public void testVersionRelatedAnnotations() throws Exception {
    XMLContext context = buildContext( "org/hibernate/test/reflection/java/xml/orm.xml" );
    Method method = Administration.class.getDeclaredMethod( "getVersion" );
    EJB3OverridenAnnotationReader reader = new EJB3OverridenAnnotationReader( method, context );
    assertNotNull( reader.getAnnotation( Version.class ) );

    Field field = Match.class.getDeclaredField( "version" );
View Full Code Here

    reader = new EJB3OverridenAnnotationReader( field, context );
    assertNotNull( reader.getAnnotation( Version.class ) );
  }

  public void testTransientAndEmbeddedRelatedAnnotations() throws Exception {
    XMLContext context = buildContext( "org/hibernate/test/reflection/java/xml/orm.xml" );

    Field field = Administration.class.getDeclaredField( "transientField" );
    EJB3OverridenAnnotationReader reader = new EJB3OverridenAnnotationReader( field, context );
    assertNotNull( reader.getAnnotation( Transient.class ) );
    assertNull( reader.getAnnotation( Basic.class ) );
View Full Code Here

    reader = new EJB3OverridenAnnotationReader( field, context );
    assertNotNull( reader.getAnnotation( Embedded.class ) );
  }

  public void testAssociationRelatedAnnotations() throws Exception {
    XMLContext context = buildContext( "org/hibernate/test/reflection/java/xml/orm.xml" );

    Field field = Administration.class.getDeclaredField( "defaultBusTrip" );
    EJB3OverridenAnnotationReader reader = new EJB3OverridenAnnotationReader( field, context );
    assertNotNull( reader.getAnnotation( OneToOne.class ) );
    assertNull( reader.getAnnotation( JoinColumns.class ) );
View Full Code Here

TOP

Related Classes of org.hibernate.reflection.java.xml.XMLContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.