[hibernate-commits] Hibernate SVN: r19405 - 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 09:46:35 EDT 2010


Author: hardy.ferentschik
Date: 2010-05-07 09:46:32 -0400 (Fri, 07 May 2010)
New Revision: 19405

Added:
   core/trunk/testing/src/main/java/org/hibernate/junit/RequiresDialectFeature.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/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 12:25:26 UTC (rev 19404)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/id/sequences/IdTest.java	2010-05-07 13:46:32 UTC (rev 19405)
@@ -5,6 +5,7 @@
 import org.hibernate.Transaction;
 import org.hibernate.cfg.AnnotationConfiguration;
 import org.hibernate.cfg.Configuration;
+import org.hibernate.junit.RequiresDialectFeature;
 import org.hibernate.mapping.Column;
 import org.hibernate.test.annotations.TestCase;
 import org.hibernate.test.annotations.id.sequences.entities.Ball;
@@ -29,27 +30,28 @@
  * @author Emmanuel Bernard
  */
 @SuppressWarnings("unchecked")
+ at RequiresDialectFeature("supportsSequences")
 public class IdTest extends TestCase {
 	public void testGenericGenerator() throws Exception {
 		Session s = openSession();
 		Transaction tx = s.beginTransaction();
 		SoundSystem system = new SoundSystem();
-		system.setBrand("Genelec");
-		system.setModel("T234");
+		system.setBrand( "Genelec" );
+		system.setModel( "T234" );
 		Furniture fur = new Furniture();
-		s.persist(system);
-		s.persist(fur);
+		s.persist( system );
+		s.persist( fur );
 		tx.commit();
 		s.close();
 
 		s = openSession();
 		tx = s.beginTransaction();
-		system = (SoundSystem) s.get(SoundSystem.class, system.getId());
-		fur = (Furniture) s.get(Furniture.class, fur.getId());
-		assertNotNull(system);
-		assertNotNull(fur);
-		s.delete(system);
-		s.delete(fur);
+		system = ( SoundSystem ) s.get( SoundSystem.class, system.getId() );
+		fur = ( Furniture ) s.get( Furniture.class, fur.getId() );
+		assertNotNull( system );
+		assertNotNull( fur );
+		s.delete( system );
+		s.delete( fur );
 		tx.commit();
 		s.close();
 
@@ -59,13 +61,14 @@
 	 * Ensures that GenericGenerator annotations wrapped inside a
 	 * GenericGenerators holder are bound correctly
 	 */
+
 	public void testGenericGenerators() throws Exception {
 		Session s = openSession();
 		Transaction tx = s.beginTransaction();
 		Monkey monkey = new Monkey();
-		s.persist(monkey);
+		s.persist( monkey );
 		s.flush();
-		assertNotNull(monkey.getId());
+		assertNotNull( monkey.getId() );
 		tx.rollback();
 		s.close();
 	}
@@ -77,21 +80,23 @@
 		Ball b = new Ball();
 		Dog d = new Dog();
 		Computer c = new Computer();
-		s.persist(b);
-		s.persist(d);
-		s.persist(c);
+		s.persist( b );
+		s.persist( d );
+		s.persist( c );
 		tx.commit();
 		s.close();
-		assertEquals("table id not generated", new Integer(1), b.getId());
-		assertEquals("generator should not be shared", new Integer(1), d
-				.getId());
-		assertEquals("default value should work", new Long(1), c.getId());
+		assertEquals( "table id not generated", new Integer( 1 ), b.getId() );
+		assertEquals(
+				"generator should not be shared", new Integer( 1 ), d
+						.getId()
+		);
+		assertEquals( "default value should work", new Long( 1 ), c.getId() );
 
 		s = openSession();
 		tx = s.beginTransaction();
-		s.delete(s.get(Ball.class, new Integer(1)));
-		s.delete(s.get(Dog.class, new Integer(1)));
-		s.delete(s.get(Computer.class, new Long(1)));
+		s.delete( s.get( Ball.class, new Integer( 1 ) ) );
+		s.delete( s.get( Dog.class, new Integer( 1 ) ) );
+		s.delete( s.get( Computer.class, new Long( 1 ) ) );
 		tx.commit();
 		s.close();
 	}
@@ -100,14 +105,14 @@
 		Session s = openSession();
 		Transaction tx = s.beginTransaction();
 		Shoe b = new Shoe();
-		s.persist(b);
+		s.persist( b );
 		tx.commit();
 		s.close();
-		assertNotNull(b.getId());
+		assertNotNull( b.getId() );
 
 		s = openSession();
 		tx = s.beginTransaction();
-		s.delete(s.get(Shoe.class, b.getId()));
+		s.delete( s.get( Shoe.class, b.getId() ) );
 		tx.commit();
 		s.close();
 	}
