HHH-7500 Moving BaseAnnotationBindingTest into the testing module. This way it can be reused by other annotation based tests

This commit is contained in:
Hardy Ferentschik 2012-08-03 13:18:37 +02:00
parent f79001e675
commit 39f509e886
25 changed files with 59 additions and 12 deletions

View File

@ -34,6 +34,8 @@ import org.junit.Test;
import org.hibernate.AnnotationException;
import org.hibernate.metamodel.spi.binding.EntityBinding;
import org.hibernate.testing.junit4.BaseAnnotationBindingTestCase;
import org.hibernate.testing.junit4.Resources;
import static junit.framework.Assert.assertEquals;

View File

@ -30,6 +30,8 @@ import org.junit.Test;
import org.hibernate.annotations.BatchSize;
import org.hibernate.metamodel.spi.binding.EntityBinding;
import org.hibernate.testing.junit4.BaseAnnotationBindingTestCase;
import org.hibernate.testing.junit4.Resources;
import static junit.framework.Assert.assertEquals;

View File

@ -35,6 +35,8 @@ import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.cache.spi.access.AccessType;
import org.hibernate.metamodel.spi.binding.Caching;
import org.hibernate.metamodel.spi.binding.EntityBinding;
import org.hibernate.testing.junit4.BaseAnnotationBindingTestCase;
import org.hibernate.testing.junit4.Resources;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNotNull;

View File

@ -36,6 +36,8 @@ import org.hibernate.annotations.SQLUpdate;
import org.hibernate.engine.spi.ExecuteUpdateResultCheckStyle;
import org.hibernate.metamodel.spi.binding.CustomSQL;
import org.hibernate.metamodel.spi.binding.EntityBinding;
import org.hibernate.testing.junit4.BaseAnnotationBindingTestCase;
import org.hibernate.testing.junit4.Resources;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNotNull;

View File

@ -36,6 +36,8 @@ import org.hibernate.annotations.Target;
import org.hibernate.metamodel.spi.binding.BasicAttributeBinding;
import org.hibernate.metamodel.spi.binding.CompositeAttributeBinding;
import org.hibernate.metamodel.spi.binding.EntityBinding;
import org.hibernate.testing.junit4.BaseAnnotationBindingTestCase;
import org.hibernate.testing.junit4.Resources;
import org.junit.Test;

View File

@ -34,6 +34,8 @@ import org.junit.Test;
import org.hibernate.metamodel.spi.binding.EntityBinding;
import org.hibernate.metamodel.spi.binding.EntityIdentifier;
import org.hibernate.testing.junit4.BaseAnnotationBindingTestCase;
import org.hibernate.testing.junit4.Resources;
import static junit.framework.Assert.assertTrue;

View File

@ -38,6 +38,8 @@ import org.junit.Test;
import org.hibernate.metamodel.spi.binding.AttributeBinding;
import org.hibernate.metamodel.spi.binding.EntityBinding;
import org.hibernate.metamodel.spi.binding.HibernateTypeDescriptor;
import org.hibernate.testing.junit4.BaseAnnotationBindingTestCase;
import org.hibernate.testing.junit4.Resources;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;

View File

@ -44,7 +44,8 @@ import org.hibernate.metamodel.spi.binding.EntityIdentifier;
import org.hibernate.metamodel.spi.source.MappingException;
import org.hibernate.service.ServiceRegistryBuilder;
import org.hibernate.testing.FailureExpected;
import org.hibernate.testing.junit4.BaseAnnotationBindingTestCase;
import org.hibernate.testing.junit4.Resources;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertFalse;

View File

@ -42,6 +42,8 @@ import org.hibernate.metamodel.spi.binding.EntityBinding;
import org.hibernate.metamodel.spi.binding.EntityDiscriminator;
import org.hibernate.metamodel.spi.relational.DerivedValue;
import org.hibernate.metamodel.spi.relational.Value;
import org.hibernate.testing.junit4.BaseAnnotationBindingTestCase;
import org.hibernate.testing.junit4.Resources;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertFalse;

View File

