db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b..@apache.org
Subject cvs commit: db-ojb/src/test/org/apache/ojb repository_junit.xml
Date Wed, 04 Aug 2004 21:05:19 GMT
brj         2004/08/04 14:05:19

  Modified:    src/test/org/apache/ojb/broker ProxyExamples.java
               src/test/org/apache/ojb repository_junit.xml
  Log:
  testcase for proxied references
  
  Revision  Changes    Path
  1.15      +44 -3     db-ojb/src/test/org/apache/ojb/broker/ProxyExamples.java
  
  Index: ProxyExamples.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/ProxyExamples.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- ProxyExamples.java	15 Jul 2004 21:46:56 -0000	1.14
  +++ ProxyExamples.java	4 Aug 2004 21:05:18 -0000	1.15
  @@ -1,15 +1,16 @@
   package org.apache.ojb.broker;
   
  +import java.lang.reflect.Proxy;
   import java.util.Collection;
   import java.util.Iterator;
   import java.util.Vector;
   
  +import org.apache.ojb.broker.core.proxy.ProxyHelper;
   import org.apache.ojb.broker.core.proxy.VirtualProxy;
  +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.junit.PBTestCase;
  -//#ifdef JDK13
  -import java.lang.reflect.Proxy;
   //#else
   /*
   import com.develop.java.lang.reflect.Proxy;
  @@ -253,7 +254,7 @@
   		}
   	}
   
  -	public void testReferenceProxies()
  +	public void testReferenceProxies1()
   	{
   		ArticleWithReferenceProxy a = new ArticleWithReferenceProxy();
   //		a.setArticleId(8888);
  @@ -275,6 +276,46 @@
   		ArticleWithReferenceProxy ar = (ArticleWithReferenceProxy) broker.getObjectByQuery(q);
   
   		assertEquals(id, ar.getProductGroup().getId());
  +	}
  +
  +	public void testReferenceProxies2()
  +	{
  +		ArticleWithReferenceProxy ar;
  +		InterfaceProductGroup pg, pga, pg_real;
  +		Criteria crit;
  +		Query query;
  +
  +		// load real obj first, then proxied obj
  +		broker.clearCache();
  +
  +		crit = new Criteria();
  +		crit.addEqualTo("groupId",new Integer(1));
  +		query = QueryFactory.newQuery(ProductGroupWithCollectionProxy.class, crit);
  +		pg = (InterfaceProductGroup)broker.getObjectByQuery(query);
  +
  +		crit = new Criteria();
  +		crit.addEqualTo("articleName","Chai");
  +		query = QueryFactory.newQuery(ArticleWithReferenceProxy.class, crit);
  +		ar = (ArticleWithReferenceProxy)broker.getObjectByQuery(query);
  +		pga = ar.getProductGroup(); 	// returns the real obj
  +
  +		assertSame(pg, pga);
  +		
  +		// load proxied obj first, then proxied obj
  +		broker.clearCache();
  +
  +		crit = new Criteria();
  +		crit.addEqualTo("articleName","Chai");
  +		query = QueryFactory.newQuery(ArticleWithReferenceProxy.class, crit);
  +		ar = (ArticleWithReferenceProxy)broker.getObjectByQuery(query);
  +		pga = ar.getProductGroup();		// returns a proxy
  +
  +		crit = new Criteria();
  +		crit.addEqualTo("groupId",new Integer(1));
  +		query = QueryFactory.newQuery(ProductGroupWithCollectionProxy.class, crit);
  +		pg = (InterfaceProductGroup)broker.getObjectByQuery(query);
  +		
  +		assertSame(pg, ProxyHelper.getIndirectionHandler(pga).getRealSubject());
   	}
   
   	/**
  
  
  
  1.118     +2 -2      db-ojb/src/test/org/apache/ojb/repository_junit.xml
  
  Index: repository_junit.xml
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/repository_junit.xml,v
  retrieving revision 1.117
  retrieving revision 1.118
  diff -u -r1.117 -r1.118
  --- repository_junit.xml	27 Jul 2004 23:38:50 -0000	1.117
  +++ repository_junit.xml	4 Aug 2004 21:05:19 -0000	1.118
  @@ -489,7 +489,7 @@
         />
         <reference-descriptor
            name="productGroup"
  -         class-ref="org.apache.ojb.broker.ProductGroup"
  +         class-ref="org.apache.ojb.broker.ProductGroupWithCollectionProxy"
            proxy="true"
            auto-update="true"
         >
  
  
  

---------------------------------------------------------------------
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