db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arm...@apache.org
Subject cvs commit: db-ojb/src/test/org/apache/ojb/broker ObjectCacheTest.java
Date Fri, 05 Sep 2003 15:01:47 GMT
arminw      2003/09/05 08:01:47

  Modified:    src/test/org/apache/ojb/broker ObjectCacheTest.java
  Log:
  update test
  
  Revision  Changes    Path
  1.7       +81 -3     db-ojb/src/test/org/apache/ojb/broker/ObjectCacheTest.java
  
  Index: ObjectCacheTest.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/ObjectCacheTest.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ObjectCacheTest.java	10 Aug 2003 09:53:13 -0000	1.6
  +++ ObjectCacheTest.java	5 Sep 2003 15:01:47 -0000	1.7
  @@ -146,9 +146,9 @@
   	/**
   	 * This test checks if the caches of two different brokers are properly isolated.
   	 * changes made to an object in tx1 should not be visible in tx2 !
  -	 * @todo: once we work without global cache this test should pass!
  +	 * TODO: once we work without global cache this test should pass!
   	 */
  -    public void XXXtestCacheIsolation() throws Exception
  +    public void YYYtestCacheIsolation() throws Exception
       {
           Object[] pk = new Object[] { new Long(42)};
           Identity oid = new Identity(Article.class, InterfaceArticle.class, pk);
  @@ -213,6 +213,54 @@
           }
       }
   
  +    /**
  +     * Test per class ObjectCache declaration. TestObject
  +     * metadata declare an 'empty ObjectCache' implementation
  +     * as cache, CacheObject use the default ObjectCache implementation.
  +     * Thus we found CacheObject instance in cache, but NOT found
  +     * TestObject instance.
  +     */
  +    public void YYYtestPerClassCache()
  +    {
  +        String name = "testPerClassCache_" + System.currentTimeMillis();
  +
  +        TestObject obj = new TestObject();
  +        obj.setName(name);
  +        CacheObject dummy = new CacheObject();
  +        dummy.setName(name);
  +
  +        PersistenceBroker broker = PersistenceBrokerFactory.defaultPersistenceBroker();
  +        try
  +        {
  +            broker.beginTransaction();
  +            broker.store(obj);
  +            broker.store(dummy);
  +            broker.commitTransaction();
  +
  +            Identity obj_oid = new Identity(obj, broker);
  +            Identity dummy_oid = new Identity(dummy, broker);
  +            ObjectCache cache = broker.serviceObjectCache();
  +            Object ret_obj = cache.lookup(obj_oid);
  +            Object ret_dummy = cache.lookup(dummy_oid);
  +            assertNull(ret_obj);
  +            assertNotNull(ret_dummy);
  +        }
  +        catch (Exception e)
  +        {
  +            e.printStackTrace();
  +            if(broker != null && broker.isInTransaction()) broker.abortTransaction();
  +        }
  +        finally
  +        {
  +            if(broker != null) broker.close();
  +        }
  +    }
  +
  +    public void YYYtestPerDatabaseCache()
  +    {
  +
  +    }
  +
   
   
       // **********************************************************************
  @@ -263,6 +311,36 @@
   
           public CacheObject_2()
           {
  +        }
  +    }
  +
  +    public static class TestObject
  +    {
  +        private Integer id;
  +        private String name;
  +
  +        public TestObject()
  +        {
  +        }
  +
  +        public Integer getId()
  +        {
  +            return id;
  +        }
  +
  +        public void setId(Integer id)
  +        {
  +            this.id = id;
  +        }
  +
  +        public String getName()
  +        {
  +            return name;
  +        }
  +
  +        public void setName(String name)
  +        {
  +            this.name = name;
           }
       }
   
  
  
  

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