[cvs] expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/core/dbobj/tests DBObjectTest.java

JCorporate Ltd jcorp at jcorp2.servlets.net
Mon Jun 7 22:49:32 PDT 2004


Update of /home/javacorp/.cvs/expresso/expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/core/dbobj/tests
In directory jcorp2.servlets.net:/tmp/cvs-serv30298/expresso-web/WEB-INF/src/com/jcorporate/expresso/core/dbobj/tests

Modified Files:
	DBObjectTest.java 
Log Message:
fix deletion during clean-up


Index: DBObjectTest.java
===================================================================
RCS file: /home/javacorp/.cvs/expresso/expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/core/dbobj/tests/DBObjectTest.java,v
retrieving revision 1.32
retrieving revision 1.33
diff -C2 -d -r1.32 -r1.33
*** DBObjectTest.java	8 Jun 2004 02:28:41 -0000	1.32
--- DBObjectTest.java	8 Jun 2004 05:49:30 -0000	1.33
***************
*** 73,76 ****
--- 73,77 ----
  import com.jcorporate.expresso.core.misc.ConfigurationException;
  import com.jcorporate.expresso.core.misc.DateTime;
+ import com.jcorporate.expresso.core.misc.StringUtil;
  import com.jcorporate.expresso.services.test.TestSystemInitializer;
  import junit.framework.Test;
***************
*** 86,90 ****
  
  /**
!  * A test case to verify the functions of DBObject.  
   */
  public class DBObjectTest
--- 87,91 ----
  
  /**
!  * A test case to verify the functions of DBObject.
   */
  public class DBObjectTest
***************
*** 273,276 ****
--- 274,278 ----
              oneTest.setDataContext(TestSystemInitializer.getTestContext());
              oneTest.setField("TestKey", "1");
+             log.warn("About to throw intentional exception having to do with duplicate key. Ignore this dup-key exception.");
              oneTest.add();
              fail("Test add should have thrown exception on duplicate key here");
***************
*** 1072,1075 ****
--- 1074,1137 ----
      }
  
+     /**
+      * test the proper handling of large chunks of text using Clob (as mapped by expresso-config.xml)
+      * with 40K, 80K, and 120K chars
+      */
+     public void testLargeText() {
+         String resourceId = null;
+         DBConnectionPool myPool = null;
+         DBConnection myConnection = null;
+         try {
+             try {
+                 myPool =
+                         DBConnectionPool.getInstance(TestSystemInitializer.getTestContext());
+                 myConnection = myPool.getConnection();
+ 
+ 
+                 for (int i = 1; i < 4; i++) {
+                     String teststr = StringUtil.repeatString("0123456789", 4000 * i);
+                     Test1 setter = new Test1(myConnection);
+                     setter.setField("TestKey", 1);
+                     log.warn("Set CLOB field to " + teststr.length() + " chars.");
+                     setter.setField("ClobTest", teststr);
+                     if ( setter.find() ) setter.update();
+                     else setter.add();
+ 
+                     Test1 getter = new Test1(myConnection);
+                     getter.setField("TestKey", 1);
+                     getter.retrieve();
+ 
+                     assertTrue("Clob is empty" ,  getter.getField("ClobTest").length() > 0);
+                     assertEquals(getter.getField("ClobTest"), setter.getField("ClobTest"));
+ 
+                     getter.delete();
+                 }
+ 
+             } catch (DBException e) {
+                 log.error("DBException!", e);
+                 if (myConnection != null)
+                     myConnection.rollback();
+                 fail("Exception occured:" + e.getMessage());
+             } finally {
+                 if (myPool != null) {
+                     myPool.release(myConnection);
+                 }
+             }
+         } catch (DBException e) {
+             log.error("DBException!", e);
+             fail("Exception occured:" + e.getMessage());
+         }
+ 
+ 
+         try {
+             log.info("Delete resource:" + resourceId);
+             Test1 resource = new Test1();
+             resource.setDataContext(TestSystemInitializer.getTestContext());
+             resource.deleteAll();
+         } catch (Exception e) {
+             log.error(e);
+             fail("Exception occured:" + e.getMessage());
+         }
+     }
  
      public void testResourceTransaction() {



More information about the cvs mailing list