From 7b8b7ead72af8c7394e9dfee7d78b45861aefd7f Mon Sep 17 00:00:00 2001 From: Gunnar Morling Date: Thu, 8 Aug 2013 10:16:02 +0200 Subject: [PATCH] METAGEN-92 Some clean-up (comments, headers, unused imports, typos) --- ...ontextProvidingValidationEventHandler.java | 4 +++- .../JpaNamespaceTransformingEventReader.java | 6 ++--- .../jpamodelgen/util/xml/XmlParserHelper.java | 5 ++--- .../util/xml/XmlParsingException.java | 2 +- .../jpamodelgen/xml/JpaDescriptorParser.java | 8 ++++--- ...nafuTest.java => Jpa21DescriptorTest.java} | 22 +++++++++---------- .../jpamodelgen/test/persistence21/Snafu.java | 2 +- .../test/persistence21/persistence.xml | 2 +- .../jpamodelgen/test/persistence21/snafu.xml | 2 +- 9 files changed, 27 insertions(+), 26 deletions(-) rename tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/persistence21/{SnafuTest.java => Jpa21DescriptorTest.java} (70%) diff --git a/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/util/xml/ContextProvidingValidationEventHandler.java b/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/util/xml/ContextProvidingValidationEventHandler.java index d0a7634338..a080360f13 100644 --- a/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/util/xml/ContextProvidingValidationEventHandler.java +++ b/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/util/xml/ContextProvidingValidationEventHandler.java @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source - * Copyright 2013, Red Hat Middleware LLC, and individual contributors + * Copyright 2013, Red Hat, Inc. and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * @@ -21,6 +21,8 @@ import javax.xml.bind.ValidationEventHandler; import javax.xml.bind.ValidationEventLocator; /** + * Validation event handler used for obtaining line and column numbers in case of parsing failures. + * * @author Hardy Ferentschik */ public class ContextProvidingValidationEventHandler implements ValidationEventHandler { diff --git a/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/util/xml/JpaNamespaceTransformingEventReader.java b/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/util/xml/JpaNamespaceTransformingEventReader.java index 08dd3d319e..b244087807 100644 --- a/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/util/xml/JpaNamespaceTransformingEventReader.java +++ b/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/util/xml/JpaNamespaceTransformingEventReader.java @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source - * Copyright 2013, Red Hat Middleware LLC, and individual contributors + * Copyright 2013, Red Hat, Inc. and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * @@ -117,7 +117,7 @@ public class JpaNamespaceTransformingEventReader extends EventReaderDelegate { private List updateElementNamespaces(StartElement startElement) { List newNamespaceList = new ArrayList(); - Iterator existingNamespaceIterator = startElement.getNamespaces(); + Iterator existingNamespaceIterator = startElement.getNamespaces(); while ( existingNamespaceIterator.hasNext() ) { Namespace namespace = (Namespace) existingNamespaceIterator.next(); if ( NAMESPACE_MAPPING.containsKey( namespace.getNamespaceURI() ) ) { @@ -139,7 +139,7 @@ public class JpaNamespaceTransformingEventReader extends EventReaderDelegate { private List updateElementAttributes(StartElement startElement) { // adjust the version attribute List newElementAttributeList = new ArrayList(); - Iterator existingAttributesIterator = startElement.getAttributes(); + Iterator existingAttributesIterator = startElement.getAttributes(); while ( existingAttributesIterator.hasNext() ) { Attribute attribute = (Attribute) existingAttributesIterator.next(); if ( VERSION_ATTRIBUTE_NAME.equals( attribute.getName().getLocalPart() ) ) { diff --git a/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/util/xml/XmlParserHelper.java b/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/util/xml/XmlParserHelper.java index 2c25ac2392..99496c81e7 100644 --- a/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/util/xml/XmlParserHelper.java +++ b/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/util/xml/XmlParserHelper.java @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source - * Copyright 2013, Red Hat Middleware LLC, and individual contributors + * Copyright 2013, Red Hat, Inc. and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * @@ -38,8 +38,7 @@ import org.hibernate.jpamodelgen.xml.jaxb.ObjectFactory; import org.xml.sax.SAXException; /** - * Provides common functionality used within the different XML descriptor - * parsers. + * Provides common functionality used for XML parsing. * * @author Gunnar Morling * @author Hardy Ferentschik diff --git a/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/util/xml/XmlParsingException.java b/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/util/xml/XmlParsingException.java index 29078051f9..a509ab39e0 100644 --- a/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/util/xml/XmlParsingException.java +++ b/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/util/xml/XmlParsingException.java @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source - * Copyright 2013, Red Hat Middleware LLC, and individual contributors + * Copyright 2013, Red Hat, Inc. and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * diff --git a/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/xml/JpaDescriptorParser.java b/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/xml/JpaDescriptorParser.java index c3d4bb41da..5617febbc1 100644 --- a/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/xml/JpaDescriptorParser.java +++ b/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/xml/JpaDescriptorParser.java @@ -49,6 +49,8 @@ import org.hibernate.jpamodelgen.xml.jaxb.PersistenceUnitDefaults; import org.hibernate.jpamodelgen.xml.jaxb.PersistenceUnitMetadata; /** + * Parser for JPA XML descriptors (persistence.xml and referenced mapping files). + * * @author Hardy Ferentschik */ public class JpaDescriptorParser { @@ -234,7 +236,7 @@ public class JpaDescriptorParser { if ( !xmlMappedTypeExists( fqcn ) ) { context.logMessage( Diagnostic.Kind.WARNING, - fqcn + " is mapped in xml, but class does not exists. Skipping meta model generation." + fqcn + " is mapped in xml, but class does not exist. Skipping meta model generation." ); continue; } @@ -261,7 +263,7 @@ public class JpaDescriptorParser { if ( !xmlMappedTypeExists( fqcn ) ) { context.logMessage( Diagnostic.Kind.WARNING, - fqcn + " is mapped in xml, but class does not exists. Skipping meta model generation." + fqcn + " is mapped in xml, but class does not exist. Skipping meta model generation." ); continue; } @@ -288,7 +290,7 @@ public class JpaDescriptorParser { if ( !xmlMappedTypeExists( fqcn ) ) { context.logMessage( Diagnostic.Kind.WARNING, - fqcn + " is mapped in xml, but class does not exists. Skipping meta model generation." + fqcn + " is mapped in xml, but class does not exist. Skipping meta model generation." ); continue; } diff --git a/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/persistence21/SnafuTest.java b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/persistence21/Jpa21DescriptorTest.java similarity index 70% rename from tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/persistence21/SnafuTest.java rename to tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/persistence21/Jpa21DescriptorTest.java index 1e684b7617..0badb735a0 100644 --- a/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/persistence21/SnafuTest.java +++ b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/persistence21/Jpa21DescriptorTest.java @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source - * Copyright 2010, Red Hat Middleware LLC, and individual contributors + * Copyright 2013, Red Hat, Inc. and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * @@ -21,30 +21,28 @@ import java.util.Map; import org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor; import org.hibernate.jpamodelgen.test.util.CompilationTest; +import org.hibernate.jpamodelgen.test.util.TestForIssue; import org.hibernate.jpamodelgen.test.util.TestUtil; -import org.hibernate.jpamodelgen.test.xmlonly.Car; -import org.hibernate.jpamodelgen.test.xmlonly.Course; -import org.hibernate.jpamodelgen.test.xmlonly.Option; -import org.hibernate.jpamodelgen.test.xmlonly.Period; -import org.hibernate.jpamodelgen.test.xmlonly.Teacher; -import org.hibernate.jpamodelgen.test.xmlonly.Tire; import org.testng.annotations.Test; import static org.hibernate.jpamodelgen.test.util.TestUtil.assertMetamodelClassGeneratedFor; -import static org.hibernate.jpamodelgen.test.util.TestUtil.assertPresenceOfFieldInMetamodelFor; /** + * Test for parsing JPA 2.1 descriptors. + * * @author Hardy Ferentschik */ -public class SnafuTest extends CompilationTest { +public class Jpa21DescriptorTest extends CompilationTest { + @Test + @TestForIssue( jiraKey = "METAGEN-92" ) public void testMetaModelGeneratedForXmlConfiguredEntity() { assertMetamodelClassGeneratedFor( Snafu.class ); } @Override protected String getPackageNameOfCurrentTest() { - return SnafuTest.class.getPackage().getName(); + return Jpa21DescriptorTest.class.getPackage().getName(); } @Override @@ -52,8 +50,8 @@ public class SnafuTest extends CompilationTest { Map properties = new HashMap(); properties.put( JPAMetaModelEntityProcessor.PERSISTENCE_XML_OPTION, - TestUtil.fcnToPath( SnafuTest.class.getPackage().getName() ) + "/persistence.xml" + TestUtil.fcnToPath( Jpa21DescriptorTest.class.getPackage().getName() ) + "/persistence.xml" ); return properties; } -} \ No newline at end of file +} diff --git a/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/persistence21/Snafu.java b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/persistence21/Snafu.java index 89adc7fd09..49292c0faa 100644 --- a/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/persistence21/Snafu.java +++ b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/persistence21/Snafu.java @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source - * Copyright 2010, Red Hat Middleware LLC, and individual contributors + * Copyright 2013, Red Hat, Inc. and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * diff --git a/tooling/metamodel-generator/src/test/resources/org/hibernate/jpamodelgen/test/persistence21/persistence.xml b/tooling/metamodel-generator/src/test/resources/org/hibernate/jpamodelgen/test/persistence21/persistence.xml index 32f855668d..d8a2fe3929 100644 --- a/tooling/metamodel-generator/src/test/resources/org/hibernate/jpamodelgen/test/persistence21/persistence.xml +++ b/tooling/metamodel-generator/src/test/resources/org/hibernate/jpamodelgen/test/persistence21/persistence.xml @@ -1,7 +1,7 @@