diff --git a/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/IdTest.java b/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/IdTest.java index 2fcde2de0d..4db7d7f7cb 100644 --- a/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/IdTest.java +++ b/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/IdTest.java @@ -1,10 +1,34 @@ //$Id$ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2010, 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.id.sequences; import org.hibernate.Session; import org.hibernate.Transaction; import org.hibernate.cfg.AnnotationConfiguration; import org.hibernate.cfg.Configuration; +import org.hibernate.junit.DialectChecks; import org.hibernate.junit.RequiresDialectFeature; import org.hibernate.mapping.Column; import org.hibernate.test.annotations.TestCase; @@ -30,7 +54,7 @@ * @author Emmanuel Bernard */ @SuppressWarnings("unchecked") -@RequiresDialectFeature("supportsSequences") +@RequiresDialectFeature(DialectChecks.SupportsSequences.class) public class IdTest extends TestCase { public void testGenericGenerator() throws Exception { Session s = openSession(); diff --git a/annotations/src/test/java/org/hibernate/test/annotations/lob/LobTest.java b/annotations/src/test/java/org/hibernate/test/annotations/lob/LobTest.java index f6b129c7ad..54f606837e 100644 --- a/annotations/src/test/java/org/hibernate/test/annotations/lob/LobTest.java +++ b/annotations/src/test/java/org/hibernate/test/annotations/lob/LobTest.java @@ -1,15 +1,39 @@ //$Id$ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2010, 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.lob; import org.hibernate.Session; import org.hibernate.Transaction; +import org.hibernate.junit.DialectChecks; import org.hibernate.junit.RequiresDialectFeature; import org.hibernate.test.annotations.TestCase; /** * @author Emmanuel Bernard */ -@RequiresDialectFeature("supportsExpectedLobUsagePattern") +@RequiresDialectFeature(DialectChecks.SupportsExpectedLobUsagePattern.class) public class LobTest extends TestCase { public void testSerializableToBlob() throws Exception { Book book = new Book(); diff --git a/annotations/src/test/java/org/hibernate/test/annotations/manytoone/referencedcolumnname/ManyToOneReferencedColumnNameTest.java b/annotations/src/test/java/org/hibernate/test/annotations/manytoone/referencedcolumnname/ManyToOneReferencedColumnNameTest.java index 56f4759c16..71b99d66b9 100644 --- a/annotations/src/test/java/org/hibernate/test/annotations/manytoone/referencedcolumnname/ManyToOneReferencedColumnNameTest.java +++ b/annotations/src/test/java/org/hibernate/test/annotations/manytoone/referencedcolumnname/ManyToOneReferencedColumnNameTest.java @@ -1,9 +1,33 @@ // $Id$ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2010, 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.manytoone.referencedcolumnname; import java.math.BigDecimal; import org.hibernate.Session; +import org.hibernate.junit.DialectChecks; import org.hibernate.junit.RequiresDialectFeature; import org.hibernate.test.annotations.TestCase; @@ -11,7 +35,7 @@ * @author Emmanuel Bernard */ public class ManyToOneReferencedColumnNameTest extends TestCase { - @RequiresDialectFeature("supportsIdentityColumns") + @RequiresDialectFeature(DialectChecks.SupportsIdentityColumns.class) public void testReoverableExceptionInFkOrdering() throws Exception { //SF should not blow up Vendor v = new Vendor(); @@ -34,7 +58,6 @@ public void testReoverableExceptionInFkOrdering() throws Exception { s.flush(); s.getTransaction().rollback(); s.close(); - } protected Class[] getAnnotatedClasses() { diff --git a/annotations/src/test/java/org/hibernate/test/annotations/xml/hbm/HbmWithIdentityTest.java b/annotations/src/test/java/org/hibernate/test/annotations/xml/hbm/HbmWithIdentityTest.java index fe4a185346..bc2c72643f 100644 --- a/annotations/src/test/java/org/hibernate/test/annotations/xml/hbm/HbmWithIdentityTest.java +++ b/annotations/src/test/java/org/hibernate/test/annotations/xml/hbm/HbmWithIdentityTest.java @@ -2,6 +2,7 @@ package org.hibernate.test.annotations.xml.hbm; import org.hibernate.Session; +import org.hibernate.junit.DialectChecks; import org.hibernate.junit.RequiresDialectFeature; import org.hibernate.test.annotations.TestCase; @@ -10,7 +11,7 @@ */ public class HbmWithIdentityTest extends TestCase { - @RequiresDialectFeature("supportsIdentityColumns") + @RequiresDialectFeature(DialectChecks.SupportsIdentityColumns.class) public void testManyToOneAndInterface() throws Exception { Session s = openSession(); s.getTransaction().begin(); diff --git a/testing/src/main/java/org/hibernate/junit/DialectChecks.java b/testing/src/main/java/org/hibernate/junit/DialectChecks.java new file mode 100644 index 0000000000..5d3dfbe5d7 --- /dev/null +++ b/testing/src/main/java/org/hibernate/junit/DialectChecks.java @@ -0,0 +1,59 @@ +// $Id$ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2010, 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.junit; + +import org.hibernate.dialect.Dialect; + +/** + * Container class for different implementation of the {@code DialectCheck} interface. + * + * @author Hardy Ferentschik + */ +abstract public class DialectChecks { + + abstract public boolean include(Dialect dialect); + + public static class SupportsSequences extends DialectChecks { + public boolean include(Dialect dialect) { + return dialect.supportsSequences(); + } + } + + public static class SupportsExpectedLobUsagePattern extends DialectChecks { + public boolean include(Dialect dialect) { + return dialect.supportsExpectedLobUsagePattern(); + } + } + + public static class SupportsIdentityColumns extends DialectChecks { + public boolean include(Dialect dialect) { + return dialect.supportsIdentityColumns(); + } + } + + +} + + diff --git a/testing/src/main/java/org/hibernate/junit/RequiresDialectFeature.java b/testing/src/main/java/org/hibernate/junit/RequiresDialectFeature.java index 42e71bad8d..17c99dd820 100644 --- a/testing/src/main/java/org/hibernate/junit/RequiresDialectFeature.java +++ b/testing/src/main/java/org/hibernate/junit/RequiresDialectFeature.java @@ -1,3 +1,4 @@ +// $Id$ /* * Hibernate, Relational Persistence for Idiomatic Java * @@ -40,5 +41,5 @@ /** * @return The name of the dialect feature. */ - String value(); + Class value(); } \ No newline at end of file diff --git a/testing/src/main/java/org/hibernate/test/annotations/HibernateTestCase.java b/testing/src/main/java/org/hibernate/test/annotations/HibernateTestCase.java index 3b28519bd8..7f868b7ae5 100644 --- a/testing/src/main/java/org/hibernate/test/annotations/HibernateTestCase.java +++ b/testing/src/main/java/org/hibernate/test/annotations/HibernateTestCase.java @@ -38,6 +38,7 @@ import org.hibernate.cfg.Configuration; import org.hibernate.dialect.Dialect; import org.hibernate.jdbc.Work; +import org.hibernate.junit.DialectChecks; import org.hibernate.junit.FailureExpected; import org.hibernate.junit.RequiresDialect; import org.hibernate.junit.RequiresDialectFeature; @@ -192,15 +193,9 @@ protected final Skip determineSkipByDialect(Dialect dialect, Method runMethod) t // then check against a dialect feature RequiresDialectFeature requiresDialectFeatureAnn = locateAnnotation( RequiresDialectFeature.class, runMethod ); if ( requiresDialectFeatureAnn != null ) { - String feature = requiresDialectFeatureAnn.value(); - boolean skip = false; - try { - Method m = dialect.getClass().getMethod( feature ); - skip = (Boolean) m.invoke( dialect ); - } - catch ( NoSuchMethodException e ) { - fail( "Dialect does not have a method: " + feature ); - } + Class checkClass = requiresDialectFeatureAnn.value(); + DialectChecks check = checkClass.newInstance(); + boolean skip = check.include( dialect ); if ( skip ) { return buildSkip( dialect, null, null ); }