@ -36,6 +36,8 @@ import org.junit.Test;
import org.hibernate.metamodel.spi.binding.AttributeBinding;
import org.hibernate.metamodel.spi.binding.EntityBinding;
import org.hibernate.metamodel.spi.binding.HibernateTypeDescriptor;
import org.hibernate.testing.junit4.BaseAnnotationBindingTestCase;
import org.hibernate.testing.junit4.Resources;
import org.hibernate.type.BlobType;
import org.hibernate.type.CharacterArrayClobType;
import org.hibernate.type.ClobType;

View File

@ -34,6 +34,8 @@ import org.junit.Test;
import org.hibernate.metamodel.spi.binding.EntityBinding;
import org.hibernate.metamodel.spi.binding.SingularAttributeBinding;
import org.hibernate.metamodel.spi.relational.Column;
import org.hibernate.testing.junit4.BaseAnnotationBindingTestCase;
import org.hibernate.testing.junit4.Resources;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNotNull;

View File

@ -35,6 +35,8 @@ import org.junit.Test;
import org.hibernate.metamodel.MetadataSources;
import org.hibernate.metamodel.spi.source.MappingException;
import org.hibernate.service.ServiceRegistryBuilder;
import org.hibernate.testing.junit4.BaseAnnotationBindingTestCase;
import org.hibernate.testing.junit4.Resources;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertTrue;

View File