@@ -116,14 +121,14 @@
 		Session s = openSession();
 		Transaction tx = s.beginTransaction();
 		Store b = new Store();
-		s.persist(b);
+		s.persist( b );
 		tx.commit();
 		s.close();
-		assertNotNull(b.getId());
+		assertNotNull( b.getId() );
 
 		s = openSession();
 		tx = s.beginTransaction();
-		s.delete(s.get(Store.class, b.getId()));
+		s.delete( s.get( Store.class, b.getId() ) );
 		tx.commit();
 		s.close();
 	}
@@ -132,14 +137,14 @@
 		Session s = openSession();
 		Transaction tx = s.beginTransaction();
 		Department b = new Department();
-		s.persist(b);
+		s.persist( b );
 		tx.commit();
 		s.close();
-		assertNotNull(b.getId());
+		assertNotNull( b.getId() );
 
 		s = openSession();
 		tx = s.beginTransaction();
-		s.delete(s.get(Department.class, b.getId()));
+		s.delete( s.get( Department.class, b.getId() ) );
 		tx.commit();
 		s.close();
 	}
@@ -150,16 +155,16 @@
 		s = openSession();
 		tx = s.beginTransaction();
 		Home h = new Home();
-		s.persist(h);
+		s.persist( h );
 		tx.commit();
 		s.close();
-		assertNotNull(h.getId());
+		assertNotNull( h.getId() );
 
 		s = openSession();
 		tx = s.beginTransaction();
-		Home reloadedHome = (Home) s.get(Home.class, h.getId());
-		assertEquals(h.getId(), reloadedHome.getId());
-		s.delete(reloadedHome);
+		Home reloadedHome = ( Home ) s.get( Home.class, h.getId() );
+		assertEquals( h.getId(), reloadedHome.getId() );
+		s.delete( reloadedHome );
 		tx.commit();
 		s.close();
 	}
@@ -170,16 +175,16 @@
 		s = openSession();
 		tx = s.beginTransaction();
 		Home h = new Home();
-		s.persist(h);
+		s.persist( h );
 		tx.commit();
 		s.close();
-		assertNotNull(h.getId());
+		assertNotNull( h.getId() );
 
 		s = openSession();
 		tx = s.beginTransaction();
-		Home reloadedHome = (Home) s.get(Home.class, h.getId());
-		assertEquals(h.getId(), reloadedHome.getId());
-		s.delete(reloadedHome);
+		Home reloadedHome = ( Home ) s.get( Home.class, h.getId() );
+		assertEquals( h.getId(), reloadedHome.getId() );
+		s.delete( reloadedHome );
 		tx.commit();
 		s.close();
 	}
@@ -190,13 +195,13 @@
 		s = openSession();
 		tx = s.beginTransaction();
 		FirTree chrismasTree = new FirTree();
-		s.persist(chrismasTree);
+		s.persist( chrismasTree );
 		tx.commit();
 		s.clear();
 		tx = s.beginTransaction();
