[hibernate-commits] Hibernate SVN: r19406 - in core/trunk: annotations/src/test/java/org/hibernate/test/annotations/lob and 4 other directories.

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Fri May 7 11:13:09 EDT 2010


Author: hardy.ferentschik
Date: 2010-05-07 11:13:09 -0400 (Fri, 07 May 2010)
New Revision: 19406

Added:
   core/trunk/testing/src/main/java/org/hibernate/junit/DialectChecks.java
Modified:
   core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/IdTest.java
   core/trunk/annotations/src/test/java/org/hibernate/test/annotations/lob/LobTest.java
   core/trunk/annotations/src/test/java/org/hibernate/test/annotations/manytoone/referencedcolumnname/ManyToOneReferencedColumnNameTest.java
   core/trunk/annotations/src/test/java/org/hibernate/test/annotations/xml/hbm/HbmWithIdentityTest.java
   core/trunk/testing/src/main/java/org/hibernate/junit/RequiresDialectFeature.java
   core/trunk/testing/src/main/java/org/hibernate/test/annotations/HibernateTestCase.java
Log:
HHH-5204

Modified: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/IdTest.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/IdTest.java	2010-05-07 13:46:32 UTC (rev 19405)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/IdTest.java	2010-05-07 15:13:09 UTC (rev 19406)
@@ -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")
- at RequiresDialectFeature("supportsSequences")
+ at RequiresDialectFeature(DialectChecks.SupportsSequences.class)
 public class IdTest extends TestCase {
 	public void testGenericGenerator() throws Exception {
 		Session s = openSession();

Modified: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/lob/LobTest.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/lob/LobTest.java	2010-05-07 13:46:32 UTC (rev 19405)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/lob/LobTest.java	2010-05-07 15:13:09 UTC (rev 19406)
@@ -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
  */
- at RequiresDialectFeature("supportsExpectedLobUsagePattern")
+ at RequiresDialectFeature(DialectChecks.SupportsExpectedLobUsagePattern.class)
 public class LobTest extends TestCase {
 	public void testSerializableToBlob() throws Exception {
 		Book book = new Book();


Property changes on: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/lob/LobTest.java
___________________________________________________________________
Name: svn:keywords
   - Date Revision Author Id
   + Id

Modified: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/manytoone/referencedcolumnname/ManyToOneReferencedColumnNameTest.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/manytoone/referencedcolumnname/ManyToOneReferencedColumnNameTest.java	2010-05-07 13:46:32 UTC (rev 19405)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/manytoone/referencedcolumnname/ManyToOneReferencedColumnNameTest.java	2010-05-07 15:13:09 UTC (rev 19406)
@@ -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 @@
 		s.flush();
 		s.getTransaction().rollback();
 		s.close();
-
 	}
 
 	protected Class[] getAnnotatedClasses() {

Modified: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/xml/hbm/HbmWithIdentityTest.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/xml/hbm/HbmWithIdentityTest.java	2010-05-07 13:46:32 UTC (rev 19405)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/xml/hbm/HbmWithIdentityTest.java	2010-05-07 15:13:09 UTC (rev 19406)
@@ -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();

Added: core/trunk/testing/src/main/java/org/hibernate/junit/DialectChecks.java
===================================================================
--- core/trunk/testing/src/main/java/org/hibernate/junit/DialectChecks.java	                        (rev 0)
+++ core/trunk/testing/src/main/java/org/hibernate/junit/DialectChecks.java	2010-05-07 15:13:09 UTC (rev 19406)
@@ -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();
+		}
+	}
+
+
+}
+
+


Property changes on: core/trunk/testing/src/main/java/org/hibernate/junit/DialectChecks.java
___________________________________________________________________
Name: svn:keywords
   + Id

Modified: core/trunk/testing/src/main/java/org/hibernate/junit/RequiresDialectFeature.java
===================================================================
--- core/trunk/testing/src/main/java/org/hibernate/junit/RequiresDialectFeature.java	2010-05-07 13:46:32 UTC (rev 19405)
+++ core/trunk/testing/src/main/java/org/hibernate/junit/RequiresDialectFeature.java	2010-05-07 15:13:09 UTC (rev 19406)
@@ -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<? extends DialectChecks> value();
 }
\ No newline at end of file

Modified: core/trunk/testing/src/main/java/org/hibernate/test/annotations/HibernateTestCase.java
===================================================================
--- core/trunk/testing/src/main/java/org/hibernate/test/annotations/HibernateTestCase.java	2010-05-07 13:46:32 UTC (rev 19405)
+++ core/trunk/testing/src/main/java/org/hibernate/test/annotations/HibernateTestCase.java	2010-05-07 15:13:09 UTC (rev 19406)
@@ -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 @@
 		// 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<? extends DialectChecks> checkClass = requiresDialectFeatureAnn.value();
+			DialectChecks check = checkClass.newInstance();
+			boolean skip = check.include( dialect );
 			if ( skip ) {
 				return buildSkip( dialect, null, null );
 			}



More information about the hibernate-commits mailing list