@ -18,6 +18,8 @@ import org.hibernate.metamodel.spi.binding.RelationalValueBinding;
import org.hibernate.metamodel.spi.binding.SingularAttributeBinding;
import org.hibernate.metamodel.spi.relational.Column;
import org.hibernate.metamodel.spi.relational.UniqueKey;
import org.hibernate.testing.junit4.BaseAnnotationBindingTestCase;
import org.hibernate.testing.junit4.Resources;
/**
* @author Strong Liu <stliu@hibernate.org>

View File

@ -30,6 +30,8 @@ import org.junit.Test;
import org.hibernate.annotations.Proxy;
import org.hibernate.metamodel.spi.binding.EntityBinding;
import org.hibernate.testing.junit4.BaseAnnotationBindingTestCase;
import org.hibernate.testing.junit4.Resources;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertFalse;

View File

@ -32,6 +32,8 @@ import org.junit.Test;
import org.hibernate.metamodel.spi.binding.EntityBinding;
import org.hibernate.metamodel.spi.relational.Identifier;
import org.hibernate.testing.junit4.BaseAnnotationBindingTestCase;
import org.hibernate.testing.junit4.Resources;
import static org.junit.Assert.assertEquals;

View File

@ -30,6 +30,8 @@ import org.junit.Test;
import org.hibernate.annotations.RowId;
import org.hibernate.metamodel.spi.binding.EntityBinding;
import org.hibernate.testing.junit4.BaseAnnotationBindingTestCase;
import org.hibernate.testing.junit4.Resources;
import static junit.framework.Assert.assertEquals;

View File

@ -35,6 +35,8 @@ import org.hibernate.metamodel.spi.binding.EntityBinding;
import org.hibernate.metamodel.spi.binding.RelationalValueBinding;
import org.hibernate.metamodel.spi.relational.ForeignKey;
import org.hibernate.metamodel.spi.relational.Table;
import org.hibernate.testing.junit4.BaseAnnotationBindingTestCase;
import org.hibernate.testing.junit4.Resources;
import org.junit.Test;

View File

@ -31,6 +31,8 @@ import org.junit.Test;
import org.hibernate.annotations.Synchronize;
import org.hibernate.metamodel.spi.binding.EntityBinding;
import org.hibernate.testing.junit4.BaseAnnotationBindingTestCase;
import org.hibernate.testing.junit4.Resources;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertTrue;

View File

@ -33,6 +33,8 @@ import org.junit.Test;
import org.hibernate.metamodel.spi.binding.EntityBinding;
import org.hibernate.metamodel.spi.binding.InheritanceType;
import org.hibernate.testing.junit4.BaseAnnotationBindingTestCase;
import org.hibernate.testing.junit4.Resources;
import static junit.framework.Assert.assertEquals;

View File

@ -35,6 +35,8 @@ import org.hibernate.AnnotationException;
import org.hibernate.metamodel.spi.binding.AttributeBinding;
import org.hibernate.metamodel.spi.binding.EntityBinding;
import org.hibernate.metamodel.spi.binding.HibernateTypeDescriptor;
import org.hibernate.testing.junit4.BaseAnnotationBindingTestCase;
import org.hibernate.testing.junit4.Resources;
import org.hibernate.type.TimestampType;
import static org.junit.Assert.assertEquals;

View File

@ -32,9 +32,10 @@ import javax.persistence.UniqueConstraint;
import org.junit.Test;
import org.hibernate.metamodel.spi.binding.EntityBinding;
import org.hibernate.metamodel.spi.relational.Column;
import org.hibernate.metamodel.spi.relational.TableSpecification;
import org.hibernate.metamodel.spi.relational.UniqueKey;
import org.hibernate.testing.junit4.BaseAnnotationBindingTestCase;
import org.hibernate.testing.junit4.Resources;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNotNull;

View File

@ -26,21 +26,18 @@ package org.hibernate.metamodel.internal.source.annotations.entity;
import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Version;
import org.junit.Test;
import org.hibernate.AnnotationException;
import org.hibernate.annotations.Source;
import org.hibernate.annotations.SourceType;
import org.hibernate.metamodel.spi.binding.AttributeBinding;
import org.hibernate.metamodel.spi.binding.EntityBinding;
import org.hibernate.metamodel.spi.binding.HibernateTypeDescriptor;
import org.hibernate.testing.junit4.BaseAnnotationBindingTestCase;
import org.hibernate.testing.junit4.Resources;
import org.hibernate.type.DbTimestampType;
import org.hibernate.type.LongType;
import org.hibernate.type.TimestampType;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;

View File

@ -7,6 +7,8 @@ import org.junit.Test;
import org.hibernate.annotations.Where;
import org.hibernate.metamodel.spi.binding.EntityBinding;
import org.hibernate.testing.junit4.BaseAnnotationBindingTestCase;
import org.hibernate.testing.junit4.Resources;
import static junit.framework.Assert.assertEquals;

View File

@ -21,7 +21,10 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.internal.source.annotations.entity;
package org.hibernate.testing.junit4;
import java.util.ArrayList;
import java.util.List;
import org.junit.After;
import org.junit.Rule;
@ -31,10 +34,9 @@ import org.junit.runners.model.FrameworkMethod;
import org.junit.runners.model.Statement;
import org.hibernate.metamodel.MetadataSources;
import org.hibernate.metamodel.spi.binding.EntityBinding;
import org.hibernate.metamodel.internal.MetadataImpl;
import org.hibernate.metamodel.spi.binding.EntityBinding;
import org.hibernate.service.ServiceRegistryBuilder;
import org.hibernate.testing.junit4.BaseUnitTestCase;
/**
* @author Hardy Ferentschik
@ -42,6 +44,7 @@ import org.hibernate.testing.junit4.BaseUnitTestCase;
public abstract class BaseAnnotationBindingTestCase extends BaseUnitTestCase {
protected MetadataSources sources;
protected MetadataImpl meta;
protected List<Class<?>> annotatedClasses = new ArrayList<Class<?>>();
@Rule
public MethodRule buildMetaData = new MethodRule() {
@ -65,6 +68,10 @@ public abstract class BaseAnnotationBindingTestCase extends BaseUnitTestCase {
return meta.getRootEntityBinding( clazz.getName() );
}
public List<Class<?>> getAnnotatedClasses() {
return annotatedClasses;
}
class KeepSetupFailureStatement extends Statement {
private final Statement origStatement;
private final FrameworkMethod origFrameworkMethod;
@ -105,13 +112,14 @@ public abstract class BaseAnnotationBindingTestCase extends BaseUnitTestCase {
sources.getMetadataBuilder().with( resourcesAnnotation.cacheMode() );
for ( Class<?> annotatedClass : resourcesAnnotation.annotatedClasses() ) {
annotatedClasses.add( annotatedClass );
sources.addAnnotatedClass( annotatedClass );
}
if ( !resourcesAnnotation.ormXmlPath().isEmpty() ) {
sources.addResource( resourcesAnnotation.ormXmlPath() );
}
}
meta = (MetadataImpl) sources.buildMetadata();
meta = ( MetadataImpl ) sources.buildMetadata();
}
catch ( final Throwable t ) {
setupError = t;

View File

@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.internal.source.annotations.entity;
package org.hibernate.testing.junit4;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;