afs commented on code in PR #3441:
URL: https://github.com/apache/jena/pull/3441#discussion_r2386170343
##########
jena-rdfconnection/src/test/java/org/apache/jena/rdfconnection/TestRDFConnectionHTTPHeaders.java:
##########
Review Comment:
Add to `TS_RDFConnection`.
##########
jena-rdfconnection/src/test/java/org/apache/jena/rdfconnection/TestRDFConnectionHTTP.java:
##########
@@ -1,99 +0,0 @@
-/*
Review Comment:
Where did the tests from this class go to?
(It should have been added to `TS_RDFConnection` when added.)
##########
jena-rdfconnection/src/main/java/org/apache/jena/rdflink/RDFLinkHTTP.java:
##########
@@ -221,163 +220,54 @@ public Graph queryDescribe(String queryString) {
public boolean queryAsk(String queryString) {
return
Txn.calculateRead(this, ()->{
- try ( QueryExec qExec = query(queryString, QueryType.ASK) ) {
+ try ( QueryExec qExec = query(queryString) ) {
return qExec.ask();
}
} );
}
- /**
Review Comment:
Could you say which this change is in the PR? The `QueryType` may no tbe
partiucaly useful in this impl but when inheriited it might be useful.
##########
jena-rdfconnection/src/test/java/org/apache/jena/rdflink/TestRDFLinkHTTPHeaders.java:
##########
@@ -0,0 +1,97 @@
+/*
+ * 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.rdflink;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import org.apache.jena.sparql.exec.http.QueryExecHTTP;
+import org.apache.jena.sparql.exec.http.QueryExecHTTPBuilder;
+import org.junit.jupiter.api.Test;
+
+public class TestRDFLinkHTTPHeaders {
Review Comment:
I don't see any tests for `acceptHeaderQuery`.
##########
jena-rdfconnection/src/test/java/org/apache/jena/rdflink/TestRDFLinkHTTPHeaders.java:
##########
@@ -0,0 +1,97 @@
+/*
+ * 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.rdflink;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import org.apache.jena.sparql.exec.http.QueryExecHTTP;
+import org.apache.jena.sparql.exec.http.QueryExecHTTPBuilder;
+import org.junit.jupiter.api.Test;
+
+public class TestRDFLinkHTTPHeaders {
Review Comment:
Add to `TS_RDFLink` please.
##########
jena-rdfconnection/src/test/java/org/apache/jena/rdfconnection/TestRDFConnectionHTTPHeaders.java:
##########
@@ -0,0 +1,121 @@
+/*
+ * 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.rdfconnection;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import org.apache.jena.query.QueryExecution;
+import org.apache.jena.sparql.exec.QueryExec;
+import org.apache.jena.sparql.exec.http.QueryExecHTTP;
+import org.apache.jena.sparql.exec.http.QueryExecutionHTTP;
+import org.apache.jena.sparql.exec.http.QueryExecutionHTTPBuilder;
+import org.junit.jupiter.api.Test;
+
+public class TestRDFConnectionHTTPHeaders {
+
+ /**
+ * Test whether connection headers are properly passed on to the query
execution.
+ * No query is actually executed.
+ */
+ @Test void test_headers_non_parsed() {
+ try (RDFConnection conn =
RDFConnectionRemote.service("urn:dummy-service")
+ .parseCheckSPARQL(false)
+ .acceptHeaderSelectQuery("s")
+ .acceptHeaderAskQuery("a")
+ .acceptHeaderGraph("g")
+ .acceptHeaderDataset("d")
+ .build()) {
+
+ try (QueryExecution qExec = conn.query("dummy query string")) {
+ QueryExecHTTP qe = (QueryExecHTTP)QueryExec.adapt(qExec);
+ assertEquals("s", qe.getAcceptHeaderSelect());
+ assertEquals("a", qe.getAcceptHeaderAsk());
+ assertEquals("g", qe.getAcceptHeaderDescribe());
+ assertEquals("g", qe.getAcceptHeaderConstructGraph());
+ assertEquals("d", qe.getAcceptHeaderConstructDataset());
+ }
+ }
+ }
+
+ @Test void test_headers_non_parsed_fallback() {
+ try (RDFConnection conn =
RDFConnectionRemote.service("urn:dummy-service")
+ .parseCheckSPARQL(false)
+ .acceptHeaderQuery("f") // fallback
+ .acceptHeaderSelectQuery(null)
+ .acceptHeaderAskQuery(null)
+ .acceptHeaderGraph(null)
+ .acceptHeaderDataset(null)
+ .build()) {
+
+ try (QueryExecution qExec = conn.query("dummy query string")) {
+ QueryExecHTTP qe = (QueryExecHTTP)QueryExec.adapt(qExec);
+ assertEquals("f", qe.getAcceptHeaderSelect());
+ assertEquals("f", qe.getAcceptHeaderAsk());
+ assertEquals("f", qe.getAcceptHeaderDescribe());
+ assertEquals("f", qe.getAcceptHeaderConstructGraph());
+ assertEquals("f", qe.getAcceptHeaderConstructDataset());
+ }
+ }
+ }
+
+ @Test void test_headers_parsed_fallback() {
+ try (RDFConnection conn =
RDFConnectionRemote.service("urn:dummy-service")
+ .acceptHeaderQuery("f") // fallback
+ .acceptHeaderSelectQuery(null)
+ .acceptHeaderAskQuery(null)
+ .acceptHeaderGraph(null)
+ .acceptHeaderDataset(null)
+ .build()) {
+
+ try (QueryExecution qExec = conn.newQuery()
+ .query("SELECT * { ?s ?p ?o }")
+ .build()) {
+ QueryExecHTTP qe = (QueryExecHTTP)QueryExec.adapt(qExec);
+ assertEquals("f", qe.getAcceptHeaderSelect());
+
+ assertEquals("f", qe.getAcceptHeaderAsk());
+ assertEquals("f", qe.getAcceptHeaderDescribe());
+ assertEquals("f", qe.getAcceptHeaderConstructGraph());
+ assertEquals("f", qe.getAcceptHeaderConstructDataset());
+ }
+ }
+ }
+
+ /**
+ * Setting an override-header on the builder should set all
+ * headers on the QueryExecHTTP instance to that override.
+ */
+ @Test
+ public void test_override_header() {
+ try (QueryExecutionHTTP qExec =
+ QueryExecutionHTTPBuilder.create()
+ .endpoint("urn:dummy-service")
+ .queryString("SELECT * { ?s ?p ?o }")
+ .acceptHeader("o") // Override header
+ .build()) {
+ QueryExecHTTP qe = (QueryExecHTTP)QueryExec.adapt(qExec);
+ assertEquals("o", qe.getAppProvidedAcceptHeader());
+ assertEquals("o", qe.getAcceptHeaderSelect());
+ assertEquals("o", qe.getAcceptHeaderAsk());
+ assertEquals("o", qe.getAcceptHeaderDescribe());
+ assertEquals("o", qe.getAcceptHeaderConstructGraph());
+ assertEquals("o", qe.getAcceptHeaderConstructDataset());
+ }
+ }
+}
Review Comment:
There is a missing test:
```
.acceptHeader("o")
.acceptHeaderAskQuery("a")
```
which I would expect to set just the ASK query type to "a" and leave
everything else as "o"
##########
jena-arq/src/main/java/org/apache/jena/sparql/exec/http/QueryExecHTTP.java:
##########
@@ -119,10 +117,28 @@ public static QueryExecHTTPBuilder service(String
serviceURL) {
private HttpClient httpClient = HttpEnv.getDftHttpClient();
private Map<String, String> httpHeaders;
+ public QueryExecHTTP(String serviceURL, Query query, String queryString,
int urlLimit,
Review Comment:
`public` does not like it is necessary
So Jena6, shall we make it `protected` and have only one constructor.
If so, add `@Deprecated` with a javadoc comment saying the constructor will
become protected on both constructors.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]