protected void setUp() throws Exception { CacheUtils.startCache(); cache = CacheUtils.getCache(); AttributesFactory attributesFactory = new AttributesFactory(); // attributesFactory.setValueConstraint(Portfolio.class); RegionAttributes regionAttributes = attributesFactory.create(); region = cache.createRegion("pos", regionAttributes); region.put("0", new Portfolio(0)); region.put("1", new Portfolio(1)); region.put("2", new Portfolio(2)); region.put("3", new Portfolio(3)); qs = cache.getQueryService(); }
public void testTyped() throws QueryException { Query q = this.qs.newQuery( // must quote "query" because it is a reserved word "IMPORT com.gemstone.gemfire.cache.\"query\".data.Portfolio;\n" + "SELECT DISTINCT *\n" + "FROM /pos TYPE Portfolio\n" + "WHERE ID = 3 "); Object r = q.execute(); CacheUtils.getLogger().fine(Utils.printResult(r)); q = this.qs.newQuery( // must quote "query" because it is a reserved word "IMPORT com.gemstone.gemfire.cache.\"query\".data.Portfolio;\n" + "SELECT DISTINCT *\n" + "FROM /pos ptfo TYPE Portfolio\n" + "WHERE ID = 3 "); r = q.execute(); CacheUtils.getLogger().fine(Utils.printResult(r)); }
public void testTypeCasted() throws QueryException { Query q = this.qs.newQuery( // must quote "query" because it is a reserved word "IMPORT com.gemstone.gemfire.cache.\"query\".data.Portfolio;\n" + "SELECT DISTINCT *\n" + "FROM (collection<Portfolio>)/pos\n" + "WHERE ID = 3 "); // // com.gemstone.gemfire.internal.util.DebuggerSupport.waitForJavaDebugger(this.cache.getLogger()); Object r = q.execute(); CacheUtils.getLogger().fine(Utils.printResult(r)); q = this.qs.newQuery( // must quote "query" because it is a reserved word "IMPORT com.gemstone.gemfire.cache.\"query\".data.Position;\n" + "SELECT DISTINCT *\n" + "FROM /pos p, (collection<Position>)p.positions.values\n" + "WHERE secId = 'IBM'"); // // com.gemstone.gemfire.internal.util.DebuggerSupport.waitForJavaDebugger(this.cache.getLogger()); r = q.execute(); CacheUtils.getLogger().fine(Utils.printResult(r)); }
public void tearDown() throws Exception { CacheUtils.closeCache(); }