@Before
 public void setUp() throws Exception {
   tblName = CacheUtils.init("CacheTest");
   cache = CacheUtils.getCache();
   AttributesFactory attributesFactory = new AttributesFactory();
   attributesFactory.setValueConstraint(Portfolio.class);
   RegionAttributes regionAttributes = attributesFactory.create();
   currRegion = cache.createRegion("portfolios", regionAttributes);
   qs = CacheUtils.getQueryService();
 }
 @Test
 public void testIndexOnCommitForDestroy() throws Exception {
   AttributesFactory af = new AttributesFactory();
   af.setDataPolicy(DataPolicy.REPLICATE);
   Region region = cache.createRegion("sample", af.create());
   qs.createIndex("foo", IndexType.FUNCTIONAL, "age", "/sample");
   Context ctx = cache.getJNDIContext();
   UserTransaction utx = (UserTransaction) ctx.lookup("java:/UserTransaction");
   Integer x = new Integer(0);
   utx.begin();
   region.create(x, new Person("xyz", 45));
   utx.commit();
   Query q = qs.newQuery("select * from /sample where age < 50");
   assertEquals(1, ((SelectResults) q.execute()).size());
   Person dsample = (Person) CopyHelper.copy(region.get(x));
   dsample.setAge(55);
   utx.begin();
   region.destroy(x);
   utx.commit();
   CacheUtils.log(((Person) region.get(x)));
   assertEquals(0, ((SelectResults) q.execute()).size());
 }
 @After
 public void tearDown() throws Exception {
   CacheUtils.destroyTable(tblName);
   cache.close();
 }
 public void afterCreate(EntryEvent event) {
   // TODO Auto-generated method stub
   CacheUtils.log("SimpleListener.create!:" + event);
   creates++;
 }
 private static void print(String str) {
   CacheUtils.log("\n" + str + "\n");
 }