From bdd8d49b6ac3c75ea3483d7f1f187cc1c71ab949 Mon Sep 17 00:00:00 2001 From: Hardy Ferentschik Date: Fri, 3 Aug 2012 13:19:57 +0200 Subject: [PATCH] HHH-7500 Using BaseAnnotationBindingTest as base for the test. This way @FailureExpectedWithNewMetamodel takes effect --- .../idmanytoone/alphabetical/A.java | 27 +++++++- .../idmanytoone/alphabetical/Acces.java | 25 +++++++- .../AlphabeticalIdManyToOneTest.java | 17 +++--- .../AlphabeticalManyToOneTest.java | 22 +++---- .../idmanytoone/alphabetical/B.java | 27 +++++++- .../idmanytoone/alphabetical/BId.java | 61 ++++++++++++++----- .../idmanytoone/alphabetical/Benefserv.java | 25 +++++++- .../idmanytoone/alphabetical/C.java | 29 ++++++++- .../idmanytoone/alphabetical/CId.java | 55 +++++++++++++---- .../idmanytoone/alphabetical/Droitacces.java | 25 +++++++- .../idmanytoone/alphabetical/Service.java | 29 ++++++++- 11 files changed, 279 insertions(+), 63 deletions(-) diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/idmanytoone/alphabetical/A.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/idmanytoone/alphabetical/A.java index 4af8841668..01347bbb9a 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/idmanytoone/alphabetical/A.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/idmanytoone/alphabetical/A.java @@ -1,5 +1,28 @@ -//$ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2008, Red Hat Inc. or third-party contributors as + * indicated by the @author tags or express copyright attribution + * statements applied by the authors. All third-party contributions are + * distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, modify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this distribution; if not, write to: + * Free Software Foundation, Inc. + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301 USA + */ package org.hibernate.test.annotations.idmanytoone.alphabetical; + import java.util.List; import javax.persistence.Entity; import javax.persistence.Id; @@ -11,7 +34,7 @@ public class A { @Id private int id; - @OneToMany( mappedBy = "parent" ) + @OneToMany(mappedBy = "parent") List children; public A() { diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/idmanytoone/alphabetical/Acces.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/idmanytoone/alphabetical/Acces.java index 8716d1f0ee..30b1a6aeb1 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/idmanytoone/alphabetical/Acces.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/idmanytoone/alphabetical/Acces.java @@ -1,5 +1,28 @@ -//$ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2008, Red Hat Inc. or third-party contributors as + * indicated by the @author tags or express copyright attribution + * statements applied by the authors. All third-party contributions are + * distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, modify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this distribution; if not, write to: + * Free Software Foundation, Inc. + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301 USA + */ package org.hibernate.test.annotations.idmanytoone.alphabetical; + import java.io.Serializable; import java.math.BigInteger; import javax.persistence.Entity; diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/idmanytoone/alphabetical/AlphabeticalIdManyToOneTest.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/idmanytoone/alphabetical/AlphabeticalIdManyToOneTest.java index b33f3aedab..76f4774c01 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/idmanytoone/alphabetical/AlphabeticalIdManyToOneTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/idmanytoone/alphabetical/AlphabeticalIdManyToOneTest.java @@ -26,20 +26,21 @@ package org.hibernate.test.annotations.idmanytoone.alphabetical; import org.junit.Test; import org.hibernate.testing.FailureExpectedWithNewMetamodel; -import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; +import org.hibernate.testing.junit4.BaseAnnotationBindingTestCase; +import org.hibernate.testing.junit4.Resources; + +import static junit.framework.Assert.assertNotNull; /** * @author Emmanuel Bernard */ @FailureExpectedWithNewMetamodel -public class AlphabeticalIdManyToOneTest extends BaseCoreFunctionalTestCase { +public class AlphabeticalIdManyToOneTest extends BaseAnnotationBindingTestCase { @Test + @Resources(annotatedClasses = { B.class, C.class, A.class }) public void testAlphabeticalTest() throws Exception { - //test through deployment - } - - @Override - protected Class[] getAnnotatedClasses() { - return new Class[] { B.class, C.class, A.class }; + for ( Class annotatedClass : getAnnotatedClasses() ) { + assertNotNull( "The Binding for A should exist", getEntityBinding( annotatedClass ) ); + } } } diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/idmanytoone/alphabetical/AlphabeticalManyToOneTest.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/idmanytoone/alphabetical/AlphabeticalManyToOneTest.java index e7090333a2..876aafe124 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/idmanytoone/alphabetical/AlphabeticalManyToOneTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/idmanytoone/alphabetical/AlphabeticalManyToOneTest.java @@ -25,24 +25,20 @@ package org.hibernate.test.annotations.idmanytoone.alphabetical; import org.junit.Test; -import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; +import org.hibernate.testing.junit4.BaseAnnotationBindingTestCase; +import org.hibernate.testing.junit4.Resources; + +import static junit.framework.Assert.assertNotNull; /** * @author Emmanuel Bernard */ -public class AlphabeticalManyToOneTest extends BaseCoreFunctionalTestCase { +public class AlphabeticalManyToOneTest extends BaseAnnotationBindingTestCase { @Test + @Resources(annotatedClasses = { Acces.class, Droitacces.class, Benefserv.class, Service.class }) public void testAlphabeticalTest() throws Exception { - //test through deployment - } - - @Override - protected Class[] getAnnotatedClasses() { - return new Class[] { - Acces.class, - Droitacces.class, - Benefserv.class, - Service.class - }; + for ( Class annotatedClass : getAnnotatedClasses() ) { + assertNotNull( "The Binding for A should exist", getEntityBinding( annotatedClass ) ); + } } } diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/idmanytoone/alphabetical/B.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/idmanytoone/alphabetical/B.java index c8a1ec99f2..5de913559e 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/idmanytoone/alphabetical/B.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/idmanytoone/alphabetical/B.java @@ -1,11 +1,34 @@ -//$ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2008, Red Hat Inc. or third-party contributors as + * indicated by the @author tags or express copyright attribution + * statements applied by the authors. All third-party contributions are + * distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, modify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this distribution; if not, write to: + * Free Software Foundation, Inc. + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301 USA + */ package org.hibernate.test.annotations.idmanytoone.alphabetical; + import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.IdClass; @Entity -@IdClass( BId.class ) +@IdClass(BId.class) public class B { @Id diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/idmanytoone/alphabetical/BId.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/idmanytoone/alphabetical/BId.java index 82a534faa0..8e78625e19 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/idmanytoone/alphabetical/BId.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/idmanytoone/alphabetical/BId.java @@ -1,5 +1,28 @@ -//$ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2008, Red Hat Inc. or third-party contributors as + * indicated by the @author tags or express copyright attribution + * statements applied by the authors. All third-party contributions are + * distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, modify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this distribution; if not, write to: + * Free Software Foundation, Inc. + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301 USA + */ package org.hibernate.test.annotations.idmanytoone.alphabetical; + import java.io.Serializable; import javax.persistence.Embeddable; import javax.persistence.JoinColumn; @@ -10,10 +33,10 @@ import javax.persistence.ManyToOne; public class BId implements Serializable { @ManyToOne - @JoinColumns( { - @JoinColumn( name = "aId", nullable = false ), - @JoinColumn( name = "bSequenceNumber", nullable = false ) - } ) + @JoinColumns({ + @JoinColumn(name = "aId", nullable = false), + @JoinColumn(name = "bSequenceNumber", nullable = false) + }) private C parent; private int sequenceNumber; @@ -48,21 +71,27 @@ public class BId implements Serializable { @Override public boolean equals(Object obj) { - if ( this == obj ) + if ( this == obj ) { return true; - if ( obj == null ) - return false; - if ( getClass() != obj.getClass() ) - return false; - final BId other = (BId) obj; - if ( parent == null ) { - if ( other.parent != null ) - return false; } - else if ( !parent.equals( other.parent ) ) + if ( obj == null ) { return false; - if ( sequenceNumber != other.sequenceNumber ) + } + if ( getClass() != obj.getClass() ) { return false; + } + final BId other = ( BId ) obj; + if ( parent == null ) { + if ( other.parent != null ) { + return false; + } + } + else if ( !parent.equals( other.parent ) ) { + return false; + } + if ( sequenceNumber != other.sequenceNumber ) { + return false; + } return true; } } diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/idmanytoone/alphabetical/Benefserv.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/idmanytoone/alphabetical/Benefserv.java index f828cea7eb..20a9701c19 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/idmanytoone/alphabetical/Benefserv.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/idmanytoone/alphabetical/Benefserv.java @@ -1,5 +1,28 @@ -//$ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2008, Red Hat Inc. or third-party contributors as + * indicated by the @author tags or express copyright attribution + * statements applied by the authors. All third-party contributions are + * distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, modify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this distribution; if not, write to: + * Free Software Foundation, Inc. + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301 USA + */ package org.hibernate.test.annotations.idmanytoone.alphabetical; + import java.math.BigInteger; import javax.persistence.Entity; import javax.persistence.Id; diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/idmanytoone/alphabetical/C.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/idmanytoone/alphabetical/C.java index dcfc3f407b..f55f62288b 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/idmanytoone/alphabetical/C.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/idmanytoone/alphabetical/C.java @@ -1,5 +1,28 @@ -//$ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2008, Red Hat Inc. or third-party contributors as + * indicated by the @author tags or express copyright attribution + * statements applied by the authors. All third-party contributions are + * distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, modify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this distribution; if not, write to: + * Free Software Foundation, Inc. + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301 USA + */ package org.hibernate.test.annotations.idmanytoone.alphabetical; + import java.util.List; import javax.persistence.Entity; import javax.persistence.Id; @@ -7,7 +30,7 @@ import javax.persistence.IdClass; import javax.persistence.OneToMany; @Entity -@IdClass( CId.class ) +@IdClass(CId.class) public class C { @Id @@ -16,7 +39,7 @@ public class C { @Id private int sequenceNumber; - @OneToMany( mappedBy = "parent" ) + @OneToMany(mappedBy = "parent") List children; public C() { diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/idmanytoone/alphabetical/CId.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/idmanytoone/alphabetical/CId.java index 47ad0926ea..1906c6ef45 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/idmanytoone/alphabetical/CId.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/idmanytoone/alphabetical/CId.java @@ -1,5 +1,28 @@ -//$ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2008, Red Hat Inc. or third-party contributors as + * indicated by the @author tags or express copyright attribution + * statements applied by the authors. All third-party contributions are + * distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, modify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this distribution; if not, write to: + * Free Software Foundation, Inc. + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301 USA + */ package org.hibernate.test.annotations.idmanytoone.alphabetical; + import java.io.Serializable; import javax.persistence.Embeddable; import javax.persistence.JoinColumn; @@ -9,7 +32,7 @@ import javax.persistence.ManyToOne; public class CId implements Serializable { @ManyToOne - @JoinColumn( name = "aId", nullable = false ) + @JoinColumn(name = "aId", nullable = false) private A parent; private int sequenceNumber; @@ -44,21 +67,27 @@ public class CId implements Serializable { @Override public boolean equals(Object obj) { - if ( this == obj ) + if ( this == obj ) { return true; - if ( obj == null ) - return false; - if ( getClass() != obj.getClass() ) - return false; - final CId other = (CId) obj; - if ( parent == null ) { - if ( other.parent != null ) - return false; } - else if ( !parent.equals( other.parent ) ) + if ( obj == null ) { return false; - if ( sequenceNumber != other.sequenceNumber ) + } + if ( getClass() != obj.getClass() ) { return false; + } + final CId other = ( CId ) obj; + if ( parent == null ) { + if ( other.parent != null ) { + return false; + } + } + else if ( !parent.equals( other.parent ) ) { + return false; + } + if ( sequenceNumber != other.sequenceNumber ) { + return false; + } return true; } diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/idmanytoone/alphabetical/Droitacces.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/idmanytoone/alphabetical/Droitacces.java index b77d1425c8..9ebbf0e73c 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/idmanytoone/alphabetical/Droitacces.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/idmanytoone/alphabetical/Droitacces.java @@ -1,5 +1,28 @@ -//$ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2008, Red Hat Inc. or third-party contributors as + * indicated by the @author tags or express copyright attribution + * statements applied by the authors. All third-party contributions are + * distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, modify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this distribution; if not, write to: + * Free Software Foundation, Inc. + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301 USA + */ package org.hibernate.test.annotations.idmanytoone.alphabetical; + import java.math.BigInteger; import javax.persistence.Entity; import javax.persistence.Id; diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/idmanytoone/alphabetical/Service.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/idmanytoone/alphabetical/Service.java index 890a04c995..6e51181272 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/idmanytoone/alphabetical/Service.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/idmanytoone/alphabetical/Service.java @@ -1,5 +1,28 @@ -//$ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2008, Red Hat Inc. or third-party contributors as + * indicated by the @author tags or express copyright attribution + * statements applied by the authors. All third-party contributions are + * distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, modify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this distribution; if not, write to: + * Free Software Foundation, Inc. + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301 USA + */ package org.hibernate.test.annotations.idmanytoone.alphabetical; + import java.math.BigInteger; import javax.persistence.Entity; import javax.persistence.Id; @@ -7,6 +30,6 @@ import javax.persistence.Id; @Entity public class Service { - @Id - private BigInteger idpk; + @Id + private BigInteger idpk; }