Package org.jboss.cache.aop.test

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


   }

   public void testDynamicRefSwapping() throws Exception
   {
      tester.createPerson("/person/test3", "Joe", 32);
      Person person = (Person)tester.getPerson("/person/test3");
      try {
         person.setAge(30);
         List med = person.getMedication();
         assertNull("Medication should be null ", med);
         person.setAge(60);
         med = person.getMedication();
         assertEquals("Medication ", (Object)"Lipitor", (Object)med.get(0));
      } catch (Exception e) {
         // should be thrown
      }
   }
View Full Code Here


    * Test replication with classloaders.
    * @throws Exception
    */
   public void testCLLeakage() throws Exception
   {
      Person p = new Person();
      p.setName("Ben");
      Address add = new Address();
      add.setCity("Taipei");

      ClassLoader cla = getClassLoader();
      WeakReference refa = new WeakReference(cla);
      cache_.registerClassLoader("/aop", cla);
      ClassLoader clb = getClassLoader();
      cache1_.registerClassLoader("/aop", clb);
      WeakReference refb = new WeakReference(clb);

      cache_.putObject("/aop", p);

      TestingUtil.sleepThread(100);
      try
      {
         Object ben = cache1_.getObject("/aop");
         assertEquals(p.toString(), ben.toString());
         ben = null;
      } catch (Exception ex)
      {
         fail("Test fails with exception " +ex);
      }
View Full Code Here


   public void testSerialization() throws Throwable
   {

      Person p = (Person) tester.testSerialization();
/*
      if (p instanceof Advised)
      {
         InstanceAdvisor advisor = ((Advised) p)._getInstanceAdvisor();
         Interceptor[] interceptors = advisor.getInterceptors();
         for (int i = 0; i < interceptors.length; i++)
         {
            assertTrue("CacheInterceptor shouldn't be serialized",
                !(interceptors[i] instanceof CacheInterceptor));
         }
      }
*/
      assertEquals((Object) "Joe Black", (Object) p.getName());
      assertEquals((Object) "Mannheim", (Object) p.getAddress().getCity());
   }
View Full Code Here

   }

   public void testDeserialization() throws Throwable
   {

      Person p = new Person();
      p.setName("test6");
      tester.testDeserialization("/person/test6", p);
      String name = tester.getName("/person/test6");
      assertEquals((Object) "test6", (Object) name);
   }
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

      ; // returns immediately in this case.  Subclasses may override where a delay is needed.
   }

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

   public void testMultipleRefence() throws Exception
   {
      log.info("testMultipleReference() ...");
      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");

      Address addr = new Address();
      addr.setStreet("123 Albert Ave.");
      addr.setCity("Sunnyvale");
      addr.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(): verify");
      Address add1 = (Address) ((Person)cache.getObject("/person/joe")).getAddress();
      Address add2 = (Address) ((Person)cache.getObject("/person/ben")).getAddress();
      assertEquals(add1.getCity(), add2.getCity());
View Full Code Here

   public void testObjectRemoved() throws Exception
   {
      log.info("testObjectRemoved() ...");
      cache.putObject("/person/joe", createPerson("Joe Black", 31));
      Person joe = (Person) cache.getObject("/person/joe");
      Address addr = new Address();
      addr.setStreet("123 Albert Ave.");
      addr.setCity("Sunnyvale");
      addr.setZip(94087);

      // They share the sub-object: address
      joe.setAddress(addr);

      log.info("testMultipleReference(): verify");
      Address add1 = (Address) ((Person)cache.getObject("/person/joe")).getAddress();

      Map map = new HashMap();
      map.put("1", "1");
      Map m1 = new HashMap();
      m1.put("2", "2");
      map.put("m1", m1);
      joe.setHobbies(map);

      cache.removeObject("/person/joe");
      joe = (Person) cache.getObject("/person/joe");
      assertNull("Joe should be null ", joe);
   }
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

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

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.