Package org.jboss.cache.aop.test

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


   public void testRelationshipWithSharedMap1() throws Exception
   {
      log.info("testRelationshipWithMap() ....");
      Map map1 = new HashMap();
      Address addr = new Address();
      addr.setCity("San Jose");
      addr.setZip(95123);
      map1.put("key1", addr);

      // Pure set
      cache1.putObject("/map", map1);
      // We specifically need to use Proxy otherwise it won't work with multiple references
      map1 = (Map)cache1.getObject("/map");
      cache1.putObject("/alias", map1);

      Map map2 = (Map)cache1.getObject("/alias");
      Address add1 = (Address)((Map.Entry)map2.entrySet().iterator().next()).getValue();
      assertNotNull("Address should not be null", add1);
      assertEquals("Zip ", 95123, add1.getZip());

      map1 = (Map)cache2.getObject("/map");
      map2 = (Map)cache2.getObject("/alias");
      assertTrue("Map size should not be 0 ", (map2.size() != 0));
      assertEquals("Both maps should be equal ", map1, map2);
      add1 = (Address)((Map.Entry)map2.entrySet().iterator().next()).getValue();
      assertNotNull("Address should not be null", add1);
      assertEquals("Zip ", 95123, add1.getZip());
   }
View Full Code Here


   public void testRelationshipWithSharedMap2() throws Exception
   {
      log.info("testRelationshipWithMap2() ....");
      Map map1 = new HashMap();
      Address addr = new Address();
      addr.setCity("San Jose");
      addr.setZip(95123);
      map1.put("key1", addr);

      Map map2 = new HashMap();
      map2.put("key2", addr);

      cache2.putObject("/map1", map1);
      cache2.putObject("/map2", map2);

      map1 = (Map)cache2.getObject("/map1");
      map2 = (Map)cache2.getObject("/map2");
      assertTrue("Map size should not be 0 ", (map2.size() != 0));
      assertEquals("Both maps should be equal ", map1.get("key1"), map2.get("key2"));
      Address add1 = (Address)((Map.Entry)map2.entrySet().iterator().next()).getValue();
      assertNotNull("Address should not be null", add1);
      assertEquals("Zip ", 95123, add1.getZip());
   }
View Full Code Here

   public void testKeySetRemoveWithSharedMap1() throws Exception
   {
      log.info("testKeySetRemoveWithSharedMap1() ....");
      Map map1 = new HashMap();
      Address addr = new Address();
      addr.setCity("San Jose");
      addr.setZip(95123);
      map1.put("key1_map1", addr);
      map1.put("key2_map1", null);
      map1.put(null,"null value test");
      Map map2 = new HashMap();
      map2.put("key1_map2", addr);
View Full Code Here

      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());
      addr.setCity("Santa Clara");
      assertEquals(add1.getCity(), add2.getCity());

      cache.evict(Fqn.fromString("/person/joe"));
      cache.evict(Fqn.fromString("/person/ben"));

      log.info("testMultipleReference(): after eviction");
      add1 = (Address) ((Person)cache.getObject("/person/joe")).getAddress();
      add2 = (Address) ((Person)cache.getObject("/person/ben")).getAddress();
      assertEquals(add1.getCity(), add2.getCity());
      add1.setCity("Santa Clara");
      // Still not working now. Will need to support it. JCACHE-223
//      assertEquals(add1.getCity(), add2.getCity());
   }
View Full Code Here

   public void testListWithMultipleSharedObjccts() throws Exception
   {
      log.info("testListWithMultipleSharedObjects() ....");
      List list1 = new ArrayList();
      Address addr = new Address();
      addr.setCity("San Jose");
      addr.setZip(95123);
      list1.add(addr);

      List list2 = new ArrayList();
      List list3 = new ArrayList();
      list2.add(addr);
      list3.add(addr);

      cache_.putObject("/list1", list1);
      cache_.putObject("/list2", list2);
      cache_.putObject("/list3", list3);

      list3 = (List)cache_.getObject("/list3");
      assertTrue("List size should not be 0 ", (list3.size() != 0));
      assertEquals("Address ", addr.getZip(), ((Address)list3.get(0)).getZip());
      addr.setCity("Sunnyvale");
      assertEquals("Address ", addr.getCity(), ((Address)list3.get(0)).getCity());

      cache_.removeObject("/list1");
      cache_.removeObject("/list2");
      cache_.removeObject("/list3");
   }
View Full Code Here

   public void testRelationshipWithSharedList1() throws Exception
   {
      log.info("testRelationshipWithList() ....");
      List list1 = new ArrayList();
      Address addr = new Address();
      addr.setCity("San Jose");
      addr.setZip(95123);
      list1.add(addr);

      cache_.putObject("/list", list1);
      list1 = (List)cache_.getObject("/list");
      assertEquals("List size should be ", 1, list1.size());
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");
View Full Code Here

   public void testRelationshipWithSharedList2() throws Exception
   {
      log.info("testRelationshipWithList2() ....");
      List list1 = new ArrayList();
      Address addr = new Address();
      addr.setCity("San Jose");
      addr.setZip(95123);
      list1.add(addr);

      List list2 = new ArrayList();
      list2.add(addr);

      cache_.putObject("/list1", list1);
      cache_.putObject("/list2", list2);
      Address add2 = (Address)((List)cache_.getObject("/list2")).get(0);
      Address add1 = (Address)((List)cache_.getObject("/list1")).get(0);
      assertEquals("Address should be the same", add1, add2);
      assertEquals("Both shared object should be equal ", add2.getZip(), add1.getZip());
   }
View Full Code Here

   public void testListWithAttachAndDetach() throws Exception
   {
      log.info("testListWithAttachAndDetach() ....");
      List list1 = new ArrayList();
      Address addr1 = new Address();
      addr1.setCity("San Jose");
      addr1.setZip(95123);

      Address addr2 = new Address();
      addr2.setCity("Sunnyvale");
      addr2.setZip(94086);
      list1.add(addr2);

      cache_.putObject("/list", list1);
      list1 = (List)cache_.getObject("/list");
      assertEquals("List size should be ", 1, list1.size());
View Full Code Here

   public void testRelationshipWithSharedSet1() throws Exception
   {
      log.info("testRelationshipWithSet() ....");
      Set set1 = new HashSet();
      Address addr = new Address();
      addr.setCity("San Jose");
      addr.setZip(95123);
      set1.add(addr);

      // Pure set
      cache_.putObject("/set", set1);
      // We specifically need to use Proxy otherwise it won't work with multiple references
      set1 = (Set)cache_.getObject("/set");
      cache_.putObject("/alias", set1);

      set1 = (Set)cache_.getObject("/set");
      Set set2 = (Set)cache_.getObject("/alias");
      assertTrue("Set size should not be 0 ", (set2.size() != 0));
      assertEquals("Both sets should be equal ", set1, set2);
      Address add1 = (Address)set2.iterator().next();
      assertNotNull("Address should not be null", add1);
      assertEquals("Zip ", 95123, add1.getZip());
   }
View Full Code Here

TOP

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

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.