[jboss-cvs] JBossAS SVN: r111522 - in branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts: crash and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Jun 6 11:00:54 EDT 2011


Author: istudens at redhat.com
Date: 2011-06-06 11:00:53 -0400 (Mon, 06 Jun 2011)
New Revision: 111522

Modified:
   branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/ASCrashRecovery01/TestWithJPA.java
   branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/crash/TestEntityHelper.java
   branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/crash/TestEntityHelperLocal.java
   branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/crash/TestEntityHelperRem.java
Log:
test for JBPAPP-6614

Modified: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/ASCrashRecovery01/TestWithJPA.java
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/ASCrashRecovery01/TestWithJPA.java	2011-06-05 01:12:52 UTC (rev 111521)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/ASCrashRecovery01/TestWithJPA.java	2011-06-06 15:00:53 UTC (rev 111522)
@@ -133,6 +133,18 @@
 
       System.out.println(sb);
 
+	   try 
+	   {
+		   TestEntityHelperRem hlp = (TestEntityHelperRem) config.getNamingContext(serverName).lookup(TestEntityHelper.REMOTE_JNDI_NAME);
+		   boolean result = hlp.testJBTM575();
+		   print("JBTM575: " + result);
+	   }
+	   catch (Exception e)
+	   {
+		   print("catched an exception: " + e.getMessage());
+		   e.printStackTrace();
+	   }
+/*
       try 
       {
          String serverPath = config.getServerPath(serverName);
@@ -201,7 +213,7 @@
             e.printStackTrace();
 
          throw new BuildException(e);
-      }
+      }*/
    }
 
    private void initDatabase(String entityPK) throws Exception

Modified: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/crash/TestEntityHelper.java
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/crash/TestEntityHelper.java	2011-06-05 01:12:52 UTC (rev 111521)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/crash/TestEntityHelper.java	2011-06-06 15:00:53 UTC (rev 111522)
@@ -24,6 +24,7 @@
 import javax.ejb.Stateless;
 import javax.ejb.TransactionAttribute;
 import javax.ejb.TransactionAttributeType;
+import javax.naming.InitialContext;
 import javax.persistence.EntityManager;
 import javax.persistence.PersistenceContext;
 
@@ -106,5 +107,69 @@
       }
       return false;
    }
+
+   // ----------------------------------   JBTM-575    ---------------------------------------------------------
+   @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
+   public boolean testJBTM575()
+   {
+	   boolean result = true;
+	   try 
+	   {
+		   InitialContext cx = new InitialContext(); 
+		   TestEntityHelperLocal me = (TestEntityHelperLocal) cx.lookup(TestEntityHelper.LOCAL_JNDI_NAME);
+		   
+		   me.createTestEntityForJBTM575("jbtm575");
+		   
+		   me.createTestEntityForJBTM575("jbtm575");
+		   
+	   }
+	   catch (javax.ejb.EJBTransactionRolledbackException e)
+	   {
+		   // expected exception
+		   log.info("catched the expected exception: " + e.getMessage(), e);
+		   // check if we can navigate from the catched exception to the ConstraintViolationException
+		   result = goDownThroughException(e, "org.hibernate.exception.ConstraintViolationException");
+	   }
+	   catch (Exception e)
+	   {
+		   // unexpected exception
+		   log.warn("catched an unexpected exception: " + e.getMessage(), e);
+		   result = false;
+		   goDownThroughException(e, "org.hibernate.exception.ConstraintViolationException");
+	   }
+	   return result;
+   }
    
+   private boolean goDownThroughException(Throwable exception, String expectedCauseExceptionClassName)
+   {
+	   log.info("expectedCauseExceptionClassName="+expectedCauseExceptionClassName);
+	   boolean reachedCauseException = false;
+	   
+	   Throwable causeException = exception;
+	   do 
+	   {
+		   causeException = causeException.getCause();
+		   
+		   log.info("causeException: " + ((causeException != null) ? causeException.getClass().getName() : "null"));
+		   
+		   if (causeException != null && expectedCauseExceptionClassName.equals(causeException.getClass().getName()))
+		   {
+			   log.info("got it");
+			   reachedCauseException = true;
+			   break;
+		   }
+	   }
+	   while (causeException != null);
+	   
+	   return reachedCauseException;
+   }
+
+   @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
+   public TestEntity createTestEntityForJBTM575(String entityPK)
+   {
+      TestEntity entity = new TestEntity(entityPK, TEST_ENTITY_INIT_VALUE);
+      em.persist(entity);
+      return entity;
+   }
+
 }

Modified: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/crash/TestEntityHelperLocal.java
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/crash/TestEntityHelperLocal.java	2011-06-05 01:12:52 UTC (rev 111521)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/crash/TestEntityHelperLocal.java	2011-06-06 15:00:53 UTC (rev 111522)
@@ -26,5 +26,8 @@
 @Local
 public interface TestEntityHelperLocal
 {
-   public boolean updateTestEntity(String entityPK);
+   public boolean updateTestEntity(String entityPK);   
+   
+   public boolean testJBTM575();
+   public TestEntity createTestEntityForJBTM575(String entityPK);
 }

Modified: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/crash/TestEntityHelperRem.java
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/crash/TestEntityHelperRem.java	2011-06-05 01:12:52 UTC (rev 111521)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/crash/TestEntityHelperRem.java	2011-06-06 15:00:53 UTC (rev 111522)
@@ -28,4 +28,6 @@
 {
    public TestEntity initTestEntity(String entityPK);
    public TestEntity getTestEntity(String entityPK);
+   
+   public boolean testJBTM575();
 }



More information about the jboss-cvs-commits mailing list