protected void doTupleLinksAndStylesheetNoStarts(TupleQueryResultFormat format, TupleQueryResult input, TupleQueryResult expected, List<String> links, String stylesheetUrl) throws QueryResultHandlerException, QueryEvaluationException, QueryResultParseException, UnsupportedQueryResultFormatException, IOException { ByteArrayOutputStream out = new ByteArrayOutputStream(4096); TupleQueryResultWriter writer = QueryResultIO.createTupleWriter(format, out); // Test for handling when startDocument and startHeader are not called writer.handleStylesheet(stylesheetUrl); writer.handleLinks(links); QueryResults.report(input, writer); // System.out.println("output: " + out.toString("UTF-8")); ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray()); TupleQueryResult output = QueryResultIO.parseTuple(in, format); assertQueryResultsEqual(expected, output); }
protected void doTupleLinks(TupleQueryResultFormat format, TupleQueryResult input, TupleQueryResult expected, List<String> links) throws QueryResultHandlerException, QueryEvaluationException, QueryResultParseException, UnsupportedQueryResultFormatException, IOException { ByteArrayOutputStream out = new ByteArrayOutputStream(4096); TupleQueryResultWriter writer = QueryResultIO.createTupleWriter(format, out); writer.startDocument(); writer.startHeader(); writer.handleLinks(links); QueryResults.report(input, writer); // System.out.println("output: " + out.toString("UTF-8")); ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray()); TupleQueryResult output = QueryResultIO.parseTuple(in, format); assertQueryResultsEqual(expected, output); }
protected void doTupleLinksAndStylesheetAndNamespaces(TupleQueryResultFormat format, TupleQueryResult input, TupleQueryResult expected, List<String> links, String stylesheetUrl, Map<String, String> namespaces) throws QueryResultHandlerException, QueryEvaluationException, QueryResultParseException, UnsupportedQueryResultFormatException, IOException { ByteArrayOutputStream out = new ByteArrayOutputStream(4096); TupleQueryResultWriter writer = QueryResultIO.createTupleWriter(format, out); for (String nextPrefix : namespaces.keySet()) { writer.handleNamespace(nextPrefix, namespaces.get(nextPrefix)); } writer.startDocument(); writer.handleStylesheet(stylesheetUrl); writer.startHeader(); writer.handleLinks(links); QueryResults.report(input, writer); // System.out.println("output: " + out.toString("UTF-8")); ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray()); TupleQueryResult output = QueryResultIO.parseTuple(in, format); assertQueryResultsEqual(expected, output); }
protected void doTupleLinksAndStylesheet(TupleQueryResultFormat format, TupleQueryResult input, TupleQueryResult expected, List<String> links, String stylesheetUrl) throws QueryResultHandlerException, QueryEvaluationException, QueryResultParseException, UnsupportedQueryResultFormatException, IOException { ByteArrayOutputStream out = new ByteArrayOutputStream(4096); TupleQueryResultWriter writer = QueryResultIO.createTupleWriter(format, out); writer.startDocument(); writer.handleStylesheet(stylesheetUrl); writer.startHeader(); writer.handleLinks(links); QueryResults.report(input, writer); // System.out.println("output: " + out.toString("UTF-8")); ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray()); TupleQueryResult output = QueryResultIO.parseTuple(in, format); assertQueryResultsEqual(expected, output); }
writer.handleStylesheet(stylesheetUrl); writer.startHeader(); writer.handleLinks(links); QueryResults.report(input, writer);
protected void doTupleLinksAndStylesheetMultipleEndHeaders(TupleQueryResultFormat format, TupleQueryResult input, TupleQueryResult expected, List<String> links, String stylesheetUrl) throws QueryResultHandlerException, QueryEvaluationException, QueryResultParseException, UnsupportedQueryResultFormatException, IOException { ByteArrayOutputStream out = new ByteArrayOutputStream(4096); TupleQueryResultWriter writer = QueryResultIO.createTupleWriter(format, out); // Test for handling when startDocument and startHeader are not called writer.handleStylesheet(stylesheetUrl); writer.startQueryResult(input.getBindingNames()); writer.handleLinks(links); writer.endHeader(); writer.endHeader(); try { while (input.hasNext()) { BindingSet bindingSet = input.next(); writer.handleSolution(bindingSet); } } finally { input.close(); } writer.endQueryResult(); // System.out.println("output: " + out.toString("UTF-8")); ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray()); TupleQueryResult output = QueryResultIO.parseTuple(in, format); assertQueryResultsEqual(expected, output); }
protected void doTupleMissingStartQueryResult(TupleQueryResultFormat format, TupleQueryResult input, TupleQueryResult expected, List<String> links, String stylesheetUrl) throws QueryResultHandlerException, QueryEvaluationException, QueryResultParseException, UnsupportedQueryResultFormatException, IOException { ByteArrayOutputStream out = new ByteArrayOutputStream(4096); TupleQueryResultWriter writer = QueryResultIO.createTupleWriter(format, out); // Test for handling when startDocument and startHeader are not called writer.startDocument(); writer.handleStylesheet(stylesheetUrl); writer.startHeader(); writer.handleLinks(links); writer.endHeader(); try { while (input.hasNext()) { BindingSet bindingSet = input.next(); writer.handleSolution(bindingSet); } writer.endQueryResult(); fail("Expected exception when calling handleSolution without startQueryResult"); } catch (IllegalStateException ise) { // Expected exception } finally { input.close(); } }