[jboss-cvs] JBossAS SVN: r63708 - in trunk/ejb3/src/test/org/jboss/ejb3/test/entityexception: unit and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Jun 28 07:41:25 EDT 2007


Author: wolfc
Date: 2007-06-28 07:41:25 -0400 (Thu, 28 Jun 2007)
New Revision: 63708

Modified:
   trunk/ejb3/src/test/org/jboss/ejb3/test/entityexception/ExceptionTest.java
   trunk/ejb3/src/test/org/jboss/ejb3/test/entityexception/ExceptionTestBean.java
   trunk/ejb3/src/test/org/jboss/ejb3/test/entityexception/Person.java
   trunk/ejb3/src/test/org/jboss/ejb3/test/entityexception/unit/EntityExceptionTestCase.java
Log:
Merged entityexception unit test from Branch_4_2

Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/entityexception/ExceptionTest.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/entityexception/ExceptionTest.java	2007-06-28 11:24:22 UTC (rev 63707)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/entityexception/ExceptionTest.java	2007-06-28 11:41:25 UTC (rev 63708)
@@ -38,6 +38,7 @@
    void testEMCreateQueryExceptions();
    void testEMRefreshExceptions();
    void testEMContainsExceptions();
+   void testQueryNonEntity();
    void testQuerySingleResultExceptions();
    void testQuerySetHintAndParameter();
 }

Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/entityexception/ExceptionTestBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/entityexception/ExceptionTestBean.java	2007-06-28 11:24:22 UTC (rev 63707)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/entityexception/ExceptionTestBean.java	2007-06-28 11:41:25 UTC (rev 63708)
@@ -31,6 +31,7 @@
 import javax.persistence.PersistenceContext;
 import javax.persistence.Query;
 import javax.persistence.TransactionRequiredException;
+import javax.persistence.NoResultException;
 
 /**
  *
@@ -256,24 +257,43 @@
       Query query = manager.createQuery("from Person");
       try
       {
+         System.out.println("Before query");
          query.getSingleResult();
+         System.out.println("After query");
          throw new RuntimeException("NonUniqueResultException not thrown for getSingleResult");
       }
       catch(NonUniqueResultException e)
       {
+
+         System.out.println("Actual exception");
+         e.printStackTrace( );
       }
-      
+
+      System.out.println("Second query");
       Query query2 = manager.createQuery("from Person where id=999");
       try
       {
          query2.getSingleResult();
-         throw new RuntimeException("EntityNotFoundException not thrown for getSingleResult returning no results");
+         throw new RuntimeException("NoResultException not thrown for getSingleResult returning no results");
       }
-      catch(EntityNotFoundException e)
+      catch(NoResultException e)
       {
       }
    }
    
+   public void testQueryNonEntity()
+   {
+      try
+      {
+         manager.createQuery("from NonEntity");
+         throw new RuntimeException("Expected IllegalArgumentException");
+      }
+      catch(IllegalArgumentException e)
+      {
+         
+      }
+   }
+   
    public void testQuerySetHintAndParameter()
    {
       
@@ -308,8 +328,8 @@
       }
       
       query = manager.createQuery("from Person where id=? and name=?");
-      query.setParameter(0, 1);
-      query.setParameter(1, "XXX");
+      query.setParameter(1, 1);
+      query.setParameter(2, "XXX");
       try
       {
          query.setParameter(-1, "HELLO");
@@ -317,7 +337,12 @@
       }
       catch(IllegalArgumentException e)
       {
+         // spec
       }
+      catch(IndexOutOfBoundsException e)
+      {
+         // current impl
+      }
 
       try
       {
@@ -326,7 +351,12 @@
       }
       catch(IllegalArgumentException e)
       {
+         // spec
       }
+      catch(IndexOutOfBoundsException e)
+      {
+         // current impl
+      }
    }
 
 }

Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/entityexception/Person.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/entityexception/Person.java	2007-06-28 11:24:22 UTC (rev 63707)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/entityexception/Person.java	2007-06-28 11:41:25 UTC (rev 63708)
@@ -24,8 +24,9 @@
 import java.io.Serializable;
 
 import javax.persistence.Entity;
-import javax.persistence.GeneratedValue; import javax.persistence.GenerationType;
-import javax.persistence.Id;;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
 /**
  *
  * @author <a href="mailto:kabir.khan at jboss.org">Kabir Khan</a>

Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/entityexception/unit/EntityExceptionTestCase.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/entityexception/unit/EntityExceptionTestCase.java	2007-06-28 11:24:22 UTC (rev 63707)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/entityexception/unit/EntityExceptionTestCase.java	2007-06-28 11:41:25 UTC (rev 63708)
@@ -89,6 +89,13 @@
       test.testEMContainsExceptions();
    }
    
+   public void testQueryNonEntity() throws Exception
+   {
+      ExceptionTest test = 
+         (ExceptionTest)getInitialContext().lookup("ExceptionTestBean/remote");
+      test.testQueryNonEntity();
+   }
+   
    public void testQuerySingleResultExceptions()throws Exception
    {
       ExceptionTest test = 




More information about the jboss-cvs-commits mailing list