-		chrismasTree = (FirTree) s.get(FirTree.class, chrismasTree.getId());
-		assertNotNull(chrismasTree);
-		s.delete(chrismasTree);
+		chrismasTree = ( FirTree ) s.get( FirTree.class, chrismasTree.getId() );
+		assertNotNull( chrismasTree );
+		s.delete( chrismasTree );
 		tx.commit();
 		s.close();
 	}
@@ -206,55 +211,58 @@
 		Transaction tx;
 		s = openSession();
 		tx = s.beginTransaction();
-		Footballer fb = new Footballer("David", "Beckam", "Arsenal");
-		GoalKeeper keeper = new GoalKeeper("Fabien", "Bartez", "OM");
-		s.persist(fb);
-		s.persist(keeper);
+		Footballer fb = new Footballer( "David", "Beckam", "Arsenal" );
+		GoalKeeper keeper = new GoalKeeper( "Fabien", "Bartez", "OM" );
+		s.persist( fb );
+		s.persist( keeper );
 		tx.commit();
 		s.clear();
 
 		// lookup by id
 		tx = s.beginTransaction();
-		FootballerPk fpk = new FootballerPk("David", "Beckam");
-		fb = (Footballer) s.get(Footballer.class, fpk);
-		FootballerPk fpk2 = new FootballerPk("Fabien", "Bartez");
-		keeper = (GoalKeeper) s.get(GoalKeeper.class, fpk2);
-		assertNotNull(fb);
-		assertNotNull(keeper);
-		assertEquals("Beckam", fb.getLastname());
-		assertEquals("Arsenal", fb.getClub());
-		assertEquals(1, s.createQuery(
-				"from Footballer f where f.firstname = 'David'").list().size());
+		FootballerPk fpk = new FootballerPk( "David", "Beckam" );
+		fb = ( Footballer ) s.get( Footballer.class, fpk );
+		FootballerPk fpk2 = new FootballerPk( "Fabien", "Bartez" );
+		keeper = ( GoalKeeper ) s.get( GoalKeeper.class, fpk2 );
+		assertNotNull( fb );
+		assertNotNull( keeper );
+		assertEquals( "Beckam", fb.getLastname() );
+		assertEquals( "Arsenal", fb.getClub() );
+		assertEquals(
+				1, s.createQuery(
+						"from Footballer f where f.firstname = 'David'"
+				).list().size()
+		);
 		tx.commit();
 
 		// reattach by merge
 		tx = s.beginTransaction();
-		fb.setClub("Bimbo FC");
-		s.merge(fb);
+		fb.setClub( "Bimbo FC" );
+		s.merge( fb );
 		tx.commit();
 
 		// reattach by saveOrUpdate
 		tx = s.beginTransaction();
-		fb.setClub("Bimbo FC SA");
-		s.saveOrUpdate(fb);
+		fb.setClub( "Bimbo FC SA" );
+		s.saveOrUpdate( fb );
 		tx.commit();
 
 		// clean up
 		s.clear();
 		tx = s.beginTransaction();
