HHH-8893 @FailureExpectedWithNewUnifiedXsd & a @FailureExpectedMarker

meta-annotation
This commit is contained in:
Brett Meyer 2014-05-21 17:22:19 -04:00
parent 754af46a70
commit 3e1d73cae8
16 changed files with 165 additions and 65 deletions

View File

@ -46,7 +46,7 @@ import javax.persistence.OneToMany;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.collection.internal.PersistentMap;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.junit.Test;
@ -57,7 +57,7 @@ import org.junit.Test;
* @author Steve Ebersole
* @author Brett Meyer
*/
@FailureExpectedWithNewMetamodel(message = "HbmXmlTransformer does not support formulas within map keys")
@FailureExpectedWithNewUnifiedXsd(message = "HbmXmlTransformer does not support formulas within map keys")
public class PersistentMapTest extends BaseCoreFunctionalTestCase {
@Override
public String[] getMappings() {

View File

@ -22,31 +22,30 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.test.entitymode.map.basic;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.junit.Test;
import org.hibernate.EntityMode;
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
/**
* @author Gavin King
*/
@FailureExpectedWithNewMetamodel(message = "HbmXmlTransformer does not currently support EntityMode.MAP")
@FailureExpectedWithNewUnifiedXsd(message = "HbmXmlTransformer does not currently support EntityMode.MAP")
public class DynamicClassTest extends BaseCoreFunctionalTestCase {
@Override
public String[] getMappings() {

View File

@ -34,7 +34,7 @@ import java.util.Map;
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.junit.Test;
@ -42,7 +42,7 @@ import org.junit.Test;
/**
* @author Gavin King
*/
@FailureExpectedWithNewMetamodel(message = "HbmXmlTransformer does not support formulas within map keys")
@FailureExpectedWithNewUnifiedXsd(message = "HbmXmlTransformer does not support formulas within map keys")
public class ExtraLazyTest extends BaseCoreFunctionalTestCase {
@Override
public String[] getMappings() {

View File

@ -46,6 +46,7 @@ import org.hibernate.id.IdentifierGenerator;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.testing.DialectChecks;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
import org.hibernate.testing.RequiresDialectFeature;
import org.hibernate.testing.SkipForDialect;
import org.hibernate.testing.SkipLog;
@ -58,7 +59,7 @@ import org.junit.Test;
*
* @author Steve Ebersole
*/
@FailureExpectedWithNewMetamodel(message = "*.hbm.xml mappings are doing something not supported in the transformer")
@FailureExpectedWithNewUnifiedXsd(message = "*.hbm.xml mappings are doing something not supported in the transformer")
public class BulkManipulationTest extends BaseCoreFunctionalTestCase {
public String[] getMappings() {
return new String[] {

View File

@ -22,9 +22,11 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.test.joinfetch;
import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import java.util.List;
import org.hibernate.FetchMode;
import org.hibernate.Hibernate;
@ -34,17 +36,14 @@ import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
import org.hibernate.criterion.Projections;
import org.hibernate.criterion.Restrictions;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
/**
* @author Gavin King
*/
@FailureExpectedWithNewMetamodel(message = "HbmXmlTransformer does not support formulas within map keys")
@FailureExpectedWithNewUnifiedXsd(message = "HbmXmlTransformer does not support formulas within map keys")
public class JoinFetchTest extends BaseCoreFunctionalTestCase {
@Override
public String[] getMappings() {

View File

@ -36,9 +36,10 @@ import org.hibernate.cfg.Environment;
import org.hibernate.criterion.Example;
import org.hibernate.criterion.Restrictions;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
import org.junit.Test;
@FailureExpectedWithNewMetamodel(message = "HbmXmlTransformer does not currently support EntityMode.MAP")
@FailureExpectedWithNewUnifiedXsd(message = "HbmXmlTransformer does not currently support EntityMode.MAP")
public class MapTest extends LegacyTestCase {
@Override
public String[] getMappings() {

View File

@ -22,22 +22,21 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.test.map;
import static org.junit.Assert.assertEquals;
import java.util.List;
import java.util.Map;
import org.junit.Test;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
/**
* @author Gavin King
*/
@FailureExpectedWithNewMetamodel(message = "HbmXmlTransformer does not support formulas within map keys")
@FailureExpectedWithNewUnifiedXsd(message = "HbmXmlTransformer does not support formulas within map keys")
public class MapIndexFormulaTest extends BaseCoreFunctionalTestCase {
public String[] getMappings() {
return new String[] { "map/UserGroup.hbm.xml" };

View File

@ -1,26 +1,25 @@
//$Id: DynamicMapOneToOneTest.java 10977 2006-12-12 23:28:04Z steve.ebersole@jboss.com $
package org.hibernate.test.onetoone.nopojo;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import java.util.HashMap;
import java.util.Map;
import org.junit.Test;
import org.hibernate.EntityMode;
import org.hibernate.Session;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
import org.hibernate.stat.EntityStatistics;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import org.junit.Test;
/**
* @author Gavin King
*/
@FailureExpectedWithNewMetamodel(message = "HbmXmlTransformer does not currently support EntityMode.MAP")
@FailureExpectedWithNewUnifiedXsd(message = "HbmXmlTransformer does not currently support EntityMode.MAP")
public class DynamicMapOneToOneTest extends BaseCoreFunctionalTestCase {
@Override
public String[] getMappings() {

View File

@ -23,13 +23,18 @@
*/
package org.hibernate.test.tm;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.fail;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.transaction.Transaction;
import org.junit.Test;
import javax.transaction.Transaction;
import org.hibernate.ConnectionReleaseMode;
import org.hibernate.EntityMode;
@ -40,22 +45,17 @@ import org.hibernate.cfg.Environment;
import org.hibernate.criterion.Order;
import org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory;
import org.hibernate.testing.DialectChecks;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
import org.hibernate.testing.RequiresDialectFeature;
import org.hibernate.testing.jta.TestingJtaBootstrap;
import org.hibernate.testing.jta.TestingJtaPlatformImpl;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.fail;
import org.junit.Test;
/**
* @author Gavin King
*/
@FailureExpectedWithNewMetamodel(message = "HbmXmlTransformer does not currently support EntityMode.MAP")
@FailureExpectedWithNewUnifiedXsd(message = "HbmXmlTransformer does not currently support EntityMode.MAP")
public class CMTTest extends BaseCoreFunctionalTestCase {
@Override
public String[] getMappings() {

View File

@ -36,6 +36,7 @@ import java.lang.annotation.Target;
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.METHOD, ElementType.TYPE })
@FailureExpectedMarker
public @interface FailureExpected {
/**
* The key of a JIRA issue which covers this expected failure.

View File

@ -0,0 +1,11 @@
package org.hibernate.testing;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.ANNOTATION_TYPE)
public @interface FailureExpectedMarker {
}

View File

@ -0,0 +1,37 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* JBoss, Home of Professional Open Source
* Copyright 2014 Red Hat Inc. and/or its affiliates and other contributors
* as indicated by the @authors tag. All rights reserved.
* See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* 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, v. 2.1.
* This program is distributed in the hope that it will be useful, but WITHOUT A
* 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,
* v.2.1 along with this distribution; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
package org.hibernate.testing;
import java.lang.annotation.Annotation;
/**
* @author Brett Meyer
*/
public class FailureExpectedUtil {
public static boolean hasFailureExpectedMarker(Annotation[] annotations) {
for (Annotation annotation : annotations) {
if (annotation.getClass().getAnnotation( FailureExpectedMarker.class ) != null) {
return true;
}
}
return false;
}
}

View File

@ -34,6 +34,7 @@ import java.lang.annotation.Target;
*/
@Retention( RetentionPolicy.RUNTIME )
@Target( { ElementType.METHOD, ElementType.TYPE } )
@FailureExpectedMarker
public @interface FailureExpectedWithNewMetamodel {
/**

View File

@ -0,0 +1,45 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, 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.testing;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention( RetentionPolicy.RUNTIME )
@Target( { ElementType.METHOD, ElementType.TYPE } )
@FailureExpectedMarker
public @interface FailureExpectedWithNewUnifiedXsd {
/**
* @return an optional JIRA issue key that covers the expected failure
*/
String jiraKey() default "";
/**
* @return an optional message related to the expected failure
*/
String message() default "";
}

View File

@ -23,11 +23,9 @@
*/
package org.hibernate.testing.junit4;
import org.hibernate.testing.FailureExpectedUtil;
import org.junit.runners.model.Statement;
import org.hibernate.testing.FailureExpected;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
/**
* @author Steve Ebersole
*/
@ -48,8 +46,7 @@ public class BeforeClassCallbackHandler extends Statement {
}
catch ( Throwable error ) {
runner.setBeforeClassMethodFailed();
if ( runner.getTestClass().getJavaClass().getAnnotation( FailureExpected.class ) == null
&& runner.getTestClass().getJavaClass().getAnnotation( FailureExpectedWithNewMetamodel.class ) == null ) {
if (FailureExpectedUtil.hasFailureExpectedMarker( runner.getTestClass().getJavaClass().getAnnotations() )) {
throw error;
}
}

View File

@ -32,16 +32,18 @@ import java.util.List;
import org.hibernate.dialect.Dialect;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.testing.DialectCheck;
import org.hibernate.testing.FailureExpected;
import org.hibernate.testing.FailureExpectedUtil;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
import org.hibernate.testing.RequiresDialect;
import org.hibernate.testing.RequiresDialectFeature;
import org.hibernate.testing.RequiresDialects;
import org.hibernate.testing.Skip;
import org.hibernate.testing.SkipForDialect;
import org.hibernate.testing.SkipForDialects;
import org.jboss.logging.Logger;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
@ -52,8 +54,6 @@ import org.junit.runners.model.FrameworkMethod;
import org.junit.runners.model.InitializationError;
import org.junit.runners.model.Statement;
import org.jboss.logging.Logger;
/**
* The Hibernate-specific {@link org.junit.runner.Runner} implementation which layers {@link ExtendedFrameworkMethod}
* support on top of the standard JUnit {@link FrameworkMethod} for extra information after checking to make sure the
@ -137,8 +137,7 @@ public class CustomRunner extends BlockJUnit4ClassRunner {
protected Statement classBlock( RunNotifier notifier ) {
log.info( BeforeClass.class.getSimpleName() + ": " + getName() );
if ( getTestClass().getJavaClass().getAnnotation( FailureExpected.class ) != null
|| getTestClass().getJavaClass().getAnnotation( FailureExpectedWithNewMetamodel.class ) != null ) {
if ( FailureExpectedUtil.hasFailureExpectedMarker( getTestClass().getJavaClass().getAnnotations() ) ) {
log.info( FailureExpected.class.getSimpleName() );
}
@ -149,8 +148,7 @@ public class CustomRunner extends BlockJUnit4ClassRunner {
protected Statement methodBlock(FrameworkMethod method) {
log.info( Test.class.getSimpleName() + ": " + method.getName() );
if ( method.getAnnotation( FailureExpected.class ) != null
|| method.getAnnotation( FailureExpectedWithNewMetamodel.class ) != null ) {
if ( FailureExpectedUtil.hasFailureExpectedMarker( method.getAnnotations() ) ) {
log.info( FailureExpected.class.getSimpleName() );
}
@ -210,12 +208,21 @@ public class CustomRunner extends BlockJUnit4ClassRunner {
for ( FrameworkMethod frameworkMethod : methods ) {
FailureExpected failureExpected = Helper.locateAnnotation( FailureExpected.class, frameworkMethod, getTestClass() );
// TODO: Re-think what's given to the ExtendedFrameworkMethod, rather than mocking the FailureExpected?
if ( failureExpected == null ) {
// see if there is a FailureExpectedWithNewMetamodel, and if so treat it like FailureExpected
final FailureExpectedWithNewMetamodel failureExpectedWithNewMetamodel
= Helper.locateAnnotation( FailureExpectedWithNewMetamodel.class, frameworkMethod, getTestClass() );
if ( failureExpectedWithNewMetamodel != null ) {
failureExpected = new FailureExpectedWithNewMetamodelAdapter( failureExpectedWithNewMetamodel );
failureExpected = new FailureExpectedAdapter( failureExpectedWithNewMetamodel.message(),
failureExpectedWithNewMetamodel.jiraKey() );
}
}
if ( failureExpected == null ) {
final FailureExpectedWithNewUnifiedXsd failureExpectedWithNewUnifiedXsd
= Helper.locateAnnotation( FailureExpectedWithNewUnifiedXsd.class, frameworkMethod, getTestClass() );
if ( failureExpectedWithNewUnifiedXsd != null ) {
failureExpected = new FailureExpectedAdapter( failureExpectedWithNewUnifiedXsd.message(),
failureExpectedWithNewUnifiedXsd.jiraKey() );
}
}
// potentially ignore based on expected failure
@ -378,11 +385,14 @@ public class CustomRunner extends BlockJUnit4ClassRunner {
}
@SuppressWarnings("ClassExplicitlyAnnotation")
private class FailureExpectedWithNewMetamodelAdapter implements FailureExpected {
private final FailureExpectedWithNewMetamodel failureExpectedWithNewMetamodel;
private class FailureExpectedAdapter implements FailureExpected {
private final String message;
public FailureExpectedWithNewMetamodelAdapter(FailureExpectedWithNewMetamodel failureExpectedWithNewMetamodel) {
this.failureExpectedWithNewMetamodel = failureExpectedWithNewMetamodel;
private final String jiraKey;
public FailureExpectedAdapter(String message, String jiraKey) {
this.message = message;
this.jiraKey = jiraKey;
}
@Override
public Class< ? extends Annotation > annotationType() {
@ -391,12 +401,12 @@ public class CustomRunner extends BlockJUnit4ClassRunner {
@Override
public String message() {
return failureExpectedWithNewMetamodel.message();
return message;
}
@Override
public String jiraKey() {
return failureExpectedWithNewMetamodel.jiraKey();
return jiraKey;
}
}
}