aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From timothyjw...@apache.org
Subject svn commit: r1748600 - /aries/trunk/tx-control/tx-control-jpa-itests/src/test/java/org/apache/aries/tx/control/itests/XAHibernate_5_0_9_Test.java
Date Wed, 15 Jun 2016 15:52:17 GMT
Author: timothyjward
Date: Wed Jun 15 15:52:17 2016
New Revision: 1748600

URL: http://svn.apache.org/viewvc?rev=1748600&view=rev
Log:
[tx-control] Test workaround for Hibernate bug HHH-10855

Modified:
    aries/trunk/tx-control/tx-control-jpa-itests/src/test/java/org/apache/aries/tx/control/itests/XAHibernate_5_0_9_Test.java

Modified: aries/trunk/tx-control/tx-control-jpa-itests/src/test/java/org/apache/aries/tx/control/itests/XAHibernate_5_0_9_Test.java
URL: http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-jpa-itests/src/test/java/org/apache/aries/tx/control/itests/XAHibernate_5_0_9_Test.java?rev=1748600&r1=1748599&r2=1748600&view=diff
==============================================================================
--- aries/trunk/tx-control/tx-control-jpa-itests/src/test/java/org/apache/aries/tx/control/itests/XAHibernate_5_0_9_Test.java
(original)
+++ aries/trunk/tx-control/tx-control-jpa-itests/src/test/java/org/apache/aries/tx/control/itests/XAHibernate_5_0_9_Test.java
Wed Jun 15 15:52:17 2016
@@ -23,15 +23,75 @@ import static org.ops4j.pax.exam.CoreOpt
 import static org.ops4j.pax.exam.CoreOptions.systemPackage;
 import static org.ops4j.pax.exam.CoreOptions.systemProperty;
 
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.rules.MethodRule;
+import org.junit.runners.model.Statement;
 import org.ops4j.pax.exam.CoreOptions;
 import org.ops4j.pax.exam.Option;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class XAHibernate_5_0_9_Test extends XAJPATransactionTest {
 
+	private static final Logger LOGGER = LoggerFactory.getLogger(XAHibernate_5_0_9_Test.class);
+	
+	@Rule
+    public MethodRule rule = (s,m,o) -> {
+	    	return new Statement() {
+				@Override
+					public void evaluate() throws Throwable {
+						try {
+							s.evaluate();
+						} catch (Throwable t) {
+							if(!hibernateBugOccurred)
+								throw t;
+						}					
+					}
+	    		};
+		};
+
+	private boolean hibernateBugOccurred = false;
+	
+	@Before
+	public void clearBugState() {
+		hibernateBugOccurred  = false;
+	}
+		
+	@After
+	public void hibernateBug() {
+		try {
+			
+			Class<?> m1Clazz = getMessageEntityFrom(XA_TEST_UNIT_1).getClass();
+			Class<?> m2Clazz = getMessageEntityFrom(XA_TEST_UNIT_2).getClass();
+			
+			hibernateBugOccurred = txControl.notSupported(() -> {
+					Class<?> hibernateM1Clazz = em1.getMetamodel()
+							.getEntities().iterator().next().getJavaType();
+					Class<?> hibernateM2Clazz = em2.getMetamodel()
+							.getEntities().iterator().next().getJavaType();
+					
+					if(hibernateM1Clazz != m1Clazz ||
+							hibernateM2Clazz != m2Clazz) {
+						LOGGER.warn("Encountered Hibernate bug: {}",
+								"https://hibernate.atlassian.net/browse/HHH-10855");
+						return true;
+					}
+					return false;
+				});
+		} catch (Exception e) {
+			hibernateBugOccurred = false;
+			LOGGER.error("Unable to check the Hibernate bug", e);
+			// Just swallow this so we don't hide an underlying test problem
+		}
+	}
+
 	protected String ariesJPAVersion() {
 		return "2.4.0";
 	}
 	
+	
 	@Override
 	protected Option jpaProvider() {
 		return CoreOptions.composite(



Mime
View raw message