Package org.jboss.cache.aop.test

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


      person.setAddress(addr);
   }

   public Address createAddress()
   {
      return new Address();
   }
View Full Code Here


         if (!(p instanceof Externalizable)) {
        throw new RuntimeException("p not Externalizable");
         }
         */
         p.setName("Joe Black");
         Address address = new Address();
         address.setCity("Mannheim");
         p.setAddress(address);
         cache.putObject("/person/joe", p);
         return (Person) cache.getObject("/person/joe");
      } catch (Throwable t) {
         throw new RuntimeException(t);
View Full Code Here

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

      Address addr2 = new Address();
      addr2.setCity("Santa Clara");
      addr2.setZip(95131);

      Address addr3 = new Address();
      addr3.setCity("Sunnyvale");
      addr3.setZip(94086);

      // Pure list
      cache1.putObject("/set", set1);
      set1 = (Set)cache1.getObject("/set");
      set1.add(addr2);
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
      cache1.putObject("/set", set1);
      // We specifically need to use Proxy otherwise it won't work with multiple references
      set1 = (Set)cache1.getObject("/set");
      cache1.putObject("/alias", set1);

      Set set2 = (Set)cache1.getObject("/alias");
      Address add1 = (Address)set2.iterator().next();
      assertNotNull("Address should not be null", add1);
      assertEquals("Zip ", 95123, add1.getZip());

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

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

      Set set2 = new HashSet();
      set2.add(addr);

      cache1.putObject("/set1", set1);
      cache1.putObject("/set2", set2);
      Address add2 = (Address)((Set)cache2.getObject("/set2")).iterator().next();
      Address add1 = (Address)((Set)cache2.getObject("/set1")).iterator().next();
      assertEquals("Address should be the same", add1, add2);
      assertEquals("Both shared object should be equal ", add2.getZip(), add1.getZip());
   }
View Full Code Here

      System.out.println(cache_.printDetails());
   }

   public void testPojoAttachAndDetach() throws Exception
   {
      Address add1 = new Address();
      add1.setCity("San Jose");
      add1.setZip(95123);

      Address add2 = new Address();
      add2.setCity("Sunnyvale");
      add2.setZip(94086);

      Address add3 = new Address();
      add3.setCity("Santa Clara");
      add3.setZip(951131);

      List list = new ArrayList();
      list.add(add1);
      list.add(add2);
      list.add(add3);
View Full Code Here

         ArrayList lang = new ArrayList();
         lang.add("English");
         lang.add("French");
         lang.add("Mandarin");
         person_.setLanguages(lang);
         Address addr = new Address();
         addr.setZip(95123);
         addr.setStreet("Almeria");
         addr.setCity("San Jose");
         person_.setAddress(addr);
      }
View Full Code Here

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

      Address addr2 = new Address();
      addr2.setCity("Santa Clara");
      addr2.setZip(95131);

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

      // Pure list
      cache1.putObject("/map", map1);
      map1 = (Map)cache1.getObject("/map");
      map1.put("key2",addr2);
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());
   }
View Full Code Here

      Person joe = createPerson("Joe Black", 31);
      Person ben = createPerson("Ben Hogan", 51);
      cache_.putObject("/person/joe", joe);
      cache_.putObject("/person/ben", ben);

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

      joe.setAddress(addr);
      ben.setAddress(addr);
      // They share the sub-object: address
      Address add1 = (Address) ((Person)cache_.getObject("/person/joe")).getAddress();
      Address add2 = (Address) ((Person)cache_.getObject("/person/ben")).getAddress();
      assertEquals("Joe's address should still be valid ", "Sunnyvale", add1.getCity());
      assertEquals("Ben's address should still be valid ", "Sunnyvale", add2.getCity());
   }
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.