Package org.jboss.cache.aop.test

Examples of org.jboss.cache.aop.test.Person


   public void testRemoveObject2() throws Exception
   {
      log.info("testRemoveObject2() ...");
      cache_.putObject("/person/joe", createPerson("Joe Black", 31));
      Person joe = (Person) cache_.getObject("/person/joe");
      cache_.putObject("/person/ben", createPerson("Ben Hogan", 51));
      Person ben = (Person) cache_.getObject("/person/ben");
      cache_.putObject("/person/john", createPerson("John Daly", 41));
      Person john = (Person) cache_.getObject("/person/john");

      Address addr = new Address();
      addr.setStreet("123 Albert Ave.");
      addr.setCity("Sunnyvale");
      addr.setZip(94087);

      Address addr1 = new Address();
      addr1.setStreet("123 Albert Ave.");
      addr1.setCity("San Jose");
      addr1.setZip(94087);

      // They share the sub-object: address
      log.info("testMultipleReference(): set Joe address");
      joe.setAddress(addr);
      log.info("testMultipleReference(): set Ben address");
      ben.setAddress(addr);
      log.info("testMultipleReference(): set John address");
      john.setAddress(addr);

      Address add1 = (Address) ((Person)cache_.getObject("/person/joe")).getAddress();
      Address add2 = (Address) ((Person)cache_.getObject("/person/ben")).getAddress();
      assertEquals(add1.getCity(), add2.getCity());
      addr.setCity("Santa Clara");
View Full Code Here


   }

   public void testPutPutLocal() throws Exception
   {
      log_.info("testPutPut() ....");
      Person test = new Person();
      test.setName("Ben");
      test.setAge(10);
      Address addr = new Address();
      addr.setZip(95123);
      addr.setCity("Sunnyvale");
      test.setAddress(addr);
      cache_.putObject("/a", test);
      Person result = (Person)cache_.getObject("/a");
      assertEquals(" ", test, result);

      Person joe = new Person();
      joe.setName("joe");
      joe.setAge(20);
      cache_.putObject("/a", joe);
      Person joe1 = (Person)cache_.getObject("/a");
      assertEquals("Age should be ", 20, joe1.getAge());

      assertEquals("Age should be ", 10, result.getAge());
      assertEquals("Zip should be ", 95123, result.getAddress().getZip());

      // Try to re-use the pojo
      cache_.putObject("/a", test);
      Person result1 = (Person)cache_.getObject("/a");
      assertEquals("Zip should be ", 95123, result1.getAddress().getZip());

   }
View Full Code Here

   }

   public void testPutPut() throws Exception
   {
      log_.info("testPutPut() ....");
      Person test = new Person();
      test.setName("Ben");
      test.setAge(10);
      Address addr = new Address();
      addr.setZip(95123);
      addr.setCity("Sunnyvale");
      test.setAddress(addr);
      cache_.putObject("/a", test);
      Person result = (Person)cache_.getObject("/a");
      assertEquals(" ", test, result);

      Person result1 = (Person)cache1_.getObject("/a");
      assertEquals("Age should be ", 10, result1.getAge());
      assertEquals("Zip should be ", 95123, result1.getAddress().getZip());

      Person joe = new Person();
      joe.setName("joe");
      joe.setAge(20);
      cache_.putObject("/a", joe);
      Person joe1 = (Person)cache_.getObject("/a");
      assertEquals("Age should be ", 20, joe1.getAge());

      assertEquals("Age should be ", 10, result.getAge());
      assertEquals("Zip should be ", 95123, result.getAddress().getZip());
   }
View Full Code Here

   }

   public void testPutCollection() throws Exception
   {
      log_.info("testPutCollection() ....");
      Person p1 = new Person();
      p1.setName("Ben");
      p1.setAge(10);
      p1.setAddress(getAddress("Sunnyvale"));

      List lang = new ArrayList();
      lang.add(getAddress("Taipei"));
      lang.add(getAddress("Tainan"));
      p1.setLanguages(lang);

      cache_.putObject("/a", p1);
      Person result = (Person)cache_.getObject("/a");
      assertEquals(" ", p1, result);

      Person result1 = (Person)cache1_.getObject("/a");
      assertEquals("Age should be ", 10, result1.getAge());
      assertEquals("Zip should be ", 95123, result1.getAddress().getZip());

      Person p2 = new Person();
      p2.setName("joe");
      p2.setAge(20);
      cache_.putObject("/a", p2);
      Person joe1 = (Person)cache_.getObject("/a");
      assertEquals("Age should be ", 20, joe1.getAge());

      // put p1 again
      cache_.putObject("/a", p1);

      // remove p1
      Person p3 = (Person)cache_.removeObject("/a");
      assertEquals("Zip should be ", 95123, p3.getAddress().getZip());

      assertEquals("Age should be ", 10, result.getAge());
      assertEquals("Zip should be ", 95123, result.getAddress().getZip());
   }
