[jbosscache-commits] JBoss Cache SVN: r5428 - in pojo/branches/2.1/src: test/java/org/jboss/cache/pojo and 1 other directories.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Thu Mar 13 17:47:59 EDT 2008


Author: jason.greene at jboss.com
Date: 2008-03-13 17:47:59 -0400 (Thu, 13 Mar 2008)
New Revision: 5428

Added:
   pojo/branches/2.1/src/test/java/org/jboss/cache/pojo/test/DoubleRef.java
Modified:
   pojo/branches/2.1/src/main/java/org/jboss/cache/pojo/impl/PojoInstance.java
   pojo/branches/2.1/src/test/java/org/jboss/cache/pojo/LocalTest.java
Log:
Fix PCACHE-61


Modified: pojo/branches/2.1/src/main/java/org/jboss/cache/pojo/impl/PojoInstance.java
===================================================================
--- pojo/branches/2.1/src/main/java/org/jboss/cache/pojo/impl/PojoInstance.java	2008-03-13 16:51:00 UTC (rev 5427)
+++ pojo/branches/2.1/src/main/java/org/jboss/cache/pojo/impl/PojoInstance.java	2008-03-13 21:47:59 UTC (rev 5428)
@@ -104,10 +104,6 @@
          referencedBy_ = new ArrayList();
       }
 
-      if (referencedBy_.contains(sourceFqn))
-         throw new IllegalStateException("PojoReference.incrementRefCount(): source fqn: " +
-                                         sourceFqn + " is already present.");
-
       if (util_ == null) util_ = new PojoUtil();
       refCount_ = util_.incrementReferenceCount(sourceFqn, refCount_, referencedBy_);
 //      referencedBy_.add(sourceFqn);

Modified: pojo/branches/2.1/src/test/java/org/jboss/cache/pojo/LocalTest.java
===================================================================
--- pojo/branches/2.1/src/test/java/org/jboss/cache/pojo/LocalTest.java	2008-03-13 16:51:00 UTC (rev 5427)
+++ pojo/branches/2.1/src/test/java/org/jboss/cache/pojo/LocalTest.java	2008-03-13 21:47:59 UTC (rev 5428)
@@ -19,8 +19,10 @@
 import org.jboss.cache.Fqn;
 import org.jboss.cache.pojo.impl.PojoReference;
 import org.jboss.cache.pojo.test.Address;
+import org.jboss.cache.pojo.test.DoubleRef;
 import org.jboss.cache.pojo.test.Person;
 import org.jboss.cache.pojo.test.Student;
+import org.testng.AssertJUnit;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
@@ -406,4 +408,15 @@
       PojoReference ref = (PojoReference) cache_.getCache().get(fqn,  PojoReference.KEY);
       assertTrue(cache_.exists(ref.getFqn()));
    }
+   
+   public void testDoubleRef() throws Exception
+   {
+      DoubleRef ref = new DoubleRef();
+      cache_.attach("/test", ref);
+
+      AssertJUnit.assertSame(ref.getOne(), ref.getTwo());
+      
+      ref.setOne(null);
+      ref.setTwo(null);
+   }
 }
\ No newline at end of file

Added: pojo/branches/2.1/src/test/java/org/jboss/cache/pojo/test/DoubleRef.java
===================================================================
--- pojo/branches/2.1/src/test/java/org/jboss/cache/pojo/test/DoubleRef.java	                        (rev 0)
+++ pojo/branches/2.1/src/test/java/org/jboss/cache/pojo/test/DoubleRef.java	2008-03-13 21:47:59 UTC (rev 5428)
@@ -0,0 +1,56 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.cache.pojo.test;
+
+import org.jboss.cache.pojo.annotation.Replicable;
+
+/**
+ * Contains two fields referring to the same object reference
+ *
+ * @author Jason T. Greene
+ */
+ at Replicable
+public class DoubleRef
+{
+   private Student one = new Student();
+   private Student two = one;
+  
+   public Student getOne()
+   {
+      return one;
+   }
+   
+   public void setOne(Student one)
+   {
+      this.one = one;
+   }
+   
+   public Student getTwo()
+   {
+      return two;
+   }
+   
+   public void setTwo(Student two)
+   {
+      this.two = two;
+   }
+}




More information about the jbosscache-commits mailing list