01: /*
02: * Copyright Aduna (http://www.aduna-software.com/) (c) 2007.
03: *
04: * Licensed under the Aduna BSD-style license.
05: */
06: package org.openrdf.query.resultio;
07:
08: import java.io.ByteArrayInputStream;
09: import java.io.ByteArrayOutputStream;
10: import java.io.IOException;
11:
12: import junit.framework.TestCase;
13:
14: import org.openrdf.query.QueryEvaluationException;
15:
16: public class BooleanQueryResultSerializationTest extends TestCase {
17:
18: public void testSPARQLResultFormat() throws IOException,
19: QueryResultParseException,
20: UnsupportedQueryResultFormatException,
21: QueryEvaluationException {
22: testQueryResultFormat(BooleanQueryResultFormat.SPARQL, true);
23: testQueryResultFormat(BooleanQueryResultFormat.SPARQL, false);
24: }
25:
26: public void testTextResultFormat() throws IOException,
27: QueryResultParseException,
28: UnsupportedQueryResultFormatException,
29: QueryEvaluationException {
30: testQueryResultFormat(BooleanQueryResultFormat.TEXT, true);
31: testQueryResultFormat(BooleanQueryResultFormat.TEXT, false);
32: }
33:
34: private void testQueryResultFormat(BooleanQueryResultFormat format,
35: boolean input) throws IOException,
36: QueryResultParseException,
37: UnsupportedQueryResultFormatException,
38: QueryEvaluationException {
39: ByteArrayOutputStream out = new ByteArrayOutputStream(4096);
40: QueryResultIO.write(input, format, out);
41: out.flush();
42: ByteArrayInputStream in = new ByteArrayInputStream(out
43: .toByteArray());
44: boolean output = QueryResultIO.parse(in, format);
45:
46: assertEquals(output, input);
47: }
48: }
|