-		fpk = new FootballerPk("David", "Beckam");
-		fb = (Footballer) s.get(Footballer.class, fpk);
-		assertEquals("Bimbo FC SA", fb.getClub());
-		s.delete(fb);
-		s.delete(keeper);
+		fpk = new FootballerPk( "David", "Beckam" );
+		fb = ( Footballer ) s.get( Footballer.class, fpk );
+		assertEquals( "Bimbo FC SA", fb.getClub() );
+		s.delete( fb );
+		s.delete( keeper );
 		tx.commit();
 		s.close();
 	}
 
 	public void testColumnDefinition() {
-		Column idCol = (Column) getCfg().getClassMapping(Ball.class.getName())
+		Column idCol = ( Column ) getCfg().getClassMapping( Ball.class.getName() )
 				.getIdentifierProperty().getValue().getColumnIterator().next();
-		assertEquals("ball_id", idCol.getName());
+		assertEquals( "ball_id", idCol.getName() );
 	}
 
 	public void testLowAllocationSize() throws Exception {
@@ -264,42 +272,39 @@
 		tx = s.beginTransaction();
 		int size = 4;
 		BreakDance[] bds = new BreakDance[size];
-		for (int i = 0; i < size; i++) {
+		for ( int i = 0; i < size; i++ ) {
 			bds[i] = new BreakDance();
-			s.persist(bds[i]);
+			s.persist( bds[i] );
 		}
 		s.flush();
-		for (int i = 0; i < size; i++) {
-			assertEquals(i + 1, bds[i].id.intValue());
+		for ( int i = 0; i < size; i++ ) {
+			assertEquals( i + 1, bds[i].id.intValue() );
 		}
 		tx.rollback();
 		s.close();
 	}
-	
-	
-	
-	@Override
-	protected boolean runForCurrentDialect() {
-		return super.runForCurrentDialect() && getDialect().supportsSequences();
-	}
 
 	/**
 	 * @see org.hibernate.test.annotations.TestCase#getAnnotatedClasses()
 	 */
 	protected Class[] getAnnotatedClasses() {
-		return new Class[] { Ball.class, Shoe.class, Store.class,
+		return new Class[] {
+				Ball.class, Shoe.class, Store.class,
 				Department.class, Dog.class, Computer.class, Home.class,
 				Phone.class, Tree.class, FirTree.class, Footballer.class,
 				SoundSystem.class, Furniture.class, GoalKeeper.class,
-				BreakDance.class, Monkey.class};
+				BreakDance.class, Monkey.class
+		};
 	}
-	
+
 	/**
 	 * @see org.hibernate.test.annotations.TestCase#getAnnotatedPackages()
 	 */
 	protected String[] getAnnotatedPackages() {
-		return new String[] { "org.hibernate.test.annotations",
-				"org.hibernate.test.annotations.id" };
+		return new String[] {
+				"org.hibernate.test.annotations",
+				"org.hibernate.test.annotations.id"
+		};
 	}
 
 	@Override

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 12:25:26 UTC (rev 19404)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/lob/LobTest.java	2010-05-07 13:46:32 UTC (rev 19405)
@@ -3,12 +3,13 @@
 
 import org.hibernate.Session;
 import org.hibernate.Transaction;
-import org.hibernate.dialect.Dialect;
+import org.hibernate.junit.RequiresDialectFeature;
 import org.hibernate.test.annotations.TestCase;
 
 /**
  * @author Emmanuel Bernard
  */
+ at RequiresDialectFeature("supportsExpectedLobUsagePattern")
 public class LobTest extends TestCase {
 	public void testSerializableToBlob() throws Exception {
 		Book book = new Book();
@@ -118,11 +119,6 @@
 		super( x );
 	}
 
-	@Override
-	protected boolean runForCurrentDialect() {
-		return super.runForCurrentDialect() && getDialect().supportsExpectedLobUsagePattern();
-	}
-
 	protected Class[] getAnnotatedClasses() {
 		return new Class[] {
 				Book.class,

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 12:25:26 UTC (rev 19404)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/manytoone/referencedcolumnname/ManyToOneReferencedColumnNameTest.java	2010-05-07 13:46:32 UTC (rev 19405)
@@ -1,29 +1,31 @@
-//$
+// $Id$
 package org.hibernate.test.annotations.manytoone.referencedcolumnname;
 
 import java.math.BigDecimal;
 
-import org.hibernate.test.annotations.TestCase;
 import org.hibernate.Session;
+import org.hibernate.junit.RequiresDialectFeature;
+import org.hibernate.test.annotations.TestCase;
 
 /**
  * @author Emmanuel Bernard
  */
 public class ManyToOneReferencedColumnNameTest extends TestCase {
+	@RequiresDialectFeature("supportsIdentityColumns")
 	public void testReoverableExceptionInFkOrdering() throws Exception {
 		//SF should not blow up
 		Vendor v = new Vendor();
 		Item i = new Item();
 		ZItemCost ic = new ZItemCost();
-		ic.setCost( new BigDecimal(2) );
+		ic.setCost( new BigDecimal( 2 ) );
 		ic.setItem( i );
 		ic.setVendor( v );
 		WarehouseItem wi = new WarehouseItem();
 		wi.setDefaultCost( ic );
 		wi.setItem( i );
 		wi.setVendor( v );
-		wi.setQtyInStock( new BigDecimal(2) );
-		Session s = openSession(  );
+		wi.setQtyInStock( new BigDecimal( 2 ) );
+		Session s = openSession();
 		s.getTransaction().begin();
 		s.save( i );
 		s.save( v );
@@ -32,16 +34,9 @@
 		s.flush();
 		s.getTransaction().rollback();
 		s.close();
-		
+
 	}
-	
-	@Override
-	protected boolean runForCurrentDialect() {
-		return super.runForCurrentDialect() && getDialect().supportsIdentityColumns();
-	}
 
-
-
 	protected Class[] getAnnotatedClasses() {
 		return new Class[] {
 				Item.class,

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 12:25:26 UTC (rev 19404)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/xml/hbm/HbmWithIdentityTest.java	2010-05-07 13:46:32 UTC (rev 19405)
@@ -2,6 +2,7 @@
 package org.hibernate.test.annotations.xml.hbm;
 
 import org.hibernate.Session;
+import org.hibernate.junit.RequiresDialectFeature;
 import org.hibernate.test.annotations.TestCase;
 
 /**
@@ -9,6 +10,7 @@
  */
 public class HbmWithIdentityTest extends TestCase {
 
+	@RequiresDialectFeature("supportsIdentityColumns")
 	public void testManyToOneAndInterface() throws Exception {
 		Session s = openSession();
 		s.getTransaction().begin();
@@ -23,11 +25,6 @@
 		s.close();
 	}
 
-	@Override
-	protected boolean runForCurrentDialect() {
-		return super.runForCurrentDialect() && getDialect().supportsIdentityColumns();
-	}
-
 	protected Class[] getAnnotatedClasses() {
 		return new Class[] {
 				Sky.class,

Copied: core/trunk/testing/src/main/java/org/hibernate/junit/RequiresDialectFeature.java (from rev 19404, core/trunk/testing/src/main/java/org/hibernate/junit/RequiresDialect.java)
===================================================================
--- core/trunk/testing/src/main/java/org/hibernate/junit/RequiresDialectFeature.java	                        (rev 0)
+++ core/trunk/testing/src/main/java/org/hibernate/junit/RequiresDialectFeature.java	2010-05-07 13:46:32 UTC (rev 19405)
@@ -0,0 +1,44 @@
+/*
+ * 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 java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Annotation used to indicate that a test should be run only when the current dialect suppports the
+ * specified feature.
+ *
+ * @author Hardy Ferentschik
+ */
+ at Target({ ElementType.METHOD, ElementType.TYPE })
+ at Retention(RetentionPolicy.RUNTIME)
+public @interface RequiresDialectFeature {
+	/**
+	 * @return The name of the dialect feature.
+	 */
+	String 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 12:25:26 UTC (rev 19404)
+++ core/trunk/testing/src/main/java/org/hibernate/test/annotations/HibernateTestCase.java	2010-05-07 13:46:32 UTC (rev 19405)
@@ -1,4 +1,4 @@
-// $Id:$
+// $Id$
 /*
  * Hibernate, Relational Persistence for Idiomatic Java
  *
@@ -30,8 +30,6 @@
 import java.lang.reflect.Modifier;
 import java.sql.Connection;
 import java.sql.SQLException;
-import java.util.HashSet;
-import java.util.Set;
 
 import junit.framework.TestCase;
 import org.slf4j.Logger;
@@ -42,6 +40,7 @@
 import org.hibernate.jdbc.Work;
 import org.hibernate.junit.FailureExpected;
 import org.hibernate.junit.RequiresDialect;
+import org.hibernate.junit.RequiresDialectFeature;
 import org.hibernate.junit.SkipForDialect;
 import org.hibernate.junit.SkipLog;
 import org.hibernate.tool.hbm2ddl.SchemaExport;
@@ -60,23 +59,6 @@
 	protected static Configuration cfg;
 	private static Class<?> lastTestClass;
 
-
-	/**
-	 * Flag indicating whether the test should be run or skipped.
-	 */
-	private boolean runTest = true;
-
-	/**
-	 * List of required dialect for the current {@code runMethod}. If the list is empty any dialect is allowed.
-	 * Otherwise the current dialect or a superclass of the current dialect must be in the list.
-	 */
-	private final Set<Class<? extends Dialect>> requiredDialectList = new HashSet<Class<? extends Dialect>>();
-
-	/**
-	 * List of dialects for which the current {@code runMethod} should be skipped.
-	 */
-	private final Set<Class<? extends Dialect>> skipForDialectList = new HashSet<Class<? extends Dialect>>();
-
 	public HibernateTestCase() {
 		super();
 	}
@@ -172,7 +154,7 @@
 		}
 	}
 
-	protected final Skip determineSkipByDialect(Dialect dialect, Method runMethod) {
+	protected final Skip determineSkipByDialect(Dialect dialect, Method runMethod) throws Exception {
 		// skips have precedence, so check them first
 		SkipForDialect skipForDialectAnn = locateAnnotation( SkipForDialect.class, runMethod );
 		if ( skipForDialectAnn != null ) {
@@ -195,18 +177,34 @@
 		if ( requiresDialectAnn != null ) {
 			for ( Class<? extends Dialect> dialectClass : requiresDialectAnn.value() ) {
 				if ( requiresDialectAnn.strictMatching() ) {
-					if ( dialectClass.equals( dialect.getClass() ) ) {
+					if ( !dialectClass.equals( dialect.getClass() ) ) {
 						return buildSkip( dialect, null, null );
 					}
 				}
 				else {
-					if ( dialectClass.isInstance( dialect ) ) {
+					if ( !dialectClass.isInstance( dialect ) ) {
 						return buildSkip( dialect, null, null );
 					}
 				}
 			}
 		}
 
+		// 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 );
+			}
+			if ( skip ) {
+				return buildSkip( dialect, null, null );
+			}
+		}
 		return null;
 	}
 
@@ -244,30 +242,6 @@
 		return this.getClass().getName() + "#" + this.getName();
 	}
 
-	protected boolean runForCurrentDialect() {
-		boolean runTestForCurrentDialect = true;
-
-		// check whether the current dialect is assignableFrom from any of the specified required dialects.
-		for ( Class<? extends Dialect> dialect : requiredDialectList ) {
-			if ( dialect.isAssignableFrom( Dialect.getDialect().getClass() ) ) {
-				runTestForCurrentDialect = true;
-				break;
-			}
-			runTestForCurrentDialect = false;
-		}
-
-		// check whether the current dialect is assignableFrom from any of the specified skip for dialects.
-		for ( Class<? extends Dialect> dialect : skipForDialectList ) {
-			if ( dialect.isAssignableFrom( Dialect.getDialect().getClass() ) ) {
-				runTestForCurrentDialect = false;
-				break;
-			}
-			runTestForCurrentDialect = true;
-		}
-
-		return runTestForCurrentDialect;
-	}
-
 	private Method findTestMethod() {
 		String fName = getName();
 		assertNotNull( fName );
@@ -289,7 +263,7 @@
 	protected abstract Class<?>[] getAnnotatedClasses();
 
 	protected String[] getMappings() {
-		return new String[]{};
+		return new String[] { };
 	}
 
 	protected abstract void handleUnclosedResources();



More information about the hibernate-commits mailing list