protected void setUp() throws Exception { if (mn == null) { mn = new Main("jetty"); mn.run(new String[] {"jetty"}); } QueryService service = new QueryServiceLocator(); query = service.getQuery(new URL(query_url)); sessionId = query.connect("admin", ""); AdminService aservice = new AdminServiceLocator(); admin = aservice.getAdmin(new URL(admin_url)); }
/** Start all cqs running for this VM, and create a CQHistory instance for each CQ. */ private void startCQsWithHistory() { initializeQueryService(); CqAttributesFactory cqFac = new CqAttributesFactory(); cqFac.addCqListener(new CQHistoryListener()); cqFac.addCqListener(new CQGatherListener()); CqAttributes cqAttr = cqFac.create(); Iterator it = queryMap.keySet().iterator(); while (it.hasNext()) { String queryName = (String) (it.next()); String query = (String) (queryMap.get(queryName)); try { CqQuery cq = qService.newCq(queryName, query, cqAttr); CQHistory history = new CQHistory(cq.getName()); CQHistoryListener.recordHistory(history); Log.getLogWriter() .info( "Creating CQ with name " + queryName + ": " + query + ", cq attributes: " + cqAttr); Log.getLogWriter().info("Calling executeWithInitialResults on " + cq); CqResults rs = cq.executeWithInitialResults(); SelectResults sr = CQUtil.getSelectResults(rs); if (sr == null) { throw new TestException( "For cq " + cq + " with name " + cq.getName() + " executeWithInitialResults returned " + sr); } Log.getLogWriter() .info( "Done calling executeWithInitializResults on " + cq + " with name " + queryName + ", select results size is " + sr.size()); history.setSelectResults(sr); logNumOps(); // log the select results List srList = sr.asList(); StringBuffer aStr = new StringBuffer(); aStr.append("SelectResults returned from " + queryName + " is\n"); for (int i = 0; i < srList.size(); i++) { aStr.append(srList.get(i) + "\n"); } Log.getLogWriter().info(aStr.toString()); } catch (CqExistsException e) { throw new TestException(TestHelper.getStackTrace(e)); } catch (RegionNotFoundException e) { throw new TestException(TestHelper.getStackTrace(e)); } catch (CqException e) { throw new TestException(TestHelper.getStackTrace(e)); } } }
/** * Verify the result of the CQs registered for this VM. Query results from * executeWithInitialResults are combined with subsequent cq events to form the final result. */ protected void verifyQueryResultsCombine() { Log.getLogWriter().info("In verifyQueryResultsCombine"); Iterator it = queryMap.keySet().iterator(); int count = 0; while (it.hasNext()) { count++; String cqName = (String) (it.next()); Log.getLogWriter() .info("Verifying query " + count + " out of " + queryMap.size() + " with name " + cqName); CqQuery cq = qService.getCq(cqName); String queryStr = cq.getQueryString(); String readableQueryStr = CQTest.getReadableQueryString(queryStr); // combine the initial selectResults with history of events CQHistory history = CQHistoryListener.getCQHistory(cqName); Map combinedMap = history.getCombinedResults(); List combinedList = new ArrayList(combinedMap.values()); List expectedResults = CQTestInstance.getExpectedResults(queryStr); List missingInCombined = new ArrayList(expectedResults); List unexpectedInCombined = new ArrayList(combinedList); unexpectedInCombined.removeAll(expectedResults); missingInCombined.removeAll(combinedList); // prepare error Strings StringBuffer aStr = new StringBuffer(); if (unexpectedInCombined.size() > 0) { String tmpStr = getLocationString(unexpectedInCombined, expectedResults, history) + "\n" + "Found the following " + unexpectedInCombined.size() + " unexpected elements in combined results for cq " + cqName + ", " + readableQueryStr + ": " + QueryObject.toStringFull(unexpectedInCombined); Log.getLogWriter().info(tmpStr); aStr.append(tmpStr); } if (missingInCombined.size() > 0) { String tmpStr = getLocationString(missingInCombined, expectedResults, history) + "\n" + "The following " + missingInCombined.size() + " elements were missing from combined results for cq " + cqName + ", " + readableQueryStr + ": " + QueryObject.toStringFull(missingInCombined); Log.getLogWriter().info(tmpStr); aStr.append(tmpStr); } if (aStr.length() > 0) { throw new TestException( "Probably bug 38065: For cq " + cqName + ", " + readableQueryStr + "\n" + aStr.toString()); } } Log.getLogWriter().info("Done verifying " + count + " queries"); }
public String doAction(int actFlag) { Map<String, Object> queConfig = objectValidity(qcoId, "HiQueConfig", "hiquery", "qco"); if (queConfig == null) { return txt(getResource("hiquery.getobject.fail", qcoId), null); } String info = ""; Session ses = openSession(); try { switch (actFlag) { case ActionConstant.HiQueryActionFlag.QUERY: String qcoConfig = ActionUtil.isNvl(queConfig.get("qcoConfig")); HttpServletRequest req = ActionUtil.getRequest(); String configText = QueryUtil.hiConfigText(conn, req, qcoConfig); String forwardUrl = ConfigTextUtil.getNodeTextIfThen(configText, "QUERY.FORWARD").trim(); if (!forwardUrl.equals("")) { return dispatch(null, forwardUrl); } queryService.queryExternalClass(req, req.getSession(), configText, "init"); // ses = sesFactory.openSession(); queryService.doFilter(ses, conn, this); queryService.doList(ses, conn, this); queryService.queryExternalClass(req, req.getSession(), configText, "process"); // ses.close(); break; case ActionConstant.HiQueryActionFlag.FILTER: queryService.doFilter(ses, conn, this); break; case ActionConstant.HiQueryActionFlag.LIST: queryService.doList(ses, conn, this); break; case ActionConstant.HiQueryActionFlag.QUERYDATA: queryService.doListdata(ses, conn, this); break; case ActionConstant.HiQueryActionFlag.LISTDATA: queryService.doListdata(ses, conn, this); break; case ActionConstant.HiQueryActionFlag.SQL: ActionPrinter.printToPlain(getSql()); break; case ActionConstant.HiQueryActionFlag.TREE: queryService.doTree(ses, conn, this); break; case ActionConstant.HiQueryActionFlag.EXPORT: queryService.doExport(ses, conn, this); break; case ActionConstant.HiQueryActionFlag.CHART: queryService.doChart(ses, conn, this); break; case ActionConstant.HiQueryActionFlag.AMCHART: queryService.doAmChart(ses, conn, this); break; case ActionConstant.HiQueryActionFlag.ECHART: queryService.doEChart(ses, conn, this); break; case ActionConstant.HiQueryActionFlag.STANDATA: info = queryService.doJsonData(ses, conn, this, ActionConstant.HiQueryActionFlag.STANDATA); break; case ActionConstant.HiQueryActionFlag.TRANDATA: info = queryService.doJsonData(ses, conn, this, ActionConstant.HiQueryActionFlag.TRANDATA); break; case ActionConstant.HiQueryActionFlag.DATA: info = queryService.doJsonData(ses, conn, this, ActionConstant.HiQueryActionFlag.DATA); break; case ActionConstant.HiQueryActionFlag.JSON: info = queryService.doJsonData(ses, conn, this, ActionConstant.HiQueryActionFlag.JSON); break; case ActionConstant.HiQueryActionFlag.PLATDATA: info = queryService.doJsonData(ses, conn, this, ActionConstant.HiQueryActionFlag.PLATDATA); break; default: break; } } catch (Exception e) { log.info(e.getMessage()); } finally { closeSession(ses); } if (actFlag == ActionConstant.HiQueryActionFlag.QUERY || actFlag == ActionConstant.HiQueryActionFlag.FILTER || actFlag == ActionConstant.HiQueryActionFlag.LIST || actFlag == ActionConstant.HiQueryActionFlag.TREE || actFlag == ActionConstant.HiQueryActionFlag.CHART || actFlag == ActionConstant.HiQueryActionFlag.ECHART || actFlag == ActionConstant.HiQueryActionFlag.AMCHART) { return html(); } else if (actFlag == ActionConstant.HiQueryActionFlag.STANDATA || actFlag == ActionConstant.HiQueryActionFlag.TRANDATA || actFlag == ActionConstant.HiQueryActionFlag.DATA || actFlag == ActionConstant.HiQueryActionFlag.JSON || actFlag == ActionConstant.HiQueryActionFlag.PLATDATA) { return json(info, null); } else if (actFlag == ActionConstant.HiQueryActionFlag.EXPORT) { return txt(); } else { return txt(); } }
public String getQueryAttribute(QueryServiceHelperBean helperBean, Node itemNode) { helperBean.setItemNode(itemNode); helperBean.setParentElementName(QueryService.super.getQueryAttribute(helperBean, itemNode)); return helperBean.getParentElementName(); }