Skip to content

Commit 3e1d73c

Browse files
committed
HHH-8893 @FailureExpectedWithNewUnifiedXsd & a @FailureExpectedMarker
meta-annotation
1 parent 754af46 commit 3e1d73c

16 files changed

+166
-66
lines changed

Diff for: hibernate-core/src/test/java/org/hibernate/test/collection/map/PersistentMapTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
import org.hibernate.Query;
4747
import org.hibernate.Session;
4848
import org.hibernate.collection.internal.PersistentMap;
49-
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
49+
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
5050
import org.hibernate.testing.TestForIssue;
5151
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
5252
import org.junit.Test;
@@ -57,7 +57,7 @@
5757
* @author Steve Ebersole
5858
* @author Brett Meyer
5959
*/
60-
@FailureExpectedWithNewMetamodel(message = "HbmXmlTransformer does not support formulas within map keys")
60+
@FailureExpectedWithNewUnifiedXsd(message = "HbmXmlTransformer does not support formulas within map keys")
6161
public class PersistentMapTest extends BaseCoreFunctionalTestCase {
6262
@Override
6363
public String[] getMappings() {

Diff for: hibernate-core/src/test/java/org/hibernate/test/entitymode/map/basic/DynamicClassTest.java

+7-8
Original file line numberDiff line numberDiff line change
@@ -22,31 +22,30 @@
2222
* Boston, MA 02110-1301 USA
2323
*/
2424
package org.hibernate.test.entitymode.map.basic;
25+
import static org.junit.Assert.assertEquals;
26+
import static org.junit.Assert.assertFalse;
27+
import static org.junit.Assert.assertTrue;
28+
2529
import java.util.ArrayList;
2630
import java.util.HashMap;
2731
import java.util.Iterator;
2832
import java.util.List;
2933
import java.util.Map;
3034

31-
import org.junit.Test;
32-
3335
import org.hibernate.EntityMode;
3436
import org.hibernate.Hibernate;
3537
import org.hibernate.Session;
3638
import org.hibernate.Transaction;
3739
import org.hibernate.cfg.Configuration;
3840
import org.hibernate.cfg.Environment;
39-
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
41+
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
4042
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
41-
42-
import static org.junit.Assert.assertEquals;
43-
import static org.junit.Assert.assertFalse;
44-
import static org.junit.Assert.assertTrue;
43+
import org.junit.Test;
4544

4645
/**
4746
* @author Gavin King
4847
*/
49-
@FailureExpectedWithNewMetamodel(message = "HbmXmlTransformer does not currently support EntityMode.MAP")
48+
@FailureExpectedWithNewUnifiedXsd(message = "HbmXmlTransformer does not currently support EntityMode.MAP")
5049
public class DynamicClassTest extends BaseCoreFunctionalTestCase {
5150
@Override
5251
public String[] getMappings() {

Diff for: hibernate-core/src/test/java/org/hibernate/test/extralazy/ExtraLazyTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@
3434
import org.hibernate.Hibernate;
3535
import org.hibernate.Session;
3636
import org.hibernate.Transaction;
37-
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
37+
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
3838
import org.hibernate.testing.TestForIssue;
3939
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
4040
import org.junit.Test;
4141

4242
/**
4343
* @author Gavin King
4444
*/
45-
@FailureExpectedWithNewMetamodel(message = "HbmXmlTransformer does not support formulas within map keys")
45+
@FailureExpectedWithNewUnifiedXsd(message = "HbmXmlTransformer does not support formulas within map keys")
4646
public class ExtraLazyTest extends BaseCoreFunctionalTestCase {
4747
@Override
4848
public String[] getMappings() {

Diff for: hibernate-core/src/test/java/org/hibernate/test/hql/BulkManipulationTest.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
import org.hibernate.persister.entity.EntityPersister;
4747
import org.hibernate.testing.DialectChecks;
4848
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
49+
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
4950
import org.hibernate.testing.RequiresDialectFeature;
5051
import org.hibernate.testing.SkipForDialect;
5152
import org.hibernate.testing.SkipLog;
@@ -58,7 +59,7 @@
5859
*
5960
* @author Steve Ebersole
6061
*/
61-
@FailureExpectedWithNewMetamodel(message = "*.hbm.xml mappings are doing something not supported in the transformer")
62+
@FailureExpectedWithNewUnifiedXsd(message = "*.hbm.xml mappings are doing something not supported in the transformer")
6263
public class BulkManipulationTest extends BaseCoreFunctionalTestCase {
6364
public String[] getMappings() {
6465
return new String[] {

Diff for: hibernate-core/src/test/java/org/hibernate/test/joinfetch/JoinFetchTest.java

+7-8
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,11 @@
2222
* Boston, MA 02110-1301 USA
2323
*/
2424
package org.hibernate.test.joinfetch;
25-
import java.util.List;
25+
import static org.junit.Assert.assertEquals;
26+
import static org.junit.Assert.assertFalse;
27+
import static org.junit.Assert.assertTrue;
2628

27-
import org.junit.Test;
29+
import java.util.List;
2830

2931
import org.hibernate.FetchMode;
3032
import org.hibernate.Hibernate;
@@ -34,17 +36,14 @@
3436
import org.hibernate.cfg.Environment;
3537
import org.hibernate.criterion.Projections;
3638
import org.hibernate.criterion.Restrictions;
37-
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
39+
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
3840
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
39-
40-
import static org.junit.Assert.assertEquals;
41-
import static org.junit.Assert.assertFalse;
42-
import static org.junit.Assert.assertTrue;
41+
import org.junit.Test;
4342

4443
/**
4544
* @author Gavin King
4645
*/
47-
@FailureExpectedWithNewMetamodel(message = "HbmXmlTransformer does not support formulas within map keys")
46+
@FailureExpectedWithNewUnifiedXsd(message = "HbmXmlTransformer does not support formulas within map keys")
4847
public class JoinFetchTest extends BaseCoreFunctionalTestCase {
4948
@Override
5049
public String[] getMappings() {

Diff for: hibernate-core/src/test/java/org/hibernate/test/legacy/MapTest.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,10 @@
3636
import org.hibernate.criterion.Example;
3737
import org.hibernate.criterion.Restrictions;
3838
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
39+
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
3940
import org.junit.Test;
4041

41-
@FailureExpectedWithNewMetamodel(message = "HbmXmlTransformer does not currently support EntityMode.MAP")
42+
@FailureExpectedWithNewUnifiedXsd(message = "HbmXmlTransformer does not currently support EntityMode.MAP")
4243
public class MapTest extends LegacyTestCase {
4344
@Override
4445
public String[] getMappings() {

Diff for: hibernate-core/src/test/java/org/hibernate/test/map/MapIndexFormulaTest.java

+5-6
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,21 @@
2222
* Boston, MA 02110-1301 USA
2323
*/
2424
package org.hibernate.test.map;
25+
import static org.junit.Assert.assertEquals;
26+
2527
import java.util.List;
2628
import java.util.Map;
2729

28-
import org.junit.Test;
29-
3030
import org.hibernate.Session;
3131
import org.hibernate.Transaction;
32-
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
32+
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
3333
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
34-
35-
import static org.junit.Assert.assertEquals;
34+
import org.junit.Test;
3635

3736
/**
3837
* @author Gavin King
3938
*/
40-
@FailureExpectedWithNewMetamodel(message = "HbmXmlTransformer does not support formulas within map keys")
39+
@FailureExpectedWithNewUnifiedXsd(message = "HbmXmlTransformer does not support formulas within map keys")
4140
public class MapIndexFormulaTest extends BaseCoreFunctionalTestCase {
4241
public String[] getMappings() {
4342
return new String[] { "map/UserGroup.hbm.xml" };

Diff for: hibernate-core/src/test/java/org/hibernate/test/onetoone/nopojo/DynamicMapOneToOneTest.java

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,25 @@
11
//$Id: DynamicMapOneToOneTest.java 10977 2006-12-12 23:28:04Z [email protected] $
22
package org.hibernate.test.onetoone.nopojo;
33

4+
import static org.junit.Assert.assertEquals;
5+
import static org.junit.Assert.assertNotNull;
6+
47
import java.util.HashMap;
58
import java.util.Map;
69

7-
import org.junit.Test;
8-
910
import org.hibernate.EntityMode;
1011
import org.hibernate.Session;
1112
import org.hibernate.cfg.Configuration;
1213
import org.hibernate.cfg.Environment;
1314
import org.hibernate.stat.EntityStatistics;
14-
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
15+
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
1516
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
16-
17-
import static org.junit.Assert.assertEquals;
18-
import static org.junit.Assert.assertNotNull;
17+
import org.junit.Test;
1918

2019
/**
2120
* @author Gavin King
2221
*/
23-
@FailureExpectedWithNewMetamodel(message = "HbmXmlTransformer does not currently support EntityMode.MAP")
22+
@FailureExpectedWithNewUnifiedXsd(message = "HbmXmlTransformer does not currently support EntityMode.MAP")
2423
public class DynamicMapOneToOneTest extends BaseCoreFunctionalTestCase {
2524
@Override
2625
public String[] getMappings() {

Diff for: hibernate-core/src/test/java/org/hibernate/test/tm/CMTTest.java

+10-10
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,18 @@
2323
*/
2424
package org.hibernate.test.tm;
2525

26+
import static org.junit.Assert.assertEquals;
27+
import static org.junit.Assert.assertFalse;
28+
import static org.junit.Assert.assertNotNull;
29+
import static org.junit.Assert.assertSame;
30+
import static org.junit.Assert.fail;
31+
2632
import java.util.HashMap;
2733
import java.util.Iterator;
2834
import java.util.List;
2935
import java.util.Map;
30-
import javax.transaction.Transaction;
3136

32-
import org.junit.Test;
37+
import javax.transaction.Transaction;
3338

3439
import org.hibernate.ConnectionReleaseMode;
3540
import org.hibernate.EntityMode;
@@ -40,22 +45,17 @@
4045
import org.hibernate.criterion.Order;
4146
import org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory;
4247
import org.hibernate.testing.DialectChecks;
43-
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
48+
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
4449
import org.hibernate.testing.RequiresDialectFeature;
4550
import org.hibernate.testing.jta.TestingJtaBootstrap;
4651
import org.hibernate.testing.jta.TestingJtaPlatformImpl;
4752
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
48-
49-
import static org.junit.Assert.assertEquals;
50-
import static org.junit.Assert.assertFalse;
51-
import static org.junit.Assert.assertNotNull;
52-
import static org.junit.Assert.assertSame;
53-
import static org.junit.Assert.fail;
53+
import org.junit.Test;
5454

5555
/**
5656
* @author Gavin King
5757
*/
58-
@FailureExpectedWithNewMetamodel(message = "HbmXmlTransformer does not currently support EntityMode.MAP")
58+
@FailureExpectedWithNewUnifiedXsd(message = "HbmXmlTransformer does not currently support EntityMode.MAP")
5959
public class CMTTest extends BaseCoreFunctionalTestCase {
6060
@Override
6161
public String[] getMappings() {

Diff for: hibernate-testing/src/main/java/org/hibernate/testing/FailureExpected.java

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
*/
3737
@Retention(RetentionPolicy.RUNTIME)
3838
@Target({ ElementType.METHOD, ElementType.TYPE })
39+
@FailureExpectedMarker
3940
public @interface FailureExpected {
4041
/**
4142
* The key of a JIRA issue which covers this expected failure.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package org.hibernate.testing;
2+
3+
import java.lang.annotation.ElementType;
4+
import java.lang.annotation.Retention;
5+
import java.lang.annotation.RetentionPolicy;
6+
import java.lang.annotation.Target;
7+
8+
@Retention(RetentionPolicy.RUNTIME)
9+
@Target(ElementType.ANNOTATION_TYPE)
10+
public @interface FailureExpectedMarker {
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Hibernate, Relational Persistence for Idiomatic Java
3+
*
4+
* JBoss, Home of Professional Open Source
5+
* Copyright 2014 Red Hat Inc. and/or its affiliates and other contributors
6+
* as indicated by the @authors tag. All rights reserved.
7+
* See the copyright.txt in the distribution for a
8+
* full listing of individual contributors.
9+
*
10+
* This copyrighted material is made available to anyone wishing to use,
11+
* modify, copy, or redistribute it subject to the terms and conditions
12+
* of the GNU Lesser General Public License, v. 2.1.
13+
* This program is distributed in the hope that it will be useful, but WITHOUT A
14+
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
15+
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
16+
* You should have received a copy of the GNU Lesser General Public License,
17+
* v.2.1 along with this distribution; if not, write to the Free Software
18+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19+
* MA 02110-1301, USA.
20+
*/
21+
package org.hibernate.testing;
22+
23+
import java.lang.annotation.Annotation;
24+
25+
/**
26+
* @author Brett Meyer
27+
*/
28+
public class FailureExpectedUtil {
29+
public static boolean hasFailureExpectedMarker(Annotation[] annotations) {
30+
for (Annotation annotation : annotations) {
31+
if (annotation.getClass().getAnnotation( FailureExpectedMarker.class ) != null) {
32+
return true;
33+
}
34+
}
35+
return false;
36+
}
37+
}

Diff for: hibernate-testing/src/main/java/org/hibernate/testing/FailureExpectedWithNewMetamodel.java

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
*/
3535
@Retention( RetentionPolicy.RUNTIME )
3636
@Target( { ElementType.METHOD, ElementType.TYPE } )
37+
@FailureExpectedMarker
3738
public @interface FailureExpectedWithNewMetamodel {
3839

3940
/**
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Hibernate, Relational Persistence for Idiomatic Java
3+
*
4+
* Copyright (c) 2011, Red Hat Inc. or third-party contributors as
5+
* indicated by the @author tags or express copyright attribution
6+
* statements applied by the authors. All third-party contributions are
7+
* distributed under license by Red Hat Inc.
8+
*
9+
* This copyrighted material is made available to anyone wishing to use, modify,
10+
* copy, or redistribute it subject to the terms and conditions of the GNU
11+
* Lesser General Public License, as published by the Free Software Foundation.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15+
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
16+
* for more details.
17+
*
18+
* You should have received a copy of the GNU Lesser General Public License
19+
* along with this distribution; if not, write to:
20+
* Free Software Foundation, Inc.
21+
* 51 Franklin Street, Fifth Floor
22+
* Boston, MA 02110-1301 USA
23+
*/
24+
package org.hibernate.testing;
25+
26+
import java.lang.annotation.ElementType;
27+
import java.lang.annotation.Retention;
28+
import java.lang.annotation.RetentionPolicy;
29+
import java.lang.annotation.Target;
30+
31+
@Retention( RetentionPolicy.RUNTIME )
32+
@Target( { ElementType.METHOD, ElementType.TYPE } )
33+
@FailureExpectedMarker
34+
public @interface FailureExpectedWithNewUnifiedXsd {
35+
36+
/**
37+
* @return an optional JIRA issue key that covers the expected failure
38+
*/
39+
String jiraKey() default "";
40+
41+
/**
42+
* @return an optional message related to the expected failure
43+
*/
44+
String message() default "";
45+
}

Diff for: hibernate-testing/src/main/java/org/hibernate/testing/junit4/BeforeClassCallbackHandler.java

+2-5
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,9 @@
2323
*/
2424
package org.hibernate.testing.junit4;
2525

26+
import org.hibernate.testing.FailureExpectedUtil;
2627
import org.junit.runners.model.Statement;
2728

28-
import org.hibernate.testing.FailureExpected;
29-
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
30-
3129
/**
3230
* @author Steve Ebersole
3331
*/
@@ -48,8 +46,7 @@ public void evaluate() throws Throwable {
4846
}
4947
catch ( Throwable error ) {
5048
runner.setBeforeClassMethodFailed();
51-
if ( runner.getTestClass().getJavaClass().getAnnotation( FailureExpected.class ) == null
52-
&& runner.getTestClass().getJavaClass().getAnnotation( FailureExpectedWithNewMetamodel.class ) == null ) {
49+
if (FailureExpectedUtil.hasFailureExpectedMarker( runner.getTestClass().getJavaClass().getAnnotations() )) {
5350
throw error;
5451
}
5552
}

0 commit comments

Comments
 (0)