Aklakan commented on code in PR #3441: URL: https://github.com/apache/jena/pull/3441#discussion_r2389221931
########## jena-rdfconnection/src/test/java/org/apache/jena/rdfconnection/TestRDFConnectionHTTPHeaders.java: ########## @@ -0,0 +1,136 @@ +/* + * 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) Review Comment: There are `acceptHeaderQuery` tests are in RDF**Connection**HTTPHeaders - if desired, they could be duplicated for the RDFLink level. Note: The comment on the field `acceptSparqlResults` originally read: > // All purpose SPARQL results header used if above specific cases do not apply. So I interpreted this as a fallback. An alternative interpretation is that this sets *all* SPARQL query headers - in this case, separate SPARQL-only fields should be introduced that are not shared with GSP. `acceptHeaderQuery` would then set the fields for sparql graph results (construct and describe) but not for GSP retrieval. -- 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]
