@Test public void basic() throws Exception { TestingDataProcessor processor = TestingDataProcessor.loadData( h2Info.connection.get(), Files.toString(new File(TESTDATA_PATH + "guide_plan.data"), Charsets.UTF_8)); for (Pair<String, String> entry : processor.getCases()) { GuidePlanRequest.Builder reqBuilder = GuidePlanRequest.newBuilder(); TextFormat.merge(entry.getValue0(), reqBuilder); GuidePlanResponse.Builder respBuilder = GuidePlanResponse.newBuilder(); TextFormat.merge(entry.getValue1(), respBuilder); GuidePlanRequestHandler handler = injector.getInstance(GuidePlanRequestHandler.class); Assert.assertEquals(respBuilder.build(), handler.process(reqBuilder.build())); } }
private void loadAnswers(File folder) { // if(!folder.exists() && !folder.isDirectory()) // return; File f = folder; // for(File f: folder.listFiles()){ if (f.getName().contains("answer")) { // if(f.getName().equals(this.answerPath)){ // continue; // }else{ this.answerPath = f.getName(); // } try { ((DefaultTableModel) topKTable.getModel()).setRowCount(0); answers.clear(); InputStreamReader reader = new InputStreamReader(new FileInputStream(f), "ASCII"); AnswerCodingArray.Builder builder = AnswerCodingArray.newBuilder(); TextFormat.merge(reader, builder); AnswerCodingArray answer_array = builder.build(); for (int i = 0; i < answer_array.getAnswersCount(); i++) { answers.add(answer_array.getAnswers(i)); } } catch (Exception e) { System.out.println(e.toString()); } } // } Collections.sort(answers, new AnswerComparator()); ((DefaultTableModel) topKTable.getModel()).setRowCount(answers.size()); for (int i = 0; i < answers.size(); i++) { this.topKTable.setValueAt(i + 1, i, 0); this.topKTable.setValueAt(answers.get(i).getScore(), i, 1); } }
@Override public CompilerPass getProcessor(final Compiler compiler) { ConformanceConfig.Builder builder = ConformanceConfig.newBuilder(); try { TextFormat.merge(configuration, builder); } catch (Exception e) { Throwables.propagate(e); } return new CheckConformance(compiler, ImmutableList.of(builder.build())); }
/** * Creates an intrument functions compiler pass. * * @param compiler The JSCompiler * @param functionNames Assigned function identifiers. * @param templateFilename Template filename; for use during error reporting only. * @param appNameStr String to pass to appNameSetter. * @param readable Instrumentation template protobuf text. */ InstrumentFunctions( AbstractCompiler compiler, FunctionNames functionNames, String templateFilename, String appNameStr, Readable readable) { this.compiler = compiler; this.functionNames = functionNames; this.templateFilename = templateFilename; this.appNameStr = appNameStr; Instrumentation.Builder builder = Instrumentation.newBuilder(); try { TextFormat.merge(readable, builder); } catch (IOException e) { compiler.report( JSError.make( RhinoErrorReporter.PARSE_ERROR, "Error reading instrumentation template protobuf at " + templateFilename)); this.initCodeSource = ""; this.definedFunctionName = ""; this.reportFunctionName = ""; this.reportFunctionExitName = ""; this.appNameSetter = ""; this.declarationsToRemove = Lists.newArrayList(); return; } Instrumentation template = builder.build(); StringBuilder initCodeSourceBuilder = new StringBuilder(); for (String line : template.getInitList()) { initCodeSourceBuilder.append(line).append("\n"); } this.initCodeSource = initCodeSourceBuilder.toString(); this.definedFunctionName = template.getReportDefined(); this.reportFunctionName = template.getReportCall(); this.reportFunctionExitName = template.getReportExit(); this.appNameSetter = template.getAppNameSetter(); this.declarationsToRemove = ImmutableList.copyOf(template.getDeclarationToRemoveList()); }