This is an automated email from the ASF dual-hosted git repository.
andy pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/jena.git
The following commit(s) were added to refs/heads/main by this push:
new 1b39bf7 JENA-2273: Fix ASK in Result- and RowSetWriterCSV and -TSV
new 2d4e707 Merge pull request #1189 from cygri/JENA-2273
1b39bf7 is described below
commit 1b39bf7eb922b7f579f939dde8a86b9b00056193
Author: Richard Cyganiak <[email protected]>
AuthorDate: Sat Feb 5 14:21:09 2022 +0000
JENA-2273: Fix ASK in Result- and RowSetWriterCSV and -TSV
---
.../jena/riot/resultset/rw/ResultSetWriterCSV.java | 16 +++++---
.../jena/riot/resultset/rw/ResultSetWriterTSV.java | 4 +-
.../jena/riot/rowset/rw/RowSetWriterCSV.java | 16 +++++---
.../jena/riot/rowset/rw/RowSetWriterTSV.java | 4 +-
.../riot/resultset/rw/TS_ResultSetRIOT_RW.java | 30 ++++++++++++++
.../riot/resultset/rw/TestResultSetWriterCSV.java | 48 ++++++++++++++++++++++
.../riot/resultset/rw/TestResultSetWriterTSV.java | 48 ++++++++++++++++++++++
.../jena/riot/rowset/rw/TS_RowSetRIOT_RW.java | 30 ++++++++++++++
.../jena/riot/rowset/rw/TestRowSetWriterCSV.java | 48 ++++++++++++++++++++++
.../jena/riot/rowset/rw/TestRowSetWriterTSV.java | 48 ++++++++++++++++++++++
10 files changed, 278 insertions(+), 14 deletions(-)
diff --git
a/jena-arq/src/main/java/org/apache/jena/riot/resultset/rw/ResultSetWriterCSV.java
b/jena-arq/src/main/java/org/apache/jena/riot/resultset/rw/ResultSetWriterCSV.java
index 05d8dd8..11c0ad5 100644
---
a/jena-arq/src/main/java/org/apache/jena/riot/resultset/rw/ResultSetWriterCSV.java
+++
b/jena-arq/src/main/java/org/apache/jena/riot/resultset/rw/ResultSetWriterCSV.java
@@ -63,12 +63,16 @@ public class ResultSetWriterCSV implements ResultSetWriter {
}
private static void output(AWriter out, boolean booleanResult) {
- out.write(headerBytes);
- if ( booleanResult )
- out.write(yesBytes);
- else
- out.write(noBytes);
- out.write(NL);
+ try {
+ out.write(headerBytes);
+ if ( booleanResult )
+ out.write(yesBytes);
+ else
+ out.write(noBytes);
+ out.write(NL);
+ } finally {
+ out.flush();
+ }
}
private static void output(AWriter out, ResultSet resultSet) {
diff --git
a/jena-arq/src/main/java/org/apache/jena/riot/resultset/rw/ResultSetWriterTSV.java
b/jena-arq/src/main/java/org/apache/jena/riot/resultset/rw/ResultSetWriterTSV.java
index 2ba137c..5c56996 100644
---
a/jena-arq/src/main/java/org/apache/jena/riot/resultset/rw/ResultSetWriterTSV.java
+++
b/jena-arq/src/main/java/org/apache/jena/riot/resultset/rw/ResultSetWriterTSV.java
@@ -59,7 +59,9 @@ public class ResultSetWriterTSV implements ResultSetWriter {
}
@Override
- public void write(OutputStream out, boolean result, Context context) {}
+ public void write(OutputStream out, boolean result, Context context) {
+ output(IO.wrapUTF8(out), result);
+ }
private static void output(AWriter out, boolean booleanResult) {
out.write(headerBytes);
diff --git
a/jena-arq/src/main/java/org/apache/jena/riot/rowset/rw/RowSetWriterCSV.java
b/jena-arq/src/main/java/org/apache/jena/riot/rowset/rw/RowSetWriterCSV.java
index 5f4ab76..7887aed 100644
--- a/jena-arq/src/main/java/org/apache/jena/riot/rowset/rw/RowSetWriterCSV.java
+++ b/jena-arq/src/main/java/org/apache/jena/riot/rowset/rw/RowSetWriterCSV.java
@@ -67,12 +67,16 @@ public class RowSetWriterCSV implements RowSetWriter {
}
private static void output(AWriter out, boolean booleanResult) {
- out.write(headerBytes);
- if ( booleanResult )
- out.write(yesString);
- else
- out.write(noString);
- out.write(NL);
+ try {
+ out.write(headerBytes);
+ if ( booleanResult )
+ out.write(yesString);
+ else
+ out.write(noString);
+ out.write(NL);
+ } finally {
+ out.flush();
+ }
}
private static void output(AWriter out, RowSet rowSet) {
diff --git
a/jena-arq/src/main/java/org/apache/jena/riot/rowset/rw/RowSetWriterTSV.java
b/jena-arq/src/main/java/org/apache/jena/riot/rowset/rw/RowSetWriterTSV.java
index f5b24e0..47feaf2 100644
--- a/jena-arq/src/main/java/org/apache/jena/riot/rowset/rw/RowSetWriterTSV.java
+++ b/jena-arq/src/main/java/org/apache/jena/riot/rowset/rw/RowSetWriterTSV.java
@@ -65,7 +65,9 @@ public class RowSetWriterTSV implements RowSetWriter {
}
@Override
- public void write(OutputStream out, boolean result, Context context) {}
+ public void write(OutputStream out, boolean result, Context context) {
+ output(IO.wrapUTF8(out), result);
+ }
private static void output(AWriter out, boolean booleanResult) {
out.write(headerBytes);
diff --git
a/jena-arq/src/test/java/org/apache/jena/riot/resultset/rw/TS_ResultSetRIOT_RW.java
b/jena-arq/src/test/java/org/apache/jena/riot/resultset/rw/TS_ResultSetRIOT_RW.java
new file mode 100644
index 0000000..0d10eaf
--- /dev/null
+++
b/jena-arq/src/test/java/org/apache/jena/riot/resultset/rw/TS_ResultSetRIOT_RW.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.riot.resultset.rw;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+@RunWith(Suite.class)
[email protected]( {
+ TestResultSetWriterCSV.class,
+ TestResultSetWriterTSV.class
+})
+
+public class TS_ResultSetRIOT_RW { }
diff --git
a/jena-arq/src/test/java/org/apache/jena/riot/resultset/rw/TestResultSetWriterCSV.java
b/jena-arq/src/test/java/org/apache/jena/riot/resultset/rw/TestResultSetWriterCSV.java
new file mode 100644
index 0000000..6aa0a50
--- /dev/null
+++
b/jena-arq/src/test/java/org/apache/jena/riot/resultset/rw/TestResultSetWriterCSV.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.riot.resultset.rw;
+
+import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.ByteArrayOutputStream;
+
+import org.apache.jena.riot.Lang;
+import org.apache.jena.riot.resultset.ResultSetWriter;
+import org.junit.Test;
+
+public class TestResultSetWriterCSV {
+
+ @Test
+ public void testFactory() {
+ ResultSetWriter writer = ResultSetWriterCSV.factory.create(Lang.CSV);
+ assertNotNull(writer);
+ }
+
+ @Test
+ public void testWriteBoolean() {
+ ResultSetWriter writer = ResultSetWriterCSV.factory.create(Lang.CSV);
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ writer.write(out, true, null);
+ String output = out.toString(UTF_8);
+ assertThat(output, containsString("true"));
+ }
+}
diff --git
a/jena-arq/src/test/java/org/apache/jena/riot/resultset/rw/TestResultSetWriterTSV.java
b/jena-arq/src/test/java/org/apache/jena/riot/resultset/rw/TestResultSetWriterTSV.java
new file mode 100644
index 0000000..742ed11
--- /dev/null
+++
b/jena-arq/src/test/java/org/apache/jena/riot/resultset/rw/TestResultSetWriterTSV.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.riot.resultset.rw;
+
+import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.ByteArrayOutputStream;
+
+import org.apache.jena.riot.Lang;
+import org.apache.jena.riot.resultset.ResultSetWriter;
+import org.junit.Test;
+
+public class TestResultSetWriterTSV {
+
+ @Test
+ public void testFactory() {
+ ResultSetWriter writer = ResultSetWriterTSV.factory.create(Lang.TSV);
+ assertNotNull(writer);
+ }
+
+ @Test
+ public void testWriteBoolean() {
+ ResultSetWriter writer = ResultSetWriterTSV.factory.create(Lang.TSV);
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ writer.write(out, true, null);
+ String output = out.toString(UTF_8);
+ assertThat(output, containsString("true"));
+ }
+}
diff --git
a/jena-arq/src/test/java/org/apache/jena/riot/rowset/rw/TS_RowSetRIOT_RW.java
b/jena-arq/src/test/java/org/apache/jena/riot/rowset/rw/TS_RowSetRIOT_RW.java
new file mode 100644
index 0000000..5212e22
--- /dev/null
+++
b/jena-arq/src/test/java/org/apache/jena/riot/rowset/rw/TS_RowSetRIOT_RW.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.riot.rowset.rw;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+@RunWith(Suite.class)
[email protected]( {
+ TestRowSetWriterCSV.class,
+ TestRowSetWriterTSV.class
+})
+
+public class TS_RowSetRIOT_RW { }
diff --git
a/jena-arq/src/test/java/org/apache/jena/riot/rowset/rw/TestRowSetWriterCSV.java
b/jena-arq/src/test/java/org/apache/jena/riot/rowset/rw/TestRowSetWriterCSV.java
new file mode 100644
index 0000000..a8f2e00
--- /dev/null
+++
b/jena-arq/src/test/java/org/apache/jena/riot/rowset/rw/TestRowSetWriterCSV.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.riot.rowset.rw;
+
+import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.ByteArrayOutputStream;
+
+import org.apache.jena.riot.Lang;
+import org.apache.jena.riot.rowset.RowSetWriter;
+import org.junit.Test;
+
+public class TestRowSetWriterCSV {
+
+ @Test
+ public void testFactory() {
+ RowSetWriter writer = RowSetWriterCSV.factory.create(Lang.CSV);
+ assertNotNull(writer);
+ }
+
+ @Test
+ public void testWriteBoolean() {
+ RowSetWriter writer = RowSetWriterCSV.factory.create(Lang.CSV);
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ writer.write(out, true, null);
+ String output = out.toString(UTF_8);
+ assertThat(output, containsString("true"));
+ }
+}
diff --git
a/jena-arq/src/test/java/org/apache/jena/riot/rowset/rw/TestRowSetWriterTSV.java
b/jena-arq/src/test/java/org/apache/jena/riot/rowset/rw/TestRowSetWriterTSV.java
new file mode 100644
index 0000000..2a900c4
--- /dev/null
+++
b/jena-arq/src/test/java/org/apache/jena/riot/rowset/rw/TestRowSetWriterTSV.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.riot.rowset.rw;
+
+import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.ByteArrayOutputStream;
+
+import org.apache.jena.riot.Lang;
+import org.apache.jena.riot.rowset.RowSetWriter;
+import org.junit.Test;
+
+public class TestRowSetWriterTSV {
+
+ @Test
+ public void testFactory() {
+ RowSetWriter writer = RowSetWriterTSV.factory.create(Lang.TSV);
+ assertNotNull(writer);
+ }
+
+ @Test
+ public void testWriteBoolean() {
+ RowSetWriter writer = RowSetWriterTSV.factory.create(Lang.TSV);
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ writer.write(out, true, null);
+ String output = out.toString(UTF_8);
+ assertThat(output, containsString("true"));
+ }
+}