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");
assertEquals(add1.getCity(), add2.getCity());
// Remove pojo joe will relocate the address field to ben's
joe.setAddress(addr1);
add2 = (Address) ((Person)cache_.getObject("/person/joe")).getAddress();
assertEquals("City ", "San Jose", add2.getCity());
add2 = (Address) ((Person)cache_.getObject("/person/ben")).getAddress();
assertEquals("City ", "Santa Clara", add2.getCity());
add2 = (Address) ((Person)cache_.getObject("/person/john")).getAddress();
assertEquals("City ", "Santa Clara", add2.getCity());
}