diff --git a/tooling/metamodel-generator/pom.xml b/tooling/metamodel-generator/pom.xml
index 11cc4955a8..25b0f42428 100644
--- a/tooling/metamodel-generator/pom.xml
+++ b/tooling/metamodel-generator/pom.xml
@@ -46,7 +46,7 @@
Emmanuel Bernard
emmanuel@hibernate.org
http://in.relation.to/Bloggers/Emmanuel
-
+
hardy.ferentschik
Hardy Ferentschik
@@ -85,36 +85,6 @@
-proc:none
-
- org.apache.maven.plugins
- maven-antrun-plugin
-
-
- process_annotations
- process-test-resources
-
-
-
-
-
-
-
-
-
-
-
-
- ${project.build.directory}/generated-src/jpamodelgen
-
-
- run
-
-
-
-
org.codehaus.mojo
jaxb2-maven-plugin
@@ -149,6 +119,16 @@
org.apache.maven.plugins
maven-surefire-plugin
+
+
+ sourceBaseDir
+ ${basedir}/src/test/java
+
+
+ outBaseDir
+ ${basedir}/target/test-classes
+
+
${basedir}/src/test/suite/unit-tests.xml
@@ -215,7 +195,7 @@
-
+
org.apache.maven.plugins
maven-release-plugin
diff --git a/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/ClassWriter.java b/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/ClassWriter.java
index 29552db433..5587fafefe 100644
--- a/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/ClassWriter.java
+++ b/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/ClassWriter.java
@@ -24,7 +24,6 @@ import java.io.StringWriter;
import java.util.List;
import javax.annotation.processing.ProcessingEnvironment;
import javax.annotation.processing.FilerException;
-import javax.annotation.Generated;
import javax.tools.FileObject;
import javax.tools.Diagnostic;
import javax.lang.model.type.TypeMirror;
@@ -38,7 +37,7 @@ import javax.lang.model.element.TypeElement;
*/
public class ClassWriter {
- public static void writeFile(IMetaEntity entity, ProcessingEnvironment processingEnv, Context context) {
+ public static void writeFile(MetaEntity entity, ProcessingEnvironment processingEnv, Context context) {
try {
String metaModelPackage = entity.getPackageName();
@@ -85,7 +84,7 @@ public class ClassWriter {
*
* @return body content
*/
- private static StringBuffer generateBody(IMetaEntity entity, Context context) {
+ private static StringBuffer generateBody(MetaEntity entity, Context context) {
StringWriter sw = new StringWriter();
PrintWriter pw = null;
@@ -103,9 +102,9 @@ public class ClassWriter {
pw.println();
- List members = entity.getMembers();
+ List members = entity.getMembers();
- for ( IMetaAttribute metaMember : members ) {
+ for ( MetaAttribute metaMember : members ) {
pw.println( " " + metaMember.getDeclarationString() );
}
pw.println();
@@ -119,7 +118,7 @@ public class ClassWriter {
}
}
- private static void printClassDeclaration(IMetaEntity entity, PrintWriter pw, Context context) {
+ private static void printClassDeclaration(MetaEntity entity, PrintWriter pw, Context context) {
pw.print( "public abstract class " + entity.getSimpleName() + "_" );
final TypeMirror superClass = entity.getTypeElement().getSuperclass();
diff --git a/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/Context.java b/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/Context.java
index 19f711c4b9..d903aad28b 100644
--- a/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/Context.java
+++ b/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/Context.java
@@ -26,7 +26,7 @@ import javax.persistence.AccessType;
import javax.annotation.processing.ProcessingEnvironment;
import javax.tools.Diagnostic;
-import org.hibernate.jpamodelgen.annotation.MetaEntity;
+import org.hibernate.jpamodelgen.annotation.AnnotationMetaEntity;
/**
* @author Max Andersen
@@ -38,8 +38,8 @@ public class Context {
private Map accessTypes = new HashMap();
private Set elementsAlreadyProcessed = new HashSet();
private ProcessingEnvironment pe;
- private final Map metaEntitiesToProcess = new HashMap();
- private final Map metaSuperclassAndEmbeddableToProcess = new HashMap();
+ private final Map metaEntitiesToProcess = new HashMap();
+ private final Map metaSuperclassAndEmbeddableToProcess = new HashMap();
private static class AccessTypeHolder {
public AccessType elementAccessType;
@@ -50,11 +50,11 @@ public class Context {
this.pe = pe;
}
- public Map getMetaEntitiesToProcess() {
+ public Map getMetaEntitiesToProcess() {
return metaEntitiesToProcess;
}
- public Map getMetaSuperclassAndEmbeddableToProcess() {
+ public Map getMetaSuperclassAndEmbeddableToProcess() {
return metaSuperclassAndEmbeddableToProcess;
}
@@ -98,7 +98,7 @@ public class Context {
return;
}
- ClassWriter.writeFile( new MetaEntity( pe, element, this, defaultAccessTypeForHierarchy ), pe, this );
+ ClassWriter.writeFile( new AnnotationMetaEntity( pe, element, this, defaultAccessTypeForHierarchy ), pe, this );
elementsAlreadyProcessed.add( element.getQualifiedName().toString() );
}
}
diff --git a/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/JPAMetaModelEntityProcessor.java b/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/JPAMetaModelEntityProcessor.java
index a03b1363a8..68ee00a56f 100644
--- a/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/JPAMetaModelEntityProcessor.java
+++ b/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/JPAMetaModelEntityProcessor.java
@@ -48,7 +48,7 @@ import javax.xml.validation.SchemaFactory;
import org.xml.sax.SAXException;
-import org.hibernate.jpamodelgen.annotation.MetaEntity;
+import org.hibernate.jpamodelgen.annotation.AnnotationMetaEntity;
import org.hibernate.jpamodelgen.xml.XmlMetaEntity;
import org.hibernate.jpamodelgen.xml.jaxb.Entity;
import org.hibernate.jpamodelgen.xml.jaxb.EntityMappings;
@@ -125,7 +125,7 @@ public class JPAMetaModelEntityProcessor extends AbstractProcessor {
}
private void createMetaModelClasses() {
- for ( IMetaEntity entity : context.getMetaEntitiesToProcess().values() ) {
+ for ( MetaEntity entity : context.getMetaEntitiesToProcess().values() ) {
processingEnv.getMessager()
.printMessage( Diagnostic.Kind.NOTE, "Writing meta model for " + entity );
ClassWriter.writeFile( entity, processingEnv, context );
@@ -136,7 +136,7 @@ public class JPAMetaModelEntityProcessor extends AbstractProcessor {
context.getMetaSuperclassAndEmbeddableToProcess().remove( className );
}
- for ( IMetaEntity entity : context.getMetaSuperclassAndEmbeddableToProcess().values() ) {
+ for ( MetaEntity entity : context.getMetaSuperclassAndEmbeddableToProcess().values() ) {
processingEnv.getMessager()
.printMessage( Diagnostic.Kind.NOTE, "Writing meta model for " + entity );
ClassWriter.writeFile( entity, processingEnv, context );
@@ -325,13 +325,13 @@ public class JPAMetaModelEntityProcessor extends AbstractProcessor {
if ( element.getKind() == ElementKind.CLASS ) {
if ( annotationType.equals( ENTITY_ANN ) ) {
- MetaEntity metaEntity = new MetaEntity( processingEnv, ( TypeElement ) element, context );
+ AnnotationMetaEntity metaEntity = new AnnotationMetaEntity( processingEnv, ( TypeElement ) element, context );
// TODO instead of just adding the entity we have to do some merging.
context.getMetaEntitiesToProcess().put( metaEntity.getQualifiedName(), metaEntity );
}
else if ( annotationType.equals( MAPPED_SUPERCLASS_ANN )
|| annotationType.equals( EMBEDDABLE_ANN ) ) {
- MetaEntity metaEntity = new MetaEntity( processingEnv, ( TypeElement ) element, context );
+ AnnotationMetaEntity metaEntity = new AnnotationMetaEntity( processingEnv, ( TypeElement ) element, context );
// TODO instead of just adding the entity we have to do some merging.
context.getMetaSuperclassAndEmbeddableToProcess().put( metaEntity.getQualifiedName(), metaEntity );
@@ -351,11 +351,11 @@ public class JPAMetaModelEntityProcessor extends AbstractProcessor {
ormStream = fileObject.openInputStream();
}
catch ( IOException e1 ) {
- processingEnv.getMessager()
- .printMessage(
- Diagnostic.Kind.WARNING,
- "Could not load " + resource + " using processingEnv.getFiler().getResource(). Using classpath..."
- );
+// processingEnv.getMessager()
+// .printMessage(
+// Diagnostic.Kind.WARNING,
+// "Could not load " + resource + " using processingEnv.getFiler().getResource(). Using classpath..."
+// );
// TODO
// unfortunately, the Filer.getResource API seems not to be able to load from /META-INF. One gets a
diff --git a/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/IMetaAttribute.java b/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/MetaAttribute.java
similarity index 96%
rename from tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/IMetaAttribute.java
rename to tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/MetaAttribute.java
index 4bab627ff0..946447ff6a 100644
--- a/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/IMetaAttribute.java
+++ b/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/MetaAttribute.java
@@ -20,7 +20,7 @@ package org.hibernate.jpamodelgen;
/**
* @author Hardy Ferentschik
*/
-public interface IMetaAttribute {
+public interface MetaAttribute {
String getDeclarationString();
String getMetaType();
diff --git a/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/IMetaCollection.java b/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/MetaCollection.java
similarity index 88%
rename from tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/IMetaCollection.java
rename to tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/MetaCollection.java
index b478f56377..7cb2b5ee0b 100644
--- a/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/IMetaCollection.java
+++ b/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/MetaCollection.java
@@ -17,10 +17,10 @@
*/
package org.hibernate.jpamodelgen;
-import org.hibernate.jpamodelgen.IMetaAttribute;
+import org.hibernate.jpamodelgen.MetaAttribute;
/**
* @author Hardy Ferentschik
*/
-public interface IMetaCollection extends IMetaAttribute {
+public interface MetaCollection extends MetaAttribute {
}
diff --git a/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/IMetaEntity.java b/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/MetaEntity.java
similarity index 93%
rename from tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/IMetaEntity.java
rename to tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/MetaEntity.java
index b764d5e9dc..7b42c9e118 100644
--- a/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/IMetaEntity.java
+++ b/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/MetaEntity.java
@@ -24,14 +24,14 @@ import java.util.List;
/**
* @author Hardy Ferentschik
*/
-public interface IMetaEntity extends ImportContext {
+public interface MetaEntity extends ImportContext {
String getSimpleName();
String getQualifiedName();
String getPackageName();
- List getMembers();
+ List getMembers();
String generateImports();
diff --git a/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/IMetaSingleAttribute.java b/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/MetaSingleAttribute.java
similarity index 93%
rename from tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/IMetaSingleAttribute.java
rename to tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/MetaSingleAttribute.java
index a865e5fcf2..36e960e712 100644
--- a/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/IMetaSingleAttribute.java
+++ b/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/MetaSingleAttribute.java
@@ -20,5 +20,5 @@ package org.hibernate.jpamodelgen;
/**
* @author Hardy Ferentschik
*/
-public interface IMetaSingleAttribute extends IMetaAttribute {
+public interface MetaSingleAttribute extends MetaAttribute {
}
diff --git a/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/annotation/MetaAttribute.java b/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/annotation/AnnotationMetaAttribute.java
similarity index 87%
rename from tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/annotation/MetaAttribute.java
rename to tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/annotation/AnnotationMetaAttribute.java
index c905410897..9b9a9c67f0 100644
--- a/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/annotation/MetaAttribute.java
+++ b/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/annotation/AnnotationMetaAttribute.java
@@ -17,7 +17,7 @@
*/
package org.hibernate.jpamodelgen.annotation;
-import org.hibernate.jpamodelgen.IMetaAttribute;
+import org.hibernate.jpamodelgen.MetaAttribute;
import java.beans.Introspector;
@@ -31,14 +31,14 @@ import javax.lang.model.element.ElementKind;
* @author Hardy Ferentschik
* @author Emmanuel Bernard
*/
-public abstract class MetaAttribute implements IMetaAttribute {
+public abstract class AnnotationMetaAttribute implements MetaAttribute {
final protected Element element;
- final protected MetaEntity parent;
+ final protected AnnotationMetaEntity parent;
final protected ProcessingEnvironment pe;
private final String type;
- public MetaAttribute(MetaEntity parent, Element element, String type) {
+ public AnnotationMetaAttribute(AnnotationMetaEntity parent, Element element, String type) {
this.element = element;
this.parent = parent;
this.type = type;
diff --git a/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/annotation/MetaCollection.java b/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/annotation/AnnotationMetaCollection.java
similarity index 78%
rename from tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/annotation/MetaCollection.java
rename to tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/annotation/AnnotationMetaCollection.java
index e25633705b..4a31684a8c 100644
--- a/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/annotation/MetaCollection.java
+++ b/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/annotation/AnnotationMetaCollection.java
@@ -17,7 +17,7 @@
*/
package org.hibernate.jpamodelgen.annotation;
-import org.hibernate.jpamodelgen.IMetaCollection;
+import org.hibernate.jpamodelgen.MetaCollection;
import javax.lang.model.element.Element;
@@ -27,12 +27,12 @@ import javax.lang.model.element.Element;
* @author Hardy Ferentschik
* @author Emmanuel Bernard
*/
-public class MetaCollection extends MetaAttribute implements IMetaCollection {
+public class AnnotationMetaCollection extends AnnotationMetaAttribute implements MetaCollection {
private String collectionType;
- public MetaCollection(MetaEntity parent, Element element, String collectionType, String elementType) {
+ public AnnotationMetaCollection(AnnotationMetaEntity parent, Element element, String collectionType, String elementType) {
super(parent, element, elementType);
this.collectionType = collectionType;
}
diff --git a/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/annotation/MetaEntity.java b/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/annotation/AnnotationMetaEntity.java
similarity index 87%
rename from tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/annotation/MetaEntity.java
rename to tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/annotation/AnnotationMetaEntity.java
index 2cd07df255..c235f2e515 100644
--- a/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/annotation/MetaEntity.java
+++ b/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/annotation/AnnotationMetaEntity.java
@@ -48,8 +48,8 @@ import javax.persistence.ElementCollection;
import javax.tools.Diagnostic.Kind;
import javax.tools.Diagnostic;
-import org.hibernate.jpamodelgen.IMetaEntity;
-import org.hibernate.jpamodelgen.IMetaAttribute;
+import org.hibernate.jpamodelgen.MetaEntity;
+import org.hibernate.jpamodelgen.MetaAttribute;
import org.hibernate.jpamodelgen.ImportContext;
import org.hibernate.jpamodelgen.ImportContextImpl;
import org.hibernate.jpamodelgen.TypeUtils;
@@ -61,7 +61,7 @@ import org.hibernate.jpamodelgen.Context;
* @author Hardy Ferentschik
* @author Emmanuel Bernard
*/
-public class MetaEntity implements IMetaEntity {
+public class AnnotationMetaEntity implements MetaEntity {
final TypeElement element;
final protected ProcessingEnvironment pe;
@@ -72,14 +72,14 @@ public class MetaEntity implements IMetaEntity {
private AccessType defaultAccessTypeForHierarchy;
private AccessType defaultAccessTypeForElement;
- public MetaEntity(ProcessingEnvironment pe, TypeElement element, Context context) {
+ public AnnotationMetaEntity(ProcessingEnvironment pe, TypeElement element, Context context) {
this.element = element;
this.pe = pe;
importContext = new ImportContextImpl( getPackageName() );
this.context = context;
}
- public MetaEntity(ProcessingEnvironment pe, TypeElement element, Context context, AccessType accessType) {
+ public AnnotationMetaEntity(ProcessingEnvironment pe, TypeElement element, Context context, AccessType accessType) {
this(pe, element, context);
this.defaultAccessTypeForHierarchy = accessType;
}
@@ -101,8 +101,8 @@ public class MetaEntity implements IMetaEntity {
return pe.getElementUtils().getName( packageOf.getQualifiedName() ).toString();
}
- public List getMembers() {
- List membersFound = new ArrayList();
+ public List getMembers() {
+ List membersFound = new ArrayList();
final AccessType elementAccessType = getAccessTypeForElement();
List extends Element> fieldsOfClass = ElementFilter.fieldsIn( element.getEnclosedElements() );
@@ -132,7 +132,7 @@ public class MetaEntity implements IMetaEntity {
}
private void addPersistentMembers(
- List membersFound,
+ List membersFound,
AccessType elementAccessType,
List extends Element> membersOfClass,
AccessType membersKind) {
@@ -149,7 +149,7 @@ public class MetaEntity implements IMetaEntity {
}
for ( Element memberOfClass : membersOfClass ) {
- MetaAttribute result = memberOfClass.asType().accept( new TypeVisitor( this, explicitAccessType ),
+ AnnotationMetaAttribute result = memberOfClass.asType().accept( new TypeVisitor( this, explicitAccessType ),
memberOfClass
);
if ( result != null ) {
@@ -296,27 +296,27 @@ public class MetaEntity implements IMetaEntity {
COLLECTIONS.put( "java.util.Map", "javax.persistence.metamodel.MapAttribute" );
}
- class TypeVisitor extends SimpleTypeVisitor6 {
+ class TypeVisitor extends SimpleTypeVisitor6 {
- MetaEntity parent;
+ AnnotationMetaEntity parent;
//if null, process all members as implicit
//if not null, only process members marked as @Access(explicitAccessType)
private AccessType explicitAccessType;
- TypeVisitor(MetaEntity parent, AccessType explicitAccessType) {
+ TypeVisitor(AnnotationMetaEntity parent, AccessType explicitAccessType) {
this.parent = parent;
this.explicitAccessType = explicitAccessType;
}
@Override
- protected MetaAttribute defaultAction(TypeMirror e, Element p) {
+ protected AnnotationMetaAttribute defaultAction(TypeMirror e, Element p) {
return super.defaultAction( e, p );
}
@Override
- public MetaAttribute visitPrimitive(PrimitiveType t, Element element) {
+ public AnnotationMetaAttribute visitPrimitive(PrimitiveType t, Element element) {
if ( isPersistent( element ) ) {
- return new MetaSingleAttribute( parent, element, TypeUtils.toTypeString( t ) );
+ return new AnnotationMetaSingleAttribute( parent, element, TypeUtils.toTypeString( t ) );
}
else {
return null;
@@ -344,7 +344,7 @@ public class MetaEntity implements IMetaEntity {
@Override
- public MetaAttribute visitDeclared(DeclaredType t, Element element) {
+ public AnnotationMetaAttribute visitDeclared(DeclaredType t, Element element) {
//FIXME consider XML
if ( isPersistent( element ) ) {
TypeElement returnedElement = ( TypeElement ) pe.getTypeUtils().asElement( t );
@@ -359,10 +359,10 @@ public class MetaEntity implements IMetaEntity {
this.parent.defaultAccessTypeForElement );
}
if ( collection.equals( "javax.persistence.metamodel.MapAttribute" ) ) {
- return new MetaMap( parent, element, collection, getKeyType( t ), getElementType( t ) );
+ return new AnnotationMetaMap( parent, element, collection, getKeyType( t ), getElementType( t ) );
}
else {
- return new MetaCollection( parent, element, collection, getElementType( t ) );
+ return new AnnotationMetaCollection( parent, element, collection, getElementType( t ) );
}
}
else {
@@ -372,7 +372,7 @@ public class MetaEntity implements IMetaEntity {
this.parent.context.processElement( returnedElement,
this.parent.defaultAccessTypeForElement );
}
- return new MetaSingleAttribute( parent, element, returnedElement.getQualifiedName().toString() );
+ return new AnnotationMetaSingleAttribute( parent, element, returnedElement.getQualifiedName().toString() );
}
}
else {
@@ -382,7 +382,7 @@ public class MetaEntity implements IMetaEntity {
@Override
- public MetaAttribute visitExecutable(ExecutableType t, Element p) {
+ public AnnotationMetaAttribute visitExecutable(ExecutableType t, Element p) {
String string = p.getSimpleName().toString();
// TODO: implement proper property get/is/boolean detection
diff --git a/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/annotation/MetaMap.java b/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/annotation/AnnotationMetaMap.java
similarity index 87%
rename from tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/annotation/MetaMap.java
rename to tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/annotation/AnnotationMetaMap.java
index 106e926146..36fb896bf6 100644
--- a/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/annotation/MetaMap.java
+++ b/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/annotation/AnnotationMetaMap.java
@@ -25,16 +25,16 @@ import javax.lang.model.element.Element;
* @author Hardy Ferentschik
* @author Emmanuel Bernard
*/
-public class MetaMap extends MetaCollection {
+public class AnnotationMetaMap extends AnnotationMetaCollection {
private final String keyType;
- public MetaMap(MetaEntity parent, Element element, String collectionType,
+ public AnnotationMetaMap(AnnotationMetaEntity parent, Element element, String collectionType,
String keyType, String elementType) {
super(parent, element, collectionType, elementType);
this.keyType = keyType;
}
-
+
public String getDeclarationString() {
return "public static volatile " + parent.importType(getMetaType()) + "<" + parent.importType(parent.getQualifiedName()) + ", " + parent.importType(keyType) + ", " + parent.importType(getTypeDeclaration()) + "> " + getPropertyName() + ";";
}
diff --git a/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/annotation/MetaSingleAttribute.java b/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/annotation/AnnotationMetaSingleAttribute.java
similarity index 78%
rename from tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/annotation/MetaSingleAttribute.java
rename to tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/annotation/AnnotationMetaSingleAttribute.java
index 2507ef5bba..f8c52f312a 100644
--- a/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/annotation/MetaSingleAttribute.java
+++ b/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/annotation/AnnotationMetaSingleAttribute.java
@@ -17,7 +17,7 @@
*/
package org.hibernate.jpamodelgen.annotation;
-import org.hibernate.jpamodelgen.IMetaSingleAttribute;
+import org.hibernate.jpamodelgen.MetaSingleAttribute;
import javax.lang.model.element.Element;
@@ -27,9 +27,9 @@ import javax.lang.model.element.Element;
* @author Hardy Ferentschik
* @author Emmanuel Bernard
*/
-public class MetaSingleAttribute extends MetaAttribute implements IMetaSingleAttribute {
+public class AnnotationMetaSingleAttribute extends AnnotationMetaAttribute implements MetaSingleAttribute {
- public MetaSingleAttribute(MetaEntity parent, Element element, String type) {
+ public AnnotationMetaSingleAttribute(AnnotationMetaEntity parent, Element element, String type) {
super(parent, element, type);
}
diff --git a/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/xml/XmlMetaAttribute.java b/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/xml/XmlMetaAttribute.java
index 6ed7322422..14dbded3a0 100644
--- a/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/xml/XmlMetaAttribute.java
+++ b/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/xml/XmlMetaAttribute.java
@@ -18,12 +18,12 @@
package org.hibernate.jpamodelgen.xml;
-import org.hibernate.jpamodelgen.IMetaAttribute;
+import org.hibernate.jpamodelgen.MetaAttribute;
/**
* @author Hardy Ferentschik
*/
-public abstract class XmlMetaAttribute implements IMetaAttribute {
+public abstract class XmlMetaAttribute implements MetaAttribute {
private XmlMetaEntity parentEntity;
diff --git a/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/xml/XmlMetaCollection.java b/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/xml/XmlMetaCollection.java
index 18c2a216f9..e7a55d637a 100644
--- a/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/xml/XmlMetaCollection.java
+++ b/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/xml/XmlMetaCollection.java
@@ -17,12 +17,12 @@
*/
package org.hibernate.jpamodelgen.xml;
-import org.hibernate.jpamodelgen.IMetaCollection;
+import org.hibernate.jpamodelgen.MetaCollection;
/**
* @author Hardy Ferentschik
*/
-public class XmlMetaCollection extends XmlMetaAttribute implements IMetaCollection {
+public class XmlMetaCollection extends XmlMetaAttribute implements MetaCollection {
String collectionType;
diff --git a/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/xml/XmlMetaEntity.java b/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/xml/XmlMetaEntity.java
index 5c86fd70d7..2dbae22142 100644
--- a/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/xml/XmlMetaEntity.java
+++ b/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/xml/XmlMetaEntity.java
@@ -26,9 +26,9 @@ import javax.lang.model.element.Name;
import javax.lang.model.element.TypeElement;
import javax.lang.model.type.DeclaredType;
-import org.hibernate.jpamodelgen.IMetaAttribute;
+import org.hibernate.jpamodelgen.MetaAttribute;
import org.hibernate.jpamodelgen.ImportContextImpl;
-import org.hibernate.jpamodelgen.IMetaEntity;
+import org.hibernate.jpamodelgen.MetaEntity;
import org.hibernate.jpamodelgen.ImportContext;
import org.hibernate.jpamodelgen.xml.jaxb.Attributes;
import org.hibernate.jpamodelgen.xml.jaxb.Basic;
@@ -45,7 +45,7 @@ import org.hibernate.jpamodelgen.xml.jaxb.OneToOne;
/**
* @author Hardy Ferentschik
*/
-public class XmlMetaEntity implements IMetaEntity {
+public class XmlMetaEntity implements MetaEntity {
static Map COLLECTIONS = new HashMap();
@@ -62,7 +62,7 @@ public class XmlMetaEntity implements IMetaEntity {
final private ImportContext importContext;
- final private List members = new ArrayList();
+ final private List members = new ArrayList();
private TypeElement element;
@@ -135,7 +135,7 @@ public class XmlMetaEntity implements IMetaEntity {
return packageName;
}
- public List getMembers() {
+ public List getMembers() {
return members;
}
diff --git a/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/xml/XmlMetaSingleAttribute.java b/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/xml/XmlMetaSingleAttribute.java
index 654639f82a..231dd715f0 100644
--- a/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/xml/XmlMetaSingleAttribute.java
+++ b/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/xml/XmlMetaSingleAttribute.java
@@ -17,12 +17,12 @@
*/
package org.hibernate.jpamodelgen.xml;
-import org.hibernate.jpamodelgen.IMetaSingleAttribute;
+import org.hibernate.jpamodelgen.MetaSingleAttribute;
/**
* @author Hardy Ferentschik
*/
-public class XmlMetaSingleAttribute extends XmlMetaAttribute implements IMetaSingleAttribute {
+public class XmlMetaSingleAttribute extends XmlMetaAttribute implements MetaSingleAttribute {
public XmlMetaSingleAttribute(XmlMetaEntity parent, String propertyName, String type) {
super(parent, propertyName, type);
diff --git a/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/accesstype/AccessTypeTest.java b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/accesstype/AccessTypeTest.java
new file mode 100644
index 0000000000..6a2370f558
--- /dev/null
+++ b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/accesstype/AccessTypeTest.java
@@ -0,0 +1,90 @@
+// $Id$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.jpamodelgen.test.accesstype;
+
+import org.testng.annotations.Test;
+
+import org.hibernate.jpamodelgen.test.util.CompilationTest;
+import static org.hibernate.jpamodelgen.test.util.TestUtil.assertAbsenceOfField;
+import static org.hibernate.jpamodelgen.test.util.TestUtil.assertPresenceOfField;
+
+/**
+ * @author Emmanuel Bernard
+ * @author Hardy Ferentschik
+ */
+public class AccessTypeTest extends CompilationTest {
+
+ @Test
+ public void testExcludeTransientFieldAndStatic() throws Exception {
+ assertAbsenceOfField( Product.class.getName() + "_", "nonPersistent" );
+ assertAbsenceOfField( Product.class.getName() + "_", "nonPersistent2" );
+ }
+
+ @Test
+ public void testDefaultAccessTypeOnEntity() throws Exception {
+ assertAbsenceOfField( User.class.getName() + "_", "nonPersistent" );
+ }
+
+ @Test
+ public void testDefaultAccessTypeForSubclassOfEntity() throws Exception {
+ assertAbsenceOfField( Customer.class.getName() + "_", "nonPersistent" );
+ }
+
+ @Test
+ public void testDefaultAccessTypeForEmbeddable() throws Exception {
+ assertAbsenceOfField( Detail.class.getName() + "_", "nonPersistent" );
+ }
+
+ @Test
+ public void testInheritedAccessTypeForEmbeddable() throws Exception {
+ assertAbsenceOfField( Country.class.getName() + "_", "nonPersistent" );
+ assertAbsenceOfField(
+ Pet.class.getName() + "_", "nonPersistent", "Collection of embeddable not taken care of"
+ );
+ }
+
+ @Test
+ public void testDefaultAccessTypeForMappedSuperclass() throws Exception {
+ assertAbsenceOfField( Detail.class.getName() + "_", "volume" );
+ }
+
+ @Test
+ public void testExplicitAccessTypeAndDefaultFromRootEntity() throws Exception {
+ assertAbsenceOfField(
+ LivingBeing.class.getName() + "_",
+ "nonPersistent",
+ "explicit access type on mapped superclass"
+ );
+ assertAbsenceOfField( Hominidae.class.getName() + "_", "nonPersistent", "explicit access type on entity" );
+ assertAbsenceOfField(
+ Human.class.getName() + "_",
+ "nonPersistent",
+ "proper inheritance from root entity access type"
+ );
+ }
+
+ @Test
+ public void testMemberAccessType() throws Exception {
+ assertPresenceOfField( Customer.class.getName() + "_", "goodPayer", "access type overriding" );
+ }
+
+ @Override
+ protected String getTestPackage() {
+ return Product.class.getPackage().getName();
+ }
+}
diff --git a/tooling/metamodel-generator/src/test/java/model/Address.java b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/accesstype/Address.java
similarity index 97%
rename from tooling/metamodel-generator/src/test/java/model/Address.java
rename to tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/accesstype/Address.java
index 0dc36351f8..de5b3a0a9e 100644
--- a/tooling/metamodel-generator/src/test/java/model/Address.java
+++ b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/accesstype/Address.java
@@ -15,12 +15,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package model;
+package org.hibernate.jpamodelgen.test.accesstype;
import java.util.Set;
import javax.persistence.Embeddable;
import javax.persistence.Access;
-import javax.persistence.AccessType;
import javax.persistence.ElementCollection;
import javax.persistence.CollectionTable;
diff --git a/tooling/metamodel-generator/src/test/java/model/Area.java b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/accesstype/Area.java
similarity index 96%
rename from tooling/metamodel-generator/src/test/java/model/Area.java
rename to tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/accesstype/Area.java
index 633afa4ef8..68acadb1b2 100644
--- a/tooling/metamodel-generator/src/test/java/model/Area.java
+++ b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/accesstype/Area.java
@@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package model;
+package org.hibernate.jpamodelgen.test.accesstype;
import javax.persistence.MappedSuperclass;
diff --git a/tooling/metamodel-generator/src/test/java/model/Building.java b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/accesstype/Building.java
similarity index 95%
rename from tooling/metamodel-generator/src/test/java/model/Building.java
rename to tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/accesstype/Building.java
index ea1d153998..66bee6307f 100644
--- a/tooling/metamodel-generator/src/test/java/model/Building.java
+++ b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/accesstype/Building.java
@@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package model;
+package org.hibernate.jpamodelgen.test.accesstype;
import javax.persistence.MappedSuperclass;
diff --git a/tooling/metamodel-generator/src/test/java/model/Country.java b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/accesstype/Country.java
similarity index 95%
rename from tooling/metamodel-generator/src/test/java/model/Country.java
rename to tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/accesstype/Country.java
index b38c8b035b..8fff44f047 100644
--- a/tooling/metamodel-generator/src/test/java/model/Country.java
+++ b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/accesstype/Country.java
@@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package model;
+package org.hibernate.jpamodelgen.test.accesstype;
import javax.persistence.Embeddable;
diff --git a/tooling/metamodel-generator/src/test/java/model/Customer.java b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/accesstype/Customer.java
similarity index 96%
rename from tooling/metamodel-generator/src/test/java/model/Customer.java
rename to tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/accesstype/Customer.java
index d05fd6a284..993dcf3971 100644
--- a/tooling/metamodel-generator/src/test/java/model/Customer.java
+++ b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/accesstype/Customer.java
@@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package model;
+package org.hibernate.jpamodelgen.test.accesstype;
import java.util.Set;
import javax.persistence.Entity;
diff --git a/tooling/metamodel-generator/src/test/java/model/Detail.java b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/accesstype/Detail.java
similarity index 96%
rename from tooling/metamodel-generator/src/test/java/model/Detail.java
rename to tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/accesstype/Detail.java
index b9480d6027..06101ca8b6 100644
--- a/tooling/metamodel-generator/src/test/java/model/Detail.java
+++ b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/accesstype/Detail.java
@@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package model;
+package org.hibernate.jpamodelgen.test.accesstype;
import javax.persistence.Embeddable;
diff --git a/tooling/metamodel-generator/src/test/java/model/Hominidae.java b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/accesstype/Hominidae.java
similarity index 95%
rename from tooling/metamodel-generator/src/test/java/model/Hominidae.java
rename to tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/accesstype/Hominidae.java
index 7b7812c5e8..34a81e79cf 100644
--- a/tooling/metamodel-generator/src/test/java/model/Hominidae.java
+++ b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/accesstype/Hominidae.java
@@ -15,11 +15,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package model;
+package org.hibernate.jpamodelgen.test.accesstype;
import javax.persistence.Entity;
import javax.persistence.Access;
-import javax.persistence.AccessType;
/**
* @author Emmanuel Bernard
diff --git a/tooling/metamodel-generator/src/test/java/model/House.java b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/accesstype/House.java
similarity index 95%
rename from tooling/metamodel-generator/src/test/java/model/House.java
rename to tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/accesstype/House.java
index c00fe85755..46d01bffe0 100644
--- a/tooling/metamodel-generator/src/test/java/model/House.java
+++ b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/accesstype/House.java
@@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package model;
+package org.hibernate.jpamodelgen.test.accesstype;
import javax.persistence.Id;
import javax.persistence.Entity;
diff --git a/tooling/metamodel-generator/src/test/java/model/Human.java b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/accesstype/Human.java
similarity index 95%
rename from tooling/metamodel-generator/src/test/java/model/Human.java
rename to tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/accesstype/Human.java
index 2d486f2167..c1108b7384 100644
--- a/tooling/metamodel-generator/src/test/java/model/Human.java
+++ b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/accesstype/Human.java
@@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package model;
+package org.hibernate.jpamodelgen.test.accesstype;
import javax.persistence.Entity;
diff --git a/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/accesstype/Image.java b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/accesstype/Image.java
new file mode 100644
index 0000000000..1102b2b3a8
--- /dev/null
+++ b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/accesstype/Image.java
@@ -0,0 +1,46 @@
+// $Id$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.jpamodelgen.test.accesstype;
+
+import javax.persistence.Entity;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+public class Image {
+ private String name;
+
+ private byte[] data;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public byte[] getData() {
+ return data;
+ }
+
+ public void setData(byte[] data) {
+ this.data = data;
+ }
+}
\ No newline at end of file
diff --git a/tooling/metamodel-generator/src/test/java/model/Inhabitant.java b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/accesstype/Inhabitant.java
similarity index 95%
rename from tooling/metamodel-generator/src/test/java/model/Inhabitant.java
rename to tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/accesstype/Inhabitant.java
index a4030bde23..3b530d4e14 100644
--- a/tooling/metamodel-generator/src/test/java/model/Inhabitant.java
+++ b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/accesstype/Inhabitant.java
@@ -15,12 +15,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package model;
+package org.hibernate.jpamodelgen.test.accesstype;
import java.util.Set;
import javax.persistence.Embeddable;
import javax.persistence.Access;
-import javax.persistence.AccessType;
import javax.persistence.ElementCollection;
/**
diff --git a/tooling/metamodel-generator/src/test/java/model/Item.java b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/accesstype/Item.java
similarity index 94%
rename from tooling/metamodel-generator/src/test/java/model/Item.java
rename to tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/accesstype/Item.java
index d7b33baa6a..e1239e8bd7 100644
--- a/tooling/metamodel-generator/src/test/java/model/Item.java
+++ b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/accesstype/Item.java
@@ -15,16 +15,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package model;
+package org.hibernate.jpamodelgen.test.accesstype;
import java.util.Map;
-import java.util.Set;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
+import org.hibernate.jpamodelgen.test.accesstype.Product;
+
/**
*
* @author Max Andersen
diff --git a/tooling/metamodel-generator/src/test/java/model/LivingBeing.java b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/accesstype/LivingBeing.java
similarity index 95%
rename from tooling/metamodel-generator/src/test/java/model/LivingBeing.java
rename to tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/accesstype/LivingBeing.java
index 3d30b85a2a..a220317ee1 100644
--- a/tooling/metamodel-generator/src/test/java/model/LivingBeing.java
+++ b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/accesstype/LivingBeing.java
@@ -15,11 +15,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package model;
+package org.hibernate.jpamodelgen.test.accesstype;
import javax.persistence.MappedSuperclass;
import javax.persistence.Access;
-import javax.persistence.AccessType;
/**
* @author Emmanuel Bernard
diff --git a/tooling/metamodel-generator/src/test/java/model/Mammals.java b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/accesstype/Mammals.java
similarity index 96%
rename from tooling/metamodel-generator/src/test/java/model/Mammals.java
rename to tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/accesstype/Mammals.java
index 0101dc7a2b..06fc36769a 100644
--- a/tooling/metamodel-generator/src/test/java/model/Mammals.java
+++ b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/accesstype/Mammals.java
@@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package model;
+package org.hibernate.jpamodelgen.test.accesstype;
import javax.persistence.Entity;
import javax.persistence.Id;
diff --git a/tooling/metamodel-generator/src/test/java/model/Order.java b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/accesstype/Order.java
similarity index 95%
rename from tooling/metamodel-generator/src/test/java/model/Order.java
rename to tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/accesstype/Order.java
index 51de07bd8a..41bba2b35b 100644
--- a/tooling/metamodel-generator/src/test/java/model/Order.java
+++ b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/accesstype/Order.java
@@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package model;
+package org.hibernate.jpamodelgen.test.accesstype;
import java.util.Date;
import java.util.List;
diff --git a/tooling/metamodel-generator/src/test/java/model/Pet.java b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/accesstype/Pet.java
similarity index 95%
rename from tooling/metamodel-generator/src/test/java/model/Pet.java
rename to tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/accesstype/Pet.java
index 3ad0ef44f2..887da349e5 100644
--- a/tooling/metamodel-generator/src/test/java/model/Pet.java
+++ b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/accesstype/Pet.java
@@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package model;
+package org.hibernate.jpamodelgen.test.accesstype;
import javax.persistence.Embeddable;
diff --git a/tooling/metamodel-generator/src/test/java/model/Product.java b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/accesstype/Product.java
similarity index 88%
rename from tooling/metamodel-generator/src/test/java/model/Product.java
rename to tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/accesstype/Product.java
index d598e19895..a63a5cfcae 100644
--- a/tooling/metamodel-generator/src/test/java/model/Product.java
+++ b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/accesstype/Product.java
@@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package model;
+package org.hibernate.jpamodelgen.test.accesstype;
import java.math.BigDecimal;
import java.util.Set;
@@ -25,6 +25,9 @@ import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
+import org.hibernate.jpamodelgen.test.accesstype.Item;
+import org.hibernate.jpamodelgen.test.accesstype.Shop;
+
/**
*
* @author Max Andersen
diff --git a/tooling/metamodel-generator/src/test/java/model/Shop.java b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/accesstype/Shop.java
similarity index 95%
rename from tooling/metamodel-generator/src/test/java/model/Shop.java
rename to tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/accesstype/Shop.java
index 953860f7b0..aecabdcc18 100644
--- a/tooling/metamodel-generator/src/test/java/model/Shop.java
+++ b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/accesstype/Shop.java
@@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package model;
+package org.hibernate.jpamodelgen.test.accesstype;
import javax.persistence.Entity;
import javax.persistence.Id;
diff --git a/tooling/metamodel-generator/src/test/java/model/User.java b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/accesstype/User.java
similarity index 96%
rename from tooling/metamodel-generator/src/test/java/model/User.java
rename to tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/accesstype/User.java
index 15926ee876..804244154a 100644
--- a/tooling/metamodel-generator/src/test/java/model/User.java
+++ b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/accesstype/User.java
@@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package model;
+package org.hibernate.jpamodelgen.test.accesstype;
import javax.persistence.Entity;
import javax.persistence.Id;
diff --git a/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/inheritance/Area.java b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/inheritance/Area.java
new file mode 100644
index 0000000000..235e384c8d
--- /dev/null
+++ b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/inheritance/Area.java
@@ -0,0 +1,59 @@
+// $Id$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.jpamodelgen.test.inheritance;
+
+import javax.persistence.MappedSuperclass;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@MappedSuperclass
+public class Area {
+ private int length;
+ private int width;
+ private int height;
+
+ //should not be persistent
+ public int getVolume() {
+ return length*width*height;
+ }
+
+ public int getLength() {
+ return length;
+ }
+
+ public void setLength(int length) {
+ this.length = length;
+ }
+
+ public int getWidth() {
+ return width;
+ }
+
+ public void setWidth(int width) {
+ this.width = width;
+ }
+
+ public int getHeight() {
+ return height;
+ }
+
+ public void setHeight(int height) {
+ this.height = height;
+ }
+}
\ No newline at end of file
diff --git a/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/inheritance/Building.java b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/inheritance/Building.java
new file mode 100644
index 0000000000..725a3d294b
--- /dev/null
+++ b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/inheritance/Building.java
@@ -0,0 +1,38 @@
+// $Id$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.jpamodelgen.test.inheritance;
+
+import java.sql.Date;
+import javax.persistence.MappedSuperclass;
+
+
+/**
+ * @author Emmanuel Bernard
+ */
+@MappedSuperclass
+public class Building extends Area {
+ public Date getBuiltIn() {
+ return builtIn;
+ }
+
+ public void setBuiltIn(Date builtIn) {
+ this.builtIn = builtIn;
+ }
+
+ private Date builtIn;
+}
\ No newline at end of file
diff --git a/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/inheritance/Customer.java b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/inheritance/Customer.java
new file mode 100644
index 0000000000..922f069679
--- /dev/null
+++ b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/inheritance/Customer.java
@@ -0,0 +1,27 @@
+// $Id$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.jpamodelgen.test.inheritance;
+
+import javax.persistence.Entity;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+public class Customer extends User {
+}
\ No newline at end of file
diff --git a/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/inheritance/House.java b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/inheritance/House.java
new file mode 100644
index 0000000000..10f99ab576
--- /dev/null
+++ b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/inheritance/House.java
@@ -0,0 +1,38 @@
+// $Id$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.jpamodelgen.test.inheritance;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+public class House extends Building {
+ @Id
+ private Long id;
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+}
\ No newline at end of file
diff --git a/tooling/metamodel-generator/src/test/java/test/InheritanceTest.java b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/inheritance/InheritanceTest.java
similarity index 60%
rename from tooling/metamodel-generator/src/test/java/test/InheritanceTest.java
rename to tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/inheritance/InheritanceTest.java
index 627a7d5eb1..cd5302b7ba 100644
--- a/tooling/metamodel-generator/src/test/java/test/InheritanceTest.java
+++ b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/inheritance/InheritanceTest.java
@@ -15,32 +15,33 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package test;
+package org.hibernate.jpamodelgen.test.inheritance;
import org.testng.annotations.Test;
-import org.testng.Assert;
-import model.Customer_;
-import model.User_;
-import model.House_;
-import model.Building_;
-import model.Area_;
+
+import org.hibernate.jpamodelgen.test.util.CompilationTest;
+import static org.hibernate.jpamodelgen.test.util.TestUtil.assertSuperClass;
/**
* @author Emmanuel Bernard
+ * @author Hardy Ferentschik
*/
-@Test
-public class InheritanceTest {
+public class InheritanceTest extends CompilationTest {
@Test
public void testSuperEntity() throws Exception {
- Assert.assertEquals( Customer_.class.getSuperclass(), User_.class,
- "Entity with super entity should inherit at the metamodel level");
+ assertSuperClass(
+ Customer.class.getName() + "_", User.class.getName() + "_"
+ );
}
@Test
public void testMappedSuperclass() throws Exception {
- Assert.assertEquals( House_.class.getSuperclass(), Building_.class,
- "Entity with mapped superclass should inherit at the metamodel level");
- Assert.assertEquals( Building_.class.getSuperclass(), Area_.class,
- "mapped superclass with mapped superclass should inherit at the metamodel level");
+ assertSuperClass( House.class.getName() + "_", Building.class.getName() + "_" );
+ assertSuperClass( Building.class.getName() + "_", Area.class.getName() + "_" );
+ }
+
+ @Override
+ protected String getTestPackage() {
+ return Customer.class.getPackage().getName();
}
}
diff --git a/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/inheritance/User.java b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/inheritance/User.java
new file mode 100644
index 0000000000..c66feebc64
--- /dev/null
+++ b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/inheritance/User.java
@@ -0,0 +1,58 @@
+// $Id$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.jpamodelgen.test.inheritance;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Transient;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+public class User {
+ private Long id;
+ private String nonPersistent;
+ private String name;
+
+ @Id
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ @Transient
+ public String getNonPersistent() {
+ return nonPersistent;
+ }
+
+ public void setNonPersistent(String nonPersistent) {
+ this.nonPersistent = nonPersistent;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+}
\ No newline at end of file
diff --git a/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/util/CompilationTest.java b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/util/CompilationTest.java
new file mode 100644
index 0000000000..c9589881d4
--- /dev/null
+++ b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/util/CompilationTest.java
@@ -0,0 +1,127 @@
+// $Id:$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.jpamodelgen.test.util;
+
+import java.io.File;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import javax.tools.Diagnostic;
+import javax.tools.DiagnosticCollector;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.ToolProvider;
+
+import static org.testng.FileAssert.fail;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public abstract class CompilationTest {
+
+ private static final String PATH_SEPARATOR = System.getProperty( "file.separator" );
+ private static final String sourceBaseDir;
+ private static final String outBaseDir;
+
+ static {
+ String tmp = System.getProperty( "sourceBaseDir" );
+ if ( tmp == null ) {
+ fail( "The system property sourceBaseDir has to be set and point to the base directory of the test java sources." );
+ }
+ sourceBaseDir = tmp;
+
+ tmp = System.getProperty( "outBaseDir" );
+ if ( tmp == null ) {
+ fail( "The system property outBaseDir has to be set and point to the base directory of the test output directory." );
+ }
+ outBaseDir = tmp;
+ }
+
+ public CompilationTest() {
+ try {
+ compile();
+ }
+ catch ( Exception e ) {
+ fail( "Unable to compile test sources. " + e.getMessage() );
+ }
+ }
+
+ private void compile() throws IOException {
+ List options = createJavaOptions();
+
+ JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
+ DiagnosticCollector diagnostics = new DiagnosticCollector();
+ StandardJavaFileManager fileManager = compiler.getStandardFileManager( diagnostics, null, null );
+ Iterable extends JavaFileObject> compilationUnits = fileManager.getJavaFileObjectsFromFiles(
+ getCompilationUnits( sourceBaseDir )
+ );
+
+ // TODO - need to call the compiler twice. Once to compile the test classes and generate the java files
+ // of the generated metamodel. The second compile is for generated the class files of the metamodel.
+ // Note sure why this is not recursive the same way as on the command line
+ compileSources( options, compiler, diagnostics, fileManager, compilationUnits );
+
+ compilationUnits = fileManager.getJavaFileObjectsFromFiles(
+ getCompilationUnits( outBaseDir )
+ );
+ compileSources( options, compiler, diagnostics, fileManager, compilationUnits );
+ fileManager.close();
+ }
+
+ private void compileSources(List options, JavaCompiler compiler, DiagnosticCollector diagnostics, StandardJavaFileManager fileManager, Iterable extends JavaFileObject> compilationUnits) {
+ JavaCompiler.CompilationTask task = compiler.getTask(
+ null, fileManager, diagnostics, options, null, compilationUnits
+ );
+ task.call();
+// for ( Diagnostic diagnostic : diagnostics.getDiagnostics() ) {
+// System.out.println( diagnostic.getMessage( null ) );
+// }
+ }
+
+ private List createJavaOptions() {
+ // TODO
+ // passing any other options as -d seems to throw IllegalArgumentExceptions. I would like to set -s for example
+ // in order to see whether recursive recompilation would work then. Also '-proc only' could be interesting
+ List options = new ArrayList();
+ options.add( "-d" );
+ options.add( outBaseDir );
+ return options;
+ }
+
+ private List getCompilationUnits(String baseDir) {
+ List javaFiles = new ArrayList();
+ String packageDirName = baseDir + PATH_SEPARATOR + getTestPackage().replace( ".", PATH_SEPARATOR );
+ File packageDir = new File( packageDirName );
+ FilenameFilter javaFileFilter = new FilenameFilter() {
+ @Override
+ public boolean accept(File dir, String name) {
+ return name.endsWith( ".java" );
+ }
+ };
+ for ( File file : packageDir.listFiles( javaFileFilter ) ) {
+ javaFiles.add( file );
+ }
+ return javaFiles;
+ }
+
+ abstract protected String getTestPackage();
+}
+
+
diff --git a/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/util/TestUtil.java b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/util/TestUtil.java
new file mode 100644
index 0000000000..8d7d71d72f
--- /dev/null
+++ b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/util/TestUtil.java
@@ -0,0 +1,83 @@
+// $Id:$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.jpamodelgen.test.util;
+
+import org.testng.Assert;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.FileAssert.fail;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class TestUtil {
+
+ private TestUtil() {
+ }
+
+ public static void assertClassGenerated(String className) {
+ try {
+ assertNotNull( Class.forName( className ) );
+ }
+ catch ( ClassNotFoundException e ) {
+ fail( e.getMessage() );
+ }
+ }
+
+ public static void assertAbsenceOfField(String className, String fieldName) throws ClassNotFoundException {
+ assertAbsenceOfField( className, fieldName, "field should not be persistent" );
+ }
+
+ public static void assertAbsenceOfField(String className, String fieldName, String errorString)
+ throws ClassNotFoundException {
+ Assert.assertFalse( isFieldHere( className, fieldName ), errorString );
+ }
+
+ public static void assertPresenceOfField(String className, String fieldName, String errorString)
+ throws ClassNotFoundException {
+ Assert.assertTrue( isFieldHere( className, fieldName ), errorString );
+ }
+
+ public static void assertSuperClass(String className, String superClassName) {
+ Class> clazz;
+ Class> superClazz;
+ try {
+ clazz = Class.forName( className );
+ superClazz = Class.forName( superClassName );
+ Assert.assertEquals(
+ clazz.getSuperclass(), superClazz,
+ "Entity " + superClassName + " should be the superclass of " + className
+ );
+ }
+ catch ( ClassNotFoundException e ) {
+ fail( "Unable to load metamodel class: " + e.getMessage() );
+ }
+ }
+
+ private static boolean isFieldHere(String className, String fieldName) throws ClassNotFoundException {
+ Class> clazz = Class.forName( className );
+ try {
+ clazz.getField( fieldName );
+ return true;
+ }
+ catch ( NoSuchFieldException e ) {
+ return false;
+ }
+ }
+}
+
+
diff --git a/tooling/metamodel-generator/src/test/java/model/xmlmapped/Address.java b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/xmlmapped/Address.java
similarity index 96%
rename from tooling/metamodel-generator/src/test/java/model/xmlmapped/Address.java
rename to tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/xmlmapped/Address.java
index f6d9bb08ba..9f0124b62b 100644
--- a/tooling/metamodel-generator/src/test/java/model/xmlmapped/Address.java
+++ b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/xmlmapped/Address.java
@@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package model.xmlmapped;
+package org.hibernate.jpamodelgen.test.xmlmapped;
/**
* @author Hardy Ferentschik
diff --git a/tooling/metamodel-generator/src/test/java/model/xmlmapped/Building.java b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/xmlmapped/Building.java
similarity index 79%
rename from tooling/metamodel-generator/src/test/java/model/xmlmapped/Building.java
rename to tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/xmlmapped/Building.java
index 21315643b0..3b3d38d007 100644
--- a/tooling/metamodel-generator/src/test/java/model/xmlmapped/Building.java
+++ b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/xmlmapped/Building.java
@@ -15,10 +15,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package model.xmlmapped;
+package org.hibernate.jpamodelgen.test.xmlmapped;
-import model.Address;
-import model.Area;
+import org.hibernate.jpamodelgen.test.accesstype.*;
+import org.hibernate.jpamodelgen.test.accesstype.Address;
/**
* @author Hardy Ferentschik
@@ -30,7 +30,7 @@ public class Building extends Area {
return address;
}
- public void setAddress(Address address) {
+ public void setAddress(org.hibernate.jpamodelgen.test.accesstype.Address address) {
this.address = address;
}
}
\ No newline at end of file
diff --git a/tooling/metamodel-generator/src/test/java/model/xmlmapped/LivingBeing.java b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/xmlmapped/LivingBeing.java
similarity index 95%
rename from tooling/metamodel-generator/src/test/java/model/xmlmapped/LivingBeing.java
rename to tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/xmlmapped/LivingBeing.java
index e27616d15d..a8de6332ad 100644
--- a/tooling/metamodel-generator/src/test/java/model/xmlmapped/LivingBeing.java
+++ b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/xmlmapped/LivingBeing.java
@@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package model.xmlmapped;
+package org.hibernate.jpamodelgen.test.xmlmapped;
/**
* @author Hardy Ferentschik
diff --git a/tooling/metamodel-generator/src/test/java/model/xmlmapped/Mammal.java b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/xmlmapped/Mammal.java
similarity index 95%
rename from tooling/metamodel-generator/src/test/java/model/xmlmapped/Mammal.java
rename to tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/xmlmapped/Mammal.java
index d0213e6872..86aa2b920f 100644
--- a/tooling/metamodel-generator/src/test/java/model/xmlmapped/Mammal.java
+++ b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/xmlmapped/Mammal.java
@@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package model.xmlmapped;
+package org.hibernate.jpamodelgen.test.xmlmapped;
/**
* @author Hardy Ferentschik
diff --git a/tooling/metamodel-generator/src/test/java/test/XmlMappingTest.java b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/xmlmapped/XmlMappingTest.java
similarity index 55%
rename from tooling/metamodel-generator/src/test/java/test/XmlMappingTest.java
rename to tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/xmlmapped/XmlMappingTest.java
index 84155896ae..8e27c16555 100644
--- a/tooling/metamodel-generator/src/test/java/test/XmlMappingTest.java
+++ b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/xmlmapped/XmlMappingTest.java
@@ -15,41 +15,46 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package test;
+package org.hibernate.jpamodelgen.test.xmlmapped;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertTrue;
import org.testng.annotations.Test;
+import org.hibernate.jpamodelgen.test.util.CompilationTest;
+import static org.hibernate.jpamodelgen.test.util.TestUtil.assertClassGenerated;
+import static org.hibernate.jpamodelgen.test.util.TestUtil.assertPresenceOfField;
+import static org.hibernate.jpamodelgen.test.util.TestUtil.assertSuperClass;
+
/**
* @author Hardy Ferentschik
*/
-public class XmlMappingTest {
+public class XmlMappingTest extends CompilationTest {
@Test
public void testXmlConfiguredEmbeddedClassGenerated() throws Exception {
- assertNotNull( Class.forName( "model.xmlmapped.Address_" ) );
+ assertClassGenerated( Address.class.getName() + "_" );
}
@Test
public void testXmlConfiguredMappedSuperclassGenerated() throws Exception {
- Class> building = Class.forName( "model.xmlmapped.Building_" );
- assertNotNull( building );
- assertNotNull( building.getField( "address" ) );
+ assertClassGenerated( Building.class.getName() + "_" );
+ assertPresenceOfField(
+ Building.class.getName() + "_", "address", "address field should exist"
+ );
}
@Test
public void testClassHierarchy() throws Exception {
- Class> mammal = Class.forName( "model.xmlmapped.Mammal_" );
- assertNotNull( mammal );
-
- Class> being = Class.forName( "model.xmlmapped.LivingBeing_" );
- assertNotNull( being );
-
- assertTrue( mammal.getSuperclass().equals( being ) );
+ assertClassGenerated( Mammal.class.getName() + "_" );
+ assertClassGenerated( LivingBeing.class.getName() + "_" );
+ assertSuperClass( Mammal.class.getName() + "_", LivingBeing.class.getName() + "_" );
}
@Test(expectedExceptions = ClassNotFoundException.class)
public void testNonExistentMappedClassesGetIgnored() throws Exception {
- Class.forName( "model.Dummy_" );
+ Class.forName( "org.hibernate.jpamodelgen.test.model.Dummy_" );
+ }
+
+ @Override
+ protected String getTestPackage() {
+ return Address.class.getPackage().getName();
}
}
\ No newline at end of file
diff --git a/tooling/metamodel-generator/src/test/java/test/AccessTypeTest.java b/tooling/metamodel-generator/src/test/java/test/AccessTypeTest.java
deleted file mode 100644
index 20f4fedc80..0000000000
--- a/tooling/metamodel-generator/src/test/java/test/AccessTypeTest.java
+++ /dev/null
@@ -1,94 +0,0 @@
-// $Id$
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, Red Hat Middleware LLC, and individual contributors
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-* http://www.apache.org/licenses/LICENSE-2.0
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package test;
-
-import org.testng.annotations.Test;
-import org.testng.Assert;
-
-/**
- * @author Emmanuel Bernard
- */
-@Test
-public class AccessTypeTest {
-
- @Test
- public void testExcludeTransientFieldAndStatic() throws Exception{
- absenceOfField( "model.Product_", "nonPersistent" );
- absenceOfField( "model.Product_", "nonPersistent2" );
- }
-
- @Test
- public void testDefaultAccessTypeOnEntity() throws Exception{
- absenceOfField( "model.User_", "nonPersistent" );
- }
-
- @Test
- public void testDefaultAccessTypeForSubclassOfEntity() throws Exception{
- absenceOfField( "model.Customer_", "nonPersistent" );
- }
-
- @Test
- public void testDefaultAccessTypeForEmbeddable() throws Exception{
- absenceOfField( "model.Detail_", "nonPersistent" );
- }
-
- @Test
- public void testInheritedAccessTypeForEmbeddable() throws Exception{
- absenceOfField( "model.Country_", "nonPersistent" );
- absenceOfField( "model.Pet_", "nonPersistent", "Colleciton of membeddable not taken care of" );
- }
-
- @Test
- public void testDefaultAccessTypeForMappedSuperclass() throws Exception{
- absenceOfField( "model.Detail_", "volume" );
- }
-
- @Test
- public void testExplicitAccessTypeAndDefaultFromRootEntity() throws Exception{
- absenceOfField( "model.LivingBeing_", "nonPersistent", "eplicit access type on mapped superclass" );
- absenceOfField( "model.Hominidae_", "nonPersistent", "eplicit access type on entity" );
- absenceOfField( "model.Human_", "nonPersistent", "proper inheritance from root entity access type" );
- }
-
- @Test
- public void testMemberAccessType() throws Exception{
- presenceOfField( "model.Customer_", "goodPayer", "access type overriding" );
- }
-
- private void absenceOfField(String className, String fieldName) throws ClassNotFoundException {
- absenceOfField( className, fieldName, "field should not be persistent" );
- }
- private void absenceOfField(String className, String fieldName, String errorString) throws ClassNotFoundException {
- Assert.assertFalse( isFieldHere(className, fieldName), errorString );
- }
-
- private void presenceOfField(String className, String fieldName, String errorString) throws ClassNotFoundException {
- Assert.assertTrue( isFieldHere(className, fieldName), errorString );
- }
-
- private boolean isFieldHere(String className, String fieldName) throws ClassNotFoundException {
- Class> user_ = Class.forName( className );
- try {
- user_.getField( fieldName );
- return true;
- }
- catch (NoSuchFieldException e) {
- return false;
- }
- }
-}
diff --git a/tooling/metamodel-generator/src/test/java/test/QueryTest.java b/tooling/metamodel-generator/src/test/java/test/QueryTest.java
deleted file mode 100644
index 324b02f281..0000000000
--- a/tooling/metamodel-generator/src/test/java/test/QueryTest.java
+++ /dev/null
@@ -1,166 +0,0 @@
-// $Id$
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, Red Hat Middleware LLC, and individual contributors
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-* http://www.apache.org/licenses/LICENSE-2.0
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package test;
-
-import java.math.BigDecimal;
-import java.util.Date;
-import java.util.Set;
-import javax.persistence.Tuple;
-import javax.persistence.criteria.CriteriaBuilder;
-import javax.persistence.criteria.CriteriaQuery;
-import javax.persistence.criteria.Expression;
-import javax.persistence.criteria.Join;
-import static javax.persistence.criteria.JoinType.INNER;
-import javax.persistence.criteria.ListJoin;
-import javax.persistence.criteria.Path;
-import javax.persistence.criteria.Root;
-
-import model.Item;
-import model.Item_;
-import model.Order;
-import model.Order_;
-import model.Product;
-import model.Product_;
-import model.Shop_;
-
-/**
- * Writing queries involves passing typesafe, statically cached, metamodel
- * objects to the query builder in order to create the various parts of
- * the query. The typesafe metamodel objects were validated at init time,
- * so it is impossible to build invalid queries in the application code.
- *
- * @author Max Andersen
- * @author Hardy Ferentschik
- * @author Emmanuel Bernard
- */
-public class QueryTest {
-
- CriteriaBuilder qb;
-
- public void test() {
- CriteriaQuery q = qb.createTupleQuery();
-
- Root order = q.from( Order.class );
- Join- product = order.join( Order_.items )
- .join( Item_.product );
-
- Path price = product.get( Product_.price );
- Path filled = order.get( Order_.filled );
- Path date = order.get( Order_.date );
-
- q.select( qb.tuple( order, product ) )
- .where( qb.and( qb.gt( price, 100.00 ), qb.not( filled ) ) )
- .orderBy( qb.asc( price ), qb.desc( date ) );
- }
-
- public void testUntypesafe() {
- CriteriaQuery q = qb.createTupleQuery();
-
- Root order = q.from( Order.class );
- Join
- product = order.join( "items" )
- .join( "product" );
-
- Path price = product.get( "price" );
- Path filled = order.get( "filled" );
- Path date = order.get( "date" );
-
- q.select( qb.tuple( order, product ) )
- .where( qb.and( qb.gt( price, 100.00 ), qb.not( filled ) ) )
- .orderBy( qb.asc( price ), qb.desc( date ) );
- }
-
- /**
- * Navigation by joining
- */
- public void test2() {
- CriteriaQuery q = qb.createQuery( Product.class );
-
- Root product = q.from( Product.class );
- Join
- order = product.join( Product_.items )
- .join( Item_.order );
-
- q.select( product )
- .where( qb.equal( order.get( Order_.id ), 12345l ) );
- }
-
- public void testMap() {
- CriteriaQuery
- q = qb.createQuery( Item.class );
-
- Root
- item = q.from( Item.class );
- item.join( Item_.namedOrders );
- }
-
- /**
- * Navigation by compound Path
- */
- public void test3() {
- CriteriaQuery
- q = qb.createQuery( Item.class );
-
- Root
- item = q.from( Item.class );
- Path shopName = item.get( Item_.order )
- .get( Order_.shop )
- .get( Shop_.name );
- q.select( item )
- .where( qb.equal( shopName, "amazon.com" ) );
- }
-
-// public void test4() {
-// CriteriaQuery q = qb.create();
-//
-// Root order = q.from(Order.class);
-// ListJoin note = order.join(Order_.notes);
-// Expression> items = order.get(Order_.items);
-// order.fetch(Order_.items, JoinType.INNER);
-//
-// q.select(note)
-// .where( qb.and( qb.lt(note.index(), 10), qb.isNotEmpty(items) ) );
-// }
-
- public void test4Untypesafe() {
- CriteriaQuery q = qb.createQuery( String.class );
-
- Root order = q.from( Order.class );
- ListJoin note = order.joinList( "notes" );
- Expression> items = order.get( "items" );
- order.fetch( "items", INNER );
-
- q.select( note )
- .where( qb.and( qb.lt( note.index(), 10 ), qb.isNotEmpty( items ) ) );
- }
-
- /*public void test5() {
- Expression l= null;
- Expression i= null;
- Expression x= null;
- Expression y= null;
-
- Expression n;
- Expression f;
- Expression s = null;
-
- n = qb.quot(l, i);
-
- f = qb.sum(x, y);
-
- n = qb.quot(x, y);
-
- javax.jpamodelgen.criteria.Order o = qb.asc(n);
- javax.jpamodelgen.criteria.Order p = qb.ascending(s);
- }*/
-
-}
diff --git a/tooling/metamodel-generator/src/test/resources/META-INF/dummy.xml b/tooling/metamodel-generator/src/test/resources/META-INF/dummy.xml
index 289c09d9ec..ee6200eb36 100644
--- a/tooling/metamodel-generator/src/test/resources/META-INF/dummy.xml
+++ b/tooling/metamodel-generator/src/test/resources/META-INF/dummy.xml
@@ -5,7 +5,7 @@
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm orm_2_0.xsd"
version="2.0"
>
- model
+ org.hibernate.jpamodelgen.test.model
diff --git a/tooling/metamodel-generator/src/test/resources/META-INF/jpa1-orm.xml b/tooling/metamodel-generator/src/test/resources/META-INF/jpa1-orm.xml
index 3d2d93046b..6c7d4a0e98 100644
--- a/tooling/metamodel-generator/src/test/resources/META-INF/jpa1-orm.xml
+++ b/tooling/metamodel-generator/src/test/resources/META-INF/jpa1-orm.xml
@@ -5,7 +5,7 @@
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm orm_1_0.xsd"
version="1.0"
>
- model
+ org.hibernate.jpamodelgen.test.model
diff --git a/tooling/metamodel-generator/src/test/resources/META-INF/malformed-mapping-xml.xml b/tooling/metamodel-generator/src/test/resources/META-INF/malformed-mapping-xml.xml
index 26e679f6f1..aa1222bfea 100644
--- a/tooling/metamodel-generator/src/test/resources/META-INF/malformed-mapping-xml.xml
+++ b/tooling/metamodel-generator/src/test/resources/META-INF/malformed-mapping-xml.xml
@@ -5,7 +5,7 @@
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm orm_2_0.xsd"
version="2.0"
>
- model
+ org.hibernate.jpamodelgen.test.model
diff --git a/tooling/metamodel-generator/src/test/resources/META-INF/orm.xml b/tooling/metamodel-generator/src/test/resources/META-INF/orm.xml
index 3ec7df5579..9b504d313f 100644
--- a/tooling/metamodel-generator/src/test/resources/META-INF/orm.xml
+++ b/tooling/metamodel-generator/src/test/resources/META-INF/orm.xml
@@ -5,7 +5,7 @@
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm orm_2_0.xsd"
version="2.0"
>
- model
+ org.hibernate.jpamodelgen.test.accesstype
@@ -16,7 +16,7 @@
diff --git a/tooling/metamodel-generator/src/test/resources/META-INF/persistence.xml b/tooling/metamodel-generator/src/test/resources/META-INF/persistence.xml
index 3b120d9ad4..f628a575cc 100644
--- a/tooling/metamodel-generator/src/test/resources/META-INF/persistence.xml
+++ b/tooling/metamodel-generator/src/test/resources/META-INF/persistence.xml
@@ -7,8 +7,8 @@
/META-INF/dummy.xml
/META-INF/malformed-mapping-xml.xml
/META-INF/jpa1-orm.xml
- /model/xmlmapped/address.xml
- /model/xmlmapped/building.xml
- /model/xmlmapped/mammal.xml
+ /org/hibernate/jpamodelgen/test/xmlmapped/address.xml
+ /org/hibernate/jpamodelgen/test/xmlmapped/building.xml
+ /org/hibernate/jpamodelgen/test/xmlmapped/mammal.xml
diff --git a/tooling/metamodel-generator/src/test/resources/model/xmlmapped/address.xml b/tooling/metamodel-generator/src/test/resources/org/hibernate/jpamodelgen/test/xmlmapped/address.xml
similarity index 87%
rename from tooling/metamodel-generator/src/test/resources/model/xmlmapped/address.xml
rename to tooling/metamodel-generator/src/test/resources/org/hibernate/jpamodelgen/test/xmlmapped/address.xml
index 3688245ff3..0d60e50920 100644
--- a/tooling/metamodel-generator/src/test/resources/model/xmlmapped/address.xml
+++ b/tooling/metamodel-generator/src/test/resources/org/hibernate/jpamodelgen/test/xmlmapped/address.xml
@@ -5,7 +5,7 @@
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm orm_2_0.xsd"
version="2.0"
>
- model.xmlmapped
+ org.hibernate.jpamodelgen.test.xmlmapped
diff --git a/tooling/metamodel-generator/src/test/resources/model/xmlmapped/building.xml b/tooling/metamodel-generator/src/test/resources/org/hibernate/jpamodelgen/test/xmlmapped/building.xml
similarity index 89%
rename from tooling/metamodel-generator/src/test/resources/model/xmlmapped/building.xml
rename to tooling/metamodel-generator/src/test/resources/org/hibernate/jpamodelgen/test/xmlmapped/building.xml
index e112bef012..bc3e0edec3 100644
--- a/tooling/metamodel-generator/src/test/resources/model/xmlmapped/building.xml
+++ b/tooling/metamodel-generator/src/test/resources/org/hibernate/jpamodelgen/test/xmlmapped/building.xml
@@ -5,7 +5,7 @@
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm orm_2_0.xsd"
version="2.0"
>
- model.xmlmapped
+ org.hibernate.jpamodelgen.test.xmlmapped
diff --git a/tooling/metamodel-generator/src/test/resources/model/xmlmapped/mammal.xml b/tooling/metamodel-generator/src/test/resources/org/hibernate/jpamodelgen/test/xmlmapped/mammal.xml
similarity index 91%
rename from tooling/metamodel-generator/src/test/resources/model/xmlmapped/mammal.xml
rename to tooling/metamodel-generator/src/test/resources/org/hibernate/jpamodelgen/test/xmlmapped/mammal.xml
index 3024096ea0..57216ccd1c 100644
--- a/tooling/metamodel-generator/src/test/resources/model/xmlmapped/mammal.xml
+++ b/tooling/metamodel-generator/src/test/resources/org/hibernate/jpamodelgen/test/xmlmapped/mammal.xml
@@ -5,7 +5,7 @@
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm orm_2_0.xsd"
version="2.0"
>
- model.xmlmapped
+ org.hibernate.jpamodelgen.test.xmlmapped
diff --git a/tooling/metamodel-generator/src/test/suite/unit-tests.xml b/tooling/metamodel-generator/src/test/suite/unit-tests.xml
index b63742033e..c584a6eda6 100644
--- a/tooling/metamodel-generator/src/test/suite/unit-tests.xml
+++ b/tooling/metamodel-generator/src/test/suite/unit-tests.xml
@@ -3,7 +3,9 @@
-
+
+
+
\ No newline at end of file