db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bri...@apache.org
Subject cvs commit: db-ojb/src/test/org/apache/ojb/jdo TestPersistenceManager.java
Date Sat, 03 Apr 2004 01:51:13 GMT
brianm      2004/04/02 17:51:13

  Added:       src/test/org/apache/ojb/jdo TestPersistenceManager.java
  Log:
  OJB Native JDO unit test
  
  Revision  Changes    Path
  1.1                  db-ojb/src/test/org/apache/ojb/jdo/TestPersistenceManager.java
  
  Index: TestPersistenceManager.java
  ===================================================================
  package org.apache.ojb.jdo;
  
  import junit.framework.TestCase;
  
  import javax.jdo.PersistenceManager;
  import javax.jdo.Extent;
  import javax.jdo.Transaction;
  import javax.jdo.Query;
  
  import org.apache.ojb.odmg.Article;
  import org.apache.ojb.otm.Person;
  
  import java.util.Collection;
  
  public class TestPersistenceManager extends TestCase
  {
  
      private PersistenceManagerFactoryImpl factory = new PersistenceManagerFactoryImpl();
  
      public void testLoadExtent() throws Exception
      {
          PersistenceManager pm = factory.getPersistenceManager();
          Transaction tx = pm.currentTransaction();
          tx.begin();
          Extent extent = pm.getExtent(Article.class, true);
          tx.commit();
          assertNotNull(extent);
      }
  
      /**
       * @todo figure out if transactions can be re-begined in JDO
       */ 
      public void testTwoTransactions() throws Exception
      {
          Person person = new Person();
          person.setFirstname("Brian");
          person.setLastname("McCallister");
          PersistenceManager pm = factory.getPersistenceManager();
          Transaction tx = pm.currentTransaction();
          tx.begin();
          pm.makePersistent(person);
          tx.commit();
  
          tx = pm.currentTransaction();
          tx.begin();
          Query q = pm.newQuery(Person.class);
          Collection persons = (Collection) q.execute();
          tx.commit();
          assertTrue(persons.size() > 0);
      }
  }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Mime
View raw message