Question: should be changes made in simple serializable objects propagatet when 
using PojoCache?

Why in prestented code testPojo fails with error:
junit.framework.AssertionFailedError: expected:<2> but was:<1>
and testTreeCache success?

  | package org.jboss.cache.aop;
  | 
  | import java.util.Properties;
  | 
  | import javax.naming.Context;
  | 
  | import junit.framework.TestCase;
  | 
  | import org.jboss.cache.CacheException;
  | import org.jboss.cache.PropertyConfigurator;
  | 
  | public class PojoCacheSerializableTest extends TestCase {
  |     PojoCache cache_;
  | 
  |     PojoCache cache1_;
  | 
  |     public PojoCacheSerializableTest(String name) {
  |             super(name);
  |     }
  | 
  |     protected void setUp() throws Exception {
  |             super.setUp();
  |             Properties prop = new Properties();
  |             prop.put(Context.INITIAL_CONTEXT_FACTORY, 
"org.jboss.cache.transaction.DummyContextFactory");
  |             cache_ = new PojoCache();
  |             PropertyConfigurator config = new PropertyConfigurator(); // 
configure tree cache.
  |             config.configure(cache_, "META-INF/replSync-service.xml");
  | 
  |             cache1_ = new PojoCache();
  |             config.configure(cache1_, "META-INF/replSync-service.xml");
  |             cache_.start();
  |             cache1_.start();
  |     }
  | 
  |     protected void tearDown() throws Exception {
  |             super.tearDown();
  |             cache_.stop();
  |             cache1_.stop();
  |     }
  | 
  |     public void testPojo() throws CacheException {
  |             SimplePojo simplePojo = new SimplePojo();
  |             simplePojo.setStatus(1);
  |             cache_.putObject("a/b/c/d", simplePojo);
  | 
  |             SimplePojo simplePojo2 = (SimplePojo) 
cache1_.getObject("a/b/c/d");
  |             simplePojo2.setStatus(2);
  |             cache1_.putObject("a/b/c/d", simplePojo2);
  | 
  |             SimplePojo simplePojo3 = (SimplePojo) 
cache_.getObject("a/b/c/d");
  |             assertEquals(2, simplePojo3.getStatus());
  |     }
  | 
  |     public void testTreeCache() throws CacheException {
  |             SimplePojo simplePojo = new SimplePojo();
  |             simplePojo.setStatus(1);
  |             cache_.put("a/b/c/d", "key", simplePojo);
  | 
  |             SimplePojo simplePojo1 = (SimplePojo) cache1_.get("a/b/c/d", 
"key");
  |             simplePojo1.setStatus(2);
  |             cache1_.put("a/b/c/d", "key", simplePojo1);
  | 
  |             SimplePojo simplePojo2 = (SimplePojo) cache_.get("a/b/c/d", 
"key");
  |             assertEquals(2, simplePojo2.getStatus());
  |     }
  | }
  | 
  | 


SimplePojo

  | package org.jboss.cache.aop;
  | 
  | import java.io.Serializable;
  | 
  | import org.jboss.cache.aop.annotation.InstanceOfPojoCacheable;
  | public class SimplePojo implements Serializable{
  |     private int status;
  |     public int getStatus() {
  |             return status;
  |     }
  |     public void setStatus(int status) {
  |             this.status = status;
  |     }
  | }
  | 
  | 

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4029760#4029760

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4029760
_______________________________________________
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to