db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From olegn...@apache.org
Subject cvs commit: db-ojb/src/test/org/apache/ojb/odmg BatchModeTest.java AllTests.java
Date Sun, 16 Feb 2003 17:32:06 GMT
olegnitz    2003/02/16 09:32:05

  Modified:    src/test/org/apache/ojb/broker AllTests.java
               src/test/org/apache/ojb/odmg AllTests.java
  Added:       src/test/org/apache/ojb/broker BatchModeTest.java
               src/test/org/apache/ojb/odmg BatchModeTest.java
  Log:
  Added batch mode tests
  
  Revision  Changes    Path
  1.18      +17 -5     db-ojb/src/test/org/apache/ojb/broker/AllTests.java
  
  Index: AllTests.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/AllTests.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- AllTests.java	31 Jan 2003 17:50:05 -0000	1.17
  +++ AllTests.java	16 Feb 2003 17:32:05 -0000	1.18
  @@ -7,13 +7,22 @@
   import org.apache.ojb.broker.metadata.RepositoryPersistorTest;
   import org.apache.ojb.broker.sequence.SequenceManagerTest;
   
  -/**
 * the facade to all TestCases in this package.
 *
 * @author: Thomas Mahler
 */
  +/**
  + * the facade to all TestCases in this package.
  + *
  + * @author: Thomas Mahler
  + */
   public class AllTests extends junit.framework.TestSuite
   {
  -    /** static reference to .class.
     * Java does not provide any way to obtain the
Class object from
     * static method without naming it.
     */
  +    /** static reference to .class.
  +     * Java does not provide any way to obtain the Class object from
  +     * static method without naming it.
  +     */
       private static Class CLASS = AllTests.class;
   
  -    /**
     * runs the suite in a junit.textui.TestRunner.
     */
  +    /**
  +     * runs the suite in a junit.textui.TestRunner.
  +     */
       public static void main(String[] args)
       {
           String[] arr = {CLASS.getName()};
  @@ -50,13 +59,16 @@
           suite.addTest(new TestSuite(SequenceManagerTest.class));
           suite.addTest(new TestSuite(ConvertedKeyReferenceTest.class));
           suite.addTest(new TestSuite(KeyConstraintViolationTest.class));
  -        suite.addTest(new TestSuite(RsIteratorTest.class));
        //suite.addTest(new
TestSuite(BlobTest.class)); /* doesn't work for hsqldb */
        suite.addTest(new TestSuite(LogServiceTest.class));
  +        suite.addTest(new TestSuite(RsIteratorTest.class));
  +        //suite.addTest(new TestSuite(BlobTest.class)); /* doesn't work for hsqldb */
  +        suite.addTest(new TestSuite(LogServiceTest.class));
           suite.addTest(new TestSuite(ManyToManyTest.class));
           suite.addTest(new TestSuite(OneToOneTest.class));
           suite.addTest(new TestSuite(MetaDataSerializationTest.class));
           suite.addTest(new TestSuite(MetadataTest.class));
           suite.addTest(new TestSuite(FieldConversionForeigenKeyTest.class));
  +        suite.addTest(new TestSuite(BatchModeTest.class));
           return suite;
       }
   
  -}
  \ No newline at end of file
  +}
  
  
  
  1.1                  db-ojb/src/test/org/apache/ojb/broker/BatchModeTest.java
  
  Index: BatchModeTest.java
  ===================================================================
  /*
   * BatchModeTest.java
   * JUnit based test
   *
   * Created on February 15, 2003, 12:47 AM
   */
  
  package org.apache.ojb.broker;
  
  import junit.framework.*;
  import org.apache.ojb.broker.util.logging.LoggerFactory;
  import org.apache.ojb.broker.accesslayer.ConnectionManagerIF;
  import java.util.*;
  
  /**
   * @author Oleg Nitz
   */
  public class BatchModeTest extends TestCase
  {
  
      PersistenceBroker broker;
  
      public BatchModeTest(String testName)
      {
          super(testName);
      }
  
      public void setUp()
      {
          try
          {
              broker = PersistenceBrokerFactory.defaultPersistenceBroker();
          }
          catch (Throwable t)
          {
              LoggerFactory.getBootLogger().error("error getting broker", t);
          }
      }
  
      public void tearDown()
      {
          try
          {
              broker.clearCache();
              broker.close();
          }
          catch (Throwable t)
          {
          }
      }
  
      public static void main(String[] args)
      {
          junit.textui.TestRunner.run(suite());
      }
  
      public static Test suite()
      {
          TestSuite suite = new TestSuite(BatchModeTest.class);
          return suite;
      }
  
      public void testBatchStatementsOrder()
      {
          ConnectionManagerIF conMan = broker.serviceConnectionManager();
          boolean saveBatchMode = conMan.isBatchMode();
          try
          {
              conMan.setBatchMode(true);
  
              broker.beginTransaction();
  
              ProductGroup pg1 = new ProductGroup();
              pg1.setId(20001);
              pg1.setName("BatchModeTest ProductGroup #1");
              broker.store(pg1);
  
              conMan.executeBatch();
  
              Article a1 = new Article();
              a1.setArticleId(20001);
              a1.setArticleName("BatchModeTest Article #1");
              a1.setProductGroup(pg1);
              pg1.add(a1);
              broker.store(a1);
  
              ProductGroup pg2 = new ProductGroup();
              pg2.setId(20002);
              pg2.setName("BatchModeTest ProductGroup #2");
              broker.store(pg2);
  
              Article a2 = new Article();
              a2.setArticleId(20002);
              a2.setArticleName("BatchModeTest Article #2");
              a2.setProductGroup(pg2);
              pg2.add(a2);
              broker.store(a2);
  
              ProductGroup pg3 = new ProductGroup();
              pg3.setId(20003);
              pg3.setName("BatchModeTest ProductGroup #3");
              broker.store(pg3);
  
              Article a3 = new Article();
              a3.setArticleId(20003);
              a3.setArticleName("BatchModeTest Article #3");
              a3.setProductGroup(pg3);
              pg3.add(a3);
              broker.store(a3);
  
              conMan.executeBatch();
  
              broker.delete(a1);
  
              conMan.executeBatch();
  
              broker.delete(pg1);
              broker.delete(a2);
              broker.delete(pg2);
              broker.delete(a3);
              broker.delete(pg3);
  
              conMan.executeBatch();
          }
          finally
          {
              broker.commitTransaction();
              conMan.setBatchMode(saveBatchMode);
          }
      }
  }
  
  
  
  1.11      +1 -0      db-ojb/src/test/org/apache/ojb/odmg/AllTests.java
  
  Index: AllTests.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/odmg/AllTests.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- AllTests.java	15 Feb 2003 16:05:26 -0000	1.10
  +++ AllTests.java	16 Feb 2003 17:32:05 -0000	1.11
  @@ -53,6 +53,7 @@
           suite.addTest(new TestSuite(OneToManyTest.class));
           suite.addTest(new TestSuite(OQLOrOnForeignKeyTest.class));
           suite.addTest(new TestSuite(FieldConversion_ForeigenKeyTest.class));
  +        suite.addTest(new TestSuite(BatchModeTest.class));
   		//suite.addTest(new TestSuite(OdmgCollectionsTest.class));
   		suite.addTest(new TestSuite(PersonWithArrayTest.class));
           return suite;
  
  
  
  1.1                  db-ojb/src/test/org/apache/ojb/odmg/BatchModeTest.java
  
  Index: BatchModeTest.java
  ===================================================================
  /*
   * BatchModeTest.java
   * JUnit based test
   *
   * Created on February 15, 2003, 12:47 AM
   */
  
  package org.apache.ojb.odmg;
  
  import junit.framework.*;
  import java.util.*;
  
  import org.odmg.Database;
  import org.odmg.Implementation;
  import org.odmg.ODMGException;
  import org.odmg.Transaction;
  
  import org.apache.ojb.broker.Article;
  import org.apache.ojb.broker.ProductGroup;
  import org.apache.ojb.broker.TestHelper;
  
  /**
   * @author Oleg Nitz
   */
  public class BatchModeTest extends TestCase
  {
      public BatchModeTest(String testName)
      {
          super(testName);
      }
  
      public static void main(String[] args)
      {
          junit.textui.TestRunner.run(new TestSuite(BatchModeTest.class));
      }
  
      public void testBatchStatementsOrder()
      {
          Implementation odmg = OJB.getInstance();
          Database db = odmg.newDatabase();
          //open database
          try
          {
              db.open(TestHelper.DEF_DATABASE_NAME, Database.OPEN_READ_WRITE);
          }
          catch (ODMGException ex)
          {
              fail("ODMGException: " + ex.getMessage());
          }
          Transaction tx = odmg.newTransaction();
  
          try
          {
              tx.begin();
  
              ProductGroup pg1 = new ProductGroup();
              pg1.setId(20001);
              pg1.setName("BatchModeTest ProductGroup #1");
              db.makePersistent(pg1);
  
              tx.checkpoint();
  
              Article a1 = Article.createInstance();
              a1.setArticleId(20001);
              a1.setArticleName("BatchModeTest Article #1");
              a1.setProductGroup(pg1);
              pg1.add(a1);
              db.makePersistent(a1);
  
              ProductGroup pg2 = new ProductGroup();
              pg2.setId(20002);
              pg2.setName("BatchModeTest ProductGroup #2");
              db.makePersistent(pg2);
  
              Article a2 = Article.createInstance();
              a2.setArticleId(20002);
              a2.setArticleName("BatchModeTest Article #2");
              a2.setProductGroup(pg2);
              pg2.add(a2);
  
              tx.checkpoint();
  
              db.deletePersistent(a1);
  
              tx.checkpoint();
  
              db.deletePersistent(pg1);
              db.deletePersistent(a2);
              db.deletePersistent(pg2);
  
              tx.checkpoint();
          }
          finally
          {
              try
              {
                  tx.commit();
              }
              catch (Exception ex)
              {
              }
  
              try
              {
                  db.close();
              }
              catch (ODMGException ex)
              {
                  fail("ODMGException: " + ex.getMessage());
              }
          }
      }
  }
  
  
  

Mime
View raw message