You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-dev@db.apache.org by ar...@apache.org on 2005/03/14 19:55:17 UTC

cvs commit: db-ojb/src/test/org/apache/ojb/broker ContractVersionEffectivenessTest.java

arminw      2005/03/14 10:55:17

  Modified:    src/test/org/apache/ojb/broker Tag: OJB_1_0_RELEASE
                        ContractVersionEffectivenessTest.java
  Log:
  add new test case, testing PB.releaseAllReferences method, auto-retrieve is false, PK and FK fields are Strings
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.5.2.1   +42 -9     db-ojb/src/test/org/apache/ojb/broker/ContractVersionEffectivenessTest.java
  
  Index: ContractVersionEffectivenessTest.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/ContractVersionEffectivenessTest.java,v
  retrieving revision 1.5
  retrieving revision 1.5.2.1
  diff -u -r1.5 -r1.5.2.1
  --- ContractVersionEffectivenessTest.java	22 Jun 2004 18:16:22 -0000	1.5
  +++ ContractVersionEffectivenessTest.java	14 Mar 2005 18:55:16 -0000	1.5.2.1
  @@ -7,6 +7,7 @@
   import org.apache.ojb.broker.query.Criteria;
   import org.apache.ojb.broker.query.Query;
   import org.apache.ojb.broker.query.QueryFactory;
  +import org.apache.ojb.broker.metadata.ObjectReferenceDescriptor;
   import org.apache.ojb.junit.PBTestCase;
   
   import java.sql.Timestamp;
  @@ -41,7 +42,6 @@
       public void setUp() throws Exception
       {
           super.setUp();
  -        createTestData();
       }
   
       /**
  @@ -50,13 +50,6 @@
        */
       public void tearDown() throws Exception
       {
  -        try
  -        {
  -            testDeleteContractVersionEffectiveness();
  -        }
  -        catch (PersistenceBrokerException e)
  -        {
  -        }
           super.tearDown();
       }
   
  @@ -91,10 +84,50 @@
           }
           broker.commitTransaction();
       }
  +
  +    private void deleteTestData()
  +    {
  +
  +    }
  +
       public void testCreateContractVersionEffectiveness()
       {
  -     createTestData();
  +        createTestData();
       }
  +
  +    public void testAutoRetrieveFalse()
  +    {
  +        ojbChangeReferenceSetting(Contract.class, "relatedToContract", false,
  +                ObjectReferenceDescriptor.CASCADE_OBJECT, ObjectReferenceDescriptor.CASCADE_OBJECT, false);
  +        String name = "testAutoRetrieveFalse_" + System.currentTimeMillis();
  +        Contract contract = new Contract();
  +        contract.setPk("C"+System.currentTimeMillis());
  +        contract.setContractValue1(name + "_Contract");
  +        contract.setContractValue2(1);
  +        contract.setContractValue3("contractvalue3");
  +        contract.setContractValue4(new Timestamp(System.currentTimeMillis()));
  +
  +        RelatedToContract rc = new RelatedToContract();
  +        rc.setPk("R_" + System.currentTimeMillis());
  +        rc.setRelatedValue1(name + "_RelatedToContract");
  +
  +        contract.setRelatedToContract(rc);
  +        broker.beginTransaction();
  +        // auto-update is true
  +        broker.store(contract);
  +        broker.commitTransaction();
  +
  +        broker.clearCache();
  +        Identity oid = broker.serviceIdentity().buildIdentity(contract);
  +        Contract newC = (Contract) broker.getObjectByIdentity(oid);
  +        assertNotNull(newC);
  +        // auto-retrieve is false
  +        assertNull(newC.getRelatedToContract());
  +        broker.retrieveAllReferences(newC);
  +        // now the field should be populated
  +        assertNotNull(newC.getRelatedToContract());
  +    }
  +
       public void testUpdateContractVersionEffectiveness()
       {
           createTestData();
  
  
  

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