METAGEN-101 Adding checkstyle plugin and making some style fixes (not 100% Hibernate ORM compatible yet)

This commit is contained in:
Hardy Ferentschik 2013-10-22 15:55:07 +02:00 committed by Strong Liu
parent 0c6b601006
commit fdbfbd03ec
109 changed files with 376 additions and 155 deletions

View File

@ -4,6 +4,7 @@ apply plugin: 'maven'
apply plugin: 'maven-publish' apply plugin: 'maven-publish'
apply plugin: 'maven-publish-auth' apply plugin: 'maven-publish-auth'
apply plugin: 'jdocbook' apply plugin: 'jdocbook'
apply plugin: 'checkstyle'
task wrapper(type: Wrapper) { task wrapper(type: Wrapper) {
gradleVersion = '1.7' gradleVersion = '1.7'
@ -158,6 +159,13 @@ test {
} }
} }
checkstyle {
configFile = rootProject.file( 'src/config/checkstyle/checkstyle.xml' )
showViolations = true
ignoreFailures = true
}
checkstyleMain.exclude '**/jaxb/**'
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Javadocs // Javadocs
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -173,7 +181,7 @@ task javadocs(type: Javadoc) {
classpath = files( configurations.compile, "${buildDir}/classes/main" ) classpath = files( configurations.compile, "${buildDir}/classes/main" )
maxMemory = '512m' maxMemory = '512m'
configure( options ) { configure( options ) {
stylesheetFile = rootProject.file( 'src/main/javadoc/stylesheet.css' ) stylesheetFile = rootProject.file( 'src/config/javadoc/stylesheet.css' )
windowTitle = 'Hibernate JPA 2 Metamodel Generator JavaDocs' windowTitle = 'Hibernate JPA 2 Metamodel Generator JavaDocs'
docTitle = "Hibernate JPA 2 Metamodel Generator JavaDocs ($project.version)" docTitle = "Hibernate JPA 2 Metamodel Generator JavaDocs ($project.version)"
bottom = "Copyright &copy; 2001-$copyrightYear <a href=\"http://redhat.com\">Red Hat, Inc.</a> All Rights Reserved." bottom = "Copyright &copy; 2001-$copyrightYear <a href=\"http://redhat.com\">Red Hat, Inc.</a> All Rights Reserved."
@ -183,7 +191,7 @@ task javadocs(type: Javadoc) {
doLast { doLast {
copy { copy {
from rootProject.file( 'src/main/javadoc/images' ) from rootProject.file( 'src/config/javadoc/images' )
into new File( javadocDir, "/images" ) into new File( javadocDir, "/images" )
} }
} }
@ -298,11 +306,6 @@ publishing {
} }
} }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Artifact deploy
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
task sourcesJar(type: Jar, dependsOn: compileJava) { task sourcesJar(type: Jar, dependsOn: compileJava) {
from sourceSets.main.allSource from sourceSets.main.allSource
classifier = 'sources' classifier = 'sources'
@ -312,7 +315,10 @@ artifacts {
archives sourcesJar archives sourcesJar
} }
uploadArchives.dependsOn sourcesJar //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Release
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@ -0,0 +1,194 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Hibernate, Relational Persistence for Idiomatic Java
~
~ Copyright (c) 2013, Red Hat Inc. or third-party contributors as
~ indicated by the @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
-->
<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.1//EN" "http://www.puppycrawl.com/dtds/configuration_1_2.dtd">
<module name="Checker">
<module name="TreeWalker">
<!--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
General regex checks as part of the TreeWalker
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-->
<module name="RegexpSinglelineJava">
<property name="ignoreComments" value="true" />
<property name="format" value="^\t* +\t*\S" />
<property name="message" value="Line has leading space characters; indentation should be performed with tabs only." />
</module>
<!--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Annotation checks
See http://checkstyle.sourceforge.net/config_annotation.html
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-->
<module name="MissingDeprecated" />
<module name="MissingOverride" />
<module name="PackageAnnotation" />
<!--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Block checks
See http://checkstyle.sourceforge.net/config_blocks.html
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-->
<module name="AvoidNestedBlocks">
<property name="allowInSwitchCase" value="true" />
<property name="severity" value="warning" />
</module>
<module name="NeedBraces" />
<module name="LeftCurly">
<property name="option" value="eol" />
</module>
<module name="RightCurly">
<property name="option" value="alone" />
</module>
<!--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Design checks
See http://checkstyle.sourceforge.net/config_design.html
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-->
<module name="HideUtilityClassConstructor" />
<module name="MutableException" />
<!--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Coding checks
See http://checkstyle.sourceforge.net/config_coding.html
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-->
<module name="EmptyStatement" />
<module name="EqualsHashCode" />
<module name="MissingSwitchDefault" />
<module name="SimplifyBooleanExpression" />
<module name="SimplifyBooleanReturn" />
<module name="StringLiteralEquality" />
<module name="NoFinalizer" />
<module name="ExplicitInitialization" />
<module name="MissingSwitchDefault" />
<module name="DefaultComesLast" />
<module name="FallThrough" />
<module name="OneStatementPerLine" />
<!--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Import checks
See http://checkstyle.sourceforge.net/config_imports.html
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-->
<module name="AvoidStarImport" />
<module name="RedundantImport" />
<module name="UnusedImports" />
<!--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Misc checks
See http://checkstyle.sourceforge.net/config_misc.html
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-->
<module name="UpperEll" />
<module name="ArrayTypeStyle" />
<module name="TrailingComment">
<property name="severity" value="warning" />
</module>
<!--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Modifier checks
See http://checkstyle.sourceforge.net/config_modifier.html
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-->
<module name="ModifierOrder"/>
<!--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Naming checks
See http://checkstyle.sourceforge.net/config_naming.html
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-->
<module name="AbstractClassName">
<!-- we are just using this to make sure that classes matching the pattern (Abstract*) have the abstract modifier -->
<property name="format" value="^Abstract.*$" />
<property name="ignoreName" value="true" />
</module>
<module name="ConstantName">
<property name="format" value="^[A-Z](_?[A-Z0-9]+)*$|log" />
</module>
<module name="LocalFinalVariableName" />
<module name="LocalVariableName" />
<module name="MemberName" />
<!--
The org.hibernate.engine.spi.ManagedEntity method names (prefixed with '&&_') muck with this
<module name="MethodName" />
-->
<module name="MethodTypeParameterName" />
<module name="PackageName" />
<module name="ParameterName" />
<module name="StaticVariableName" />
<module name="TypeName" />
<!--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Whitespace checks
See http://checkstyle.sourceforge.net/config_whitespace.html
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-->
<module name="MethodParamPad" />
<module name="TypecastParenPad" />
<module name="ParenPad">
<property name="tokens" value="CTOR_CALL, METHOD_CALL, SUPER_CTOR_CALL" />
<property name="option" value="space" />
</module>
</module>
<!--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Misc checks
See http://checkstyle.sourceforge.net/config_misc.html
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-->
<module name="NewlineAtEndOfFile" />
</module>

View File

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

Before

Width:  |  Height:  |  Size: 270 B

After

Width:  |  Height:  |  Size: 270 B

View File

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View File

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

Before

Width:  |  Height:  |  Size: 7.0 KiB

After

Width:  |  Height:  |  Size: 7.0 KiB

View File

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@ -64,7 +64,7 @@ public final class Context {
* Whether all mapping files are xml-mapping-metadata-complete. In this case no annotation processing will take * Whether all mapping files are xml-mapping-metadata-complete. In this case no annotation processing will take
* place. * place.
*/ */
private Boolean fullyXmlConfigured = null; private Boolean fullyXmlConfigured;
private boolean addGeneratedAnnotation = true; private boolean addGeneratedAnnotation = true;
private boolean addGenerationDate; private boolean addGenerationDate;
private boolean addSuppressWarningsAnnotation; private boolean addSuppressWarningsAnnotation;

View File

@ -37,7 +37,7 @@ public class ImportContextImpl implements ImportContext {
private String basePackage = ""; private String basePackage = "";
private static String LINE_SEPARATOR = System.getProperty( "line.separator" ); private static final String LINE_SEPARATOR = System.getProperty( "line.separator" );
private static final Map<String, String> PRIMITIVES = new HashMap<String, String>(); private static final Map<String, String> PRIMITIVES = new HashMap<String, String>();
static { static {
@ -110,7 +110,7 @@ public class ImportContextImpl implements ImportContext {
if ( inSamePackage( fqcn ) || ( imports.contains( pureFqcn ) && canBeSimple ) ) { if ( inSamePackage( fqcn ) || ( imports.contains( pureFqcn ) && canBeSimple ) ) {
result = unqualify( result ); // de-qualify result = unqualify( result );
} }
else if ( inJavaLang( fqcn ) ) { else if ( inJavaLang( fqcn ) ) {
result = result.substring( "java.lang.".length() ); result = result.substring( "java.lang.".length() );

View File

@ -80,7 +80,7 @@ public abstract class AnnotationMetaAttribute implements MetaAttribute {
return parent; return parent;
} }
abstract public String getMetaType(); public abstract String getMetaType();
public String getTypeDeclaration() { public String getTypeDeclaration() {
return type; return type;

View File

@ -34,7 +34,10 @@ public class AnnotationMetaMap extends AnnotationMetaCollection {
} }
public String getDeclarationString() { public String getDeclarationString() {
return "public static volatile " + getHostingEntity().importType( getMetaType() ) + "<" + getHostingEntity().importType( getHostingEntity().getQualifiedName() ) + ", " + getHostingEntity() return "public static volatile " + getHostingEntity().importType( getMetaType() )
.importType( keyType ) + ", " + getHostingEntity().importType( getTypeDeclaration() ) + "> " + getPropertyName() + ";"; + "<" + getHostingEntity().importType( getHostingEntity().getQualifiedName() )
+ ", " + getHostingEntity().importType( keyType ) + ", "
+ getHostingEntity().importType( getTypeDeclaration() ) + "> "
+ getPropertyName() + ";";
} }
} }

View File

@ -41,7 +41,7 @@ public final class Constants {
public static final String ELEMENT_COLLECTION = "javax.persistence.ElementCollection"; public static final String ELEMENT_COLLECTION = "javax.persistence.ElementCollection";
public static final String ACCESS = "javax.persistence.Access"; public static final String ACCESS = "javax.persistence.Access";
public static Map<String, String> COLLECTIONS = new HashMap<String, String>(); public static final Map<String, String> COLLECTIONS = new HashMap<String, String>();
static { static {
COLLECTIONS.put( java.util.Collection.class.getName(), "javax.persistence.metamodel.CollectionAttribute" ); COLLECTIONS.put( java.util.Collection.class.getName(), "javax.persistence.metamodel.CollectionAttribute" );
@ -54,7 +54,7 @@ public final class Constants {
COLLECTIONS.put( java.util.SortedMap.class.getName(), "javax.persistence.metamodel.MapAttribute" ); COLLECTIONS.put( java.util.SortedMap.class.getName(), "javax.persistence.metamodel.MapAttribute" );
} }
public static List<String> BASIC_TYPES = new ArrayList<String>(); public static final List<String> BASIC_TYPES = new ArrayList<String>();
static { static {
BASIC_TYPES.add( java.lang.String.class.getName() ); BASIC_TYPES.add( java.lang.String.class.getName() );
@ -76,7 +76,7 @@ public final class Constants {
BASIC_TYPES.add( java.sql.Blob.class.getName() ); BASIC_TYPES.add( java.sql.Blob.class.getName() );
} }
public static List<String> BASIC_ARRAY_TYPES = new ArrayList<String>(); public static final List<String> BASIC_ARRAY_TYPES = new ArrayList<String>();
static { static {
BASIC_ARRAY_TYPES.add( java.lang.Character.class.getName() ); BASIC_ARRAY_TYPES.add( java.lang.Character.class.getName() );

View File

@ -55,9 +55,9 @@ public class XmlParserHelper {
*/ */
private static final int NUMBER_OF_SCHEMAS = 4; private static final int NUMBER_OF_SCHEMAS = 4;
private static final XMLInputFactory xmlInputFactory = XMLInputFactory.newInstance(); private static final XMLInputFactory XML_INPUT_FACTORY = XMLInputFactory.newInstance();
private static final ConcurrentMap<String, Schema> schemaCache = new ConcurrentHashMap<String, Schema>( private static final ConcurrentMap<String, Schema> SCHEMA_CACHE = new ConcurrentHashMap<String, Schema>(
NUMBER_OF_SCHEMAS NUMBER_OF_SCHEMAS
); );
@ -102,14 +102,14 @@ public class XmlParserHelper {
} }
public Schema getSchema(String schemaResource) throws XmlParsingException { public Schema getSchema(String schemaResource) throws XmlParsingException {
Schema schema = schemaCache.get( schemaResource ); Schema schema = SCHEMA_CACHE.get( schemaResource );
if ( schema != null ) { if ( schema != null ) {
return schema; return schema;
} }
schema = loadSchema( schemaResource ); schema = loadSchema( schemaResource );
Schema previous = schemaCache.putIfAbsent( schemaResource, schema ); Schema previous = SCHEMA_CACHE.putIfAbsent( schemaResource, schema );
return previous != null ? previous : schema; return previous != null ? previous : schema;
} }
@ -147,7 +147,7 @@ public class XmlParserHelper {
} }
private synchronized XMLEventReader createXmlEventReader(InputStream xmlStream) throws XMLStreamException { private synchronized XMLEventReader createXmlEventReader(InputStream xmlStream) throws XMLStreamException {
return xmlInputFactory.createXMLEventReader( xmlStream ); return XML_INPUT_FACTORY.createXMLEventReader( xmlStream );
} }
private String getPackage(String resourceName) { private String getPackage(String resourceName) {

View File

@ -450,6 +450,8 @@ public class JpaDescriptorParser {
case PROPERTY: { case PROPERTY: {
return AccessType.PROPERTY; return AccessType.PROPERTY;
} }
default: {
}
} }
return null; return null;
} }

View File

@ -55,7 +55,7 @@ public abstract class XmlMetaAttribute implements MetaAttribute {
} }
@Override @Override
abstract public String getMetaType(); public abstract String getMetaType();
@Override @Override
public String toString() { public String toString() {

View File

@ -61,7 +61,7 @@ import org.hibernate.jpamodelgen.xml.jaxb.OneToOne;
*/ */
public class XmlMetaEntity implements MetaEntity { public class XmlMetaEntity implements MetaEntity {
static Map<String, String> COLLECTIONS = new HashMap<String, String>(); static final Map<String, String> COLLECTIONS = new HashMap<String, String>();
static { static {
COLLECTIONS.put( "java.util.Collection", "javax.persistence.metamodel.CollectionAttribute" ); COLLECTIONS.put( "java.util.Collection", "javax.persistence.metamodel.CollectionAttribute" );
@ -354,6 +354,8 @@ public class XmlMetaEntity implements MetaEntity {
case TYPEVAR: { case TYPEVAR: {
return mirror.toString(); return mirror.toString();
} }
default: {
}
} }
} }

View File

@ -23,8 +23,6 @@ import javax.persistence.Id;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
import javax.persistence.OneToMany; import javax.persistence.OneToMany;
import org.hibernate.jpamodelgen.test.accesstype.Product;
/** /**
* *
* @author Max Andersen * @author Max Andersen
@ -34,49 +32,49 @@ import org.hibernate.jpamodelgen.test.accesstype.Product;
@Entity @Entity
public class Item { public class Item {
long _id; long id;
int _quantity; int quantity;
Product _product; Product product;
Order _order; Order order;
Detail detail; Detail detail;
@Id @Id
public long getId() { public long getId() {
return _id; return id;
} }
public void setId(long id) { public void setId(long id) {
this._id = id; this.id = id;
} }
public int getQuantity() { public int getQuantity() {
return _quantity; return quantity;
} }
public void setQuantity(int quantity) { public void setQuantity(int quantity) {
this._quantity = quantity; this.quantity = quantity;
} }
@ManyToOne @ManyToOne
public Product getProduct() { public Product getProduct() {
return _product; return product;
} }
public void setProduct(Product product) { public void setProduct(Product product) {
this._product = product; this.product = product;
} }
@ManyToOne @ManyToOne
public Order getOrder() { public Order getOrder() {
return _order; return order;
} }
public void setOrder(Order order) { public void setOrder(Order order) {
this._order = order; this.order = order;
} }
@OneToMany @OneToMany

View File

@ -18,17 +18,12 @@ package org.hibernate.jpamodelgen.test.accesstype;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Set; import java.util.Set;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
import javax.persistence.OneToMany; import javax.persistence.OneToMany;
import org.hibernate.jpamodelgen.test.accesstype.Item;
import org.hibernate.jpamodelgen.test.accesstype.Shop;
/** /**
*
* @author Max Andersen * @author Max Andersen
* @author Hardy Ferentschik * @author Hardy Ferentschik
* @author Emmanuel Bernard * @author Emmanuel Bernard

View File

@ -20,7 +20,6 @@ import javax.persistence.Entity;
import javax.persistence.Id; import javax.persistence.Id;
/** /**
*
* @author Max Andersen * @author Max Andersen
* @author Hardy Ferentschik * @author Hardy Ferentschik
* @author Emmanuel Bernard * @author Emmanuel Bernard
@ -32,3 +31,4 @@ public class Shop {
String name; String name;
} }

View File

@ -5,7 +5,7 @@ import java.io.Serializable;
/** /**
* @author Hardy Ferentschik * @author Hardy Ferentschik
*/ */
public class AbstractRef implements Serializable { public abstract class AbstractRef implements Serializable {
private final int id; private final int id;
protected AbstractRef() { protected AbstractRef() {

View File

@ -19,11 +19,10 @@ package org.hibernate.jpamodelgen.test.generatedannotation;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.testng.annotations.Test;
import org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor; import org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor;
import org.hibernate.jpamodelgen.test.util.CompilationTest; import org.hibernate.jpamodelgen.test.util.CompilationTest;
import org.hibernate.jpamodelgen.test.util.TestForIssue; import org.hibernate.jpamodelgen.test.util.TestForIssue;
import org.testng.annotations.Test;
import static org.hibernate.jpamodelgen.test.util.TestUtil.assertMetamodelClassGeneratedFor; import static org.hibernate.jpamodelgen.test.util.TestUtil.assertMetamodelClassGeneratedFor;
import static org.hibernate.jpamodelgen.test.util.TestUtil.getMetaModelSourceAsString; import static org.hibernate.jpamodelgen.test.util.TestUtil.getMetaModelSourceAsString;

View File

@ -16,10 +16,9 @@
*/ */
package org.hibernate.jpamodelgen.test.hashcode; package org.hibernate.jpamodelgen.test.hashcode;
import org.testng.annotations.Test;
import org.hibernate.jpamodelgen.test.util.CompilationTest; import org.hibernate.jpamodelgen.test.util.CompilationTest;
import org.hibernate.jpamodelgen.test.util.TestForIssue; import org.hibernate.jpamodelgen.test.util.TestForIssue;
import org.testng.annotations.Test;
import static org.hibernate.jpamodelgen.test.util.TestUtil.assertAbsenceOfFieldInMetamodelFor; import static org.hibernate.jpamodelgen.test.util.TestUtil.assertAbsenceOfFieldInMetamodelFor;
import static org.hibernate.jpamodelgen.test.util.TestUtil.assertMetamodelClassGeneratedFor; import static org.hibernate.jpamodelgen.test.util.TestUtil.assertMetamodelClassGeneratedFor;

View File

@ -59,3 +59,4 @@ public class InheritanceTest extends CompilationTest {
return InheritanceTest.class.getPackage().getName(); return InheritanceTest.class.getPackage().getName();
} }
} }

View File

@ -25,7 +25,7 @@ import javax.persistence.MappedSuperclass;
@Embeddable @Embeddable
@MappedSuperclass @MappedSuperclass
public class EmbeddableAndMappedSuperClass { public class EmbeddableAndMappedSuperClass {
} }

View File

@ -39,3 +39,4 @@ public class Car extends Vehicle {
} }

View File

@ -67,3 +67,4 @@ public class EmployeeWithRawType implements java.io.Serializable {
this.desks = desks; this.desks = desks;
} }
} }

View File

@ -49,8 +49,8 @@ public abstract class CompilationTest {
private static final String ANNOTATION_PROCESSOR_OPTION_PREFIX = "-A"; private static final String ANNOTATION_PROCESSOR_OPTION_PREFIX = "-A";
private static final String SOURCE_BASE_DIR_PROPERTY = "sourceBaseDir"; private static final String SOURCE_BASE_DIR_PROPERTY = "sourceBaseDir";
private static final String OUT_BASE_DIR_PROPERTY = "outBaseDir"; private static final String OUT_BASE_DIR_PROPERTY = "outBaseDir";
private static final String sourceBaseDir; private static final String SOURCE_BASE_DIR;
private static final String outBaseDir; private static final String OUT_BASE_DIR;
public static final String DIRECTORY_SEPARATOR = File.separator; public static final String DIRECTORY_SEPARATOR = File.separator;
@ -61,13 +61,13 @@ public abstract class CompilationTest {
if ( tmp == null ) { if ( tmp == null ) {
fail( "The system property sourceBaseDir has to be set and point to the base directory of the test java sources." ); fail( "The system property sourceBaseDir has to be set and point to the base directory of the test java sources." );
} }
sourceBaseDir = tmp; SOURCE_BASE_DIR = tmp;
tmp = System.getProperty( OUT_BASE_DIR_PROPERTY ); tmp = System.getProperty( OUT_BASE_DIR_PROPERTY );
if ( tmp == null ) { if ( tmp == null ) {
fail( "The system property outBaseDir has to be set and point to the base directory of the test output directory." ); fail( "The system property outBaseDir has to be set and point to the base directory of the test output directory." );
} }
outBaseDir = tmp; OUT_BASE_DIR = tmp;
} }
public CompilationTest() { public CompilationTest() {
@ -79,14 +79,14 @@ public abstract class CompilationTest {
} }
public static String getSourceBaseDir() { public static String getSourceBaseDir() {
return sourceBaseDir; return SOURCE_BASE_DIR;
} }
@BeforeClass @BeforeClass
protected void compileAllTestEntities() throws Exception { protected void compileAllTestEntities() throws Exception {
List<File> sourceFiles = getCompilationUnits( sourceBaseDir, getPackageNameOfCurrentTest() ); List<File> sourceFiles = getCompilationUnits( SOURCE_BASE_DIR, getPackageNameOfCurrentTest() );
// make sure there are no relics from previous runs // make sure there are no relics from previous runs
TestUtil.deleteGeneratedSourceFiles( new File( outBaseDir ) ); TestUtil.deleteGeneratedSourceFiles( new File( OUT_BASE_DIR ) );
compile( sourceFiles ); compile( sourceFiles );
} }
@ -134,7 +134,7 @@ public abstract class CompilationTest {
return javaFiles; return javaFiles;
} }
abstract protected String getPackageNameOfCurrentTest(); protected abstract String getPackageNameOfCurrentTest();
protected Map<String, String> getProcessorOptions() { protected Map<String, String> getProcessorOptions() {
return Collections.emptyMap(); return Collections.emptyMap();
@ -157,7 +157,7 @@ public abstract class CompilationTest {
private List<String> createJavaOptions() { private List<String> createJavaOptions() {
List<String> options = new ArrayList<String>(); List<String> options = new ArrayList<String>();
options.add( "-d" ); options.add( "-d" );
options.add( outBaseDir ); options.add( OUT_BASE_DIR );
// pass orm files if specified // pass orm files if specified
if ( !getOrmFiles().isEmpty() ) { if ( !getOrmFiles().isEmpty() ) {

View File

@ -46,14 +46,14 @@ public class TestUtil {
private static final String PATH_SEPARATOR = System.getProperty( "file.separator" ); private static final String PATH_SEPARATOR = System.getProperty( "file.separator" );
private static final String PACKAGE_SEPARATOR = "."; private static final String PACKAGE_SEPARATOR = ".";
private static final String META_MODEL_CLASS_POSTFIX = "_"; private static final String META_MODEL_CLASS_POSTFIX = "_";
private static final String outBaseDir; private static final String OUT_BASE_DIR;
static { static {
String tmp = System.getProperty( "outBaseDir" ); String tmp = System.getProperty( "outBaseDir" );
if ( tmp == null ) { if ( tmp == null ) {
fail( "The system property outBaseDir has to be set and point to the base directory of the test output directory." ); fail( "The system property outBaseDir has to be set and point to the base directory of the test output directory." );
} }
outBaseDir = tmp; OUT_BASE_DIR = tmp;
} }
private TestUtil() { private TestUtil() {
@ -112,7 +112,7 @@ public class TestUtil {
// generate the file name // generate the file name
String fileName = metaModelClassName.replace( PACKAGE_SEPARATOR, PATH_SEPARATOR ); String fileName = metaModelClassName.replace( PACKAGE_SEPARATOR, PATH_SEPARATOR );
fileName = fileName.concat( ".java" ); fileName = fileName.concat( ".java" );
return new File( outBaseDir + PATH_SEPARATOR + fileName ); return new File( OUT_BASE_DIR + PATH_SEPARATOR + fileName );
} }
public static String getMetaModelSourceAsString(Class<?> clazz) { public static String getMetaModelSourceAsString(Class<?> clazz) {
@ -122,7 +122,7 @@ public class TestUtil {
try { try {
BufferedReader input = new BufferedReader( new FileReader( sourceFile ) ); BufferedReader input = new BufferedReader( new FileReader( sourceFile ) );
try { try {
String line = null; //not declared within while loop String line = null;
/* /*
* readLine is a bit quirky : * readLine is a bit quirky :
* it returns the content of a line MINUS the newline. * it returns the content of a line MINUS the newline.
@ -281,7 +281,7 @@ public class TestUtil {
} }
else { else {
fail( "Unexpected component type" ); fail( "Unexpected component type" );
return null; // making the compiler happy return null;
} }
} }

View File

@ -30,3 +30,4 @@ public abstract class BusinessEntity<T extends Serializable> implements Serializ
} }

View File

@ -16,8 +16,8 @@
*/ */
package org.hibernate.jpamodelgen.test.xmlmapped; package org.hibernate.jpamodelgen.test.xmlmapped;
import org.hibernate.jpamodelgen.test.accesstype.*;
import org.hibernate.jpamodelgen.test.accesstype.Address; import org.hibernate.jpamodelgen.test.accesstype.Address;
import org.hibernate.jpamodelgen.test.accesstype.Area;
/** /**
* @author Hardy Ferentschik * @author Hardy Ferentschik

View File

@ -30,7 +30,8 @@ import static org.hibernate.jpamodelgen.test.util.TestUtil.assertMetamodelClassG
/** /**
* @author Hardy Ferentschik * @author Hardy Ferentschik
*/ */
public class IgnoreInvalidXmlTest extends CompilationTest { public class
IgnoreInvalidXmlTest extends CompilationTest {
@Test @Test
public void testInvalidXmlFilesGetIgnored() { public void testInvalidXmlFilesGetIgnored() {
// this is only a indirect test, but if the invalid xml files would cause the processor to abort the // this is only a indirect test, but if the invalid xml files would cause the processor to abort the

View File

@ -35,3 +35,4 @@ public class Dummy {
this.id = id; this.id = id;
} }
} }

View File

@ -57,3 +57,4 @@ public class XmlMetaDataCompleteMultiplePersistenceUnitsTest extends Compilation
return properties; return properties;
} }
} }

View File

@ -35,3 +35,4 @@ public class Dummy {
this.id = id; this.id = id;
} }
} }

View File

@ -33,3 +33,4 @@ public class Car {
public void setTires(Set<Tire> tires) { public void setTires(Set<Tire> tires) {
} }
} }

View File

@ -20,3 +20,4 @@ public class Option {
private Long id; private Long id;
private Period period; private Period period;
} }

View File

@ -22,3 +22,4 @@ public class Period {
private Date start; private Date start;
private Date end; private Date end;
} }

View File

@ -22,3 +22,4 @@ public class Teacher {
private Long id; private Long id;
private Set<Course> qualifiedFor; private Set<Course> qualifiedFor;
} }

View File

@ -31,3 +31,4 @@ public class Tire {
public void setCar(Car car) { public void setCar(Car car) {
} }
} }