View Full Code Here

   }
   */
   public void testRemoteRemove() throws Exception
   {
      log_.info("testRemoteRemove() ....");
      Person test = new Person();
      test.setName("Ben");
      test.setAge(10);
      Address addr = new Address();
      addr.setCity("Taipei");
      addr.setZip(106);
      test.setAddress(addr);
      cache_.putObject("/a", test);
      Person result = (Person)cache_.getObject("/a");
      assertEquals(" ", test, result);

      Person remote = (Person)cache1_.getObject("/a");
      assertEquals("Age should be ", 10, remote.getAge());

      // Remote remove
      cache_.removeObject("/a");
      assertNull("Object should be null ", cache_.getObject("/a"));

      assertNull("Object should be null ", cache1_.getObject("/a"));
      // It is 0 since it will be un-initialized.
      assertEquals("Age should be ", 0, remote.getAge());
   }
View Full Code Here

   }

   public void testPutArray2() throws Exception
   {
      log_.info("testPutArray2() ....");
      Person p1 = new Person();
      p1.setName("Ben");
      p1.setAge(10);

      Person p2 = new Person();
      p2.setName("Joe");
      p2.setAge(20);
      Person[] arr = new Person[] {p1, p2};

      cache_.putObject("array", arr);

      Person[] a2 = (Person[])cache1_.getObject("array");
View Full Code Here

    * @throws Exception
    */
   public void testStateTransfer() throws Exception
   {
      log_.info("testStateTransfer() ....");
      Person test = new Person();
      test.setName("Ben");
      test.setAge(10);
      cache_.putObject("/a", test);
      Person result = (Person)cache_.getObject("/a");
      assertEquals(" ", test, result);

      // restart cache1_
      cache1_.stop();
      cache1_.remove("/a");
      cache1_.start();
      // Start from scratch for initial state transfer
      Person remote = (Person)cache1_.getObject("/a");
      assertEquals("Age should be ", 10, remote.getAge());
   }
View Full Code Here

//   public void testDummy() {}


   protected Person createPerson(String name, int age)
   {
      Person p = new Person();
      p.setName(name);
      p.setAge(age);
      return p;
   }
View Full Code Here

   }

   private void stage0() throws Exception
   {
      cache1.putObject("/person/joe", createPerson("Joe Black", 31));
      Person joe = (Person) cache1.getObject("/person/joe");
      cache1.putObject("/person/ben", createPerson("Ben Hogan", 51));
      Person ben = (Person) cache1.getObject("/person/ben");

      Address addr = new Address();
      addr.setStreet("123 Albert Ave.");
      addr.setCity("Sunnyvale");
      addr.setZip(94087);
      cache1.putObject("/address", addr);

      // They share the sub-object: address
      joe.setAddress(addr);
      ben.setAddress(addr);
      assertEquals("Joe's address should still be valid ", "Sunnyvale", joe.getAddress().getCity());
      assertEquals("Ben's address should still be valid ", "Sunnyvale", ben.getAddress().getCity());
   }
View Full Code Here

   }

   private void stage1() throws Exception
   {
      cache1.putObject("/person/joe", createPerson("Joe Black", 31));
      Person joe = (Person) cache1.getObject("/person/joe");
      cache1.putObject("/person/ben", createPerson("Ben Hogan", 51));
      Person ben = (Person) cache1.getObject("/person/ben");

      Address addr = new Address();
      addr.setStreet("123 Albert Ave.");
      addr.setCity("Sunnyvale");
      addr.setZip(94087);

      // They share the sub-object: address
      joe.setAddress(addr);
      ben.setAddress(addr);
      assertEquals("Joe's address should still be valid ", "Sunnyvale", joe.getAddress().getCity());
      assertEquals("Ben's address should still be valid ", "Sunnyvale", ben.getAddress().getCity());
   }
View Full Code Here

TOP

Related Classes of org.jboss.cache.aop.test.Person

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.