1 Reply Latest reply on Feb 13, 2007 3:00 AM by ben.wang

    JBossCache-1.4.1.GA - annotated50 example not working propar

    haviv.rosh

      Hello,
      I am trying to run the JBossCache-1.4.1.GA (stand alone-jdk1.5) annotated50 examples to work.
      The strange thing is that the weaving example(build.bat run.aop.example) works ok, but the loadtime mode(build.bat run.loadtime.example) doesn't.

      I have changed a bit the original StudentMaintTest Test case so it would check also the object graph replication.
      It seems that the Student's Address attribute isn't getting replicated.
      Any ideas?

      Here is the code I am testing :
      
      package test.examples;
      
      import junit.framework.TestCase;
      import junit.textui.TestRunner;
      
      import org.jboss.cache.PropertyConfigurator;
      import org.jboss.cache.aop.PojoCache;
      
      import examples.Address;
      import examples.Course;
      import examples.Student;
      
      /**
       * Driver test to illustrate the sensor netowrk supervising system using pojo cache. By using the cache, it will have:
       * <ul>
       * <li>automatic state fail over</li>
       * <li>fine-grained replication</li>
       * <li>preservation of object graph relationship</li>
       * </ul>
       */
      public class StudentMaintTest extends TestCase {
      
       private Student joe_;
       private Student mary_;
       private Course foo_;
       private Course bar_;
      
       // cache1 and cache2 are in the same clustering group.
       private PojoCache cache1_;
       private PojoCache cache2_;
      
       protected void setUp() throws Exception {
       cache1_ = createCache("TestCluster");
       cache2_ = createCache("TestCluster");
       init();
       }
      
       protected void tearDown() throws Exception {
       cache1_.remove("/");
       cache1_.stop();
       cache2_.stop();
       }
      
       private PojoCache createCache(String name) throws Exception {
       PojoCache tree = new PojoCache();
       PropertyConfigurator config = new PropertyConfigurator(); // configure the cache through injection
       // read in the replSync xml. Here we use synchronous mode replication.
       config.configure(tree, "META-INF/replSync-service.xml");
       tree.setClusterName(name); // We can set a different cluster group.
       tree.start(); // kick start the cache
       return tree;
       }
      
       /**
       * Populate the propagation tree.
       *
       * @throws Exception
       */
       protected void init() throws Exception {
      
      
       mary_ = new Student();
       mary_.setName("Mary Smith");
      
       Address address = new Address();
       address.setStreet("456 Oak Drive");
       address.setCity("Pleasantville, CA");
       address.setZip(94555);
      
       mary_.setAddress(address);
      
      
      
      
       }
      
       public void testPropagation() throws Exception {
      
       // Here we ask the pojo cache to manage mary_ and joe_
       cache1_.putObject("/students/54321", mary_);
      
       // Retrieve the pojos from the Server #2
       Student mary2 = (Student) cache2_.getObject("/students/54321");
      
       assertEquals(mary2.getName() , mary_.getName());
       //here it fails - sinch mary2.address object is null - probably not replicated
       assertEquals(mary_.getAddress().getCity() , mary2.getAddress().getCity());
      
      
       }
      
      
      
       public static void main(String[] args) throws Exception {
       TestRunner.run(StudentMaintTest.class);
       }
      }