You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2016/12/22 17:55:01 UTC

[01/11] jena git commit: JENA-1267: Module jena-rdfconnection

Repository: jena
Updated Branches:
  refs/heads/master 9075e9ac2 -> 9f42f00b3


http://git-wip-us.apache.org/repos/asf/jena/blob/2e26b78e/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/SparqlQueryConnection.java
----------------------------------------------------------------------
diff --git a/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/SparqlQueryConnection.java b/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/SparqlQueryConnection.java
new file mode 100644
index 0000000..3c40ae9
--- /dev/null
+++ b/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/SparqlQueryConnection.java
@@ -0,0 +1,105 @@
+/*
+ * 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 java.util.function.Consumer ;
+
+import org.apache.jena.query.* ;
+import org.apache.jena.rdf.model.Model ;
+import org.apache.jena.sparql.core.Transactional ;
+
+/** SPARQL Query Operations on a connection.
+ * 
+ * @see RDFConnection
+ * @see RDFConnectionFactory
+ */  
+public interface SparqlQueryConnection extends Transactional, AutoCloseable
+{
+    /**
+     * Execute a SELECT query and process the ResultSet with the handler code.  
+     * @param query
+     * @param resultSetAction
+     */
+    public void queryResultSet(String query, Consumer<ResultSet> resultSetAction) ;
+    
+    /**
+     * Execute a SELECT query and process the ResultSet with the handler code.  
+     * @param query
+     * @param resultSetAction
+     */
+    public void queryResultSet(Query query, Consumer<ResultSet> resultSetAction) ; 
+
+    /**
+     * Execute a SELECT query and process the rows of the results with the handler code.  
+     * @param query
+     * @param rowAction
+     */
+    public void querySelect(String query, Consumer<QuerySolution> rowAction) ;
+    
+    /**
+     * Execute a SELECT query and process the rows of the results with the handler code.  
+     * @param query
+     * @param rowAction
+     */
+    public void querySelect(Query query, Consumer<QuerySolution> rowAction) ; 
+
+    /** Execute a CONSTRUCT query and return as a Model */
+    public Model queryConstruct(String query) ;
+    
+    /** Execute a CONSTRUCT query and return as a Model */
+    public Model queryConstruct(Query query) ;
+
+    /** Execute a DESCRIBE query and return as a Model */
+    public Model queryDescribe(String query) ;
+    
+    /** Execute a DESCRIBE query and return as a Model */
+    public Model queryDescribe(Query query) ;
+    
+    /** Execute a ASK query and return a boolean */
+    public boolean queryAsk(String query) ;
+
+    /** Execute a ASK query and return a boolean */
+    public boolean queryAsk(Query query) ;
+    
+    /** Setup a SPARQL query execution.
+     * 
+     *  See also {@link #querySelect(Query, Consumer)}, {@link #queryConstruct(Query)}, 
+     *  {@link #queryDescribe(Query)}, {@link #queryAsk(Query)}
+     *  for ways to execute queries for of a specific form.
+     * 
+     * @param query
+     * @return QueryExecution
+     */
+    public QueryExecution query(Query query) ;
+
+    /** Setup a SPARQL query execution.
+     * 
+     *  See also {@link #querySelect(String, Consumer)}, {@link #queryConstruct(String)}, 
+     *  {@link #queryDescribe(String)}, {@link #queryAsk(String)}
+     *  for ways to execute queries for of a specific form.
+     * 
+     * @param queryString 
+     * @return QueryExecution
+     */
+    public QueryExecution query(String queryString) ;
+    
+    /** Close this connection.  Use with try-resource. */ 
+    @Override public void close() ;
+}
+

http://git-wip-us.apache.org/repos/asf/jena/blob/2e26b78e/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/SparqlUpdateConnection.java
----------------------------------------------------------------------
diff --git a/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/SparqlUpdateConnection.java b/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/SparqlUpdateConnection.java
new file mode 100644
index 0000000..2428122
--- /dev/null
+++ b/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/SparqlUpdateConnection.java
@@ -0,0 +1,53 @@
+/*
+ * 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 org.apache.jena.sparql.core.Transactional ;
+import org.apache.jena.update.Update ;
+import org.apache.jena.update.UpdateRequest ;
+
+/** SPARQL Update Operations on a connection.
+ * 
+ * @see RDFConnection
+ * @see RDFConnectionFactory
+ */  
+public interface SparqlUpdateConnection extends Transactional, AutoCloseable
+{
+    /** Execute a SPARQL Update.
+     * 
+     * @param update
+     */
+    public void update(Update update) ;
+
+    /** Execute a SPARQL Update.
+     * 
+     * @param update
+     */
+    public void update(UpdateRequest update) ; 
+    
+    /** Execute a SPARQL Update.
+     * 
+     * @param updateString
+     */
+    public void update(String updateString) ;
+    
+    /** Close this connection. */ 
+    @Override public void close() ;
+}
+

http://git-wip-us.apache.org/repos/asf/jena/blob/2e26b78e/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/examples/RDFConnectionExample1.java
----------------------------------------------------------------------
diff --git a/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/examples/RDFConnectionExample1.java b/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/examples/RDFConnectionExample1.java
new file mode 100644
index 0000000..c86727a
--- /dev/null
+++ b/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/examples/RDFConnectionExample1.java
@@ -0,0 +1,45 @@
+/*
+ * 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.examples;
+
+import org.apache.jena.query.*;
+import org.apache.jena.rdfconnection.RDFConnection;
+import org.apache.jena.rdfconnection.RDFConnectionFactory;
+import org.apache.jena.system.Txn;
+
+/** RDF Connection example */
+public class RDFConnectionExample1 {
+    public static void main(String ...args) {
+        Query query = QueryFactory.create("SELECT * { {?s ?p ?o } UNION { GRAPH ?g { ?s ?p ?o } } }");
+        Dataset dataset = DatasetFactory.createTxnMem();
+        RDFConnection conn = RDFConnectionFactory.connect(dataset);
+        
+        Txn.executeWrite(conn, () ->{
+            System.out.println("Load a file");
+            conn.load("data.ttl");
+            conn.load("http://example/g0", "data.ttl");
+            System.out.println("In write transaction");
+            conn.queryResultSet(query, ResultSetFormatter::out);
+        });
+        // And again - implicit READ transaction.
+        System.out.println("After write transaction");
+        conn.queryResultSet(query, ResultSetFormatter::out);
+    }
+}
+

http://git-wip-us.apache.org/repos/asf/jena/blob/2e26b78e/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/examples/RDFConnectionExample2.java
----------------------------------------------------------------------
diff --git a/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/examples/RDFConnectionExample2.java b/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/examples/RDFConnectionExample2.java
new file mode 100644
index 0000000..0fcffd1
--- /dev/null
+++ b/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/examples/RDFConnectionExample2.java
@@ -0,0 +1,67 @@
+/*
+ * 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.examples;
+
+import org.apache.jena.query.* ;
+import org.apache.jena.rdfconnection.RDFConnection;
+import org.apache.jena.rdfconnection.RDFConnectionFactory;
+import org.apache.jena.riot.Lang ;
+import org.apache.jena.riot.RDFDataMgr ;
+import org.apache.jena.system.Txn ;
+
+/* 
+ * Example of a connection performng a number of transactional operations.
+ */
+public class RDFConnectionExample2 {
+    public static void main(String ...args) {
+        Query query = QueryFactory.create("SELECT * { {?s ?p ?o } UNION { GRAPH ?g { ?s ?p ?o } } }") ;
+        Dataset dataset = DatasetFactory.createTxnMem();
+        
+        try ( RDFConnection conn = RDFConnectionFactory.connect(dataset) ) {
+            System.out.println("** Load a file");
+            // ---- Transaction 1: load data. 
+            Txn.executeWrite(conn, ()->conn.load("data.ttl")) ;
+            
+            // ---- Transaction 2: explicit styles 
+            conn.begin(ReadWrite.WRITE);
+            conn.load("http://example/g0", "data.ttl") ;
+            
+            System.out.println("** Inside multistep transaction - query dataset");
+            conn.queryResultSet(query, ResultSetFormatter::out) ;
+            
+            conn.abort();
+            conn.end() ;
+            System.out.println("** After abort 1") ;
+            
+            // ---- Transaction 3: explicit styles
+            Txn.executeWrite(conn, ()->{
+                conn.load("http://example/g0", "data.ttl") ;
+                System.out.println("** Inside multistep transaction - fetch dataset");
+                Dataset ds2 = conn.fetchDataset() ;
+                RDFDataMgr.write(System.out, ds2, Lang.TRIG) ;
+                conn.abort();
+            }) ;
+            
+            System.out.println("** After abort 2") ;
+            // Only default graph showing.
+            conn.queryResultSet(query, ResultSetFormatter::out);
+        }
+    }
+}
+

http://git-wip-us.apache.org/repos/asf/jena/blob/2e26b78e/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/examples/RDFConnectionExample3.java
----------------------------------------------------------------------
diff --git a/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/examples/RDFConnectionExample3.java b/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/examples/RDFConnectionExample3.java
new file mode 100644
index 0000000..89b2008
--- /dev/null
+++ b/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/examples/RDFConnectionExample3.java
@@ -0,0 +1,42 @@
+/*
+ * 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.examples;
+
+import org.apache.jena.query.Query ;
+import org.apache.jena.query.QueryFactory ;
+import org.apache.jena.query.ResultSetFormatter ;
+import org.apache.jena.rdfconnection.RDFConnection;
+import org.apache.jena.rdfconnection.RDFConnectionFactory;
+
+/* 
+ * Example of a connection performing a remote query.
+ * (assumes sparql.org is up and running)
+ */
+public class RDFConnectionExample3 {
+    public static void main(String ...args) {
+        Query query = QueryFactory.create("SELECT * { <http://example.org/book/book1> ?p ?o }") ;
+        String queryService = "http://sparql.org/books/query" ;
+
+        // Query service, no update, no graph store protocol.
+        try ( RDFConnection conn = RDFConnectionFactory.connect(queryService, null, null) ) {
+            conn.queryResultSet(query, ResultSetFormatter::out);
+        }
+    }
+}
+

http://git-wip-us.apache.org/repos/asf/jena/blob/2e26b78e/jena-rdfconnection/src/main/resources/LICENSE
----------------------------------------------------------------------
diff --git a/jena-rdfconnection/src/main/resources/LICENSE b/jena-rdfconnection/src/main/resources/LICENSE
new file mode 100644
index 0000000..f433b1a
--- /dev/null
+++ b/jena-rdfconnection/src/main/resources/LICENSE
@@ -0,0 +1,177 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS

http://git-wip-us.apache.org/repos/asf/jena/blob/2e26b78e/jena-rdfconnection/src/main/resources/NOTICE
----------------------------------------------------------------------
diff --git a/jena-rdfconnection/src/main/resources/NOTICE b/jena-rdfconnection/src/main/resources/NOTICE
new file mode 100644
index 0000000..81363e4
--- /dev/null
+++ b/jena-rdfconnection/src/main/resources/NOTICE
@@ -0,0 +1,5 @@
+Apache Jena - RDF Connection
+Copyright 2016 The Apache Software Foundation
+
+This code is licensed under an Apache Software License.
+See LICENSE.

http://git-wip-us.apache.org/repos/asf/jena/blob/2e26b78e/jena-rdfconnection/src/test/java/org/apache/jena/rdfconnection/AbstractTestRDFConnection.java
----------------------------------------------------------------------
diff --git a/jena-rdfconnection/src/test/java/org/apache/jena/rdfconnection/AbstractTestRDFConnection.java b/jena-rdfconnection/src/test/java/org/apache/jena/rdfconnection/AbstractTestRDFConnection.java
new file mode 100644
index 0000000..db8ace5
--- /dev/null
+++ b/jena-rdfconnection/src/test/java/org/apache/jena/rdfconnection/AbstractTestRDFConnection.java
@@ -0,0 +1,382 @@
+/*
+ * 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 java.util.concurrent.atomic.AtomicInteger ;
+
+import org.apache.jena.atlas.iterator.Iter ;
+import org.apache.jena.atlas.junit.BaseTest ;
+import org.apache.jena.atlas.lib.StrUtils ;
+import org.apache.jena.query.Dataset ;
+import org.apache.jena.query.DatasetFactory ;
+import org.apache.jena.query.ReadWrite ;
+import org.apache.jena.rdf.model.Model ;
+import org.apache.jena.rdf.model.ModelFactory ;
+import org.apache.jena.rdfconnection.RDFConnection;
+import org.apache.jena.riot.RDFDataMgr ;
+import org.apache.jena.sparql.core.DatasetGraph ;
+import org.apache.jena.sparql.sse.SSE ;
+import org.apache.jena.sparql.util.IsoMatcher ;
+import org.apache.jena.system.Txn ;
+import org.junit.Assume ;
+import org.junit.Test ;
+
+public abstract class AbstractTestRDFConnection extends BaseTest {
+    // Testing data.
+    static String DIR = "testing/RDFConnection/" ;
+    
+    protected abstract RDFConnection connection() ;
+    // Not all RDFConenction types support.
+    //  (may acquite RDFConnection.supportTransactionalAbort but ATM that isn't included)
+    protected abstract boolean supportsAbort() ; 
+
+    // ---- Data
+    static String dsgdata = StrUtils.strjoinNL
+        ("(dataset"
+        ,"  (graph (:s :p :o) (:s0 :p0 _:a))"
+        ,"  (graph :g1 (:s :p :o) (:s1 :p1 :o1))"
+        ,"  (graph :g2 (:s :p :o) (:s2 :p2 :o))"
+        ,")"
+        ) ;
+    
+    static String dsgdata2 = StrUtils.strjoinNL
+        ("(dataset"
+        ,"  (graph (:x :y :z))"
+        ,"  (graph :g9 (:s :p :o))"
+        ,")"
+        ) ;
+
+    
+    static String graph1 = StrUtils.strjoinNL
+        ("(graph (:s :p :o) (:s1 :p1 :o))"
+        ) ;
+
+    static String graph2 = StrUtils.strjoinNL
+        ("(graph (:s :p :o) (:s2 :p2 :o))"
+        ) ;
+    
+    static DatasetGraph dsg        = SSE.parseDatasetGraph(dsgdata);
+    static Dataset      dataset    = DatasetFactory.wrap(dsg);
+    static DatasetGraph dsg2       = SSE.parseDatasetGraph(dsgdata2);
+    static Dataset      dataset2   = DatasetFactory.wrap(dsg2);
+
+    static String       graphName  = "http://test/graph";
+    static String       graphName2 = "http://test/graph2";
+    static Model        model1     = ModelFactory.createModelForGraph(SSE.parseGraph(graph1));
+    static Model        model2     = ModelFactory.createModelForGraph(SSE.parseGraph(graph2));
+    // ---- Data
+
+    @Test public void connect_01() {
+        @SuppressWarnings("resource")
+        RDFConnection conn = connection() ;
+        assertFalse(conn.isClosed()) ;
+        conn.close() ;
+        assertTrue(conn.isClosed()) ;
+        // Allow multiple close()
+        conn.close() ;
+    }
+    
+    @Test public void dataset_load_1() {
+        String testDataFile = DIR+"data.trig" ; 
+        try ( RDFConnection conn = connection() ) {
+            conn.loadDataset(testDataFile);
+            Dataset ds0 = RDFDataMgr.loadDataset(testDataFile) ;
+            Dataset ds = conn.fetchDataset() ;
+            assertTrue("Datasets not isomorphic", isomorphic(ds0, ds)) ;
+        }
+    }
+
+    @Test public void dataset_put_1() {
+        try ( RDFConnection conn = connection() ) {
+            conn.putDataset(dataset) ; 
+            Dataset ds1 = conn.fetchDataset() ;
+            assertTrue("Datasets not isomorphic", isomorphic(dataset, ds1)) ;
+        }
+    }
+
+    @Test public void dataset_put_2() {
+        try ( RDFConnection conn = connection() ) {
+            conn.putDataset(dataset) ; 
+            conn.putDataset(dataset2) ;
+            Dataset ds1 = conn.fetchDataset() ;
+            assertTrue("Datasets not isomorphic", isomorphic(dataset2, ds1)) ;
+        }
+    }
+
+    @Test public void dataset_post_1() {
+        try ( RDFConnection conn = connection() ) {
+            conn.loadDataset(dataset);
+            Dataset ds1 = conn.fetchDataset() ;
+            assertTrue("Datasets not isomorphic", isomorphic(dataset, ds1)) ;
+        }
+    }
+    
+    @Test public void dataset_post_2() {
+        try ( RDFConnection conn = connection() ) {
+            conn.loadDataset(dataset);
+            conn.loadDataset(dataset2);
+            Dataset ds1 = conn.fetchDataset() ;
+            long x = Iter.count(ds1.listNames()) ;
+            assertEquals("NG count", 3, x) ;
+            assertFalse("Datasets are isomorphic", isomorphic(dataset, ds1)) ;
+            assertFalse("Datasets are isomorphic", isomorphic(dataset2, ds1)) ;
+        }
+    }
+
+    // Default graph
+    
+    @Test public void graph_load_1() {
+        String testDataFile = DIR+"data.ttl" ; 
+        Model m0 = RDFDataMgr.loadModel(testDataFile) ;
+        try ( RDFConnection conn = connection() ) {
+            conn.load(testDataFile);
+            Model m = conn.fetch() ;
+            assertTrue("Models not isomorphic", isomorphic(m0, m)) ;
+        }
+    }
+
+    @Test public void graph_put_1() {
+        try ( RDFConnection conn = connection() ) {
+            conn.put(model1); 
+            Dataset ds1 = conn.fetchDataset() ;
+            Model m0 = conn.fetch() ;
+            assertTrue("Models not isomorphic", isomorphic(model1, ds1.getDefaultModel())) ;
+            Model m = conn.fetch() ;
+            assertTrue("Models not isomorphic", isomorphic(model1, m)) ;
+        }
+    }
+
+    @Test public void graph_put_2() {
+        try ( RDFConnection conn = connection() ) {
+            conn.put(model1) ; 
+            conn.put(model2) ;
+            Model m = conn.fetch() ;
+            assertTrue("Models not isomorphic", isomorphic(m, model2)) ;
+            assertFalse("Models not isomorphic", isomorphic(m, model1)) ;
+        }
+    }
+
+    @Test public void graph_post_1() {
+        try ( RDFConnection conn = connection() ) {
+            conn.load(model1) ;
+            Model m = conn.fetch() ;
+            assertTrue("Models not isomorphic", isomorphic(m, model1)) ;
+        }
+    }
+    
+    @Test public void graph_post_2() {
+        try ( RDFConnection conn = connection() ) {
+            conn.load(model1) ;
+            conn.load(model2) ;
+            Model m = conn.fetch() ;
+            Model m0 = ModelFactory.createUnion(model2, model1) ;
+            assertTrue("Models are not isomorphic", isomorphic(m0, m)) ;
+        }
+    }
+
+    // DELETE
+    
+    // Named graphs
+    
+    @Test public void named_graph_load_1() {
+        String testDataFile = DIR+"data.ttl" ; 
+        Model m0 = RDFDataMgr.loadModel(testDataFile) ;
+        try ( RDFConnection conn = connection() ) {
+            conn.load(graphName, testDataFile);
+            Model m = conn.fetch(graphName) ;
+            assertTrue("Models not isomorphic", isomorphic(m0, m)) ;
+            Model mDft = conn.fetch() ;
+            assertTrue(mDft.isEmpty()) ;
+        }
+    }
+
+    @Test public void named_graph_put_1() {
+        try ( RDFConnection conn = connection() ) {
+            conn.put(graphName, model1); 
+            Dataset ds1 = conn.fetchDataset() ;
+            Model m0 = conn.fetch(graphName) ;
+            assertTrue("Models not isomorphic", isomorphic(model1, ds1.getNamedModel(graphName))) ;
+            Model m = conn.fetch(graphName) ;
+            assertTrue("Models not isomorphic", isomorphic(model1, m)) ;
+        }
+    }
+
+    @Test public void named_graph_put_2() {
+        try ( RDFConnection conn = connection() ) {
+            conn.put(graphName, model1) ; 
+            conn.put(graphName, model2) ;
+            Model m = conn.fetch(graphName) ;
+            assertTrue("Models not isomorphic", isomorphic(m, model2)) ;
+            assertFalse("Models not isomorphic", isomorphic(m, model1)) ;
+        }
+    }
+
+    @Test public void named_graph_put_2_different() {
+        try ( RDFConnection conn = connection() ) {
+            conn.put(graphName, model1) ; 
+            conn.put(graphName2, model2) ;
+            Model m1 = conn.fetch(graphName) ;
+            Model m2 = conn.fetch(graphName2) ;
+            assertTrue("Models not isomorphic", isomorphic(m1, model1)) ;
+            assertTrue("Models not isomorphic", isomorphic(m2, model2)) ;
+        }
+    }
+
+    @Test public void named_graph_post_1() {
+        try ( RDFConnection conn = connection() ) {
+            conn.load(graphName, model1) ;
+            Model m = conn.fetch(graphName) ;
+            assertTrue("Models not isomorphic", isomorphic(m, model1)) ;
+        }
+    }
+    
+    @Test public void named_graph_post_2() {
+        try ( RDFConnection conn = connection() ) {
+            conn.load(graphName, model1) ;
+            conn.load(graphName, model2) ;
+            Model m = conn.fetch(graphName) ;
+            Model m0 = ModelFactory.createUnion(model2, model1) ;
+            assertTrue("Models are not isomorphic", isomorphic(m0, m)) ;
+        }
+    }
+
+    // DELETE
+    
+    // Remote connections don't support transactions fully.  
+    //@Test public void transaction_01() 
+
+    private static boolean isomorphic(Dataset ds1, Dataset ds2) {
+        return IsoMatcher.isomorphic(ds1.asDatasetGraph(), ds2.asDatasetGraph()) ;
+    }
+    
+    private static boolean isomorphic(Model model1, Model model2) {
+        return model1.isIsomorphicWith(model2) ;
+    }
+    
+
+    @Test public void query_ask_01() {
+        try ( RDFConnection conn = connection() ) {
+            Txn.executeRead(conn, ()->{
+                boolean b = conn.queryAsk("ASK{}") ;
+                assertTrue(b) ;
+            }) ;
+        }
+    }
+
+    @Test public void query_ask_02() {
+        try ( RDFConnection conn = connection() ) {
+            boolean b = conn.queryAsk("ASK{}") ;
+            assertTrue(b) ;
+        }
+    }
+
+    @Test public void query_select_01() {
+        AtomicInteger counter = new AtomicInteger(0) ;
+        try ( RDFConnection conn = connection() ) {
+            Txn.executeWrite(conn, ()->conn.loadDataset(DIR+"data.trig"));
+            Txn.executeRead(conn, ()->
+                conn.querySelect("SELECT * { ?s ?p ?o }" , (r)->counter.incrementAndGet()));
+            assertEquals(2, counter.get()) ;
+        }
+    }
+
+    @Test public void query_select_02() {
+        AtomicInteger counter = new AtomicInteger(0) ;
+        try ( RDFConnection conn = connection() ) {
+            conn.loadDataset(DIR+"data.trig");
+            conn.querySelect("SELECT * { ?s ?p ?o}" , (r)->counter.incrementAndGet());
+            assertEquals(2, counter.get()) ;
+        }
+    }
+
+    @Test public void query_construct_01() {
+        try ( RDFConnection conn = connection() ) {
+            Txn.executeWrite(conn, ()->conn.loadDataset(DIR+"data.trig"));
+            Txn.executeRead(conn, ()-> {
+                Model m = conn.queryConstruct("CONSTRUCT WHERE { ?s ?p ?o }") ;
+                assertEquals(2, m.size()) ;
+            }) ;
+        }
+    }
+
+    @Test public void query_construct_02() {
+        try ( RDFConnection conn = connection() ) {
+            conn.loadDataset(DIR+"data.trig");
+            Model m = conn.queryConstruct("CONSTRUCT WHERE { ?s ?p ?o }") ;
+            assertEquals(2, m.size()) ;
+        }
+    }
+    
+    @Test public void update_01() {
+        try ( RDFConnection conn = connection() ) {
+            conn.update("INSERT DATA { <urn:x:s> <urn:x:p> <urn:x:o>}");
+        }
+    }
+
+    @Test public void update_02() {
+        try ( RDFConnection conn = connection() ) {
+            Txn.executeWrite(conn, ()->conn.update("INSERT DATA { <urn:x:s> <urn:x:p> <urn:x:o>}")) ;
+        }
+    }
+
+    // Not all Transactional support abort.
+    @Test public void transaction_commit_read_01() {
+        String testDataFile = DIR+"data.trig" ; 
+        try ( RDFConnection conn = connection() ) {
+
+            conn.begin(ReadWrite.WRITE) ;
+            conn.loadDataset(dataset);
+            conn.commit() ;
+            conn.end();
+            
+            conn.begin(ReadWrite.READ) ;
+            Model m = conn.fetch() ;
+            assertTrue(isomorphic(m, dataset.getDefaultModel())) ;
+            conn.end() ;
+        }
+    }
+    
+    // Not all RDFConnections support abort.
+    @Test public void transaction_abort_read02() {
+        Assume.assumeTrue(supportsAbort()) ;
+        
+        String testDataFile = DIR+"data.trig" ; 
+        try ( RDFConnection conn = connection() ) {
+            conn.begin(ReadWrite.WRITE) ;
+            conn.loadDataset(testDataFile);
+            conn.abort();
+            conn.end();
+            
+            conn.begin(ReadWrite.READ) ;
+            Model m = conn.fetch() ;
+            assertTrue(m.isEmpty()) ;
+            conn.end() ;
+        }
+    }
+
+    //@Test(expected=JenaTransactionException.class)
+    public void transaction_bad_01() {
+        try ( RDFConnection conn = connection() ) {
+            conn.begin(ReadWrite.WRITE) ;
+            // Should have conn.commit() ;
+            conn.end();
+        }
+    }
+}
+

http://git-wip-us.apache.org/repos/asf/jena/blob/2e26b78e/jena-rdfconnection/src/test/java/org/apache/jena/rdfconnection/TS_RDFConnection.java
----------------------------------------------------------------------
diff --git a/jena-rdfconnection/src/test/java/org/apache/jena/rdfconnection/TS_RDFConnection.java b/jena-rdfconnection/src/test/java/org/apache/jena/rdfconnection/TS_RDFConnection.java
new file mode 100644
index 0000000..ae03c22
--- /dev/null
+++ b/jena-rdfconnection/src/test/java/org/apache/jena/rdfconnection/TS_RDFConnection.java
@@ -0,0 +1,32 @@
+/*
+ * 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 org.junit.runner.RunWith ;
+import org.junit.runners.Suite ;
+
+@RunWith(Suite.class)
+@Suite.SuiteClasses( {
+    // Other tests are in jena-integration-tests
+    TestRDFConnectionLocalTxnMem.class
+    , TestRDFConnectionLocalMRSW.class
+})
+
+public class TS_RDFConnection {}
+

http://git-wip-us.apache.org/repos/asf/jena/blob/2e26b78e/jena-rdfconnection/src/test/java/org/apache/jena/rdfconnection/TestRDFConnectionLocalMRSW.java
----------------------------------------------------------------------
diff --git a/jena-rdfconnection/src/test/java/org/apache/jena/rdfconnection/TestRDFConnectionLocalMRSW.java b/jena-rdfconnection/src/test/java/org/apache/jena/rdfconnection/TestRDFConnectionLocalMRSW.java
new file mode 100644
index 0000000..adadc30
--- /dev/null
+++ b/jena-rdfconnection/src/test/java/org/apache/jena/rdfconnection/TestRDFConnectionLocalMRSW.java
@@ -0,0 +1,38 @@
+/*
+ * 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 org.apache.jena.query.Dataset ;
+import org.apache.jena.query.DatasetFactory ;
+import org.apache.jena.rdfconnection.RDFConnection;
+import org.apache.jena.rdfconnection.RDFConnectionFactory;
+
+public class TestRDFConnectionLocalMRSW extends AbstractTestRDFConnection {
+
+    @Override
+    protected boolean supportsAbort() { return false ; }
+    
+    @Override
+    protected RDFConnection connection() {
+        // General purpose, mixed storage, MRSW dataset.  
+        Dataset ds = DatasetFactory.create() ;
+        return RDFConnectionFactory.connect(ds) ;
+    }
+}
+

http://git-wip-us.apache.org/repos/asf/jena/blob/2e26b78e/jena-rdfconnection/src/test/java/org/apache/jena/rdfconnection/TestRDFConnectionLocalTxnMem.java
----------------------------------------------------------------------
diff --git a/jena-rdfconnection/src/test/java/org/apache/jena/rdfconnection/TestRDFConnectionLocalTxnMem.java b/jena-rdfconnection/src/test/java/org/apache/jena/rdfconnection/TestRDFConnectionLocalTxnMem.java
new file mode 100644
index 0000000..7059b12
--- /dev/null
+++ b/jena-rdfconnection/src/test/java/org/apache/jena/rdfconnection/TestRDFConnectionLocalTxnMem.java
@@ -0,0 +1,38 @@
+/*
+ * 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 org.apache.jena.query.Dataset ;
+import org.apache.jena.query.DatasetFactory ;
+import org.apache.jena.rdfconnection.RDFConnection;
+import org.apache.jena.rdfconnection.RDFConnectionFactory;
+
+public class TestRDFConnectionLocalTxnMem extends AbstractTestRDFConnection {
+
+    @Override
+    protected boolean supportsAbort() { return true ; }
+
+    @Override
+    protected RDFConnection connection() {
+        // Full transactional in-memory dataset.  
+        Dataset ds = DatasetFactory.createTxnMem() ;
+        return RDFConnectionFactory.connect(ds) ;
+    }
+}
+

http://git-wip-us.apache.org/repos/asf/jena/blob/2e26b78e/jena-rdfconnection/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/jena-rdfconnection/src/test/resources/log4j.properties b/jena-rdfconnection/src/test/resources/log4j.properties
new file mode 100644
index 0000000..e84e60e
--- /dev/null
+++ b/jena-rdfconnection/src/test/resources/log4j.properties
@@ -0,0 +1,40 @@
+# Licensed under the terms of http://www.apache.org/licenses/LICENSE-2.0
+
+# Plain output to stdout
+log4j.appender.jena.plainstdout=org.apache.log4j.ConsoleAppender
+log4j.appender.jena.plainstdout.target=System.out
+log4j.appender.jena.plainstdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.jena.plainstdout.layout.ConversionPattern=[%d{yyyy-MM-dd HH:mm:ss}] %-10c{1} %-5p %m%n
+## %d{ISO8601} -- includes "ss,sss"
+## log4j.appender.jena.plainstdout.layout.ConversionPattern=[%d{ISO8601}] %-10c{1} %-5p %m%n
+
+# Unadorned, for the NCSA requests log.
+log4j.appender.fuseki.plain=org.apache.log4j.ConsoleAppender
+log4j.appender.fuseki.plain.target=System.out
+log4j.appender.fuseki.plain.layout=org.apache.log4j.PatternLayout
+log4j.appender.fuseki.plain.layout.ConversionPattern=%m%n
+
+log4j.rootLogger=INFO, jena.plainstdout
+log4j.logger.org.apache.jena=WARN
+log4j.logger.org.apache.jena.fuseki=INFO
+
+# Others
+log4j.logger.org.eclipse.jetty=WARN
+log4j.logger.org.apache.shiro=WARN
+
+# Fuseki System logs.
+log4j.logger.org.apache.jena.fuseki.Server=INFO
+log4j.logger.org.apache.jena.fuseki.Fuseki=INFO
+log4j.logger.org.apache.jena.fuseki.Admin=INFO
+log4j.logger.org.apache.jena.fuseki.Validate=INFO
+log4j.logger.org.apache.jena.fuseki.Config=INFO
+
+# NCSA Request log.
+log4j.additivity.org.apache.jena.fuseki.Request=false
+log4j.logger.org.apache.jena.fuseki.Request=OFF, fuseki.plain
+
+# TDB
+log4j.logger.org.apache.jena.tdb.loader=INFO
+## Parser output
+log4j.additivity.org.apache.jena.riot=false
+log4j.logger.org.apache.jena.riot=INFO, jena.plainstdout

http://git-wip-us.apache.org/repos/asf/jena/blob/2e26b78e/jena-rdfconnection/testing/RDFConnection/data.trig
----------------------------------------------------------------------
diff --git a/jena-rdfconnection/testing/RDFConnection/data.trig b/jena-rdfconnection/testing/RDFConnection/data.trig
new file mode 100644
index 0000000..e8a6f04
--- /dev/null
+++ b/jena-rdfconnection/testing/RDFConnection/data.trig
@@ -0,0 +1,16 @@
+## Licensed under the terms of http://www.apache.org/licenses/LICENSE-2.0
+
+prefix : <http://example/>
+
+:s :p :o .
+:s0 :p0 :o .
+
+:g1 {
+   :s :p :o .
+   :s1 :p1 :o1 .
+   }
+
+:g2 {
+  :s :p :o .
+  :s2 :p2 :o .
+  }

http://git-wip-us.apache.org/repos/asf/jena/blob/2e26b78e/jena-rdfconnection/testing/RDFConnection/data.ttl
----------------------------------------------------------------------
diff --git a/jena-rdfconnection/testing/RDFConnection/data.ttl b/jena-rdfconnection/testing/RDFConnection/data.ttl
new file mode 100644
index 0000000..aa1b76c
--- /dev/null
+++ b/jena-rdfconnection/testing/RDFConnection/data.ttl
@@ -0,0 +1,6 @@
+## Licensed under the terms of http://www.apache.org/licenses/LICENSE-2.0
+
+prefix : <http://example/>
+
+:s :p :o .
+:s0 :p0 123 .


[09/11] jena git commit: JENA-1267: Merge commit 'refs/pull/197/head' of github.com:apache/jena

Posted by an...@apache.org.
JENA-1267: Merge commit 'refs/pull/197/head' of github.com:apache/jena

This closes #197.


Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/f1ef499e
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/f1ef499e
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/f1ef499e

Branch: refs/heads/master
Commit: f1ef499e03af332a50cf2c417df219a47e98ed88
Parents: 9075e9a 4e456a8
Author: Andy Seaborne <an...@apache.org>
Authored: Thu Dec 22 16:57:15 2016 +0000
Committer: Andy Seaborne <an...@apache.org>
Committed: Thu Dec 22 16:57:15 2016 +0000

----------------------------------------------------------------------
 apache-jena-libs/pom.xml                        |   6 +
 apache-jena/pom.xml                             |  22 +
 .../org/apache/jena/riot/system/Serializer.java |   2 +-
 jena-integration-tests/LICENSE                  | 177 +++++++
 jena-integration-tests/NOTICE                   |   4 +
 jena-integration-tests/README.md                |  11 +
 jena-integration-tests/pom.xml                  | 159 +++++++
 .../test/rdfconnection/TS_RDFConnection2.java   |  36 ++
 .../TestRDFConnectionLocalTDB.java              |  38 ++
 .../rdfconnection/TestRDFConnectionRemote.java  |  78 +++
 .../src/test/resources/log4j.properties         |  40 ++
 .../testing/RDFConnection/data.trig             |  16 +
 .../testing/RDFConnection/data.ttl              |   6 +
 jena-rdfconnection/Documentation.md             | 222 +++++++++
 jena-rdfconnection/LICENSE                      | 177 +++++++
 jena-rdfconnection/NOTICE                       |   5 +
 jena-rdfconnection/README.md                    |   6 +
 jena-rdfconnection/pom.xml                      | 164 +++++++
 .../apache/jena/rdfconnection/Isolation.java    |   5 +
 .../rdfconnection/JenaConnectionException.java  |  29 ++
 .../org/apache/jena/rdfconnection/RDFConn.java  |  40 ++
 .../jena/rdfconnection/RDFConnection.java       | 367 +++++++++++++++
 .../rdfconnection/RDFConnectionFactory.java     | 112 +++++
 .../jena/rdfconnection/RDFConnectionLocal.java  | 312 ++++++++++++
 .../rdfconnection/RDFConnectionModular.java     | 195 ++++++++
 .../jena/rdfconnection/RDFConnectionRemote.java | 471 +++++++++++++++++++
 .../RDFDatasetAccessConnection.java             |  57 +++
 .../rdfconnection/RDFDatasetConnection.java     | 150 ++++++
 .../rdfconnection/SparqlQueryConnection.java    | 105 +++++
 .../rdfconnection/SparqlUpdateConnection.java   |  53 +++
 .../examples/RDFConnectionExample1.java         |  45 ++
 .../examples/RDFConnectionExample2.java         |  67 +++
 .../examples/RDFConnectionExample3.java         |  42 ++
 jena-rdfconnection/src/main/resources/LICENSE   | 177 +++++++
 jena-rdfconnection/src/main/resources/NOTICE    |   5 +
 .../AbstractTestRDFConnection.java              | 381 +++++++++++++++
 .../jena/rdfconnection/TS_RDFConnection.java    |  33 ++
 .../jena/rdfconnection/TestLocalIsolation.java  |  84 ++++
 .../TestRDFConnectionLocalMRSW.java             |  38 ++
 .../TestRDFConnectionLocalTxnMem.java           |  38 ++
 .../src/test/resources/log4j.properties         |  40 ++
 .../testing/RDFConnection/data.trig             |  16 +
 .../testing/RDFConnection/data.ttl              |   6 +
 pom.xml                                         |  24 +-
 44 files changed, 4054 insertions(+), 7 deletions(-)
----------------------------------------------------------------------



[07/11] jena git commit: Isolation modes, inc documentation and tests.

Posted by an...@apache.org.
Isolation modes, inc documentation and tests.


Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/cdc9f143
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/cdc9f143
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/cdc9f143

Branch: refs/heads/master
Commit: cdc9f143c599da4924f4052f9fbbd4cfcc29504d
Parents: 53758b5
Author: Andy Seaborne <an...@apache.org>
Authored: Sun Dec 18 19:55:09 2016 +0000
Committer: Andy Seaborne <an...@apache.org>
Committed: Sun Dec 18 20:04:22 2016 +0000

----------------------------------------------------------------------
 jena-rdfconnection/Documentation.md             | 23 ++++-
 .../apache/jena/rdfconnection/Isolation.java    |  5 ++
 .../jena/rdfconnection/RDFConnection.java       | 92 ++++++++++----------
 .../rdfconnection/RDFConnectionFactory.java     | 27 +++++-
 .../jena/rdfconnection/RDFConnectionLocal.java  | 77 ++++++++++------
 .../jena/rdfconnection/TS_RDFConnection.java    |  1 +
 .../jena/rdfconnection/TestLocalIsolation.java  | 84 ++++++++++++++++++
 7 files changed, 234 insertions(+), 75 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/cdc9f143/jena-rdfconnection/Documentation.md
----------------------------------------------------------------------
diff --git a/jena-rdfconnection/Documentation.md b/jena-rdfconnection/Documentation.md
index d12bf34..e64eb67 100644
--- a/jena-rdfconnection/Documentation.md
+++ b/jena-rdfconnection/Documentation.md
@@ -18,8 +18,8 @@ Protocol</a>).
 data in Java.  It provides support for try-resource and functional code
 passing styles, as well the more basic sequence of methods calls.
 
-`try-resources` to manage the connection, and two operations, one to load
-some data, and one to make a query:
+For example: using `try-resources` to manage the connection, and perform two operations, one to load
+some data, and one to make a query can be written as:
 
 ```
 try ( RDFConnection conn = RDFConnectionFactory.connect(...) ) {
@@ -113,7 +113,7 @@ handled by the transaction pattern within a single JVM.
 ## Graph Store Protocol
 
 The <a href="http://www.w3.org/TR/sparql11-http-rdf-update/">SPARQL Graph
-Store Protocol</a> is a set of operations to work on whole graphs in a
+Store Protocol</a> (GSP) is a set of operations to work on whole graphs in a
 dataset.  It provides a standardised way to manage the data in a dataset.
 
 The operations are to fetch a graph, set the RDF data in a graph,
@@ -141,6 +141,23 @@ provided).
     conn.loadDataset("data-complete.trig") ;
 ```
 
+### Local vs Remote
+
+GSP operations work on while models and datasets. When used on a remote connection, 
+the result of a GSP operation is a separate copy of the remote RDF data.  When working
+with local connections, 3 isolations modes are available:
+
+* Copy &ndash; the models and datasets returned are independent copies.
+Updates are made to the return copy only. This is most like
+a remote connectionand is useful for testing.
+* Read-only &ndash; the models and datasets are made read-only but any changes
+to the underlying RDF data by changes by another route will be visible.
+This provides a form of checking for large datasets when "copy" is impractical.
+* None &ndash; the models and datasets are passed back with no additional wrappers
+and they can be updated with the changes being made the underlying dataset.
+
+The default for a local `RDFConnection` is "none".  
+
 ## Query Usage
 
 `RDFConnection` provides methods for each of the SPARQL query forms (`SELECT`,

http://git-wip-us.apache.org/repos/asf/jena/blob/cdc9f143/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/Isolation.java
----------------------------------------------------------------------
diff --git a/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/Isolation.java b/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/Isolation.java
new file mode 100644
index 0000000..79c496f
--- /dev/null
+++ b/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/Isolation.java
@@ -0,0 +1,5 @@
+package org.apache.jena.rdfconnection;
+public enum Isolation { COPY, READONLY, NONE }
+
+// XXX Expose copy-mode?
+

http://git-wip-us.apache.org/repos/asf/jena/blob/cdc9f143/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFConnection.java
----------------------------------------------------------------------
diff --git a/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFConnection.java b/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFConnection.java
index c1b95ea..3adae39 100644
--- a/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFConnection.java
+++ b/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFConnection.java
@@ -18,15 +18,15 @@
 
 package org.apache.jena.rdfconnection;
 
-import java.util.function.Consumer ;
+import java.util.function.Consumer;
 
-import org.apache.jena.query.* ;
-import org.apache.jena.rdf.model.Model ;
-import org.apache.jena.sparql.core.Transactional ;
-import org.apache.jena.system.Txn ;
-import org.apache.jena.update.Update ;
-import org.apache.jena.update.UpdateFactory ;
-import org.apache.jena.update.UpdateRequest ;
+import org.apache.jena.query.*;
+import org.apache.jena.rdf.model.Model;
+import org.apache.jena.sparql.core.Transactional;
+import org.apache.jena.system.Txn;
+import org.apache.jena.update.Update;
+import org.apache.jena.update.UpdateFactory;
+import org.apache.jena.update.UpdateRequest;
 
 /**
  * Interface for SPARQL operations on a datasets, whether local or remote.
@@ -82,7 +82,7 @@ public interface RDFConnection extends
      */
     @Override
     public default void queryResultSet(String query, Consumer<ResultSet> resultSetAction) {
-        queryResultSet(QueryFactory.create(query), resultSetAction) ;
+        queryResultSet(QueryFactory.create(query), resultSetAction);
     }
     
     /**
@@ -93,14 +93,14 @@ public interface RDFConnection extends
     @Override
     public default void queryResultSet(Query query, Consumer<ResultSet> resultSetAction) {
         if ( ! query.isSelectType() )
-            throw new JenaConnectionException("Query is not a SELECT query") ;
+            throw new JenaConnectionException("Query is not a SELECT query");
 
         Txn.executeRead(this, ()->{ 
             try ( QueryExecution qExec = query(query) ) {
-                ResultSet rs = qExec.execSelect() ;
+                ResultSet rs = qExec.execSelect();
                 resultSetAction.accept(rs);
             }
-        } ) ; 
+        } ); 
     }
 
     /**
@@ -110,7 +110,7 @@ public interface RDFConnection extends
      */
     @Override
     public default void querySelect(String query, Consumer<QuerySolution> rowAction) {
-        querySelect(QueryFactory.create(query), rowAction) ;
+        querySelect(QueryFactory.create(query), rowAction);
     }
     
     /**
@@ -121,18 +121,18 @@ public interface RDFConnection extends
     @Override
     public default void querySelect(Query query, Consumer<QuerySolution> rowAction) {
         if ( ! query.isSelectType() )
-            throw new JenaConnectionException("Query is not a SELECT query") ;
+            throw new JenaConnectionException("Query is not a SELECT query");
         Txn.executeRead(this, ()->{ 
             try ( QueryExecution qExec = query(query) ) {
                 qExec.execSelect().forEachRemaining(rowAction);
             }
-        } ) ; 
+        } ); 
     }
 
     /** Execute a CONSTRUCT query and return as a Model */
     @Override
     public default Model queryConstruct(String query) {
-        return queryConstruct(QueryFactory.create(query)) ;
+        return queryConstruct(QueryFactory.create(query));
     }
     
     /** Execute a CONSTRUCT query and return as a Model */
@@ -141,15 +141,15 @@ public interface RDFConnection extends
         return 
             Txn.calculateRead(this, ()->{ 
                 try ( QueryExecution qExec = query(query) ) {
-                    return qExec.execConstruct() ;
+                    return qExec.execConstruct();
                 }
-            } ) ; 
+            } ); 
     }
 
     /** Execute a DESCRIBE query and return as a Model */
     @Override
     public default Model queryDescribe(String query) {
-        return queryDescribe(QueryFactory.create(query)) ;
+        return queryDescribe(QueryFactory.create(query));
     }
     
     /** Execute a DESCRIBE query and return as a Model */
@@ -158,15 +158,15 @@ public interface RDFConnection extends
         return 
             Txn.calculateRead(this, ()->{ 
                 try ( QueryExecution qExec = query(query) ) {
-                    return qExec.execDescribe() ;
+                    return qExec.execDescribe();
                 }
-            } ) ; 
+            } ); 
     }
     
     /** Execute a ASK query and return a boolean */
     @Override
     public default boolean queryAsk(String query) {
-        return queryAsk(QueryFactory.create(query)) ;
+        return queryAsk(QueryFactory.create(query));
     }
 
     /** Execute a ASK query and return a boolean */
@@ -175,9 +175,9 @@ public interface RDFConnection extends
         return 
             Txn.calculateRead(this, ()->{ 
                 try ( QueryExecution qExec = query(query) ) {
-                    return qExec.execAsk() ;
+                    return qExec.execAsk();
                 }
-            } ) ; 
+            } ); 
     }
 
     /** Setup a SPARQL query execution.
@@ -190,7 +190,7 @@ public interface RDFConnection extends
      * @return QueryExecution
      */
     @Override
-    public QueryExecution query(Query query) ;
+    public QueryExecution query(Query query);
 
     /** Setup a SPARQL query execution.
      * 
@@ -203,7 +203,7 @@ public interface RDFConnection extends
      */
     @Override
     public default QueryExecution query(String queryString) {
-        return query(QueryFactory.create(queryString)) ;
+        return query(QueryFactory.create(queryString));
     }
     
     // ---- SparqlUpdateConnection
@@ -214,7 +214,7 @@ public interface RDFConnection extends
      */
     @Override
     public default void update(Update update) {
-        update(new UpdateRequest(update)) ;
+        update(new UpdateRequest(update));
     }
 
     /** Execute a SPARQL Update.
@@ -222,7 +222,7 @@ public interface RDFConnection extends
      * @param update
      */
     @Override
-    public void update(UpdateRequest update) ; 
+    public void update(UpdateRequest update); 
     
     /** Execute a SPARQL Update.
      * 
@@ -230,7 +230,7 @@ public interface RDFConnection extends
      */
     @Override
     public default void update(String updateString) {
-        update(UpdateFactory.create(updateString)) ;
+        update(UpdateFactory.create(updateString));
     }
     
     // ---- RDFDatasetConnection
@@ -242,7 +242,7 @@ public interface RDFConnection extends
      * @param file File of the data.
      */
     @Override
-    public void load(String graphName, String file) ;
+    public void load(String graphName, String file);
     
     /** Load (add, append) RDF into the default graph of a dataset.
      * This is SPARQL Graph Store Protocol HTTP POST or equivalent. 
@@ -250,7 +250,7 @@ public interface RDFConnection extends
      * @param file File of the data.
      */
     @Override
-    public void load(String file) ;
+    public void load(String file);
 
     /** Load (add, append) RDF into a named graph in a dataset.
      * This is SPARQL Graph Store Protocol HTTP POST or equivalent. 
@@ -259,7 +259,7 @@ public interface RDFConnection extends
      * @param model Data.
      */
     @Override
-    public void load(String graphName, Model model) ;
+    public void load(String graphName, Model model);
     
     /** Load (add, append) RDF into the default graph of a dataset.
      * This is SPARQL Graph Store Protocol HTTP POST or equivalent. 
@@ -267,7 +267,7 @@ public interface RDFConnection extends
      * @param model Data.
      */
     @Override
-    public void load(Model model) ;
+    public void load(Model model);
 
     /** Set the contents of a named graph of a dataset.
      * Any existing data is lost. 
@@ -277,7 +277,7 @@ public interface RDFConnection extends
      * @param file File of the data.
      */
     @Override
-    public void put(String graphName, String file) ;
+    public void put(String graphName, String file);
     
     /** Set the contents of the default graph of a dataset.
      * Any existing data is lost. 
@@ -286,7 +286,7 @@ public interface RDFConnection extends
      * @param file File of the data.
      */
     @Override
-    public void put(String file) ;
+    public void put(String file);
         
     /** Set the contents of a named graph of a dataset.
      * Any existing data is lost. 
@@ -296,7 +296,7 @@ public interface RDFConnection extends
      * @param model Data.
      */
     @Override
-    public void put(String graphName, Model model) ;
+    public void put(String graphName, Model model);
     
     /** Set the contents of the default graph of a dataset.
      * Any existing data is lost. 
@@ -305,7 +305,7 @@ public interface RDFConnection extends
      * @param model Data.
      */
     @Override
-    public void put( Model model) ;
+    public void put( Model model);
         
     /**
      * Delete a graph from the dataset.
@@ -314,27 +314,27 @@ public interface RDFConnection extends
      * @param graphName
      */
     @Override
-    public void delete(String graphName) ;
+    public void delete(String graphName);
 
     /**
      * Remove all data from the default graph.
      */ 
     @Override
-    public void delete() ;
+    public void delete();
     
     /* Load (add, append) RDF triple or quad data into a dataset. Triples wil go into the default graph.
      * This is not a SPARQL Graph Store Protocol operation.
      * It is an HTTP POST equivalent to the dataset.
      */
     @Override
-    public void loadDataset(String file) ;
+    public void loadDataset(String file);
 
     /* Load (add, append) RDF triple or quad data into a dataset. Triples wil go into the default graph.
      * This is not a SPARQL Graph Store Protocol operation.
      * It is an HTTP POST equivalent to the dataset.
      */
     @Override
-    public void loadDataset(Dataset dataset) ;
+    public void loadDataset(Dataset dataset);
 
     /* Set RDF triple or quad data as the dataset contents.
      * Triples will go into the default graph, quads in named graphs.
@@ -342,7 +342,7 @@ public interface RDFConnection extends
      * It is an HTTP PUT equivalent to the dataset.
      */
     @Override
-    public void putDataset(String file) ;
+    public void putDataset(String file);
     
     /* Set RDF triple or quad data as the dataset contents.
      * Triples will go into the default graph, quads in named graphs.
@@ -350,18 +350,18 @@ public interface RDFConnection extends
      * It is an HTTP PUT equivalent to the dataset.
      */
     @Override
-    public void putDataset(Dataset dataset) ;
+    public void putDataset(Dataset dataset);
 
     //    /** Clear the dataset - remove all named graphs, clear the default graph. */
-    //    public void clearDataset() ;
+    //    public void clearDataset();
     
     
     /** Test whether this connection is closed or not */
     @Override
-    public boolean isClosed() ;
+    public boolean isClosed();
     
     /** Close this connection.  Use with try-resource. */ 
     @Override 
-    public void close() ;
+    public void close();
 }
 

http://git-wip-us.apache.org/repos/asf/jena/blob/cdc9f143/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFConnectionFactory.java
----------------------------------------------------------------------
diff --git a/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFConnectionFactory.java b/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFConnectionFactory.java
index e7cfb57..a8c0e45 100644
--- a/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFConnectionFactory.java
+++ b/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFConnectionFactory.java
@@ -77,11 +77,36 @@ public class RDFConnectionFactory {
 
     /**
      * Connect to a local (same JVM) dataset.
+     * The default isolation is {@code NONE}. 
+     * See {@link #connect(Dataset, Isolation)} to select an isolation mode.
+     * 
      * @param dataset
      * @return RDFConnection
+     * @see RDFConnectionLocal
      */
     public static RDFConnection connect(Dataset dataset) {
         return new RDFConnectionLocal(dataset);
     }
-
+    
+    /**
+     * Connect to a local (same JVM) dataset.
+     * <p>
+     * Multiple levels of {@link Isolation} are provided, The default {@code COPY} level makes a local
+     * {@link RDFConnection} behave like a remote conenction.
+     * See <a href="https://jena.apache.org/documentation/rdfconnection/">the documentation for more details.</a>
+     * <ul>
+     * <li>{@code COPY} &ndash; {@code Model}s and {@code Dataset}s are copied. 
+     *     This is most like a remote connection.
+     * <li>{@code READONLY} &ndash; Read-only wrappers are added but changes to
+     *     the underlying model or dataset will be seen.
+     * <li>{@code NONE} (default) &ndash; Changes to the returned {@code Model}s or {@code Dataset}s act on the original object.
+     * </ul>
+     * 
+     * @param dataset
+     * @param isolation
+     * @return RDFConnection
+     */
+    public static RDFConnection connect(Dataset dataset, Isolation isolation) {
+        return new RDFConnectionLocal(dataset, isolation);
+    }
 }

http://git-wip-us.apache.org/repos/asf/jena/blob/cdc9f143/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFConnectionLocal.java
----------------------------------------------------------------------
diff --git a/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFConnectionLocal.java b/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFConnectionLocal.java
index d2fb4df..8be2704 100644
--- a/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFConnectionLocal.java
+++ b/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFConnectionLocal.java
@@ -20,6 +20,7 @@ package org.apache.jena.rdfconnection;
 
 import java.util.Objects;
 
+import org.apache.jena.atlas.lib.InternalErrorException;
 import org.apache.jena.graph.Graph;
 import org.apache.jena.query.*;
 import org.apache.jena.rdf.model.Model;
@@ -36,21 +37,36 @@ import org.apache.jena.system.Txn;
 import org.apache.jena.update.UpdateExecutionFactory;
 import org.apache.jena.update.UpdateRequest;
 
-/** 
+/**
  * Implement of {@link RDFConnection} over a {@link Dataset} in the same JVM.
+ * <p>
+ * Multiple levels of {@link Isolation} are provided, The default {@code COPY} level makes a local
+ * {@link RDFConnection} behave like a remote conenction. This should be the normal use in
+ * testing.
+ * <ul>
+ * <li>{@code COPY} &ndash; {@code Model}s and {@code Dataset}s are copied. 
+ *     This is most like a remote connection.
+ * <li>{@code READONLY} &ndash; Read-only wrappers are added but changes to
+ *     the underlying model or dataset will be seen.
+ * <li>{@code NONE} (default) &ndash; Changes to the returned {@code Model}s or {@code Dataset}s act on the original object.
+ * </ul>
  */
 
 public class RDFConnectionLocal implements RDFConnection {
-    // XXX Expose copy-mode?
-    
     private ThreadLocal<Boolean> transactionActive = ThreadLocal.withInitial(()->false);
-    private static boolean isolateByCopy = true; 
+    
     private Dataset dataset;
+    private final Isolation isolation;
     
     public RDFConnectionLocal(Dataset dataset) {
-        this.dataset = dataset;
+        this(dataset, Isolation.NONE);
     }
     
+    public RDFConnectionLocal(Dataset dataset, Isolation isolation) {
+        this.dataset = dataset;
+        this.isolation = isolation;
+    }
+
     @Override
     public QueryExecution query(Query query) {
         checkOpen();
@@ -176,35 +192,46 @@ public class RDFConnectionLocal implements RDFConnection {
     }
 
     /**
-     * Called to isolate a model from it's storage. Must be inside a
-     * transaction.
+     * Called to isolate a model from it's storage.
+     * Must be inside a transaction.
      */
     private Model isolate(Model model) {
-        if ( ! isolateByCopy ) {
-            // Half-way - read-only but dataset changes can be seen. 
-            Graph g = new GraphReadOnly(model.getGraph());
-            return ModelFactory.createModelForGraph(g);
+        switch(isolation) {
+            case COPY: {
+                // Copy - the model is completely isolated from the original. 
+                Model m2 = ModelFactory.createDefaultModel();
+                m2.add(model);
+                return m2;
+            }
+            case READONLY : {
+                Graph g = new GraphReadOnly(model.getGraph());
+                return ModelFactory.createModelForGraph(g);
+            }
+            case NONE :
+                return model;
         }
-        // Copy.
-        Model m2 = ModelFactory.createDefaultModel();
-        m2.add(model);
-        return m2;
+        throw new InternalErrorException();
     }
 
     /**
-     * Called to isolate a dataset from it's storage. Must be inside a
-     * transaction.
+     * Called to isolate a dataset from it's storage.
+     * Must be inside a transaction.
      */
     private Dataset isolate(Dataset dataset) {
-        if ( ! isolateByCopy ) {
-            DatasetGraph dsg = new DatasetGraphReadOnly(dataset.asDatasetGraph());
-            return DatasetFactory.wrap(dsg);
+        switch(isolation) {
+            case COPY: {
+                DatasetGraph dsg2 = DatasetGraphFactory.create();
+                dataset.asDatasetGraph().find().forEachRemaining(q -> dsg2.add(q) );
+                return DatasetFactory.wrap(dsg2);
+            }
+            case READONLY : {
+                DatasetGraph dsg = new DatasetGraphReadOnly(dataset.asDatasetGraph());
+                return DatasetFactory.wrap(dsg);
+            }
+            case NONE :
+                return dataset;
         }
-
-        // Copy.
-        DatasetGraph dsg2 = DatasetGraphFactory.create();
-        dataset.asDatasetGraph().find().forEachRemaining(q -> dsg2.add(q) );
-        return DatasetFactory.wrap(dsg2);
+        throw new InternalErrorException();
     }
 
     private Model modelFor(String graph) {

http://git-wip-us.apache.org/repos/asf/jena/blob/cdc9f143/jena-rdfconnection/src/test/java/org/apache/jena/rdfconnection/TS_RDFConnection.java
----------------------------------------------------------------------
diff --git a/jena-rdfconnection/src/test/java/org/apache/jena/rdfconnection/TS_RDFConnection.java b/jena-rdfconnection/src/test/java/org/apache/jena/rdfconnection/TS_RDFConnection.java
index 3f8af53..373bd52 100644
--- a/jena-rdfconnection/src/test/java/org/apache/jena/rdfconnection/TS_RDFConnection.java
+++ b/jena-rdfconnection/src/test/java/org/apache/jena/rdfconnection/TS_RDFConnection.java
@@ -26,6 +26,7 @@ import org.junit.runners.Suite;
     // Other tests are in jena-integration-tests
     TestRDFConnectionLocalTxnMem.class
     , TestRDFConnectionLocalMRSW.class
+    , TestLocalIsolation.class
 })
 
 public class TS_RDFConnection {}

http://git-wip-us.apache.org/repos/asf/jena/blob/cdc9f143/jena-rdfconnection/src/test/java/org/apache/jena/rdfconnection/TestLocalIsolation.java
----------------------------------------------------------------------
diff --git a/jena-rdfconnection/src/test/java/org/apache/jena/rdfconnection/TestLocalIsolation.java b/jena-rdfconnection/src/test/java/org/apache/jena/rdfconnection/TestLocalIsolation.java
new file mode 100644
index 0000000..bc4fc20
--- /dev/null
+++ b/jena-rdfconnection/src/test/java/org/apache/jena/rdfconnection/TestLocalIsolation.java
@@ -0,0 +1,84 @@
+/*
+ * 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.Assert.assertEquals;
+
+import org.apache.jena.query.Dataset;
+import org.apache.jena.query.DatasetFactory;
+import org.apache.jena.rdf.model.*;
+import org.apache.jena.shared.JenaException;
+import org.apache.jena.sparql.core.Quad;
+import org.apache.jena.sparql.sse.SSE;
+import org.junit.Test;
+
+public class TestLocalIsolation {
+
+    private static Resource subject = ResourceFactory.createResource();
+    private static Property property = ResourceFactory.createProperty("http://example/p");
+    private static Resource object = ResourceFactory.createResource("http://example/o");
+    
+    @Test public void localIsolation_model_1() {
+        isolationModel(Isolation.COPY,false);
+    }
+
+    @Test public void localIsolation_model_2() {
+        isolationModel(Isolation.NONE, true);
+    }
+
+    @Test(expected=JenaException.class)
+    public void localIsolation_model_3() {
+        isolationModel(Isolation.READONLY, true);
+    }
+
+    @Test public void localIsolation_dataset_1() {
+        isolationDataset(Isolation.COPY,false);
+    }
+
+    @Test public void localIsolation_dataset_2() {
+        isolationDataset(Isolation.NONE,true);
+    }
+
+    @Test(expected=UnsupportedOperationException.class)
+    public void localIsolation_dataset_3() {
+        isolationDataset(Isolation.READONLY, true);
+    }
+
+    private void isolationDataset(Isolation isolation, boolean expected) {
+        Dataset base = DatasetFactory.createTxnMem();
+        RDFConnection conn1 = RDFConnectionFactory.connect(base, isolation);
+        Quad quad = SSE.parseQuad("(:g :s :p :o)") ; 
+        try (RDFConnection conn2 = conn1;) {
+            Dataset ds = conn2.fetchDataset();
+            ds.asDatasetGraph().add(quad);
+        }
+        assertEquals(expected, base.asDatasetGraph().contains(quad));
+    }
+
+    private void isolationModel(Isolation level, boolean expected) {
+        Dataset base = DatasetFactory.createTxnMem();
+        Statement stmt = base.getDefaultModel().createStatement(subject, property, object); 
+        RDFConnection conn1 = RDFConnectionFactory.connect(base, level);
+        try (RDFConnection conn2 = conn1;) {
+            Model m = conn2.fetch();
+            m.add(stmt);
+        }
+        assertEquals(expected, base.getDefaultModel().contains(stmt));
+    }
+}


[11/11] jena git commit: TDB requires COPY isolation (or transactions)

Posted by an...@apache.org.
TDB requires COPY isolation (or transactions)


Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/9f42f00b
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/9f42f00b
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/9f42f00b

Branch: refs/heads/master
Commit: 9f42f00b33e22601f318a79114efaac733929a61
Parents: 5a70fb6
Author: Andy Seaborne <an...@apache.org>
Authored: Thu Dec 22 17:50:05 2016 +0000
Committer: Andy Seaborne <an...@apache.org>
Committed: Thu Dec 22 17:50:05 2016 +0000

----------------------------------------------------------------------
 .../apache/jena/test/rdfconnection/TestRDFConnectionLocalTDB.java | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/9f42f00b/jena-integration-tests/src/test/java/org/apache/jena/test/rdfconnection/TestRDFConnectionLocalTDB.java
----------------------------------------------------------------------
diff --git a/jena-integration-tests/src/test/java/org/apache/jena/test/rdfconnection/TestRDFConnectionLocalTDB.java b/jena-integration-tests/src/test/java/org/apache/jena/test/rdfconnection/TestRDFConnectionLocalTDB.java
index 366d73b..2a8ce9d 100644
--- a/jena-integration-tests/src/test/java/org/apache/jena/test/rdfconnection/TestRDFConnectionLocalTDB.java
+++ b/jena-integration-tests/src/test/java/org/apache/jena/test/rdfconnection/TestRDFConnectionLocalTDB.java
@@ -20,6 +20,7 @@ package org.apache.jena.test.rdfconnection;
 
 import org.apache.jena.query.Dataset ;
 import org.apache.jena.rdfconnection.AbstractTestRDFConnection;
+import org.apache.jena.rdfconnection.Isolation;
 import org.apache.jena.rdfconnection.RDFConnection;
 import org.apache.jena.rdfconnection.RDFConnectionFactory;
 import org.apache.jena.tdb.TDBFactory ;
@@ -32,7 +33,7 @@ public class TestRDFConnectionLocalTDB extends AbstractTestRDFConnection {
     @Override
     protected RDFConnection connection() {
         Dataset ds = TDBFactory.createDataset() ;
-        return RDFConnectionFactory.connect(ds) ;
+        return RDFConnectionFactory.connect(ds, Isolation.COPY) ;
     }
 }
 


[08/11] jena git commit: Merge branch 'master' into rdf-connection

Posted by an...@apache.org.
Merge branch 'master' into rdf-connection


Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/4e456a81
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/4e456a81
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/4e456a81

Branch: refs/heads/master
Commit: 4e456a811a40177db020795b48a4034debbd0134
Parents: cdc9f14 9075e9a
Author: Andy Seaborne <an...@apache.org>
Authored: Thu Dec 22 16:55:48 2016 +0000
Committer: Andy Seaborne <an...@apache.org>
Committed: Thu Dec 22 16:55:48 2016 +0000

----------------------------------------------------------------------
 .../java/org/apache/jena/riot/web/HttpOp.java   |  21 +-
 .../engine/binding/BindingInputStream.java      |  25 ++-
 .../apache/jena/sparql/graph/GraphFactory.java  |   3 +
 .../engine/binding/TestBindingStreams.java      |   9 +
 .../org/apache/jena/atlas/lib/StrUtils.java     | 214 ++++++++-----------
 .../java/org/apache/jena/test/JenaTestBase.java |   4 +
 .../java/org/apache/jena/fuseki/TestAuth.java   |  19 +-
 .../org/apache/jena/fuseki/http/TestHttpOp.java |   9 +
 .../org/apache/jena/permissions/Factory.java    |   3 +-
 .../jena/permissions/impl/SecuredItemImpl.java  |   1 -
 .../model/SecuredModelDetailTest.java           |   2 -
 11 files changed, 169 insertions(+), 141 deletions(-)
----------------------------------------------------------------------



[06/11] jena git commit: Fix typos and code formatting

Posted by an...@apache.org.
Fix typos and code formatting


Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/53758b5f
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/53758b5f
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/53758b5f

Branch: refs/heads/master
Commit: 53758b5fb4165b3484d3043a2d3fc98a1abafe61
Parents: ac1ad26
Author: Andy Seaborne <an...@apache.org>
Authored: Fri Dec 16 19:50:29 2016 +0000
Committer: Andy Seaborne <an...@apache.org>
Committed: Fri Dec 16 23:30:34 2016 +0000

----------------------------------------------------------------------
 jena-integration-tests/README.md                |   2 +-
 jena-integration-tests/pom.xml                  |  13 +
 .../AbstractTestRDFConnection.java              | 382 -------------------
 .../TestRDFConnectionLocalMRSW.java             |  39 --
 .../TestRDFConnectionLocalTxnMem.java           |  39 --
 jena-rdfconnection/Documentation.md             |  10 +-
 jena-rdfconnection/pom.xml                      |   5 +-
 .../jena/rdfconnection/RDFConnection.java       |  17 +-
 .../rdfconnection/RDFConnectionFactory.java     |  35 +-
 .../jena/rdfconnection/RDFConnectionLocal.java  | 173 +++++----
 .../rdfconnection/RDFConnectionModular.java     | 108 +++---
 .../jena/rdfconnection/RDFConnectionRemote.java | 335 ++++++++--------
 .../RDFDatasetAccessConnection.java             |  16 +-
 .../rdfconnection/RDFDatasetConnection.java     |  40 +-
 .../rdfconnection/SparqlQueryConnection.java    |  34 +-
 .../rdfconnection/SparqlUpdateConnection.java   |  14 +-
 .../examples/RDFConnectionExample2.java         |  30 +-
 .../examples/RDFConnectionExample3.java         |  10 +-
 .../AbstractTestRDFConnection.java              | 267 +++++++------
 .../jena/rdfconnection/TS_RDFConnection.java    |   4 +-
 .../TestRDFConnectionLocalMRSW.java             |  10 +-
 .../TestRDFConnectionLocalTxnMem.java           |  10 +-
 pom.xml                                         |   8 +-
 23 files changed, 576 insertions(+), 1025 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/53758b5f/jena-integration-tests/README.md
----------------------------------------------------------------------
diff --git a/jena-integration-tests/README.md b/jena-integration-tests/README.md
index 77f4df8..0759db4 100644
--- a/jena-integration-tests/README.md
+++ b/jena-integration-tests/README.md
@@ -1,4 +1,4 @@
-Jena Intrgration Tests
+Jena Integration Tests
 ======================
 
 This module provides testing of components where testing depends on

http://git-wip-us.apache.org/repos/asf/jena/blob/53758b5f/jena-integration-tests/pom.xml
----------------------------------------------------------------------
diff --git a/jena-integration-tests/pom.xml b/jena-integration-tests/pom.xml
index 9dca002..60f41e5 100644
--- a/jena-integration-tests/pom.xml
+++ b/jena-integration-tests/pom.xml
@@ -122,6 +122,19 @@
   <build>
 
     <plugins>
+
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-jar-plugin</artifactId>
+        <executions>
+          <execution>
+            <goals>
+              <goal>test-jar</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+      
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-compiler-plugin</artifactId>

http://git-wip-us.apache.org/repos/asf/jena/blob/53758b5f/jena-integration-tests/src/test/java/org/apache/jena/test/rdfconnection/AbstractTestRDFConnection.java
----------------------------------------------------------------------
diff --git a/jena-integration-tests/src/test/java/org/apache/jena/test/rdfconnection/AbstractTestRDFConnection.java b/jena-integration-tests/src/test/java/org/apache/jena/test/rdfconnection/AbstractTestRDFConnection.java
deleted file mode 100644
index 9b3a65f..0000000
--- a/jena-integration-tests/src/test/java/org/apache/jena/test/rdfconnection/AbstractTestRDFConnection.java
+++ /dev/null
@@ -1,382 +0,0 @@
-/*
- * 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.test.rdfconnection;
-
-import java.util.concurrent.atomic.AtomicInteger ;
-
-import org.apache.jena.atlas.iterator.Iter ;
-import org.apache.jena.atlas.junit.BaseTest ;
-import org.apache.jena.atlas.lib.StrUtils ;
-import org.apache.jena.query.Dataset ;
-import org.apache.jena.query.DatasetFactory ;
-import org.apache.jena.query.ReadWrite ;
-import org.apache.jena.rdf.model.Model ;
-import org.apache.jena.rdf.model.ModelFactory ;
-import org.apache.jena.rdfconnection.RDFConnection;
-import org.apache.jena.riot.RDFDataMgr ;
-import org.apache.jena.sparql.core.DatasetGraph ;
-import org.apache.jena.sparql.sse.SSE ;
-import org.apache.jena.sparql.util.IsoMatcher ;
-import org.apache.jena.system.Txn ;
-import org.junit.Assume ;
-import org.junit.Test ;
-
-public abstract class AbstractTestRDFConnection extends BaseTest {
-    // Testing data.
-    static String DIR = "testing/RDFConnection/" ;
-    
-    protected abstract RDFConnection connection() ;
-    // Not all RDFConenction types support.
-    //  (may acquite RDFConnection.supportTransactionalAbort but ATM that isn't included)
-    protected abstract boolean supportsAbort() ; 
-
-    // ---- Data
-    static String dsgdata = StrUtils.strjoinNL
-        ("(dataset"
-        ,"  (graph (:s :p :o) (:s0 :p0 _:a))"
-        ,"  (graph :g1 (:s :p :o) (:s1 :p1 :o1))"
-        ,"  (graph :g2 (:s :p :o) (:s2 :p2 :o))"
-        ,")"
-        ) ;
-    
-    static String dsgdata2 = StrUtils.strjoinNL
-        ("(dataset"
-        ,"  (graph (:x :y :z))"
-        ,"  (graph :g9 (:s :p :o))"
-        ,")"
-        ) ;
-
-    
-    static String graph1 = StrUtils.strjoinNL
-        ("(graph (:s :p :o) (:s1 :p1 :o))"
-        ) ;
-
-    static String graph2 = StrUtils.strjoinNL
-        ("(graph (:s :p :o) (:s2 :p2 :o))"
-        ) ;
-    
-    static DatasetGraph dsg        = SSE.parseDatasetGraph(dsgdata);
-    static Dataset      dataset    = DatasetFactory.wrap(dsg);
-    static DatasetGraph dsg2       = SSE.parseDatasetGraph(dsgdata2);
-    static Dataset      dataset2   = DatasetFactory.wrap(dsg2);
-
-    static String       graphName  = "http://test/graph";
-    static String       graphName2 = "http://test/graph2";
-    static Model        model1     = ModelFactory.createModelForGraph(SSE.parseGraph(graph1));
-    static Model        model2     = ModelFactory.createModelForGraph(SSE.parseGraph(graph2));
-    // ---- Data
-
-    @Test public void connect_01() {
-        @SuppressWarnings("resource")
-        RDFConnection conn = connection() ;
-        assertFalse(conn.isClosed()) ;
-        conn.close() ;
-        assertTrue(conn.isClosed()) ;
-        // Allow multiple close()
-        conn.close() ;
-    }
-    
-    @Test public void dataset_load_1() {
-        String testDataFile = DIR+"data.trig" ; 
-        try ( RDFConnection conn = connection() ) {
-            conn.loadDataset(testDataFile);
-            Dataset ds0 = RDFDataMgr.loadDataset(testDataFile) ;
-            Dataset ds = conn.fetchDataset() ;
-            assertTrue("Datasets not isomorphic", isomorphic(ds0, ds)) ;
-        }
-    }
-
-    @Test public void dataset_put_1() {
-        try ( RDFConnection conn = connection() ) {
-            conn.putDataset(dataset) ; 
-            Dataset ds1 = conn.fetchDataset() ;
-            assertTrue("Datasets not isomorphic", isomorphic(dataset, ds1)) ;
-        }
-    }
-
-    @Test public void dataset_put_2() {
-        try ( RDFConnection conn = connection() ) {
-            conn.putDataset(dataset) ; 
-            conn.putDataset(dataset2) ;
-            Dataset ds1 = conn.fetchDataset() ;
-            assertTrue("Datasets not isomorphic", isomorphic(dataset2, ds1)) ;
-        }
-    }
-
-    @Test public void dataset_post_1() {
-        try ( RDFConnection conn = connection() ) {
-            conn.loadDataset(dataset);
-            Dataset ds1 = conn.fetchDataset() ;
-            assertTrue("Datasets not isomorphic", isomorphic(dataset, ds1)) ;
-        }
-    }
-    
-    @Test public void dataset_post_2() {
-        try ( RDFConnection conn = connection() ) {
-            conn.loadDataset(dataset);
-            conn.loadDataset(dataset2);
-            Dataset ds1 = conn.fetchDataset() ;
-            long x = Iter.count(ds1.listNames()) ;
-            assertEquals("NG count", 3, x) ;
-            assertFalse("Datasets are isomorphic", isomorphic(dataset, ds1)) ;
-            assertFalse("Datasets are isomorphic", isomorphic(dataset2, ds1)) ;
-        }
-    }
-
-    // Default graph
-    
-    @Test public void graph_load_1() {
-        String testDataFile = DIR+"data.ttl" ; 
-        Model m0 = RDFDataMgr.loadModel(testDataFile) ;
-        try ( RDFConnection conn = connection() ) {
-            conn.load(testDataFile);
-            Model m = conn.fetch() ;
-            assertTrue("Models not isomorphic", isomorphic(m0, m)) ;
-        }
-    }
-
-    @Test public void graph_put_1() {
-        try ( RDFConnection conn = connection() ) {
-            conn.put(model1); 
-            Dataset ds1 = conn.fetchDataset() ;
-            Model m0 = conn.fetch() ;
-            assertTrue("Models not isomorphic", isomorphic(model1, ds1.getDefaultModel())) ;
-            Model m = conn.fetch() ;
-            assertTrue("Models not isomorphic", isomorphic(model1, m)) ;
-        }
-    }
-
-    @Test public void graph_put_2() {
-        try ( RDFConnection conn = connection() ) {
-            conn.put(model1) ; 
-            conn.put(model2) ;
-            Model m = conn.fetch() ;
-            assertTrue("Models not isomorphic", isomorphic(m, model2)) ;
-            assertFalse("Models not isomorphic", isomorphic(m, model1)) ;
-        }
-    }
-
-    @Test public void graph_post_1() {
-        try ( RDFConnection conn = connection() ) {
-            conn.load(model1) ;
-            Model m = conn.fetch() ;
-            assertTrue("Models not isomorphic", isomorphic(m, model1)) ;
-        }
-    }
-    
-    @Test public void graph_post_2() {
-        try ( RDFConnection conn = connection() ) {
-            conn.load(model1) ;
-            conn.load(model2) ;
-            Model m = conn.fetch() ;
-            Model m0 = ModelFactory.createUnion(model2, model1) ;
-            assertTrue("Models are not isomorphic", isomorphic(m0, m)) ;
-        }
-    }
-
-    // DELETE
-    
-    // Named graphs
-    
-    @Test public void named_graph_load_1() {
-        String testDataFile = DIR+"data.ttl" ; 
-        Model m0 = RDFDataMgr.loadModel(testDataFile) ;
-        try ( RDFConnection conn = connection() ) {
-            conn.load(graphName, testDataFile);
-            Model m = conn.fetch(graphName) ;
-            assertTrue("Models not isomorphic", isomorphic(m0, m)) ;
-            Model mDft = conn.fetch() ;
-            assertTrue(mDft.isEmpty()) ;
-        }
-    }
-
-    @Test public void named_graph_put_1() {
-        try ( RDFConnection conn = connection() ) {
-            conn.put(graphName, model1); 
-            Dataset ds1 = conn.fetchDataset() ;
-            Model m0 = conn.fetch(graphName) ;
-            assertTrue("Models not isomorphic", isomorphic(model1, ds1.getNamedModel(graphName))) ;
-            Model m = conn.fetch(graphName) ;
-            assertTrue("Models not isomorphic", isomorphic(model1, m)) ;
-        }
-    }
-
-    @Test public void named_graph_put_2() {
-        try ( RDFConnection conn = connection() ) {
-            conn.put(graphName, model1) ; 
-            conn.put(graphName, model2) ;
-            Model m = conn.fetch(graphName) ;
-            assertTrue("Models not isomorphic", isomorphic(m, model2)) ;
-            assertFalse("Models not isomorphic", isomorphic(m, model1)) ;
-        }
-    }
-
-    @Test public void named_graph_put_2_different() {
-        try ( RDFConnection conn = connection() ) {
-            conn.put(graphName, model1) ; 
-            conn.put(graphName2, model2) ;
-            Model m1 = conn.fetch(graphName) ;
-            Model m2 = conn.fetch(graphName2) ;
-            assertTrue("Models not isomorphic", isomorphic(m1, model1)) ;
-            assertTrue("Models not isomorphic", isomorphic(m2, model2)) ;
-        }
-    }
-
-    @Test public void named_graph_post_1() {
-        try ( RDFConnection conn = connection() ) {
-            conn.load(graphName, model1) ;
-            Model m = conn.fetch(graphName) ;
-            assertTrue("Models not isomorphic", isomorphic(m, model1)) ;
-        }
-    }
-    
-    @Test public void named_graph_post_2() {
-        try ( RDFConnection conn = connection() ) {
-            conn.load(graphName, model1) ;
-            conn.load(graphName, model2) ;
-            Model m = conn.fetch(graphName) ;
-            Model m0 = ModelFactory.createUnion(model2, model1) ;
-            assertTrue("Models are not isomorphic", isomorphic(m0, m)) ;
-        }
-    }
-
-    // DELETE
-    
-    // Remote connections don't support transactions fully.  
-    //@Test public void transaction_01() 
-
-    private static boolean isomorphic(Dataset ds1, Dataset ds2) {
-        return IsoMatcher.isomorphic(ds1.asDatasetGraph(), ds2.asDatasetGraph()) ;
-    }
-    
-    private static boolean isomorphic(Model model1, Model model2) {
-        return model1.isIsomorphicWith(model2) ;
-    }
-    
-
-    @Test public void query_ask_01() {
-        try ( RDFConnection conn = connection() ) {
-            Txn.executeRead(conn, ()->{
-                boolean b = conn.queryAsk("ASK{}") ;
-                assertTrue(b) ;
-            }) ;
-        }
-    }
-
-    @Test public void query_ask_02() {
-        try ( RDFConnection conn = connection() ) {
-            boolean b = conn.queryAsk("ASK{}") ;
-            assertTrue(b) ;
-        }
-    }
-
-    @Test public void query_select_01() {
-        AtomicInteger counter = new AtomicInteger(0) ;
-        try ( RDFConnection conn = connection() ) {
-            Txn.executeWrite(conn, ()->conn.loadDataset(DIR+"data.trig"));
-            Txn.executeRead(conn, ()->
-                conn.querySelect("SELECT * { ?s ?p ?o }" , (r)->counter.incrementAndGet()));
-            assertEquals(2, counter.get()) ;
-        }
-    }
-
-    @Test public void query_select_02() {
-        AtomicInteger counter = new AtomicInteger(0) ;
-        try ( RDFConnection conn = connection() ) {
-            conn.loadDataset(DIR+"data.trig");
-            conn.querySelect("SELECT * { ?s ?p ?o}" , (r)->counter.incrementAndGet());
-            assertEquals(2, counter.get()) ;
-        }
-    }
-
-    @Test public void query_construct_01() {
-        try ( RDFConnection conn = connection() ) {
-            Txn.executeWrite(conn, ()->conn.loadDataset(DIR+"data.trig"));
-            Txn.executeRead(conn, ()-> {
-                Model m = conn.queryConstruct("CONSTRUCT WHERE { ?s ?p ?o }") ;
-                assertEquals(2, m.size()) ;
-            }) ;
-        }
-    }
-
-    @Test public void query_construct_02() {
-        try ( RDFConnection conn = connection() ) {
-            conn.loadDataset(DIR+"data.trig");
-            Model m = conn.queryConstruct("CONSTRUCT WHERE { ?s ?p ?o }") ;
-            assertEquals(2, m.size()) ;
-        }
-    }
-    
-    @Test public void update_01() {
-        try ( RDFConnection conn = connection() ) {
-            conn.update("INSERT DATA { <urn:x:s> <urn:x:p> <urn:x:o>}");
-        }
-    }
-
-    @Test public void update_02() {
-        try ( RDFConnection conn = connection() ) {
-            Txn.executeWrite(conn, ()->conn.update("INSERT DATA { <urn:x:s> <urn:x:p> <urn:x:o>}")) ;
-        }
-    }
-
-    // Not all Transactional support abort.
-    @Test public void transaction_commit_read_01() {
-        String testDataFile = DIR+"data.trig" ; 
-        try ( RDFConnection conn = connection() ) {
-
-            conn.begin(ReadWrite.WRITE) ;
-            conn.loadDataset(dataset);
-            conn.commit() ;
-            conn.end();
-            
-            conn.begin(ReadWrite.READ) ;
-            Model m = conn.fetch() ;
-            assertTrue(isomorphic(m, dataset.getDefaultModel())) ;
-            conn.end() ;
-        }
-    }
-    
-    // Not all RDFConnections support abort.
-    @Test public void transaction_abort_read02() {
-        Assume.assumeTrue(supportsAbort()) ;
-        
-        String testDataFile = DIR+"data.trig" ; 
-        try ( RDFConnection conn = connection() ) {
-            conn.begin(ReadWrite.WRITE) ;
-            conn.loadDataset(testDataFile);
-            conn.abort();
-            conn.end();
-            
-            conn.begin(ReadWrite.READ) ;
-            Model m = conn.fetch() ;
-            assertTrue(m.isEmpty()) ;
-            conn.end() ;
-        }
-    }
-
-    //@Test(expected=JenaTransactionException.class)
-    public void transaction_bad_01() {
-        try ( RDFConnection conn = connection() ) {
-            conn.begin(ReadWrite.WRITE) ;
-            // Should have conn.commit() ;
-            conn.end();
-        }
-    }
-}
-

http://git-wip-us.apache.org/repos/asf/jena/blob/53758b5f/jena-integration-tests/src/test/java/org/apache/jena/test/rdfconnection/TestRDFConnectionLocalMRSW.java
----------------------------------------------------------------------
diff --git a/jena-integration-tests/src/test/java/org/apache/jena/test/rdfconnection/TestRDFConnectionLocalMRSW.java b/jena-integration-tests/src/test/java/org/apache/jena/test/rdfconnection/TestRDFConnectionLocalMRSW.java
deleted file mode 100644
index 8bc82ff..0000000
--- a/jena-integration-tests/src/test/java/org/apache/jena/test/rdfconnection/TestRDFConnectionLocalMRSW.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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.test.rdfconnection;
-
-import org.apache.jena.query.Dataset ;
-import org.apache.jena.query.DatasetFactory ;
-import org.apache.jena.rdfconnection.AbstractTestRDFConnection;
-import org.apache.jena.rdfconnection.RDFConnection;
-import org.apache.jena.rdfconnection.RDFConnectionFactory;
-
-public class TestRDFConnectionLocalMRSW extends AbstractTestRDFConnection {
-
-    @Override
-    protected boolean supportsAbort() { return false ; }
-    
-    @Override
-    protected RDFConnection connection() {
-        // General purpose, mixed storage, MRSW dataset.  
-        Dataset ds = DatasetFactory.create() ;
-        return RDFConnectionFactory.connect(ds) ;
-    }
-}
-

http://git-wip-us.apache.org/repos/asf/jena/blob/53758b5f/jena-integration-tests/src/test/java/org/apache/jena/test/rdfconnection/TestRDFConnectionLocalTxnMem.java
----------------------------------------------------------------------
diff --git a/jena-integration-tests/src/test/java/org/apache/jena/test/rdfconnection/TestRDFConnectionLocalTxnMem.java b/jena-integration-tests/src/test/java/org/apache/jena/test/rdfconnection/TestRDFConnectionLocalTxnMem.java
deleted file mode 100644
index dd50553..0000000
--- a/jena-integration-tests/src/test/java/org/apache/jena/test/rdfconnection/TestRDFConnectionLocalTxnMem.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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.test.rdfconnection;
-
-import org.apache.jena.query.Dataset ;
-import org.apache.jena.query.DatasetFactory ;
-import org.apache.jena.rdfconnection.AbstractTestRDFConnection;
-import org.apache.jena.rdfconnection.RDFConnection;
-import org.apache.jena.rdfconnection.RDFConnectionFactory;
-
-public class TestRDFConnectionLocalTxnMem extends AbstractTestRDFConnection {
-
-    @Override
-    protected boolean supportsAbort() { return true ; }
-
-    @Override
-    protected RDFConnection connection() {
-        // Full transactional in-memory dataset.  
-        Dataset ds = DatasetFactory.createTxnMem() ;
-        return RDFConnectionFactory.connect(ds) ;
-    }
-}
-

http://git-wip-us.apache.org/repos/asf/jena/blob/53758b5f/jena-rdfconnection/Documentation.md
----------------------------------------------------------------------
diff --git a/jena-rdfconnection/Documentation.md b/jena-rdfconnection/Documentation.md
index af5ff6a..d12bf34 100644
--- a/jena-rdfconnection/Documentation.md
+++ b/jena-rdfconnection/Documentation.md
@@ -106,8 +106,8 @@ SPARQL does not define a remote transaction standard protocol. Each remote
 operation shuld be atomic (all happens or nothing happens) - this is the
 responsibility of the remote server.
 
-An `RDFConenction` will at least provide the client-side locking features.
-This means that overlapping operations that chnage data are naturally
+An `RDFConnection` will at least provide the client-side locking features.
+This means that overlapping operations that change data are naturally
 handled by the transaction pattern within a single JVM.
 
 ## Graph Store Protocol
@@ -150,7 +150,7 @@ provided).
 When creating an `QueryExecution` explicitly, care shoud be taken to close
 it. If the application wishes to capture the result set from a SELECT query and
 retain it across the lifetime of the transaction or `QueryExecution`, then
-the application create a copy which is not attached to any external system
+the application should create a copy which is not attached to any external system
 with `ResultSetFactory.copyResults`.
 
 ```
@@ -184,7 +184,7 @@ SPARQL Update opertions can be performed and mixed with other operations.
 
 In addition to the SPARQL Graph Store Protocol, operations on whole
 datasets are provided for fetching (HTTP GET), adding data (HTTP POST) and
-settign the data (HTTP PUT) on a dataset URL.  This assumes the remote
+setting the data (HTTP PUT) on a dataset URL.  This assumes the remote
 server supported these REST-style operations.  Apache Jena Fuseki does
 provide these.
 
@@ -202,4 +202,4 @@ operations are visible to the called code.
 
 ## Examples
 
-https://github.com/afs/jena-rdfconnection/tree/master/src/main/java/rdfconnection/examples
+https://github.com/apache/jena/jena-rdfconnection/tree/master/src/main/java/rdfconnection/examples

http://git-wip-us.apache.org/repos/asf/jena/blob/53758b5f/jena-rdfconnection/pom.xml
----------------------------------------------------------------------
diff --git a/jena-rdfconnection/pom.xml b/jena-rdfconnection/pom.xml
index c58cce4..d2173c3 100644
--- a/jena-rdfconnection/pom.xml
+++ b/jena-rdfconnection/pom.xml
@@ -48,8 +48,9 @@
   <dependencies>
     <dependency>
       <groupId>org.apache.jena</groupId>
-      <artifactId>jena-arq</artifactId>
+      <artifactId>apache-jena-libs</artifactId>
       <version>3.2.0-SNAPSHOT</version>
+      <type>pom</type>
     </dependency>
 
     <dependency>
@@ -77,7 +78,7 @@
     </dependency>    
 
     <!-- Testing -->
-    <!-- Test is also done in jena-integration-tests -->
+    <!-- Tests is also done in jena-integration-tests -->
     
     <dependency>
       <groupId>org.slf4j</groupId>

http://git-wip-us.apache.org/repos/asf/jena/blob/53758b5f/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFConnection.java
----------------------------------------------------------------------
diff --git a/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFConnection.java b/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFConnection.java
index 2610bb3..c1b95ea 100644
--- a/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFConnection.java
+++ b/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFConnection.java
@@ -53,21 +53,26 @@ import org.apache.jena.update.UpdateRequest ;
  * the remote server, multiple operations are not combined into a single
  * transaction.
  * 
- * Not all implementations may implement all operations. See the implementation
- * notes for details.
+ * Not all implementations may implement all operations. 
+ * See the implementation notes for details.
  * 
  * @see RDFConnectionFactory
  * @see RDFConnectionLocal
  * @see RDFConnectionRemote
+ * @see SparqlQueryConnection
+ * @see SparqlUpdateConnection
+ * @see RDFDatasetConnection
+ * 
  */  
-public interface RDFConnection
-    // Default implementations could be pushed up but then they can't be mentioned here.  
-    extends
+public interface RDFConnection extends
         SparqlQueryConnection, SparqlUpdateConnection, RDFDatasetConnection,
         Transactional, AutoCloseable 
  {
-    // Inherits interfaces : re-mentioned to get the javadoc in one place.
+    // Default implementations could be pushed up but then they can't be mentioned here
+    // so that the Javadoc for RDFConnection is not in one place.
+    // Inheriting interfaces and re-mentioning gets the javadoc in one place.
     
+
     // ---- SparqlQueryConnection
 
     /**

http://git-wip-us.apache.org/repos/asf/jena/blob/53758b5f/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFConnectionFactory.java
----------------------------------------------------------------------
diff --git a/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFConnectionFactory.java b/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFConnectionFactory.java
index ee78a8d..e7cfb57 100644
--- a/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFConnectionFactory.java
+++ b/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFConnectionFactory.java
@@ -18,10 +18,9 @@
 
 package org.apache.jena.rdfconnection;
 
-import org.apache.jena.query.Dataset ;
-import org.apache.jena.system.JenaSystem ;
+import org.apache.jena.query.Dataset;
+import org.apache.jena.system.JenaSystem;
 
-// Pool stuff
 public class RDFConnectionFactory {
     static { JenaSystem.init(); }
     
@@ -42,32 +41,38 @@ public class RDFConnectionFactory {
      * @see #connect(String, String, String, String)
      */
     public static RDFConnection connect(String destination) {
-        return new RDFConnectionRemote(destination) ;
+        return new RDFConnectionRemote(destination);
     }
 
-    /** Create a connection to a remote location by URL.
-     * This is the URL for the dataset.
+    /** Create a connection specifying the URLs of the service.
      * 
-     *  This call requires specifying the names of the service.
-     */ 
+     * @param queryServiceEndpoint
+     * @param updateServiceEndpoint
+     * @param graphStoreProtocolEndpoint
+     * @return RDFConnection
+     */
     public static RDFConnection connect(String queryServiceEndpoint,
                                         String updateServiceEndpoint,
                                         String graphStoreProtocolEndpoint) {
-        return new RDFConnectionRemote(queryServiceEndpoint, updateServiceEndpoint, graphStoreProtocolEndpoint) ;
+        return new RDFConnectionRemote(queryServiceEndpoint, updateServiceEndpoint, graphStoreProtocolEndpoint);
    }
 
     
     /** Create a connection to a remote location by URL.
      * This is the URL for the dataset.
+     * Each service is then specified by a URL which is relative to the {@code datasetURL}.
      * 
-     *  This call requires specifying the names of the servicerelative to the dataset URL.
-     *  
-     */ 
+     * @param datasetURL
+     * @param queryServiceEndpoint
+     * @param updateServiceEndpoint
+     * @param graphStoreProtocolEndpoint
+     * @return RDFConnection
+     */
     public static RDFConnection connect(String datasetURL,
                                         String queryServiceEndpoint,
                                         String updateServiceEndpoint,
                                         String graphStoreProtocolEndpoint) {
-        return new RDFConnectionRemote(datasetURL, queryServiceEndpoint, updateServiceEndpoint, graphStoreProtocolEndpoint) ;
+        return new RDFConnectionRemote(datasetURL, queryServiceEndpoint, updateServiceEndpoint, graphStoreProtocolEndpoint);
     }
 
     /**
@@ -76,9 +81,7 @@ public class RDFConnectionFactory {
      * @return RDFConnection
      */
     public static RDFConnection connect(Dataset dataset) {
-        return new RDFConnectionLocal(dataset) ;
+        return new RDFConnectionLocal(dataset);
     }
 
-    //public RDFConnection getFromPool() ;
 }
-

http://git-wip-us.apache.org/repos/asf/jena/blob/53758b5f/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFConnectionLocal.java
----------------------------------------------------------------------
diff --git a/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFConnectionLocal.java b/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFConnectionLocal.java
index 2f7be62..d2fb4df 100644
--- a/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFConnectionLocal.java
+++ b/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFConnectionLocal.java
@@ -18,76 +18,75 @@
 
 package org.apache.jena.rdfconnection;
 
-import java.util.Objects ;
-
-import org.apache.jena.graph.Graph ;
-import org.apache.jena.query.* ;
-import org.apache.jena.rdf.model.Model ;
-import org.apache.jena.rdf.model.ModelFactory ;
-import org.apache.jena.riot.Lang ;
-import org.apache.jena.riot.RDFDataMgr ;
-import org.apache.jena.riot.RDFLanguages ;
-import org.apache.jena.sparql.ARQException ;
-import org.apache.jena.sparql.core.DatasetGraph ;
-import org.apache.jena.sparql.core.DatasetGraphFactory ;
-import org.apache.jena.sparql.core.DatasetGraphReadOnly ;
-import org.apache.jena.sparql.graph.GraphReadOnly ;
-import org.apache.jena.system.Txn ;
-import org.apache.jena.update.UpdateExecutionFactory ;
-import org.apache.jena.update.UpdateRequest ;
+import java.util.Objects;
+
+import org.apache.jena.graph.Graph;
+import org.apache.jena.query.*;
+import org.apache.jena.rdf.model.Model;
+import org.apache.jena.rdf.model.ModelFactory;
+import org.apache.jena.riot.Lang;
+import org.apache.jena.riot.RDFDataMgr;
+import org.apache.jena.riot.RDFLanguages;
+import org.apache.jena.sparql.ARQException;
+import org.apache.jena.sparql.core.DatasetGraph;
+import org.apache.jena.sparql.core.DatasetGraphFactory;
+import org.apache.jena.sparql.core.DatasetGraphReadOnly;
+import org.apache.jena.sparql.graph.GraphReadOnly;
+import org.apache.jena.system.Txn;
+import org.apache.jena.update.UpdateExecutionFactory;
+import org.apache.jena.update.UpdateRequest;
 
 /** 
- * 
+ * Implement of {@link RDFConnection} over a {@link Dataset} in the same JVM.
  */
 
 public class RDFConnectionLocal implements RDFConnection {
-    // XXX Expose copy-mode
-
+    // XXX Expose copy-mode?
     
-    private ThreadLocal<Boolean> transactionActive = ThreadLocal.withInitial(()->false) ;
-    private static boolean isolateByCopy = true ; 
-    private Dataset dataset ;
+    private ThreadLocal<Boolean> transactionActive = ThreadLocal.withInitial(()->false);
+    private static boolean isolateByCopy = true; 
+    private Dataset dataset;
     
     public RDFConnectionLocal(Dataset dataset) {
-        this.dataset = dataset ;
+        this.dataset = dataset;
     }
     
     @Override
     public QueryExecution query(Query query) {
-        checkOpen() ;
-        return Txn.calculateRead(dataset, ()->QueryExecutionFactory.create(query, dataset)) ;
+        checkOpen();
+        return Txn.calculateRead(dataset, ()->QueryExecutionFactory.create(query, dataset));
     }
 
     @Override
     public void update(UpdateRequest update) {
-        checkOpen() ;
-        Txn.executeWrite(dataset, ()->UpdateExecutionFactory.create(update, dataset).execute() ) ; 
+        checkOpen();
+        Txn.executeWrite(dataset, ()->UpdateExecutionFactory.create(update, dataset).execute() ); 
     }
 
     @Override
     public void load(String graph, String file) {
-        checkOpen() ;
-        doPutPost(graph, file, false) ;
+        checkOpen();
+        doPutPost(graph, file, false);
     }
 
     @Override
     public void load(String file) {
-        checkOpen() ;
-        doPutPost(null, file, false) ;
+        checkOpen();
+        doPutPost(null, file, false);
     }
 
     @Override
     public void load(String graphName, Model model) {
-        checkOpen() ;
+        checkOpen();
         Txn.executeWrite(dataset, ()-> {
-            Model modelDst = modelFor(graphName) ; 
-            modelDst.add(model) ;
-        }) ;
+            Model modelDst = modelFor(graphName); 
+            modelDst.add(model);
+        });
     }
 
     @Override
     public void load(Model model) { 
-        load(null, model) ;
+        load(null, model);
     }
 
     /**
@@ -99,70 +98,70 @@ public class RDFConnectionLocal implements RDFConnection {
     @Override
     public Model fetch(String graph) {
         return Txn.calculateRead(dataset, ()-> {
-            Model model = modelFor(graph) ; 
-            return isolate(model) ; 
-        }) ;
+            Model model = modelFor(graph); 
+            return isolate(model); 
+        });
     }
 
     @Override
     public Model fetch() {
-        checkOpen() ;
-        return fetch(null) ;
+        checkOpen();
+        return fetch(null);
     }
 
     @Override
     public void put(String file) {
-        checkOpen() ;
-        doPutPost(null, file, true) ;
+        checkOpen();
+        doPutPost(null, file, true);
     }
 
     @Override
     public void put(String graph, String file) {
-        checkOpen() ;
-        doPutPost(graph, file, true) ;
+        checkOpen();
+        doPutPost(graph, file, true);
     }
 
     @Override
     public void put(Model model) {
-        put(null, model) ; 
+        put(null, model); 
     }
 
     @Override
     public void put(String graphName, Model model) {
-        checkOpen() ;
+        checkOpen();
         Txn.executeWrite(dataset, ()-> {
-            Model modelDst = modelFor(graphName) ; 
+            Model modelDst = modelFor(graphName); 
             modelDst.removeAll();
-            modelDst.add(model) ;
-        }) ;
+            modelDst.add(model);
+        });
     }
 
     @Override
     public void delete(String graph) {
-        checkOpen() ;
+        checkOpen();
         Txn.executeWrite(dataset,() ->{
             if ( RDFConn.isDefault(graph) ) 
                 dataset.getDefaultModel().removeAll();
             else 
                 dataset.removeNamedModel(graph);
-        }) ;
+        });
     }
 
     @Override
     public void delete() {
-        checkOpen() ;
-        delete(null) ;
+        checkOpen();
+        delete(null);
     }
 
     private void doPutPost(String graph, String file, boolean replace) {
-        Objects.requireNonNull(file) ;
-        Lang lang = RDFLanguages.filenameToLang(file) ;
+        Objects.requireNonNull(file);
+        Lang lang = RDFLanguages.filenameToLang(file);
         
         Txn.executeWrite(dataset,() ->{
             if ( RDFLanguages.isTriples(lang) ) {
-                Model model = RDFConn.isDefault(graph) ? dataset.getDefaultModel() : dataset.getNamedModel(graph) ;
+                Model model = RDFConn.isDefault(graph) ? dataset.getDefaultModel() : dataset.getNamedModel(graph);
                 if ( replace )
-                    model.removeAll() ;
+                    model.removeAll();
                 RDFDataMgr.read(model, file); 
             }
             else if ( RDFLanguages.isQuads(lang) ) {
@@ -172,8 +171,8 @@ public class RDFConnectionLocal implements RDFConnection {
                 RDFDataMgr.read(dataset, file); 
             }
             else
-                throw new ARQException("Not an RDF format: "+file+" (lang="+lang+")") ;
-        }) ;
+                throw new ARQException("Not an RDF format: "+file+" (lang="+lang+")");
+        });
     }
 
     /**
@@ -183,13 +182,13 @@ public class RDFConnectionLocal implements RDFConnection {
     private Model isolate(Model model) {
         if ( ! isolateByCopy ) {
             // Half-way - read-only but dataset changes can be seen. 
-            Graph g = new GraphReadOnly(model.getGraph()) ;
-            return ModelFactory.createModelForGraph(g) ;
+            Graph g = new GraphReadOnly(model.getGraph());
+            return ModelFactory.createModelForGraph(g);
         }
         // Copy.
-        Model m2 = ModelFactory.createDefaultModel() ;
-        m2.add(model) ;
-        return m2 ;
+        Model m2 = ModelFactory.createDefaultModel();
+        m2.add(model);
+        return m2;
     }
 
     /**
@@ -198,72 +197,72 @@ public class RDFConnectionLocal implements RDFConnection {
      */
     private Dataset isolate(Dataset dataset) {
         if ( ! isolateByCopy ) {
-            DatasetGraph dsg = new DatasetGraphReadOnly(dataset.asDatasetGraph()) ;
-            return DatasetFactory.wrap(dsg) ;
+            DatasetGraph dsg = new DatasetGraphReadOnly(dataset.asDatasetGraph());
+            return DatasetFactory.wrap(dsg);
         }
 
         // Copy.
-        DatasetGraph dsg2 = DatasetGraphFactory.create() ;
+        DatasetGraph dsg2 = DatasetGraphFactory.create();
         dataset.asDatasetGraph().find().forEachRemaining(q -> dsg2.add(q) );
-        return DatasetFactory.wrap(dsg2) ;
+        return DatasetFactory.wrap(dsg2);
     }
 
     private Model modelFor(String graph) {
         if ( RDFConn.isDefault(graph)) 
-            return dataset.getDefaultModel() ;
-        return dataset.getNamedModel(graph) ;
+            return dataset.getDefaultModel();
+        return dataset.getNamedModel(graph);
     }
 
     @Override
     public Dataset fetchDataset() {
-        checkOpen() ;
-        return Txn.calculateRead(dataset,() -> isolate(dataset)) ;   
+        checkOpen();
+        return Txn.calculateRead(dataset,() -> isolate(dataset));   
     }
 
     @Override
     public void loadDataset(String file) {
-        checkOpen() ;
+        checkOpen();
         Txn.executeWrite(dataset,() ->{
             RDFDataMgr.read(dataset, file);
-        }) ;
+        });
     }
 
     @Override
     public void loadDataset(Dataset dataset) {
         Txn.executeWrite(dataset,() ->{
-            dataset.asDatasetGraph().find().forEachRemaining((q)->this.dataset.asDatasetGraph().add(q)) ;
-        }) ;
+            dataset.asDatasetGraph().find().forEachRemaining((q)->this.dataset.asDatasetGraph().add(q));
+        });
     }
 
     @Override
     public void putDataset(String file) {
-        checkOpen() ;
+        checkOpen();
         Txn.executeWrite(dataset,() ->{
             dataset.asDatasetGraph().clear();
             RDFDataMgr.read(dataset, file);
-        }) ;
+        });
     }
 
     @Override
     public void putDataset(Dataset dataset) {
         Txn.executeWrite(dataset,() ->{
-            this.dataset = isolate(dataset) ;
-        }) ;
+            this.dataset = isolate(dataset);
+        });
     }
 
     @Override
     public void close() {
-        dataset = null ;
+        dataset = null;
     }
     
     @Override
     public boolean isClosed() {
-        return dataset == null ;
+        return dataset == null;
     }
 
     private void checkOpen() {
         if ( dataset == null )
-            throw new ARQException("closed") ;
+            throw new ARQException("closed");
     }
 
     @Override
@@ -276,10 +275,10 @@ public class RDFConnectionLocal implements RDFConnection {
     public void abort()                     { dataset.abort(); }
 
     @Override
-    public boolean isInTransaction()        { return dataset.isInTransaction() ; }
+    public boolean isInTransaction()        { return dataset.isInTransaction(); }
 
     @Override
-    public void end()                       { dataset.end() ; }
+    public void end()                       { dataset.end(); }
     
    
 }

http://git-wip-us.apache.org/repos/asf/jena/blob/53758b5f/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFConnectionModular.java
----------------------------------------------------------------------
diff --git a/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFConnectionModular.java b/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFConnectionModular.java
index 8f36355..77e473c 100644
--- a/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFConnectionModular.java
+++ b/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFConnectionModular.java
@@ -18,23 +18,24 @@
 
 package org.apache.jena.rdfconnection;
 
-import org.apache.jena.query.Dataset ;
-import org.apache.jena.query.Query ;
-import org.apache.jena.query.QueryExecution ;
-import org.apache.jena.query.ReadWrite ;
-import org.apache.jena.rdf.model.Model ;
-import org.apache.jena.sparql.core.Transactional ;
-import org.apache.jena.update.UpdateRequest ;
-
-/** 
- * 
+import org.apache.jena.query.Dataset;
+import org.apache.jena.query.Query;
+import org.apache.jena.query.QueryExecution;
+import org.apache.jena.query.ReadWrite;
+import org.apache.jena.rdf.model.Model;
+import org.apache.jena.sparql.core.Transactional;
+import org.apache.jena.update.UpdateRequest;
+
+/**
+ * Implementation of {@link RDFConnection} where the query, update and graph store
+ * operations are given by specific implementations of the respective interfaces.
  */
 public class RDFConnectionModular implements RDFConnection {
     
-    private final SparqlQueryConnection queryConnection ;
-    private final SparqlUpdateConnection updateConnection ;
-    private final RDFDatasetConnection datasetConnection ;
-    private final Transactional transactional ;
+    private final SparqlQueryConnection queryConnection;
+    private final SparqlUpdateConnection updateConnection;
+    private final RDFDatasetConnection datasetConnection;
+    private final Transactional transactional;
     
     @Override
     public void begin(ReadWrite readWrite) { transactional.begin(readWrite); }
@@ -46,144 +47,139 @@ public class RDFConnectionModular implements RDFConnection {
     public void end() { transactional.end(); }
     @Override
     public boolean isInTransaction() { 
-        return transactional.isInTransaction() ;
+        return transactional.isInTransaction();
     }
     
     public RDFConnectionModular(SparqlQueryConnection queryConnection ,
                                 SparqlUpdateConnection updateConnection ,
                                 RDFDatasetConnection datasetConnection ) {
-        this.queryConnection = queryConnection ;
-        this.updateConnection = updateConnection ;
-        this.datasetConnection = datasetConnection ;
+        this.queryConnection = queryConnection;
+        this.updateConnection = updateConnection;
+        this.datasetConnection = datasetConnection;
         this.transactional = 
             updateConnection  != null ? updateConnection :
             datasetConnection != null ? datasetConnection :
             queryConnection   != null ? queryConnection :
-            null ;
+            null;
     }
     
-    public RDFConnectionModular(RDFConnection connection ) {
-        this.queryConnection = connection ;
-        this.updateConnection = connection ;
-        this.datasetConnection = connection ;
-        this.transactional = connection ;
+    public RDFConnectionModular(RDFConnection connection) {
+        this.queryConnection = connection;
+        this.updateConnection = connection;
+        this.datasetConnection = connection;
+        this.transactional = connection;
     }
 
     private SparqlQueryConnection queryConnection() {
         if ( queryConnection == null )
-            throw new UnsupportedOperationException("No SparqlQueryConnection") ;
-        return queryConnection ;
+            throw new UnsupportedOperationException("No SparqlQueryConnection");
+        return queryConnection;
     }
     
     private SparqlUpdateConnection updateConnection() {
         if ( updateConnection == null )
-            throw new UnsupportedOperationException("No SparqlUpdateConnection") ;
-        return updateConnection ;
+            throw new UnsupportedOperationException("No SparqlUpdateConnection");
+        return updateConnection;
     }
 
     private RDFDatasetConnection datasetConnection() {
         if ( datasetConnection == null )
-            throw new UnsupportedOperationException("No RDFDatasetConnection") ;
-        return datasetConnection ;
+            throw new UnsupportedOperationException("No RDFDatasetConnection");
+        return datasetConnection;
     }
-    
-    
 
     @Override
-    public QueryExecution query(Query query) { return queryConnection().query(query) ; }
+    public QueryExecution query(Query query) { return queryConnection().query(query); }
 
     @Override
     public void update(UpdateRequest update) {
-        updateConnection().update(update) ;
+        updateConnection().update(update);
     }
 
     @Override
     public void load(String graphName, String file) {
-        datasetConnection().load(graphName, file) ;
+        datasetConnection().load(graphName, file);
     }
 
     @Override
     public void load(String file) {
-        datasetConnection().load(file) ;
+        datasetConnection().load(file);
     }
 
     @Override
     public void load(String graphName, Model model) {
-        datasetConnection().load(graphName, model) ;
+        datasetConnection().load(graphName, model);
     }
 
     @Override
     public void load(Model model) {
-        datasetConnection().load(model) ;
+        datasetConnection().load(model);
     }
 
     @Override
     public void put(String graphName, String file) {
-        datasetConnection().put(graphName, file) ;
+        datasetConnection().put(graphName, file);
     }
 
     @Override
     public void put(String file) {
-        datasetConnection().put(file) ;
+        datasetConnection().put(file);
     }
 
     @Override
     public void put(String graphName, Model model) {
-        datasetConnection().put(graphName, model) ;
+        datasetConnection().put(graphName, model);
     }
 
     @Override
     public void put(Model model) {
-        datasetConnection().put(model) ;
+        datasetConnection().put(model);
     }
 
     @Override
     public void delete(String graphName) {
-        datasetConnection().delete(graphName) ;
+        datasetConnection().delete(graphName);
     }
 
     @Override
     public void delete() {
-        datasetConnection().delete() ;
+        datasetConnection().delete();
     }
 
     @Override
     public void loadDataset(String file) {
-        datasetConnection().loadDataset(file) ;
+        datasetConnection().loadDataset(file);
     }
 
     @Override
     public void loadDataset(Dataset dataset) {
-        datasetConnection().loadDataset(dataset) ;
+        datasetConnection().loadDataset(dataset);
     }
 
     @Override
     public void putDataset(String file) {
-        datasetConnection().putDataset(file) ;
+        datasetConnection().putDataset(file);
     }
 
     @Override
     public void putDataset(Dataset dataset) {
-        datasetConnection().putDataset(dataset) ;
+        datasetConnection().putDataset(dataset);
     }
 
-    //    /** Clear the dataset - remove all named graphs, clear the default graph. */
-    //    public void clearDataset() ;
-    
     @Override
     public Model fetch(String graphName) {
-        return datasetConnection.fetch(graphName) ;
+        return datasetConnection.fetch(graphName);
     }
     @Override
     public Model fetch() {
-        return datasetConnection().fetch() ;
+        return datasetConnection().fetch();
     }
     @Override
     public Dataset fetchDataset() {
-        return datasetConnection().fetchDataset() ;
+        return datasetConnection().fetchDataset();
     }
     @Override
-    public boolean isClosed() { return false ; }
+    public boolean isClosed() { return false; }
     
     /** Close this connection.  Use with try-resource. */ 
     @Override 
@@ -193,7 +189,7 @@ public class RDFConnectionModular implements RDFConnection {
         if ( updateConnection != null )
             updateConnection.close();
         if ( datasetConnection != null )
-            datasetConnection.close() ;
+            datasetConnection.close();
     }
 }
 

http://git-wip-us.apache.org/repos/asf/jena/blob/53758b5f/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFConnectionRemote.java
----------------------------------------------------------------------
diff --git a/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFConnectionRemote.java b/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFConnectionRemote.java
index 02d7bef..183cff1 100644
--- a/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFConnectionRemote.java
+++ b/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFConnectionRemote.java
@@ -18,65 +18,60 @@
 
 package org.apache.jena.rdfconnection;
 
-import static java.util.Objects.requireNonNull ;
-
-import java.io.File ;
-import java.io.InputStream ;
-import java.util.concurrent.locks.ReentrantLock ;
-import java.util.function.Supplier ;
-
-import org.apache.http.HttpEntity ;
-import org.apache.http.client.HttpClient ;
-import org.apache.http.entity.EntityTemplate ;
-import org.apache.http.protocol.HttpContext ;
-import org.apache.jena.atlas.io.IO ;
-import org.apache.jena.atlas.web.HttpException ;
-import org.apache.jena.atlas.web.TypedInputStream ;
-import org.apache.jena.graph.Graph ;
-import org.apache.jena.query.* ;
-import org.apache.jena.rdf.model.Model ;
-import org.apache.jena.rdf.model.ModelFactory ;
-import org.apache.jena.riot.* ;
-import org.apache.jena.riot.web.HttpCaptureResponse ;
-import org.apache.jena.riot.web.HttpOp ;
-import org.apache.jena.riot.web.HttpResponseLib ;
-import org.apache.jena.sparql.ARQException ;
-import org.apache.jena.sparql.core.DatasetGraph ;
-import org.apache.jena.sparql.core.Transactional ;
-import org.apache.jena.system.Txn ;
-import org.apache.jena.update.UpdateExecutionFactory ;
-import org.apache.jena.update.UpdateProcessor ;
-import org.apache.jena.update.UpdateRequest ;
-import org.apache.jena.web.HttpSC ;
+import static java.util.Objects.requireNonNull;
+
+import java.io.File;
+import java.io.InputStream;
+import java.util.concurrent.locks.ReentrantLock;
+import java.util.function.Supplier;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.client.HttpClient;
+import org.apache.http.entity.EntityTemplate;
+import org.apache.http.protocol.HttpContext;
+import org.apache.jena.atlas.io.IO;
+import org.apache.jena.atlas.web.HttpException;
+import org.apache.jena.atlas.web.TypedInputStream;
+import org.apache.jena.graph.Graph;
+import org.apache.jena.query.*;
+import org.apache.jena.rdf.model.Model;
+import org.apache.jena.rdf.model.ModelFactory;
+import org.apache.jena.riot.*;
+import org.apache.jena.riot.web.HttpCaptureResponse;
+import org.apache.jena.riot.web.HttpOp;
+import org.apache.jena.riot.web.HttpResponseLib;
+import org.apache.jena.sparql.ARQException;
+import org.apache.jena.sparql.core.DatasetGraph;
+import org.apache.jena.sparql.core.Transactional;
+import org.apache.jena.system.Txn;
+import org.apache.jena.update.UpdateExecutionFactory;
+import org.apache.jena.update.UpdateProcessor;
+import org.apache.jena.update.UpdateRequest;
+import org.apache.jena.web.HttpSC;
 
 /** 
- * 
+ * Implemntation of the {@link RDFConnection} interface using remote SPARQL operations.  
  */
 public class RDFConnectionRemote implements RDFConnection {
-    private static final String fusekiDftSrvQuery   = "sparql" ;
-    private static final String fusekiDftSrvUpdate  = "update" ;
-    private static final String fusekiDftSrvGSP     = "data" ;
+    private static final String fusekiDftSrvQuery   = "sparql";
+    private static final String fusekiDftSrvUpdate  = "update";
+    private static final String fusekiDftSrvGSP     = "data";
     
-    private boolean isOpen = true ; 
-    private final String destination ;
-    private final String svcQuery ;
-    private final String svcUpdate ;
-    private final String svcGraphStore ;
-    private HttpClient httpClient ;
-    private HttpContext httpContext = null ;
+    private boolean isOpen = true; 
+    private final String destination;
+    private final String svcQuery;
+    private final String svcUpdate;
+    private final String svcGraphStore;
+    private HttpClient httpClient;
+    private HttpContext httpContext = null;
     
-    // Builder?
-    // HttpContext, HttpClient.
-    // Statics for "query", "query+update" : SparqlQueryConnectionRemote > SparqlUpdateConnectionRemote > RDFConnectionRemote
-    // XXX Very long "HttpOp.execHttpPost"
-    
-    /** Create connection that wil use the {@link HttpClient} using URL of the dataset and default service names */
+    /** Create connection that will use the {@link HttpClient} using URL of the dataset and default service names */
     public RDFConnectionRemote(HttpClient httpClient, String destination) {
         this(httpClient,
              requireNonNull(destination),
              fusekiDftSrvQuery, 
              fusekiDftSrvUpdate,
-             fusekiDftSrvGSP) ;
+             fusekiDftSrvGSP);
     }
 
 
@@ -85,329 +80,327 @@ public class RDFConnectionRemote implements RDFConnection {
         this(requireNonNull(destination),
              fusekiDftSrvQuery, 
              fusekiDftSrvUpdate,
-             fusekiDftSrvGSP) ;
+             fusekiDftSrvGSP);
     }
 
     // ??
     /** Create connection, using full URLs for services. Pass a null for "no service endpoint". */
     public RDFConnectionRemote(String sQuery, String sUpdate, String sGSP) {
-        this(null, sQuery, sUpdate, sGSP) ;
+        this(null, sQuery, sUpdate, sGSP);
     }
     
     /** Create connection, using URL of the dataset and short names for the services */
     public RDFConnectionRemote(String destination, String sQuery, String sUpdate, String sGSP) {
-        this(null, destination, sQuery, sUpdate, sGSP) ;
+        this(null, destination, sQuery, sUpdate, sGSP);
     }
     
     /** Create connection, using URL of the dataset and short names for the services */
     public RDFConnectionRemote(HttpClient httpClient, String destination, String sQuery, String sUpdate, String sGSP) {
-        this.destination = destination ;
-        this.svcQuery = formServiceURL(destination,sQuery) ;
-        this.svcUpdate = formServiceURL(destination,sUpdate) ;
-        this.svcGraphStore = formServiceURL(destination,sGSP) ;
-//        if ( httpClient == null )
-//            httpClient = HttpOp.getDefaultHttpClient() ;
-        this.httpClient = httpClient ;
+        this.destination = destination;
+        this.svcQuery = formServiceURL(destination,sQuery);
+        this.svcUpdate = formServiceURL(destination,sUpdate);
+        this.svcGraphStore = formServiceURL(destination,sGSP);
+        this.httpClient = httpClient;
     }
     
     public HttpClient getHttpClient() {
-        return httpClient ;
+        return httpClient;
     }
 
     public void setHttpClient(HttpClient httpClient) {
-        this.httpClient = httpClient ;
+        this.httpClient = httpClient;
     }
 
     public HttpContext getHttpContext() {
-        return httpContext ;
+        return httpContext;
     }
 
     public void setHttpContext(HttpContext httpContext) {
-        this.httpContext = httpContext ;
+        this.httpContext = httpContext;
     }
 
     private static String formServiceURL(String destination, String srvEndpoint) {
         if ( destination == null )
-            return srvEndpoint ;
-        String dest = destination ;
+            return srvEndpoint;
+        String dest = destination;
         if ( dest.endsWith("/") )
-            dest = dest.substring(0, dest.length()-1) ;
-        return dest+"/"+srvEndpoint ;
+            dest = dest.substring(0, dest.length()-1);
+        return dest+"/"+srvEndpoint;
     }
 
     @Override
     public QueryExecution query(Query query) {
         checkQuery();
-        return exec(()->QueryExecutionFactory.createServiceRequest(svcQuery, query)) ;
+        return exec(()->QueryExecutionFactory.createServiceRequest(svcQuery, query));
     }
 
     @Override
     public void update(UpdateRequest update) {
         checkUpdate();
-        UpdateProcessor proc = UpdateExecutionFactory.createRemote(update, svcUpdate) ;
+        UpdateProcessor proc = UpdateExecutionFactory.createRemote(update, svcUpdate);
         exec(()->proc.execute());
     }
     
     @Override
     public Model fetch(String graphName) {
-        checkGSP() ;
-        String url = RDFConn.urlForGraph(svcGraphStore, graphName) ;
-        Graph graph = fetch$(url) ;
-        return ModelFactory.createModelForGraph(graph) ;
+        checkGSP();
+        String url = RDFConn.urlForGraph(svcGraphStore, graphName);
+        Graph graph = fetch$(url);
+        return ModelFactory.createModelForGraph(graph);
     }
     
     @Override
     public Model fetch() {
-        checkGSP() ;
-        return fetch(null) ;
+        checkGSP();
+        return fetch(null);
     }
     
     private Graph fetch$(String url) {
-        HttpCaptureResponse<Graph> graph = HttpResponseLib.graphHandler() ;
-        exec(()->HttpOp.execHttpGet(url, WebContent.defaultGraphAcceptHeader, graph, this.httpClient, this.httpContext)) ;
-        return graph.get() ;
+        HttpCaptureResponse<Graph> graph = HttpResponseLib.graphHandler();
+        exec(()->HttpOp.execHttpGet(url, WebContent.defaultGraphAcceptHeader, graph, this.httpClient, this.httpContext));
+        return graph.get();
     }
 
     @Override
     public void load(String graph, String file) {
-        checkGSP() ;
-        upload(graph, file, false) ;
+        checkGSP();
+        upload(graph, file, false);
     }
     
     @Override
     public void load(String file) {
-        checkGSP() ;
-        upload(null, file, false) ;
+        checkGSP();
+        upload(null, file, false);
     }
     
     @Override
     public void load(Model model) {
-        doPutPost(model, null, false) ;
+        doPutPost(model, null, false);
     }
     
     @Override
     public void load(String graphName, Model model) {
-        doPutPost(model, graphName, false) ;
+        doPutPost(model, graphName, false);
     }
     
     @Override
     public void put(String graph, String file) {
-        checkGSP() ;
-        upload(graph, file, true) ;
+        checkGSP();
+        upload(graph, file, true);
     }
     
     @Override
     public void put(String file) { 
-        checkGSP() ;
-        upload(null, file, true) ; 
+        checkGSP();
+        upload(null, file, true); 
     }
     
     @Override
     public void put(String graphName, Model model) {
-        checkGSP() ;
-        doPutPost(model, graphName, true) ;
+        checkGSP();
+        doPutPost(model, graphName, true);
     }
 
     @Override
     public void put(Model model) {
-        checkGSP() ;
-        doPutPost(model, null, true) ;
+        checkGSP();
+        doPutPost(model, null, true);
     }
     
     private void upload(String graph, String file, boolean replace) {
         // if triples
-        Lang lang = RDFLanguages.filenameToLang(file) ;
+        Lang lang = RDFLanguages.filenameToLang(file);
         if ( RDFLanguages.isQuads(lang) )
-            throw new ARQException("Can't load quads into a graph") ;
+            throw new ARQException("Can't load quads into a graph");
         if ( ! RDFLanguages.isTriples(lang) )
-            throw new ARQException("Not an RDF format: "+file+" (lang="+lang+")") ;
-        String url = RDFConn.urlForGraph(svcGraphStore, graph) ;
-        doPutPost(url, file, lang, replace) ;
+            throw new ARQException("Not an RDF format: "+file+" (lang="+lang+")");
+        String url = RDFConn.urlForGraph(svcGraphStore, graph);
+        doPutPost(url, file, lang, replace);
     }
 
     private void doPutPost(String url, String file, Lang lang, boolean replace) {
-        File f = new File(file) ;
-        long length = f.length() ; 
-        InputStream source = IO.openFile(file) ;
+        File f = new File(file);
+        long length = f.length(); 
+        InputStream source = IO.openFile(file);
         // Charset.
         exec(()->{
             if ( replace )
-                HttpOp.execHttpPut(url, lang.getContentType().getContentType(), source, length, httpClient, this.httpContext) ;
+                HttpOp.execHttpPut(url, lang.getContentType().getContentType(), source, length, httpClient, this.httpContext);
             else    
-                HttpOp.execHttpPost(url, lang.getContentType().getContentType(), source, length, null, null, httpClient, this.httpContext) ;
-        }) ;
+                HttpOp.execHttpPost(url, lang.getContentType().getContentType(), source, length, null, null, httpClient, this.httpContext);
+        });
     }
 
     private void doPutPost(Model model, String name, boolean replace) {
-        String url = RDFConn.urlForGraph(svcGraphStore, name) ;
+        String url = RDFConn.urlForGraph(svcGraphStore, name);
         exec(()->{
-            Graph graph = model.getGraph() ;
+            Graph graph = model.getGraph();
             if ( replace )
-                HttpOp.execHttpPut(url, graphToHttpEntity(graph), httpClient, this.httpContext) ;
+                HttpOp.execHttpPut(url, graphToHttpEntity(graph), httpClient, this.httpContext);
             else    
-                HttpOp.execHttpPost(url, graphToHttpEntity(graph), null, null, httpClient, this.httpContext) ;
+                HttpOp.execHttpPost(url, graphToHttpEntity(graph), null, null, httpClient, this.httpContext);
         });
     }
 
     @Override
     public void delete(String graph) {
-        checkGSP() ;
-        String url = RDFConn.urlForGraph(svcGraphStore, graph) ;
+        checkGSP();
+        String url = RDFConn.urlForGraph(svcGraphStore, graph);
         exec(()->HttpOp.execHttpDelete(url));
     }
 
     @Override
     public void delete() {
-        checkGSP() ;
-        delete(null) ;
+        checkGSP();
+        delete(null);
     }
 
     @Override
     public Dataset fetchDataset() {
         if ( destination == null )
-            throw new ARQException("Dataset operations not available - no dataset URL provided") ; 
-        Dataset ds = DatasetFactory.createTxnMem() ;
+            throw new ARQException("Dataset operations not available - no dataset URL provided"); 
+        Dataset ds = DatasetFactory.createTxnMem();
         Txn.executeWrite(ds, ()->{
-            TypedInputStream s = exec(()->HttpOp.execHttpGet(destination, WebContent.defaultDatasetAcceptHeader)) ;
-            Lang lang = RDFLanguages.contentTypeToLang(s.getContentType()) ;
-            RDFDataMgr.read(ds, s, lang) ;
-        }) ;
-        return ds ;
+            TypedInputStream s = exec(()->HttpOp.execHttpGet(destination, WebContent.defaultDatasetAcceptHeader));
+            Lang lang = RDFLanguages.contentTypeToLang(s.getContentType());
+            RDFDataMgr.read(ds, s, lang);
+        });
+        return ds;
     }
 
     @Override
     public void loadDataset(String file) { 
         if ( destination == null )
-            throw new ARQException("Dataset operations not available - no dataset URl provided") ; 
-        doPutPostDataset(file, false) ; 
+            throw new ARQException("Dataset operations not available - no dataset URl provided"); 
+        doPutPostDataset(file, false); 
     }
     
     @Override
     public void loadDataset(Dataset dataset) {
         if ( destination == null )
-            throw new ARQException("Dataset operations not available - no dataset URl provided") ; 
-        doPutPostDataset(dataset, false) ; 
+            throw new ARQException("Dataset operations not available - no dataset URl provided"); 
+        doPutPostDataset(dataset, false); 
     }
 
     @Override
     public void putDataset(String file) {
         if ( destination == null )
-            throw new ARQException("Dataset operations not available - no dataset URl provided") ; 
-        doPutPostDataset(file, true) ;
+            throw new ARQException("Dataset operations not available - no dataset URl provided"); 
+        doPutPostDataset(file, true);
     }
     
     @Override
     public void putDataset(Dataset dataset) {
         if ( destination == null )
-            throw new ARQException("Dataset operations not available - no dataset URl provided") ; 
-        doPutPostDataset(dataset, true) ; 
+            throw new ARQException("Dataset operations not available - no dataset URl provided"); 
+        doPutPostDataset(dataset, true); 
     }
 
     private void doPutPostDataset(String file, boolean replace) {
-        Lang lang = RDFLanguages.filenameToLang(file) ;
-        File f = new File(file) ;
-        long length = f.length() ;
+        Lang lang = RDFLanguages.filenameToLang(file);
+        File f = new File(file);
+        long length = f.length();
         exec(()->{
-            InputStream source = IO.openFile(file) ;
+            InputStream source = IO.openFile(file);
             if ( replace )
-                HttpOp.execHttpPut(destination, lang.getContentType().getContentType(), source, length, httpClient, httpContext) ;
+                HttpOp.execHttpPut(destination, lang.getContentType().getContentType(), source, length, httpClient, httpContext);
             else    
-                HttpOp.execHttpPost(destination, lang.getContentType().getContentType(), source, length, null, null, httpClient, httpContext) ;
+                HttpOp.execHttpPost(destination, lang.getContentType().getContentType(), source, length, null, null, httpClient, httpContext);
         });
     }
 
     private void doPutPostDataset(Dataset dataset, boolean replace) {
         exec(()->{
-            DatasetGraph dsg = dataset.asDatasetGraph() ;
+            DatasetGraph dsg = dataset.asDatasetGraph();
             if ( replace )
-                HttpOp.execHttpPut(destination, datasetToHttpEntity(dsg), httpClient, null) ;
+                HttpOp.execHttpPut(destination, datasetToHttpEntity(dsg), httpClient, null);
             else    
-                HttpOp.execHttpPost(destination, datasetToHttpEntity(dsg), httpClient, null) ;
+                HttpOp.execHttpPost(destination, datasetToHttpEntity(dsg), httpClient, null);
         });
     }
 
 
     private void checkQuery() {
-        checkOpen() ;
+        checkOpen();
         if ( svcQuery == null )
-            throw new ARQException("No query service defined for this RDFConnection") ;
+            throw new ARQException("No query service defined for this RDFConnection");
     }
     
     private void checkUpdate() {
-        checkOpen() ;
+        checkOpen();
         if ( svcUpdate == null )
-            throw new ARQException("No update service defined for this RDFConnection") ;
+            throw new ARQException("No update service defined for this RDFConnection");
     }
     
     private void checkGSP() {
-        checkOpen() ;
+        checkOpen();
         if ( svcGraphStore == null )
-            throw new ARQException("No SPARQL Graph Store service defined for this RDFConnection") ;
+            throw new ARQException("No SPARQL Graph Store service defined for this RDFConnection");
     }
     
     private void checkDataset() {
-        checkOpen() ;
+        checkOpen();
         if ( destination == null )
-            throw new ARQException("Dataset operations not available - no dataset URL provided") ; 
+            throw new ARQException("Dataset operations not available - no dataset URL provided"); 
     }
 
     private void checkOpen() {
         if ( ! isOpen )
-            throw new ARQException("closed") ;
+            throw new ARQException("closed");
     }
 
     @Override
     public void close() {
-        isOpen = false ;
+        isOpen = false;
     }
 
     @Override
     public boolean isClosed() {
-        return ! isOpen ;
+        return ! isOpen;
     }
 
     /** Create an HttpEntity for the graph */  
     protected HttpEntity graphToHttpEntity(Graph graph) {
-        return graphToHttpEntity(graph, RDFFormat.NTRIPLES) ;
+        return graphToHttpEntity(graph, RDFFormat.NTRIPLES);
     }
     
     /** Create an HttpEntity for the graph */
     protected HttpEntity graphToHttpEntity(Graph graph, RDFFormat syntax) {
-        EntityTemplate entity = new EntityTemplate((out)->RDFDataMgr.write(out, graph, syntax)) ;
-        String ct = syntax.getLang().getContentType().getContentType() ;
-        entity.setContentType(ct) ;
-        return entity ;
+        EntityTemplate entity = new EntityTemplate((out)->RDFDataMgr.write(out, graph, syntax));
+        String ct = syntax.getLang().getContentType().getContentType();
+        entity.setContentType(ct);
+        return entity;
     }
 
     /** Create an HttpEntity for the dataset */  
     protected HttpEntity datasetToHttpEntity(DatasetGraph dataset) {
-        return datasetToHttpEntity(dataset, RDFFormat.NQUADS) ;
+        return datasetToHttpEntity(dataset, RDFFormat.NQUADS);
     }
     
     /** Create an HttpEntity for the dataset */  
     protected HttpEntity datasetToHttpEntity(DatasetGraph dataset, RDFFormat syntax) {
-        EntityTemplate entity = new EntityTemplate((out)->RDFDataMgr.write(out, dataset, syntax)) ;
-        String ct = syntax.getLang().getContentType().getContentType() ;
-        entity.setContentType(ct) ;
-        return entity ;
+        EntityTemplate entity = new EntityTemplate((out)->RDFDataMgr.write(out, dataset, syntax));
+        String ct = syntax.getLang().getContentType().getContentType();
+        entity.setContentType(ct);
+        return entity;
     }
 
     /** Convert HTTP status codes to exceptions */ 
     static void exec(Runnable action)  {
-        try { action.run() ; }
-        catch (HttpException ex) { handleHttpException(ex, false) ; }
+        try { action.run(); }
+        catch (HttpException ex) { handleHttpException(ex, false); }
     }
 
     /** Convert HTTP status codes to exceptions */ 
     static <X> X exec(Supplier<X> action)  {
-        try { return action.get() ; }
-        catch (HttpException ex) { handleHttpException(ex, true) ; return null ;}
+        try { return action.get(); }
+        catch (HttpException ex) { handleHttpException(ex, true); return null;}
     }
 
     private static void handleHttpException(HttpException ex, boolean ignore404) {
         if ( ex.getResponseCode() == HttpSC.NOT_FOUND_404 && ignore404 )
-            return  ;
-        throw ex ;
+            return ;
+        throw ex;
     }
 
     /** Engine for the transaction lifecycle.
@@ -416,8 +409,8 @@ public class RDFConnectionRemote implements RDFConnection {
     
     static class TxnLifecycle implements Transactional {
         // MR+SW policy.
-        private ReentrantLock lock = new ReentrantLock() ;
-        private ThreadLocal<ReadWrite> mode = ThreadLocal.withInitial(()->null) ;
+        private ReentrantLock lock = new ReentrantLock();
+        private ThreadLocal<ReadWrite> mode = ThreadLocal.withInitial(()->null);
         @Override
         public void begin(ReadWrite readWrite) {
             if ( readWrite == ReadWrite.WRITE )
@@ -441,23 +434,23 @@ public class RDFConnectionRemote implements RDFConnection {
 
         @Override
         public boolean isInTransaction() {
-            return mode.get() != null ;
+            return mode.get() != null;
         }
 
         @Override
         public void end() {
-            ReadWrite rw = mode.get() ;
+            ReadWrite rw = mode.get();
             if ( rw == null )
-                return ;
+                return;
             if ( rw == ReadWrite.WRITE ) {
-                abort() ;
-                return ;
+                abort();
+                return;
             }
-            mode.set(null) ;
+            mode.set(null);
         }
     }
     
-    private TxnLifecycle inner = new TxnLifecycle() ;
+    private TxnLifecycle inner = new TxnLifecycle();
     
     @Override
     public void begin(ReadWrite readWrite)  { inner.begin(readWrite); }
@@ -469,7 +462,7 @@ public class RDFConnectionRemote implements RDFConnection {
     public void abort()                     { inner.abort(); }
 
     @Override
-    public boolean isInTransaction()        { return inner.isInTransaction() ; }
+    public boolean isInTransaction()        { return inner.isInTransaction(); }
 
     @Override
     public void end()                       { inner.end(); }

http://git-wip-us.apache.org/repos/asf/jena/blob/53758b5f/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFDatasetAccessConnection.java
----------------------------------------------------------------------
diff --git a/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFDatasetAccessConnection.java b/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFDatasetAccessConnection.java
index a9bfbd1..a6ba626 100644
--- a/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFDatasetAccessConnection.java
+++ b/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFDatasetAccessConnection.java
@@ -18,9 +18,9 @@
 
 package org.apache.jena.rdfconnection;
 
-import org.apache.jena.query.Dataset ;
-import org.apache.jena.rdf.model.Model ;
-import org.apache.jena.sparql.core.Transactional ;
+import org.apache.jena.query.Dataset;
+import org.apache.jena.rdf.model.Model;
+import org.apache.jena.sparql.core.Transactional;
 
 /**
  * SPARQL Graph Store Protocol (read operations) and whole dataset access.
@@ -38,20 +38,20 @@ public interface RDFDatasetAccessConnection extends Transactional, AutoCloseable
      * @param graphName URI string for the graph name (null or "default" for the default graph)
      * @return Model
      */
-    public Model fetch(String graphName) ;
+    public Model fetch(String graphName);
     
     /** Fetch the default graph.
      * This is SPARQL Graph Store Protocol HTTP GET or equivalent. 
      * @return Model
      */
-    public Model fetch() ;
+    public Model fetch();
     
     /** Fetch the contents of the dataset */ 
-    public Dataset fetchDataset() ;
+    public Dataset fetchDataset();
     
     /** Test whether this connection is closed or not */
-    public boolean isClosed() ;
+    public boolean isClosed();
     
     /** Close this connection.  Use with try-resource. */ 
-    @Override public void close() ;
+    @Override public void close();
 }

http://git-wip-us.apache.org/repos/asf/jena/blob/53758b5f/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFDatasetConnection.java
----------------------------------------------------------------------
diff --git a/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFDatasetConnection.java b/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFDatasetConnection.java
index 688e654..330dc3d 100644
--- a/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFDatasetConnection.java
+++ b/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFDatasetConnection.java
@@ -18,9 +18,9 @@
 
 package org.apache.jena.rdfconnection;
 
-import org.apache.jena.query.Dataset ;
-import org.apache.jena.rdf.model.Model ;
-import org.apache.jena.sparql.core.Transactional ;
+import org.apache.jena.query.Dataset;
+import org.apache.jena.rdf.model.Model;
+import org.apache.jena.sparql.core.Transactional;
 
 /**
  * SPARQL Graph Store Protocol and whole dataset access.
@@ -38,14 +38,14 @@ public interface RDFDatasetConnection extends RDFDatasetAccessConnection, Transa
      * @param graphName Graph name (null or "default" for the default graph)
      * @param file File of the data.
      */
-    public void load(String graphName, String file) ;
+    public void load(String graphName, String file);
     
     /** Load (add, append) RDF into the default graph of a dataset.
      * This is SPARQL Graph Store Protocol HTTP POST or equivalent. 
      * 
      * @param file File of the data.
      */
-    public void load(String file) ;
+    public void load(String file);
 
     /** Load (add, append) RDF into a named graph in a dataset.
      * This is SPARQL Graph Store Protocol HTTP POST or equivalent. 
@@ -53,14 +53,14 @@ public interface RDFDatasetConnection extends RDFDatasetAccessConnection, Transa
      * @param graphName Graph name (null or "default" for the default graph)
      * @param model Data.
      */
-    public void load(String graphName, Model model) ;
+    public void load(String graphName, Model model);
     
     /** Load (add, append) RDF into the default graph of a dataset.
      * This is SPARQL Graph Store Protocol HTTP POST or equivalent. 
      * 
      * @param model Data.
      */
-    public void load(Model model) ;
+    public void load(Model model);
 
     /** Set the contents of a named graph of a dataset.
      * Any existing data is lost. 
@@ -69,7 +69,7 @@ public interface RDFDatasetConnection extends RDFDatasetAccessConnection, Transa
      * @param graphName Graph name (null or "default" for the default graph)
      * @param file File of the data.
      */
-    public void put(String graphName, String file) ;
+    public void put(String graphName, String file);
     
     /** Set the contents of the default graph of a dataset.
      * Any existing data is lost. 
@@ -77,7 +77,7 @@ public interface RDFDatasetConnection extends RDFDatasetAccessConnection, Transa
      * 
      * @param file File of the data.
      */
-    public void put(String file) ;
+    public void put(String file);
         
     /** Set the contents of a named graph of a dataset.
      * Any existing data is lost. 
@@ -86,7 +86,7 @@ public interface RDFDatasetConnection extends RDFDatasetAccessConnection, Transa
      * @param graphName Graph name (null or "default" for the default graph)
      * @param model Data.
      */
-    public void put(String graphName, Model model) ;
+    public void put(String graphName, Model model);
     
     /** Set the contents of the default graph of a dataset.
      * Any existing data is lost. 
@@ -94,7 +94,7 @@ public interface RDFDatasetConnection extends RDFDatasetAccessConnection, Transa
      * 
      * @param model Data.
      */
-    public void put( Model model) ;
+    public void put( Model model);
         
     /**
      * Delete a graph from the dataset.
@@ -102,49 +102,49 @@ public interface RDFDatasetConnection extends RDFDatasetAccessConnection, Transa
      * 
      * @param graphName
      */
-    public void delete(String graphName) ;
+    public void delete(String graphName);
 
     /**
      * Remove all data from the default graph.
      */ 
-    public void delete() ;
+    public void delete();
     
     /* Load (add, append) RDF triple or quad data into a dataset. Triples wil go into the default graph.
      * This is not a SPARQL Graph Store Protocol operation.
      * It is an HTTP POST equivalent to the dataset.
      */
-    public void loadDataset(String file) ;
+    public void loadDataset(String file);
 
     /* Load (add, append) RDF triple or quad data into a dataset. Triples wil go into the default graph.
      * This is not a SPARQL Graph Store Protocol operation.
      * It is an HTTP POST equivalent to the dataset.
      */
-    public void loadDataset(Dataset dataset) ;
+    public void loadDataset(Dataset dataset);
 
     /* Set RDF triple or quad data as the dataset contents.
      * Triples will go into the default graph, quads in named graphs.
      * This is not a SPARQL Graph Store Protocol operation.
      * It is an HTTP PUT equivalent to the dataset.
      */
-    public void putDataset(String file) ;
+    public void putDataset(String file);
     
     /* Set RDF triple or quad data as the dataset contents.
      * Triples will go into the default graph, quads in named graphs.
      * This is not a SPARQL Graph Store Protocol operation.
      * It is an HTTP PUT equivalent to the dataset.
      */
-    public void putDataset(Dataset dataset) ;
+    public void putDataset(Dataset dataset);
 
     //    /** Clear the dataset - remove all named graphs, clear the default graph. */
-//    public void clearDataset() ;
+//    public void clearDataset();
     
     
     /** Test whether this connection is closed or not */
     @Override
-    public boolean isClosed() ;
+    public boolean isClosed();
     
     /** Close this connection.  Use with try-resource. */ 
     @Override 
-    public void close() ;
+    public void close();
 }
 

http://git-wip-us.apache.org/repos/asf/jena/blob/53758b5f/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/SparqlQueryConnection.java
----------------------------------------------------------------------
diff --git a/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/SparqlQueryConnection.java b/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/SparqlQueryConnection.java
index 3c40ae9..0484418 100644
--- a/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/SparqlQueryConnection.java
+++ b/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/SparqlQueryConnection.java
@@ -18,11 +18,11 @@
 
 package org.apache.jena.rdfconnection;
 
-import java.util.function.Consumer ;
+import java.util.function.Consumer;
 
-import org.apache.jena.query.* ;
-import org.apache.jena.rdf.model.Model ;
-import org.apache.jena.sparql.core.Transactional ;
+import org.apache.jena.query.*;
+import org.apache.jena.rdf.model.Model;
+import org.apache.jena.sparql.core.Transactional;
 
 /** SPARQL Query Operations on a connection.
  * 
@@ -36,46 +36,46 @@ public interface SparqlQueryConnection extends Transactional, AutoCloseable
      * @param query
      * @param resultSetAction
      */
-    public void queryResultSet(String query, Consumer<ResultSet> resultSetAction) ;
+    public void queryResultSet(String query, Consumer<ResultSet> resultSetAction);
     
     /**
      * Execute a SELECT query and process the ResultSet with the handler code.  
      * @param query
      * @param resultSetAction
      */
-    public void queryResultSet(Query query, Consumer<ResultSet> resultSetAction) ; 
+    public void queryResultSet(Query query, Consumer<ResultSet> resultSetAction); 
 
     /**
      * Execute a SELECT query and process the rows of the results with the handler code.  
      * @param query
      * @param rowAction
      */
-    public void querySelect(String query, Consumer<QuerySolution> rowAction) ;
+    public void querySelect(String query, Consumer<QuerySolution> rowAction);
     
     /**
      * Execute a SELECT query and process the rows of the results with the handler code.  
      * @param query
      * @param rowAction
      */
-    public void querySelect(Query query, Consumer<QuerySolution> rowAction) ; 
+    public void querySelect(Query query, Consumer<QuerySolution> rowAction); 
 
     /** Execute a CONSTRUCT query and return as a Model */
-    public Model queryConstruct(String query) ;
+    public Model queryConstruct(String query);
     
     /** Execute a CONSTRUCT query and return as a Model */
-    public Model queryConstruct(Query query) ;
+    public Model queryConstruct(Query query);
 
     /** Execute a DESCRIBE query and return as a Model */
-    public Model queryDescribe(String query) ;
+    public Model queryDescribe(String query);
     
     /** Execute a DESCRIBE query and return as a Model */
-    public Model queryDescribe(Query query) ;
+    public Model queryDescribe(Query query);
     
     /** Execute a ASK query and return a boolean */
-    public boolean queryAsk(String query) ;
+    public boolean queryAsk(String query);
 
     /** Execute a ASK query and return a boolean */
-    public boolean queryAsk(Query query) ;
+    public boolean queryAsk(Query query);
     
     /** Setup a SPARQL query execution.
      * 
@@ -86,7 +86,7 @@ public interface SparqlQueryConnection extends Transactional, AutoCloseable
      * @param query
      * @return QueryExecution
      */
-    public QueryExecution query(Query query) ;
+    public QueryExecution query(Query query);
 
     /** Setup a SPARQL query execution.
      * 
@@ -97,9 +97,9 @@ public interface SparqlQueryConnection extends Transactional, AutoCloseable
      * @param queryString 
      * @return QueryExecution
      */
-    public QueryExecution query(String queryString) ;
+    public QueryExecution query(String queryString);
     
     /** Close this connection.  Use with try-resource. */ 
-    @Override public void close() ;
+    @Override public void close();
 }
 

http://git-wip-us.apache.org/repos/asf/jena/blob/53758b5f/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/SparqlUpdateConnection.java
----------------------------------------------------------------------
diff --git a/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/SparqlUpdateConnection.java b/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/SparqlUpdateConnection.java
index 2428122..70b76e8 100644
--- a/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/SparqlUpdateConnection.java
+++ b/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/SparqlUpdateConnection.java
@@ -18,9 +18,9 @@
 
 package org.apache.jena.rdfconnection;
 
-import org.apache.jena.sparql.core.Transactional ;
-import org.apache.jena.update.Update ;
-import org.apache.jena.update.UpdateRequest ;
+import org.apache.jena.sparql.core.Transactional;
+import org.apache.jena.update.Update;
+import org.apache.jena.update.UpdateRequest;
 
 /** SPARQL Update Operations on a connection.
  * 
@@ -33,21 +33,21 @@ public interface SparqlUpdateConnection extends Transactional, AutoCloseable
      * 
      * @param update
      */
-    public void update(Update update) ;
+    public void update(Update update);
 
     /** Execute a SPARQL Update.
      * 
      * @param update
      */
-    public void update(UpdateRequest update) ; 
+    public void update(UpdateRequest update); 
     
     /** Execute a SPARQL Update.
      * 
      * @param updateString
      */
-    public void update(String updateString) ;
+    public void update(String updateString);
     
     /** Close this connection. */ 
-    @Override public void close() ;
+    @Override public void close();
 }
 


[10/11] jena git commit: Clean up jena-rdfconenction

Posted by an...@apache.org.
Clean up jena-rdfconenction


Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/5a70fb6f
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/5a70fb6f
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/5a70fb6f

Branch: refs/heads/master
Commit: 5a70fb6f85f722be1e6d1154304ba322797e8a1b
Parents: f1ef499
Author: Andy Seaborne <an...@apache.org>
Authored: Thu Dec 22 17:20:46 2016 +0000
Committer: Andy Seaborne <an...@apache.org>
Committed: Thu Dec 22 17:20:46 2016 +0000

----------------------------------------------------------------------
 jena-parent/pom.xml                             |   1 +
 jena-rdfconnection/Documentation.md             | 222 -------------------
 jena-rdfconnection/README.md                    |   6 -
 jena-rdfconnection/pom.xml                      |  13 +-
 .../apache/jena/rdfconnection/Isolation.java    |  20 +-
 pom.xml                                         |   7 +-
 6 files changed, 25 insertions(+), 244 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/5a70fb6f/jena-parent/pom.xml
----------------------------------------------------------------------
diff --git a/jena-parent/pom.xml b/jena-parent/pom.xml
index 7cb9edf..c2627c1 100644
--- a/jena-parent/pom.xml
+++ b/jena-parent/pom.xml
@@ -433,6 +433,7 @@
             <exclude>**/.project</exclude>
             <exclude>**/.settings/**</exclude>
             <exclude>**/.classpath</exclude>
+            <exclude>**/README.*</exclude>
             <exclude>**/META-INF/services/*</exclude>
             <!--
                 jena-core exclusions

http://git-wip-us.apache.org/repos/asf/jena/blob/5a70fb6f/jena-rdfconnection/Documentation.md
----------------------------------------------------------------------
diff --git a/jena-rdfconnection/Documentation.md b/jena-rdfconnection/Documentation.md
deleted file mode 100644
index e64eb67..0000000
--- a/jena-rdfconnection/Documentation.md
+++ /dev/null
@@ -1,222 +0,0 @@
-# RDF Connection : SPARQL operations API
-
-`RDFConnection` provides a unified set of operations for working on RDF
-with SPARQL operations. It provides <a
-href="http://www.w3.org/TR/sparql11-query/">SPARQL Query</a>, <a
-href="http://www.w3.org/TR/sparql11-update/">SPARQL Update</a> and the <a
-href="http://www.w3.org/TR/sparql11-http-rdf-update/">SPARQL Graph
-Store</a> operations.  The interface is uniform - the same interface
-applies to local data and to remote data using HTTP and the SPARQL
-protocols ( <a href="http://www.w3.org/TR/sparql11-protocol/">SPARQL
-protocol</a> and <a
-href="http://www.w3.org/TR/sparql11-http-rdf-update/">SPARQL Graph Store
-Protocol</a>).
-
-## Outline
-
-`RDFConnection` provides a number of different styles for working with RDF
-data in Java.  It provides support for try-resource and functional code
-passing styles, as well the more basic sequence of methods calls.
-
-For example: using `try-resources` to manage the connection, and perform two operations, one to load
-some data, and one to make a query can be written as:
-
-```
-try ( RDFConnection conn = RDFConnectionFactory.connect(...) ) {
-    conn.load("data.ttl") ;
-    conn.querySelect("SELECT DISTINCT ?s { ?s ?p ?o }", (qs)->
-       Resource subject = qs.getResource("s") ;
-       System.out.println("Subject: "+subject) ;
-    }) ;
-}
-```
-This could have been written as (approximately -- the error handling is better
-in the example above):
-
-```
-RDFConnection conn = RDFConnectionFactory.connect(...)
-conn.load("data.ttl") ;
-QueryExecution qExec = conn.query("SELECT DISTINCT ?s { ?s ?p ?o }") ;
-ResultSet rs = qExec.execSelect() ;
-while(rs.hasNext()) {
-    QuerySolution qs = rs.next() ;
-    Resource subject = qs.getResource("s") ;
-    System.out.println("Subject: "+subject) ;
-}
-qExec.close() ;
-conn.close() ;
-```
-
-Jena also provides a separate
-[SPARQL over JDBC driver](http://jena.staging.apache.org/documentation/jdbc/index.html)
-library.
-
-## Transactions
-
-Transactions are the preferred way to work with RDF data.
-Operations on an `RDFConnection` outside of an application-controlled
-transaction will cause the system to add one for the duration of the
-operation. This "autocommit" feature may lead to inefficient operations due
-to excessive overhead.
-
-The `Txn` class provides a Java8-style transaction API.  Transactions are
-code passed in the `Txn` library that handles the transaction lifecycle.
-
-```
-try ( RDFConnection conn = RDFConnectionFactory.connect(...) ) {
-    Txn.execWrite(conn, ()-> {
-        conn.load("data1.ttl") ;
-        conn.load("data2.ttl") ;
-        conn.querySelect("SELECT DISTINCT ?s { ?s ?p ?o }", (qs)->
-           Resource subject = qs.getResource("s") ;
-           System.out.println("Subject: "+subject) ;
-        }) ;
-    }) ;
-}
-```
-
-The traditional style of explicit `begin`, `commit`, `abort` is also available.
-
-```
-try ( RDFConnection conn = RDFConnectionFactory.connect(...) ) {
-    conn.begin(ReadWrite.WRITE) ;
-    try {
-        conn.load("data1.ttl") ;
-        conn.load("data2.ttl") ;
-        conn.querySelect("SELECT DISTINCT ?s { ?s ?p ?o }", (qs)->
-           Resource subject = qs.getResource("s") ;
-           System.out.println("Subject: "+subject) ;
-        }) ;
-        conn.commit() ;
-    } finally { conn.end() ; }
-}
-```
-
-The use of `try-finally` ensures that transactions are properly finished.
-The `conn.end()` provides an abort in case an exception occurs in the
-transaction and a commit has not been issued.  The use of `try-finally`
-ensures that transactions are properly finished.
-
-`Txn` is wrapping these steps up and calling the application supplied code
-for the transaction body.
-
-### Remote Transactions
-
-SPARQL does not define a remote transaction standard protocol. Each remote
-operation shuld be atomic (all happens or nothing happens) - this is the
-responsibility of the remote server.
-
-An `RDFConnection` will at least provide the client-side locking features.
-This means that overlapping operations that change data are naturally
-handled by the transaction pattern within a single JVM.
-
-## Graph Store Protocol
-
-The <a href="http://www.w3.org/TR/sparql11-http-rdf-update/">SPARQL Graph
-Store Protocol</a> (GSP) is a set of operations to work on whole graphs in a
-dataset.  It provides a standardised way to manage the data in a dataset.
-
-The operations are to fetch a graph, set the RDF data in a graph,
-add more RDF data into a graph, and delete a graph from a dataset.
-
-For example: load two files:
-```
-  try ( RDFConnection conn = RDFConnectionFactory.connect(...) ) {
-    conn.load("data1.ttl") ;
-    conn.load("data2.nt") ;
-  } 
-```
-The file extension is used to determine the syntax.
-
-There is also a set of scripts to help do these operations from the command
-line with <a href="http://jena.apache.org/documentation/fuseki2/soh.html"
->SOH</a>. It is possible to write curl scripts as well.  The SPARQL Graph
-Store Protocol provides a standardised way to manage the data in a dataset.
-
-In addition, `RDFConnection` provides an extension to give the same style
-of operation to work on a whole dataset (deleting the dataset is not
-provided).
-
-```
-    conn.loadDataset("data-complete.trig") ;
-```
-
-### Local vs Remote
-
-GSP operations work on while models and datasets. When used on a remote connection, 
-the result of a GSP operation is a separate copy of the remote RDF data.  When working
-with local connections, 3 isolations modes are available:
-
-* Copy &ndash; the models and datasets returned are independent copies.
-Updates are made to the return copy only. This is most like
-a remote connectionand is useful for testing.
-* Read-only &ndash; the models and datasets are made read-only but any changes
-to the underlying RDF data by changes by another route will be visible.
-This provides a form of checking for large datasets when "copy" is impractical.
-* None &ndash; the models and datasets are passed back with no additional wrappers
-and they can be updated with the changes being made the underlying dataset.
-
-The default for a local `RDFConnection` is "none".  
-
-## Query Usage
-
-`RDFConnection` provides methods for each of the SPARQL query forms (`SELECT`,
-`CONSTRUCT`, `DESCRIBE`, `ASK`) as well as a way to get the lower level
-`QueryExecution` for specialized configuration.
-
-When creating an `QueryExecution` explicitly, care shoud be taken to close
-it. If the application wishes to capture the result set from a SELECT query and
-retain it across the lifetime of the transaction or `QueryExecution`, then
-the application should create a copy which is not attached to any external system
-with `ResultSetFactory.copyResults`.
-
-```
-  try ( RDFConnection conn = RDFConnectionFactory.connect("foo") ) {
-      ResultSet safeCopy =
-          Txn.execReadReturn(conn, ()-> {
-              // Process results by row:
-              conn.querySelect("SELECT DISTINCT ?s { ?s ?p ?o }", (qs)->{
-                  Resource subject = qs.getResource("s") ;
-                  System.out.println("Subject: "+subject) ;
-              }) ;
-              ResultSet rs = conn.query("SELECT * { ?s ?p ?o }").execSelect() ;
-              return ResultSetFactory.copyResults(rs) ;
-          }) ;
-  }
-```
-
-## Update Usage
-
-SPARQL Update opertions can be performed and mixed with other operations.
-
-```
-  try ( RDFConnection conn = RDFConnectionFactory.connect(...) ) {
-      Txn.execWrite(conn, ()-> {
-         conn.update("DELETE DATA { ... }" ) ;
-         conn.load("data.ttl") ;
-         }) ;
-```
-
-## Dataset operations
-
-In addition to the SPARQL Graph Store Protocol, operations on whole
-datasets are provided for fetching (HTTP GET), adding data (HTTP POST) and
-setting the data (HTTP PUT) on a dataset URL.  This assumes the remote
-server supported these REST-style operations.  Apache Jena Fuseki does
-provide these.
-
-## Subinterfaces
-
-To help structure code, the `RDFConnection` consists of a number of
-different interfaces.  An `RDFConnection` can be passed to application code
-as one of these interfaces so that only certain subsets of the full
-operations are visible to the called code.
-
-* query via `SparqlQueryConnection`
-* update via `SparqlUpdateConnection`
-* graph store protocol `RDFDatasetAccessConnection` (read operations),
-   and `RDFDatasetConnection` (read and write operations).
-
-## Examples
-
-https://github.com/apache/jena/jena-rdfconnection/tree/master/src/main/java/rdfconnection/examples

http://git-wip-us.apache.org/repos/asf/jena/blob/5a70fb6f/jena-rdfconnection/README.md
----------------------------------------------------------------------
diff --git a/jena-rdfconnection/README.md b/jena-rdfconnection/README.md
deleted file mode 100644
index 1fee5e2..0000000
--- a/jena-rdfconnection/README.md
+++ /dev/null
@@ -1,6 +0,0 @@
-RDF Connection
-==============
-
-An API for SPARQL client functionality.
-
-Works for local and remote data.

http://git-wip-us.apache.org/repos/asf/jena/blob/5a70fb6f/jena-rdfconnection/pom.xml
----------------------------------------------------------------------
diff --git a/jena-rdfconnection/pom.xml b/jena-rdfconnection/pom.xml
index d2173c3..ba7d9d1 100644
--- a/jena-rdfconnection/pom.xml
+++ b/jena-rdfconnection/pom.xml
@@ -48,9 +48,8 @@
   <dependencies>
     <dependency>
       <groupId>org.apache.jena</groupId>
-      <artifactId>apache-jena-libs</artifactId>
+      <artifactId>jena-arq</artifactId>
       <version>3.2.0-SNAPSHOT</version>
-      <type>pom</type>
     </dependency>
 
     <dependency>
@@ -147,16 +146,6 @@
         <artifactId>maven-resources-plugin</artifactId>
       </plugin>
 
-      <plugin>
-        <groupId>org.apache.rat</groupId>
-        <artifactId>apache-rat-plugin</artifactId>
-        <configuration>
-          <excludes>
-            <exclude>Documentation.md</exclude>
-            <exclude>README.*</exclude>
-          </excludes>
-        </configuration>
-      </plugin>
     </plugins>
 
   </build>

http://git-wip-us.apache.org/repos/asf/jena/blob/5a70fb6f/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/Isolation.java
----------------------------------------------------------------------
diff --git a/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/Isolation.java b/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/Isolation.java
index 79c496f..1260801 100644
--- a/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/Isolation.java
+++ b/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/Isolation.java
@@ -1,5 +1,23 @@
+/*
+ * 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;
+
 public enum Isolation { COPY, READONLY, NONE }
 
-// XXX Expose copy-mode?
 

http://git-wip-us.apache.org/repos/asf/jena/blob/5a70fb6f/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 9b005e3..82c9fd4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -72,8 +72,8 @@
         
         <module>jena-core</module>
         <module>jena-arq</module>
-        <module>jena-tdb</module>
         <module>jena-rdfconnection</module>
+        <module>jena-tdb</module>
         <module>apache-jena-libs</module>
         <module>jena-cmds</module>
         
@@ -144,8 +144,8 @@
 
         <module>jena-core</module>
         <module>jena-arq</module>
-        <module>jena-tdb</module>
         <module>jena-rdfconnection</module>
+        <module>jena-tdb</module>
         <module>apache-jena-libs</module>
         <module>jena-cmds</module>
 
@@ -157,7 +157,6 @@
 
         <module>jena-fuseki1</module>
         <module>jena-fuseki2</module>
-        <module>jena-permissions</module>
 
         <!--
             Tests of artifacts that require additional 
@@ -167,6 +166,8 @@
         -->
         <module>jena-integration-tests</module>
 
+        <module>jena-permissions</module>
+
         <module>jena-jdbc</module>
         <!-- Removed because this breaks the build after the 
              upgrade of Apache parent PM to v18 - see JENA-1184 


[04/11] jena git commit: JENA-1267: Wire in jena-rdfconnection and jena-integration-tests

Posted by an...@apache.org.
JENA-1267: Wire in jena-rdfconnection and jena-integration-tests


Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/ac1ad26f
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/ac1ad26f
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/ac1ad26f

Branch: refs/heads/master
Commit: ac1ad26febd9db92f58d83b46f3e419ce2316b71
Parents: 89b1027
Author: Andy Seaborne <an...@apache.org>
Authored: Fri Dec 16 15:03:17 2016 +0000
Committer: Andy Seaborne <an...@apache.org>
Committed: Fri Dec 16 15:03:17 2016 +0000

----------------------------------------------------------------------
 apache-jena-libs/pom.xml                        |  6 ++++++
 apache-jena/pom.xml                             | 22 ++++++++++++++++++++
 .../org/apache/jena/riot/system/Serializer.java |  2 +-
 pom.xml                                         | 22 ++++++++++++++------
 4 files changed, 45 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/ac1ad26f/apache-jena-libs/pom.xml
----------------------------------------------------------------------
diff --git a/apache-jena-libs/pom.xml b/apache-jena-libs/pom.xml
index 1b35e63..9b3a6dd 100644
--- a/apache-jena-libs/pom.xml
+++ b/apache-jena-libs/pom.xml
@@ -46,6 +46,12 @@
       <version>3.2.0-SNAPSHOT</version>
     </dependency>
 
+    <dependency>
+      <groupId>org.apache.jena</groupId>
+      <artifactId>jena-rdfconnection</artifactId>
+      <version>3.2.0-SNAPSHOT</version>
+    </dependency>
+
   </dependencies>
 
 </project>

http://git-wip-us.apache.org/repos/asf/jena/blob/ac1ad26f/apache-jena/pom.xml
----------------------------------------------------------------------
diff --git a/apache-jena/pom.xml b/apache-jena/pom.xml
index a5aac4c..11aad0b 100644
--- a/apache-jena/pom.xml
+++ b/apache-jena/pom.xml
@@ -125,6 +125,28 @@
 
     <dependency>
       <groupId>org.apache.jena</groupId>
+      <artifactId>jena-rdfconnection</artifactId>
+      <version>3.2.0-SNAPSHOT</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.jena</groupId>
+      <artifactId>jena-rdfconnection</artifactId>
+      <version>3.2.0-SNAPSHOT</version>
+      <classifier>sources</classifier>
+      <optional>true</optional>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.jena</groupId>
+      <artifactId>jena-rdfconnection</artifactId>
+      <version>3.2.0-SNAPSHOT</version>
+      <classifier>javadoc</classifier>
+      <optional>true</optional>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.jena</groupId>
       <artifactId>jena-cmds</artifactId>
       <version>3.2.0-SNAPSHOT</version>
     </dependency>

http://git-wip-us.apache.org/repos/asf/jena/blob/ac1ad26f/jena-arq/src/main/java/org/apache/jena/riot/system/Serializer.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/riot/system/Serializer.java b/jena-arq/src/main/java/org/apache/jena/riot/system/Serializer.java
index 1c2e090..eb64cb5 100644
--- a/jena-arq/src/main/java/org/apache/jena/riot/system/Serializer.java
+++ b/jena-arq/src/main/java/org/apache/jena/riot/system/Serializer.java
@@ -27,7 +27,7 @@ import org.apache.jena.sparql.core.Quad;
  * This class is public to allow system initialization to inject
  * handler functions for {@link Quad}.
  * 
- * See also {@code Node} and {@ocde Triple}.  
+ * See also {@code Node} and {@code Triple}.  
  */
 public class Serializer {
     /*package*/ static Function<Quad, Object> quadWriteReplaceFunction = null;

http://git-wip-us.apache.org/repos/asf/jena/blob/ac1ad26f/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 932fee3..af6a72c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -25,7 +25,6 @@
   <url>http://jena.apache.org/</url>
   <version>3.2.0-SNAPSHOT</version>
 
-  <!-- Needed for -Papache-release -->
   <!-- The org.apache:apache version is also in jena-parent pom.xml -->
   <parent>
     <groupId>org.apache</groupId>
@@ -73,7 +72,8 @@
         
         <module>jena-core</module>
         <module>jena-arq</module>
-        <module>jena-tdb</module> 
+        <module>jena-tdb</module>
+        <module>jena-rdfconnection</module>
         <module>apache-jena-libs</module>
         <module>jena-cmds</module>
         
@@ -82,6 +82,8 @@
         <!--<module>jena-fuseki1</module>-->
         <module>jena-fuseki2</module>
 
+        <module>jena-integration-tests</module>
+
         <module>jena-permissions</module>
 
         <!-- Slow to build - exclude from dev build -->
@@ -95,10 +97,11 @@
     </profile>
 
     <profile>
-      <!-- From the start, up until profile "dev"
-           Use this is building lcoally and there are no SNAPSHOTs
-           in the "snapshots" repository.
-           This profile does a more complete "dev" build
+      <!-- From the start, up until profile "dev".
+           Use this (or a full build) when building locally
+           and there are no SNAPSHOTs in the "snapshots" repository.
+           This profile does a more complete "dev" build,
+           does not assume anything is already built,
            and does not include the longer running modules.
       -->
       
@@ -142,6 +145,7 @@
         <module>jena-core</module>
         <module>jena-arq</module>
         <module>jena-tdb</module>
+        <module>jena-rdfconnection</module>
         <module>apache-jena-libs</module>
         <module>jena-cmds</module>
 
@@ -155,6 +159,12 @@
         <module>jena-fuseki2</module>
         <module>jena-permissions</module>
 
+        <!-- Tests of artifacts that require 
+             For example, use Fuseki as a test server
+             to test remote client APIs.
+        -->
+        <module>jena-integration-tests</module>
+
         <module>jena-jdbc</module>
         <!-- Removed because this breaks the build after the 
              upgrade of Apache parent PM to v18 - see JENA-1184 


[03/11] jena git commit: Module jena-integration-tests

Posted by an...@apache.org.
Module jena-integration-tests


Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/89b1027f
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/89b1027f
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/89b1027f

Branch: refs/heads/master
Commit: 89b1027f0068bf1396bde82c37467c0a3d0bdf68
Parents: 2e26b78
Author: Andy Seaborne <an...@apache.org>
Authored: Fri Dec 16 15:02:28 2016 +0000
Committer: Andy Seaborne <an...@apache.org>
Committed: Fri Dec 16 15:02:28 2016 +0000

----------------------------------------------------------------------
 jena-integration-tests/LICENSE                  | 177 +++++++++
 jena-integration-tests/NOTICE                   |   4 +
 jena-integration-tests/README.md                |  11 +
 jena-integration-tests/pom.xml                  | 146 +++++++
 .../AbstractTestRDFConnection.java              | 382 +++++++++++++++++++
 .../test/rdfconnection/TS_RDFConnection2.java   |  36 ++
 .../TestRDFConnectionLocalMRSW.java             |  39 ++
 .../TestRDFConnectionLocalTDB.java              |  38 ++
 .../TestRDFConnectionLocalTxnMem.java           |  39 ++
 .../rdfconnection/TestRDFConnectionRemote.java  |  78 ++++
 .../src/test/resources/log4j.properties         |  40 ++
 .../testing/RDFConnection/data.trig             |  16 +
 .../testing/RDFConnection/data.ttl              |   6 +
 13 files changed, 1012 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/89b1027f/jena-integration-tests/LICENSE
----------------------------------------------------------------------
diff --git a/jena-integration-tests/LICENSE b/jena-integration-tests/LICENSE
new file mode 100644
index 0000000..f433b1a
--- /dev/null
+++ b/jena-integration-tests/LICENSE
@@ -0,0 +1,177 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS

http://git-wip-us.apache.org/repos/asf/jena/blob/89b1027f/jena-integration-tests/NOTICE
----------------------------------------------------------------------
diff --git a/jena-integration-tests/NOTICE b/jena-integration-tests/NOTICE
new file mode 100644
index 0000000..485d658
--- /dev/null
+++ b/jena-integration-tests/NOTICE
@@ -0,0 +1,4 @@
+Apache Jena - Integration Tests
+Copyright 2016 The Apache Software Foundation
+
+This code is licensed under an Apache Software License.

http://git-wip-us.apache.org/repos/asf/jena/blob/89b1027f/jena-integration-tests/README.md
----------------------------------------------------------------------
diff --git a/jena-integration-tests/README.md b/jena-integration-tests/README.md
new file mode 100644
index 0000000..77f4df8
--- /dev/null
+++ b/jena-integration-tests/README.md
@@ -0,0 +1,11 @@
+Jena Intrgration Tests
+======================
+
+This module provides testing of components where testing depends on
+infrastructure not avilable, due to dependency relationships, to the
+module.
+
+For example, tests of RDF Connection for remote access that use embedded
+Fuseki.  RDF Connection code does not itself depend on embedded Fuseki
+and exists earlier in the build order than Fuseki.
+

http://git-wip-us.apache.org/repos/asf/jena/blob/89b1027f/jena-integration-tests/pom.xml
----------------------------------------------------------------------
diff --git a/jena-integration-tests/pom.xml b/jena-integration-tests/pom.xml
new file mode 100644
index 0000000..9dca002
--- /dev/null
+++ b/jena-integration-tests/pom.xml
@@ -0,0 +1,146 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+   Licensed 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.
+ 
+   See the NOTICE file distributed with this work for additional
+   information regarding copyright ownership.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" 
+	 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.jena</groupId>
+  <artifactId>jena-integration-tests</artifactId>
+  <packaging>jar</packaging>
+  <name>Apache Jena - Integration Testing</name>
+  <version>3.2.0-SNAPSHOT</version>
+
+  <description>Apache Jena - Integration Testing</description>
+
+  <parent>
+    <groupId>org.apache.jena</groupId>
+    <artifactId>jena-parent</artifactId>
+    <version>18-SNAPSHOT</version>
+    <relativePath>../jena-parent</relativePath>
+  </parent>
+
+  <licenses>
+    <license>
+      <name>Apache 2.0 License</name>
+      <url>http://www.apache.org/licenses/LICENSE-2.0</url>
+    </license>
+  </licenses>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.jena</groupId>
+      <artifactId>apache-jena-libs</artifactId>
+      <version>3.2.0-SNAPSHOT</version>
+      <type>pom</type>
+    </dependency>
+
+    <!-- Modules that have tests here -->
+    <dependency>
+      <groupId>org.apache.jena</groupId>
+      <artifactId>jena-rdfconnection</artifactId>
+      <version>3.2.0-SNAPSHOT</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.jena</groupId>
+      <artifactId>jena-rdfconnection</artifactId>
+      <version>3.2.0-SNAPSHOT</version>
+      <classifier>tests</classifier>
+      <scope>test</scope>
+    </dependency>
+
+    <!-- The test artifacts to go with apache-jena-libs -->
+    <dependency>
+      <groupId>org.apache.jena</groupId>
+      <artifactId>jena-base</artifactId>
+      <version>3.2.0-SNAPSHOT</version>
+      <classifier>tests</classifier>
+      <scope>test</scope>
+    </dependency>
+    
+    <dependency>
+      <groupId>org.apache.jena</groupId>
+      <artifactId>jena-core</artifactId>
+      <classifier>tests</classifier>
+      <version>3.2.0-SNAPSHOT</version>
+      <scope>test</scope>
+    </dependency>    
+
+    <dependency>
+      <groupId>org.apache.jena</groupId>
+      <artifactId>jena-arq</artifactId>
+      <version>3.2.0-SNAPSHOT</version>
+      <classifier>tests</classifier>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.jena</groupId>
+      <artifactId>jena-fuseki-embedded</artifactId>
+      <version>2.5.0-SNAPSHOT</version>
+      <scope>test</scope>
+    </dependency>   
+    
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-log4j12</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>log4j</groupId>
+      <artifactId>log4j</artifactId>
+      <scope>test</scope>
+    </dependency> 
+
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+  <build>
+
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <configuration>
+          <includes>
+            <include>**/TS_*.java</include>
+          </includes>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-resources-plugin</artifactId>
+      </plugin>
+    </plugins>
+
+  </build>
+
+</project>

http://git-wip-us.apache.org/repos/asf/jena/blob/89b1027f/jena-integration-tests/src/test/java/org/apache/jena/test/rdfconnection/AbstractTestRDFConnection.java
----------------------------------------------------------------------
diff --git a/jena-integration-tests/src/test/java/org/apache/jena/test/rdfconnection/AbstractTestRDFConnection.java b/jena-integration-tests/src/test/java/org/apache/jena/test/rdfconnection/AbstractTestRDFConnection.java
new file mode 100644
index 0000000..9b3a65f
--- /dev/null
+++ b/jena-integration-tests/src/test/java/org/apache/jena/test/rdfconnection/AbstractTestRDFConnection.java
@@ -0,0 +1,382 @@
+/*
+ * 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.test.rdfconnection;
+
+import java.util.concurrent.atomic.AtomicInteger ;
+
+import org.apache.jena.atlas.iterator.Iter ;
+import org.apache.jena.atlas.junit.BaseTest ;
+import org.apache.jena.atlas.lib.StrUtils ;
+import org.apache.jena.query.Dataset ;
+import org.apache.jena.query.DatasetFactory ;
+import org.apache.jena.query.ReadWrite ;
+import org.apache.jena.rdf.model.Model ;
+import org.apache.jena.rdf.model.ModelFactory ;
+import org.apache.jena.rdfconnection.RDFConnection;
+import org.apache.jena.riot.RDFDataMgr ;
+import org.apache.jena.sparql.core.DatasetGraph ;
+import org.apache.jena.sparql.sse.SSE ;
+import org.apache.jena.sparql.util.IsoMatcher ;
+import org.apache.jena.system.Txn ;
+import org.junit.Assume ;
+import org.junit.Test ;
+
+public abstract class AbstractTestRDFConnection extends BaseTest {
+    // Testing data.
+    static String DIR = "testing/RDFConnection/" ;
+    
+    protected abstract RDFConnection connection() ;
+    // Not all RDFConenction types support.
+    //  (may acquite RDFConnection.supportTransactionalAbort but ATM that isn't included)
+    protected abstract boolean supportsAbort() ; 
+
+    // ---- Data
+    static String dsgdata = StrUtils.strjoinNL
+        ("(dataset"
+        ,"  (graph (:s :p :o) (:s0 :p0 _:a))"
+        ,"  (graph :g1 (:s :p :o) (:s1 :p1 :o1))"
+        ,"  (graph :g2 (:s :p :o) (:s2 :p2 :o))"
+        ,")"
+        ) ;
+    
+    static String dsgdata2 = StrUtils.strjoinNL
+        ("(dataset"
+        ,"  (graph (:x :y :z))"
+        ,"  (graph :g9 (:s :p :o))"
+        ,")"
+        ) ;
+
+    
+    static String graph1 = StrUtils.strjoinNL
+        ("(graph (:s :p :o) (:s1 :p1 :o))"
+        ) ;
+
+    static String graph2 = StrUtils.strjoinNL
+        ("(graph (:s :p :o) (:s2 :p2 :o))"
+        ) ;
+    
+    static DatasetGraph dsg        = SSE.parseDatasetGraph(dsgdata);
+    static Dataset      dataset    = DatasetFactory.wrap(dsg);
+    static DatasetGraph dsg2       = SSE.parseDatasetGraph(dsgdata2);
+    static Dataset      dataset2   = DatasetFactory.wrap(dsg2);
+
+    static String       graphName  = "http://test/graph";
+    static String       graphName2 = "http://test/graph2";
+    static Model        model1     = ModelFactory.createModelForGraph(SSE.parseGraph(graph1));
+    static Model        model2     = ModelFactory.createModelForGraph(SSE.parseGraph(graph2));
+    // ---- Data
+
+    @Test public void connect_01() {
+        @SuppressWarnings("resource")
+        RDFConnection conn = connection() ;
+        assertFalse(conn.isClosed()) ;
+        conn.close() ;
+        assertTrue(conn.isClosed()) ;
+        // Allow multiple close()
+        conn.close() ;
+    }
+    
+    @Test public void dataset_load_1() {
+        String testDataFile = DIR+"data.trig" ; 
+        try ( RDFConnection conn = connection() ) {
+            conn.loadDataset(testDataFile);
+            Dataset ds0 = RDFDataMgr.loadDataset(testDataFile) ;
+            Dataset ds = conn.fetchDataset() ;
+            assertTrue("Datasets not isomorphic", isomorphic(ds0, ds)) ;
+        }
+    }
+
+    @Test public void dataset_put_1() {
+        try ( RDFConnection conn = connection() ) {
+            conn.putDataset(dataset) ; 
+            Dataset ds1 = conn.fetchDataset() ;
+            assertTrue("Datasets not isomorphic", isomorphic(dataset, ds1)) ;
+        }
+    }
+
+    @Test public void dataset_put_2() {
+        try ( RDFConnection conn = connection() ) {
+            conn.putDataset(dataset) ; 
+            conn.putDataset(dataset2) ;
+            Dataset ds1 = conn.fetchDataset() ;
+            assertTrue("Datasets not isomorphic", isomorphic(dataset2, ds1)) ;
+        }
+    }
+
+    @Test public void dataset_post_1() {
+        try ( RDFConnection conn = connection() ) {
+            conn.loadDataset(dataset);
+            Dataset ds1 = conn.fetchDataset() ;
+            assertTrue("Datasets not isomorphic", isomorphic(dataset, ds1)) ;
+        }
+    }
+    
+    @Test public void dataset_post_2() {
+        try ( RDFConnection conn = connection() ) {
+            conn.loadDataset(dataset);
+            conn.loadDataset(dataset2);
+            Dataset ds1 = conn.fetchDataset() ;
+            long x = Iter.count(ds1.listNames()) ;
+            assertEquals("NG count", 3, x) ;
+            assertFalse("Datasets are isomorphic", isomorphic(dataset, ds1)) ;
+            assertFalse("Datasets are isomorphic", isomorphic(dataset2, ds1)) ;
+        }
+    }
+
+    // Default graph
+    
+    @Test public void graph_load_1() {
+        String testDataFile = DIR+"data.ttl" ; 
+        Model m0 = RDFDataMgr.loadModel(testDataFile) ;
+        try ( RDFConnection conn = connection() ) {
+            conn.load(testDataFile);
+            Model m = conn.fetch() ;
+            assertTrue("Models not isomorphic", isomorphic(m0, m)) ;
+        }
+    }
+
+    @Test public void graph_put_1() {
+        try ( RDFConnection conn = connection() ) {
+            conn.put(model1); 
+            Dataset ds1 = conn.fetchDataset() ;
+            Model m0 = conn.fetch() ;
+            assertTrue("Models not isomorphic", isomorphic(model1, ds1.getDefaultModel())) ;
+            Model m = conn.fetch() ;
+            assertTrue("Models not isomorphic", isomorphic(model1, m)) ;
+        }
+    }
+
+    @Test public void graph_put_2() {
+        try ( RDFConnection conn = connection() ) {
+            conn.put(model1) ; 
+            conn.put(model2) ;
+            Model m = conn.fetch() ;
+            assertTrue("Models not isomorphic", isomorphic(m, model2)) ;
+            assertFalse("Models not isomorphic", isomorphic(m, model1)) ;
+        }
+    }
+
+    @Test public void graph_post_1() {
+        try ( RDFConnection conn = connection() ) {
+            conn.load(model1) ;
+            Model m = conn.fetch() ;
+            assertTrue("Models not isomorphic", isomorphic(m, model1)) ;
+        }
+    }
+    
+    @Test public void graph_post_2() {
+        try ( RDFConnection conn = connection() ) {
+            conn.load(model1) ;
+            conn.load(model2) ;
+            Model m = conn.fetch() ;
+            Model m0 = ModelFactory.createUnion(model2, model1) ;
+            assertTrue("Models are not isomorphic", isomorphic(m0, m)) ;
+        }
+    }
+
+    // DELETE
+    
+    // Named graphs
+    
+    @Test public void named_graph_load_1() {
+        String testDataFile = DIR+"data.ttl" ; 
+        Model m0 = RDFDataMgr.loadModel(testDataFile) ;
+        try ( RDFConnection conn = connection() ) {
+            conn.load(graphName, testDataFile);
+            Model m = conn.fetch(graphName) ;
+            assertTrue("Models not isomorphic", isomorphic(m0, m)) ;
+            Model mDft = conn.fetch() ;
+            assertTrue(mDft.isEmpty()) ;
+        }
+    }
+
+    @Test public void named_graph_put_1() {
+        try ( RDFConnection conn = connection() ) {
+            conn.put(graphName, model1); 
+            Dataset ds1 = conn.fetchDataset() ;
+            Model m0 = conn.fetch(graphName) ;
+            assertTrue("Models not isomorphic", isomorphic(model1, ds1.getNamedModel(graphName))) ;
+            Model m = conn.fetch(graphName) ;
+            assertTrue("Models not isomorphic", isomorphic(model1, m)) ;
+        }
+    }
+
+    @Test public void named_graph_put_2() {
+        try ( RDFConnection conn = connection() ) {
+            conn.put(graphName, model1) ; 
+            conn.put(graphName, model2) ;
+            Model m = conn.fetch(graphName) ;
+            assertTrue("Models not isomorphic", isomorphic(m, model2)) ;
+            assertFalse("Models not isomorphic", isomorphic(m, model1)) ;
+        }
+    }
+
+    @Test public void named_graph_put_2_different() {
+        try ( RDFConnection conn = connection() ) {
+            conn.put(graphName, model1) ; 
+            conn.put(graphName2, model2) ;
+            Model m1 = conn.fetch(graphName) ;
+            Model m2 = conn.fetch(graphName2) ;
+            assertTrue("Models not isomorphic", isomorphic(m1, model1)) ;
+            assertTrue("Models not isomorphic", isomorphic(m2, model2)) ;
+        }
+    }
+
+    @Test public void named_graph_post_1() {
+        try ( RDFConnection conn = connection() ) {
+            conn.load(graphName, model1) ;
+            Model m = conn.fetch(graphName) ;
+            assertTrue("Models not isomorphic", isomorphic(m, model1)) ;
+        }
+    }
+    
+    @Test public void named_graph_post_2() {
+        try ( RDFConnection conn = connection() ) {
+            conn.load(graphName, model1) ;
+            conn.load(graphName, model2) ;
+            Model m = conn.fetch(graphName) ;
+            Model m0 = ModelFactory.createUnion(model2, model1) ;
+            assertTrue("Models are not isomorphic", isomorphic(m0, m)) ;
+        }
+    }
+
+    // DELETE
+    
+    // Remote connections don't support transactions fully.  
+    //@Test public void transaction_01() 
+
+    private static boolean isomorphic(Dataset ds1, Dataset ds2) {
+        return IsoMatcher.isomorphic(ds1.asDatasetGraph(), ds2.asDatasetGraph()) ;
+    }
+    
+    private static boolean isomorphic(Model model1, Model model2) {
+        return model1.isIsomorphicWith(model2) ;
+    }
+    
+
+    @Test public void query_ask_01() {
+        try ( RDFConnection conn = connection() ) {
+            Txn.executeRead(conn, ()->{
+                boolean b = conn.queryAsk("ASK{}") ;
+                assertTrue(b) ;
+            }) ;
+        }
+    }
+
+    @Test public void query_ask_02() {
+        try ( RDFConnection conn = connection() ) {
+            boolean b = conn.queryAsk("ASK{}") ;
+            assertTrue(b) ;
+        }
+    }
+
+    @Test public void query_select_01() {
+        AtomicInteger counter = new AtomicInteger(0) ;
+        try ( RDFConnection conn = connection() ) {
+            Txn.executeWrite(conn, ()->conn.loadDataset(DIR+"data.trig"));
+            Txn.executeRead(conn, ()->
+                conn.querySelect("SELECT * { ?s ?p ?o }" , (r)->counter.incrementAndGet()));
+            assertEquals(2, counter.get()) ;
+        }
+    }
+
+    @Test public void query_select_02() {
+        AtomicInteger counter = new AtomicInteger(0) ;
+        try ( RDFConnection conn = connection() ) {
+            conn.loadDataset(DIR+"data.trig");
+            conn.querySelect("SELECT * { ?s ?p ?o}" , (r)->counter.incrementAndGet());
+            assertEquals(2, counter.get()) ;
+        }
+    }
+
+    @Test public void query_construct_01() {
+        try ( RDFConnection conn = connection() ) {
+            Txn.executeWrite(conn, ()->conn.loadDataset(DIR+"data.trig"));
+            Txn.executeRead(conn, ()-> {
+                Model m = conn.queryConstruct("CONSTRUCT WHERE { ?s ?p ?o }") ;
+                assertEquals(2, m.size()) ;
+            }) ;
+        }
+    }
+
+    @Test public void query_construct_02() {
+        try ( RDFConnection conn = connection() ) {
+            conn.loadDataset(DIR+"data.trig");
+            Model m = conn.queryConstruct("CONSTRUCT WHERE { ?s ?p ?o }") ;
+            assertEquals(2, m.size()) ;
+        }
+    }
+    
+    @Test public void update_01() {
+        try ( RDFConnection conn = connection() ) {
+            conn.update("INSERT DATA { <urn:x:s> <urn:x:p> <urn:x:o>}");
+        }
+    }
+
+    @Test public void update_02() {
+        try ( RDFConnection conn = connection() ) {
+            Txn.executeWrite(conn, ()->conn.update("INSERT DATA { <urn:x:s> <urn:x:p> <urn:x:o>}")) ;
+        }
+    }
+
+    // Not all Transactional support abort.
+    @Test public void transaction_commit_read_01() {
+        String testDataFile = DIR+"data.trig" ; 
+        try ( RDFConnection conn = connection() ) {
+
+            conn.begin(ReadWrite.WRITE) ;
+            conn.loadDataset(dataset);
+            conn.commit() ;
+            conn.end();
+            
+            conn.begin(ReadWrite.READ) ;
+            Model m = conn.fetch() ;
+            assertTrue(isomorphic(m, dataset.getDefaultModel())) ;
+            conn.end() ;
+        }
+    }
+    
+    // Not all RDFConnections support abort.
+    @Test public void transaction_abort_read02() {
+        Assume.assumeTrue(supportsAbort()) ;
+        
+        String testDataFile = DIR+"data.trig" ; 
+        try ( RDFConnection conn = connection() ) {
+            conn.begin(ReadWrite.WRITE) ;
+            conn.loadDataset(testDataFile);
+            conn.abort();
+            conn.end();
+            
+            conn.begin(ReadWrite.READ) ;
+            Model m = conn.fetch() ;
+            assertTrue(m.isEmpty()) ;
+            conn.end() ;
+        }
+    }
+
+    //@Test(expected=JenaTransactionException.class)
+    public void transaction_bad_01() {
+        try ( RDFConnection conn = connection() ) {
+            conn.begin(ReadWrite.WRITE) ;
+            // Should have conn.commit() ;
+            conn.end();
+        }
+    }
+}
+

http://git-wip-us.apache.org/repos/asf/jena/blob/89b1027f/jena-integration-tests/src/test/java/org/apache/jena/test/rdfconnection/TS_RDFConnection2.java
----------------------------------------------------------------------
diff --git a/jena-integration-tests/src/test/java/org/apache/jena/test/rdfconnection/TS_RDFConnection2.java b/jena-integration-tests/src/test/java/org/apache/jena/test/rdfconnection/TS_RDFConnection2.java
new file mode 100644
index 0000000..55a0dff
--- /dev/null
+++ b/jena-integration-tests/src/test/java/org/apache/jena/test/rdfconnection/TS_RDFConnection2.java
@@ -0,0 +1,36 @@
+/*
+ * 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.test.rdfconnection;
+
+import org.junit.runner.RunWith ;
+import org.junit.runners.Suite ;
+
+@RunWith(Suite.class)
+@Suite.SuiteClasses( {
+    // Done in the module
+//    TestRDFConnectionLocalTxnMem.class ,
+//    TestRDFConnectionLocalMRSW.class ,
+    
+    // Addition tests added here.
+    TestRDFConnectionLocalTDB.class ,
+    TestRDFConnectionRemote.class
+})
+
+public class TS_RDFConnection2 {}
+

http://git-wip-us.apache.org/repos/asf/jena/blob/89b1027f/jena-integration-tests/src/test/java/org/apache/jena/test/rdfconnection/TestRDFConnectionLocalMRSW.java
----------------------------------------------------------------------
diff --git a/jena-integration-tests/src/test/java/org/apache/jena/test/rdfconnection/TestRDFConnectionLocalMRSW.java b/jena-integration-tests/src/test/java/org/apache/jena/test/rdfconnection/TestRDFConnectionLocalMRSW.java
new file mode 100644
index 0000000..8bc82ff
--- /dev/null
+++ b/jena-integration-tests/src/test/java/org/apache/jena/test/rdfconnection/TestRDFConnectionLocalMRSW.java
@@ -0,0 +1,39 @@
+/*
+ * 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.test.rdfconnection;
+
+import org.apache.jena.query.Dataset ;
+import org.apache.jena.query.DatasetFactory ;
+import org.apache.jena.rdfconnection.AbstractTestRDFConnection;
+import org.apache.jena.rdfconnection.RDFConnection;
+import org.apache.jena.rdfconnection.RDFConnectionFactory;
+
+public class TestRDFConnectionLocalMRSW extends AbstractTestRDFConnection {
+
+    @Override
+    protected boolean supportsAbort() { return false ; }
+    
+    @Override
+    protected RDFConnection connection() {
+        // General purpose, mixed storage, MRSW dataset.  
+        Dataset ds = DatasetFactory.create() ;
+        return RDFConnectionFactory.connect(ds) ;
+    }
+}
+

http://git-wip-us.apache.org/repos/asf/jena/blob/89b1027f/jena-integration-tests/src/test/java/org/apache/jena/test/rdfconnection/TestRDFConnectionLocalTDB.java
----------------------------------------------------------------------
diff --git a/jena-integration-tests/src/test/java/org/apache/jena/test/rdfconnection/TestRDFConnectionLocalTDB.java b/jena-integration-tests/src/test/java/org/apache/jena/test/rdfconnection/TestRDFConnectionLocalTDB.java
new file mode 100644
index 0000000..366d73b
--- /dev/null
+++ b/jena-integration-tests/src/test/java/org/apache/jena/test/rdfconnection/TestRDFConnectionLocalTDB.java
@@ -0,0 +1,38 @@
+/*
+ * 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.test.rdfconnection;
+
+import org.apache.jena.query.Dataset ;
+import org.apache.jena.rdfconnection.AbstractTestRDFConnection;
+import org.apache.jena.rdfconnection.RDFConnection;
+import org.apache.jena.rdfconnection.RDFConnectionFactory;
+import org.apache.jena.tdb.TDBFactory ;
+
+public class TestRDFConnectionLocalTDB extends AbstractTestRDFConnection {
+    
+    @Override
+    protected boolean supportsAbort() { return true ; }
+    
+    @Override
+    protected RDFConnection connection() {
+        Dataset ds = TDBFactory.createDataset() ;
+        return RDFConnectionFactory.connect(ds) ;
+    }
+}
+

http://git-wip-us.apache.org/repos/asf/jena/blob/89b1027f/jena-integration-tests/src/test/java/org/apache/jena/test/rdfconnection/TestRDFConnectionLocalTxnMem.java
----------------------------------------------------------------------
diff --git a/jena-integration-tests/src/test/java/org/apache/jena/test/rdfconnection/TestRDFConnectionLocalTxnMem.java b/jena-integration-tests/src/test/java/org/apache/jena/test/rdfconnection/TestRDFConnectionLocalTxnMem.java
new file mode 100644
index 0000000..dd50553
--- /dev/null
+++ b/jena-integration-tests/src/test/java/org/apache/jena/test/rdfconnection/TestRDFConnectionLocalTxnMem.java
@@ -0,0 +1,39 @@
+/*
+ * 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.test.rdfconnection;
+
+import org.apache.jena.query.Dataset ;
+import org.apache.jena.query.DatasetFactory ;
+import org.apache.jena.rdfconnection.AbstractTestRDFConnection;
+import org.apache.jena.rdfconnection.RDFConnection;
+import org.apache.jena.rdfconnection.RDFConnectionFactory;
+
+public class TestRDFConnectionLocalTxnMem extends AbstractTestRDFConnection {
+
+    @Override
+    protected boolean supportsAbort() { return true ; }
+
+    @Override
+    protected RDFConnection connection() {
+        // Full transactional in-memory dataset.  
+        Dataset ds = DatasetFactory.createTxnMem() ;
+        return RDFConnectionFactory.connect(ds) ;
+    }
+}
+

http://git-wip-us.apache.org/repos/asf/jena/blob/89b1027f/jena-integration-tests/src/test/java/org/apache/jena/test/rdfconnection/TestRDFConnectionRemote.java
----------------------------------------------------------------------
diff --git a/jena-integration-tests/src/test/java/org/apache/jena/test/rdfconnection/TestRDFConnectionRemote.java b/jena-integration-tests/src/test/java/org/apache/jena/test/rdfconnection/TestRDFConnectionRemote.java
new file mode 100644
index 0000000..5abc77e
--- /dev/null
+++ b/jena-integration-tests/src/test/java/org/apache/jena/test/rdfconnection/TestRDFConnectionRemote.java
@@ -0,0 +1,78 @@
+/*
+ * 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.test.rdfconnection;
+
+import org.apache.jena.atlas.logging.LogCtl ;
+import org.apache.jena.fuseki.Fuseki ;
+import org.apache.jena.fuseki.embedded.FusekiEmbeddedServer ;
+import org.apache.jena.rdfconnection.AbstractTestRDFConnection;
+import org.apache.jena.rdfconnection.RDFConnection;
+import org.apache.jena.rdfconnection.RDFConnectionFactory;
+import org.apache.jena.sparql.core.DatasetGraph ;
+import org.apache.jena.sparql.core.DatasetGraphFactory ;
+import org.apache.jena.system.Txn ;
+import org.junit.AfterClass ;
+import org.junit.Before ;
+import org.junit.BeforeClass ;
+
+public class TestRDFConnectionRemote extends AbstractTestRDFConnection {
+    private static FusekiEmbeddedServer server ;
+    private static DatasetGraph serverdsg = DatasetGraphFactory.createTxnMem() ;
+    
+    @BeforeClass
+    public static void beforeClass() {
+        DatasetGraph dsg = DatasetGraphFactory.createTxnMem() ;
+        server = FusekiEmbeddedServer.create()
+            .setPort(2244)
+            .add("/ds", serverdsg)
+            .build() ;
+        LogCtl.setLevel(Fuseki.serverLogName,  "WARN");
+        LogCtl.setLevel(Fuseki.actionLogName,  "WARN");
+        LogCtl.setLevel(Fuseki.requestLogName, "WARN");
+        LogCtl.setLevel(Fuseki.adminLogName,   "WARN");
+        LogCtl.setLevel(Fuseki.adminLogName,   "WARN");
+        LogCtl.setLevel("org.eclipse.jetty",   "WARN");
+        server.start() ;
+    }
+
+    @AfterClass
+    public static void afterClass() {
+        server.stop(); 
+    }
+    
+    @Before
+    public void beforeTest() {
+        // Clear server
+        Txn.executeWrite(serverdsg, ()->serverdsg.clear()) ;
+    }
+    
+//    @After
+//    public void afterTest() {}
+//    }
+
+    @Override
+    protected boolean supportsAbort() { return false ; }
+
+    @Override
+    protected RDFConnection connection() {
+        return RDFConnectionFactory.connect("http://localhost:2244/ds") ;
+    }
+
+}
+

http://git-wip-us.apache.org/repos/asf/jena/blob/89b1027f/jena-integration-tests/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/jena-integration-tests/src/test/resources/log4j.properties b/jena-integration-tests/src/test/resources/log4j.properties
new file mode 100644
index 0000000..e84e60e
--- /dev/null
+++ b/jena-integration-tests/src/test/resources/log4j.properties
@@ -0,0 +1,40 @@
+# Licensed under the terms of http://www.apache.org/licenses/LICENSE-2.0
+
+# Plain output to stdout
+log4j.appender.jena.plainstdout=org.apache.log4j.ConsoleAppender
+log4j.appender.jena.plainstdout.target=System.out
+log4j.appender.jena.plainstdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.jena.plainstdout.layout.ConversionPattern=[%d{yyyy-MM-dd HH:mm:ss}] %-10c{1} %-5p %m%n
+## %d{ISO8601} -- includes "ss,sss"
+## log4j.appender.jena.plainstdout.layout.ConversionPattern=[%d{ISO8601}] %-10c{1} %-5p %m%n
+
+# Unadorned, for the NCSA requests log.
+log4j.appender.fuseki.plain=org.apache.log4j.ConsoleAppender
+log4j.appender.fuseki.plain.target=System.out
+log4j.appender.fuseki.plain.layout=org.apache.log4j.PatternLayout
+log4j.appender.fuseki.plain.layout.ConversionPattern=%m%n
+
+log4j.rootLogger=INFO, jena.plainstdout
+log4j.logger.org.apache.jena=WARN
+log4j.logger.org.apache.jena.fuseki=INFO
+
+# Others
+log4j.logger.org.eclipse.jetty=WARN
+log4j.logger.org.apache.shiro=WARN
+
+# Fuseki System logs.
+log4j.logger.org.apache.jena.fuseki.Server=INFO
+log4j.logger.org.apache.jena.fuseki.Fuseki=INFO
+log4j.logger.org.apache.jena.fuseki.Admin=INFO
+log4j.logger.org.apache.jena.fuseki.Validate=INFO
+log4j.logger.org.apache.jena.fuseki.Config=INFO
+
+# NCSA Request log.
+log4j.additivity.org.apache.jena.fuseki.Request=false
+log4j.logger.org.apache.jena.fuseki.Request=OFF, fuseki.plain
+
+# TDB
+log4j.logger.org.apache.jena.tdb.loader=INFO
+## Parser output
+log4j.additivity.org.apache.jena.riot=false
+log4j.logger.org.apache.jena.riot=INFO, jena.plainstdout

http://git-wip-us.apache.org/repos/asf/jena/blob/89b1027f/jena-integration-tests/testing/RDFConnection/data.trig
----------------------------------------------------------------------
diff --git a/jena-integration-tests/testing/RDFConnection/data.trig b/jena-integration-tests/testing/RDFConnection/data.trig
new file mode 100644
index 0000000..e8a6f04
--- /dev/null
+++ b/jena-integration-tests/testing/RDFConnection/data.trig
@@ -0,0 +1,16 @@
+## Licensed under the terms of http://www.apache.org/licenses/LICENSE-2.0
+
+prefix : <http://example/>
+
+:s :p :o .
+:s0 :p0 :o .
+
+:g1 {
+   :s :p :o .
+   :s1 :p1 :o1 .
+   }
+
+:g2 {
+  :s :p :o .
+  :s2 :p2 :o .
+  }

http://git-wip-us.apache.org/repos/asf/jena/blob/89b1027f/jena-integration-tests/testing/RDFConnection/data.ttl
----------------------------------------------------------------------
diff --git a/jena-integration-tests/testing/RDFConnection/data.ttl b/jena-integration-tests/testing/RDFConnection/data.ttl
new file mode 100644
index 0000000..aa1b76c
--- /dev/null
+++ b/jena-integration-tests/testing/RDFConnection/data.ttl
@@ -0,0 +1,6 @@
+## Licensed under the terms of http://www.apache.org/licenses/LICENSE-2.0
+
+prefix : <http://example/>
+
+:s :p :o .
+:s0 :p0 123 .


[05/11] jena git commit: Fix typos and code formatting

Posted by an...@apache.org.
http://git-wip-us.apache.org/repos/asf/jena/blob/53758b5f/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/examples/RDFConnectionExample2.java
----------------------------------------------------------------------
diff --git a/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/examples/RDFConnectionExample2.java b/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/examples/RDFConnectionExample2.java
index 0fcffd1..4d38e5f 100644
--- a/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/examples/RDFConnectionExample2.java
+++ b/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/examples/RDFConnectionExample2.java
@@ -18,47 +18,47 @@
 
 package org.apache.jena.rdfconnection.examples;
 
-import org.apache.jena.query.* ;
+import org.apache.jena.query.*;
 import org.apache.jena.rdfconnection.RDFConnection;
 import org.apache.jena.rdfconnection.RDFConnectionFactory;
-import org.apache.jena.riot.Lang ;
-import org.apache.jena.riot.RDFDataMgr ;
-import org.apache.jena.system.Txn ;
+import org.apache.jena.riot.Lang;
+import org.apache.jena.riot.RDFDataMgr;
+import org.apache.jena.system.Txn;
 
 /* 
  * Example of a connection performng a number of transactional operations.
  */
 public class RDFConnectionExample2 {
     public static void main(String ...args) {
-        Query query = QueryFactory.create("SELECT * { {?s ?p ?o } UNION { GRAPH ?g { ?s ?p ?o } } }") ;
+        Query query = QueryFactory.create("SELECT * { {?s ?p ?o } UNION { GRAPH ?g { ?s ?p ?o } } }");
         Dataset dataset = DatasetFactory.createTxnMem();
         
         try ( RDFConnection conn = RDFConnectionFactory.connect(dataset) ) {
             System.out.println("** Load a file");
             // ---- Transaction 1: load data. 
-            Txn.executeWrite(conn, ()->conn.load("data.ttl")) ;
+            Txn.executeWrite(conn, ()->conn.load("data.ttl"));
             
             // ---- Transaction 2: explicit styles 
             conn.begin(ReadWrite.WRITE);
-            conn.load("http://example/g0", "data.ttl") ;
+            conn.load("http://example/g0", "data.ttl");
             
             System.out.println("** Inside multistep transaction - query dataset");
-            conn.queryResultSet(query, ResultSetFormatter::out) ;
+            conn.queryResultSet(query, ResultSetFormatter::out);
             
             conn.abort();
-            conn.end() ;
-            System.out.println("** After abort 1") ;
+            conn.end();
+            System.out.println("** After abort 1");
             
             // ---- Transaction 3: explicit styles
             Txn.executeWrite(conn, ()->{
-                conn.load("http://example/g0", "data.ttl") ;
+                conn.load("http://example/g0", "data.ttl");
                 System.out.println("** Inside multistep transaction - fetch dataset");
-                Dataset ds2 = conn.fetchDataset() ;
-                RDFDataMgr.write(System.out, ds2, Lang.TRIG) ;
+                Dataset ds2 = conn.fetchDataset();
+                RDFDataMgr.write(System.out, ds2, Lang.TRIG);
                 conn.abort();
-            }) ;
+            });
             
-            System.out.println("** After abort 2") ;
+            System.out.println("** After abort 2");
             // Only default graph showing.
             conn.queryResultSet(query, ResultSetFormatter::out);
         }

http://git-wip-us.apache.org/repos/asf/jena/blob/53758b5f/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/examples/RDFConnectionExample3.java
----------------------------------------------------------------------
diff --git a/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/examples/RDFConnectionExample3.java b/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/examples/RDFConnectionExample3.java
index 89b2008..cb9c8da 100644
--- a/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/examples/RDFConnectionExample3.java
+++ b/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/examples/RDFConnectionExample3.java
@@ -18,9 +18,9 @@
 
 package org.apache.jena.rdfconnection.examples;
 
-import org.apache.jena.query.Query ;
-import org.apache.jena.query.QueryFactory ;
-import org.apache.jena.query.ResultSetFormatter ;
+import org.apache.jena.query.Query;
+import org.apache.jena.query.QueryFactory;
+import org.apache.jena.query.ResultSetFormatter;
 import org.apache.jena.rdfconnection.RDFConnection;
 import org.apache.jena.rdfconnection.RDFConnectionFactory;
 
@@ -30,8 +30,8 @@ import org.apache.jena.rdfconnection.RDFConnectionFactory;
  */
 public class RDFConnectionExample3 {
     public static void main(String ...args) {
-        Query query = QueryFactory.create("SELECT * { <http://example.org/book/book1> ?p ?o }") ;
-        String queryService = "http://sparql.org/books/query" ;
+        Query query = QueryFactory.create("SELECT * { <http://example.org/book/book1> ?p ?o }");
+        String queryService = "http://sparql.org/books/query";
 
         // Query service, no update, no graph store protocol.
         try ( RDFConnection conn = RDFConnectionFactory.connect(queryService, null, null) ) {

http://git-wip-us.apache.org/repos/asf/jena/blob/53758b5f/jena-rdfconnection/src/test/java/org/apache/jena/rdfconnection/AbstractTestRDFConnection.java
----------------------------------------------------------------------
diff --git a/jena-rdfconnection/src/test/java/org/apache/jena/rdfconnection/AbstractTestRDFConnection.java b/jena-rdfconnection/src/test/java/org/apache/jena/rdfconnection/AbstractTestRDFConnection.java
index db8ace5..0a04eaa 100644
--- a/jena-rdfconnection/src/test/java/org/apache/jena/rdfconnection/AbstractTestRDFConnection.java
+++ b/jena-rdfconnection/src/test/java/org/apache/jena/rdfconnection/AbstractTestRDFConnection.java
@@ -18,33 +18,32 @@
 
 package org.apache.jena.rdfconnection;
 
-import java.util.concurrent.atomic.AtomicInteger ;
-
-import org.apache.jena.atlas.iterator.Iter ;
-import org.apache.jena.atlas.junit.BaseTest ;
-import org.apache.jena.atlas.lib.StrUtils ;
-import org.apache.jena.query.Dataset ;
-import org.apache.jena.query.DatasetFactory ;
-import org.apache.jena.query.ReadWrite ;
-import org.apache.jena.rdf.model.Model ;
-import org.apache.jena.rdf.model.ModelFactory ;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.apache.jena.atlas.iterator.Iter;
+import org.apache.jena.atlas.junit.BaseTest;
+import org.apache.jena.atlas.lib.StrUtils;
+import org.apache.jena.query.Dataset;
+import org.apache.jena.query.DatasetFactory;
+import org.apache.jena.query.ReadWrite;
+import org.apache.jena.rdf.model.Model;
+import org.apache.jena.rdf.model.ModelFactory;
 import org.apache.jena.rdfconnection.RDFConnection;
-import org.apache.jena.riot.RDFDataMgr ;
-import org.apache.jena.sparql.core.DatasetGraph ;
-import org.apache.jena.sparql.sse.SSE ;
-import org.apache.jena.sparql.util.IsoMatcher ;
-import org.apache.jena.system.Txn ;
-import org.junit.Assume ;
-import org.junit.Test ;
+import org.apache.jena.riot.RDFDataMgr;
+import org.apache.jena.sparql.core.DatasetGraph;
+import org.apache.jena.sparql.sse.SSE;
+import org.apache.jena.sparql.util.IsoMatcher;
+import org.apache.jena.system.Txn;
+import org.junit.Assume;
+import org.junit.Test;
 
 public abstract class AbstractTestRDFConnection extends BaseTest {
     // Testing data.
-    static String DIR = "testing/RDFConnection/" ;
+    static String DIR = "testing/RDFConnection/";
     
-    protected abstract RDFConnection connection() ;
-    // Not all RDFConenction types support.
-    //  (may acquite RDFConnection.supportTransactionalAbort but ATM that isn't included)
-    protected abstract boolean supportsAbort() ; 
+    protected abstract RDFConnection connection();
+    // Not all connection types support abort.
+    protected abstract boolean supportsAbort(); 
 
     // ---- Data
     static String dsgdata = StrUtils.strjoinNL
@@ -53,23 +52,23 @@ public abstract class AbstractTestRDFConnection extends BaseTest {
         ,"  (graph :g1 (:s :p :o) (:s1 :p1 :o1))"
         ,"  (graph :g2 (:s :p :o) (:s2 :p2 :o))"
         ,")"
-        ) ;
+        );
     
     static String dsgdata2 = StrUtils.strjoinNL
         ("(dataset"
         ,"  (graph (:x :y :z))"
         ,"  (graph :g9 (:s :p :o))"
         ,")"
-        ) ;
+        );
 
     
     static String graph1 = StrUtils.strjoinNL
         ("(graph (:s :p :o) (:s1 :p1 :o))"
-        ) ;
+        );
 
     static String graph2 = StrUtils.strjoinNL
         ("(graph (:s :p :o) (:s2 :p2 :o))"
-        ) ;
+        );
     
     static DatasetGraph dsg        = SSE.parseDatasetGraph(dsgdata);
     static Dataset      dataset    = DatasetFactory.wrap(dsg);
@@ -84,46 +83,46 @@ public abstract class AbstractTestRDFConnection extends BaseTest {
 
     @Test public void connect_01() {
         @SuppressWarnings("resource")
-        RDFConnection conn = connection() ;
-        assertFalse(conn.isClosed()) ;
-        conn.close() ;
-        assertTrue(conn.isClosed()) ;
+        RDFConnection conn = connection();
+        assertFalse(conn.isClosed());
+        conn.close();
+        assertTrue(conn.isClosed());
         // Allow multiple close()
-        conn.close() ;
+        conn.close();
     }
     
     @Test public void dataset_load_1() {
-        String testDataFile = DIR+"data.trig" ; 
+        String testDataFile = DIR+"data.trig"; 
         try ( RDFConnection conn = connection() ) {
             conn.loadDataset(testDataFile);
-            Dataset ds0 = RDFDataMgr.loadDataset(testDataFile) ;
-            Dataset ds = conn.fetchDataset() ;
-            assertTrue("Datasets not isomorphic", isomorphic(ds0, ds)) ;
+            Dataset ds0 = RDFDataMgr.loadDataset(testDataFile);
+            Dataset ds = conn.fetchDataset();
+            assertTrue("Datasets not isomorphic", isomorphic(ds0, ds));
         }
     }
 
     @Test public void dataset_put_1() {
         try ( RDFConnection conn = connection() ) {
-            conn.putDataset(dataset) ; 
-            Dataset ds1 = conn.fetchDataset() ;
-            assertTrue("Datasets not isomorphic", isomorphic(dataset, ds1)) ;
+            conn.putDataset(dataset); 
+            Dataset ds1 = conn.fetchDataset();
+            assertTrue("Datasets not isomorphic", isomorphic(dataset, ds1));
         }
     }
 
     @Test public void dataset_put_2() {
         try ( RDFConnection conn = connection() ) {
-            conn.putDataset(dataset) ; 
-            conn.putDataset(dataset2) ;
-            Dataset ds1 = conn.fetchDataset() ;
-            assertTrue("Datasets not isomorphic", isomorphic(dataset2, ds1)) ;
+            conn.putDataset(dataset); 
+            conn.putDataset(dataset2);
+            Dataset ds1 = conn.fetchDataset();
+            assertTrue("Datasets not isomorphic", isomorphic(dataset2, ds1));
         }
     }
 
     @Test public void dataset_post_1() {
         try ( RDFConnection conn = connection() ) {
             conn.loadDataset(dataset);
-            Dataset ds1 = conn.fetchDataset() ;
-            assertTrue("Datasets not isomorphic", isomorphic(dataset, ds1)) ;
+            Dataset ds1 = conn.fetchDataset();
+            assertTrue("Datasets not isomorphic", isomorphic(dataset, ds1));
         }
     }
     
@@ -131,62 +130,62 @@ public abstract class AbstractTestRDFConnection extends BaseTest {
         try ( RDFConnection conn = connection() ) {
             conn.loadDataset(dataset);
             conn.loadDataset(dataset2);
-            Dataset ds1 = conn.fetchDataset() ;
-            long x = Iter.count(ds1.listNames()) ;
-            assertEquals("NG count", 3, x) ;
-            assertFalse("Datasets are isomorphic", isomorphic(dataset, ds1)) ;
-            assertFalse("Datasets are isomorphic", isomorphic(dataset2, ds1)) ;
+            Dataset ds1 = conn.fetchDataset();
+            long x = Iter.count(ds1.listNames());
+            assertEquals("NG count", 3, x);
+            assertFalse("Datasets are isomorphic", isomorphic(dataset, ds1));
+            assertFalse("Datasets are isomorphic", isomorphic(dataset2, ds1));
         }
     }
 
     // Default graph
     
     @Test public void graph_load_1() {
-        String testDataFile = DIR+"data.ttl" ; 
-        Model m0 = RDFDataMgr.loadModel(testDataFile) ;
+        String testDataFile = DIR+"data.ttl"; 
+        Model m0 = RDFDataMgr.loadModel(testDataFile);
         try ( RDFConnection conn = connection() ) {
             conn.load(testDataFile);
-            Model m = conn.fetch() ;
-            assertTrue("Models not isomorphic", isomorphic(m0, m)) ;
+            Model m = conn.fetch();
+            assertTrue("Models not isomorphic", isomorphic(m0, m));
         }
     }
 
     @Test public void graph_put_1() {
         try ( RDFConnection conn = connection() ) {
             conn.put(model1); 
-            Dataset ds1 = conn.fetchDataset() ;
-            Model m0 = conn.fetch() ;
-            assertTrue("Models not isomorphic", isomorphic(model1, ds1.getDefaultModel())) ;
-            Model m = conn.fetch() ;
-            assertTrue("Models not isomorphic", isomorphic(model1, m)) ;
+            Dataset ds1 = conn.fetchDataset();
+            Model m0 = conn.fetch();
+            assertTrue("Models not isomorphic", isomorphic(model1, ds1.getDefaultModel()));
+            Model m = conn.fetch();
+            assertTrue("Models not isomorphic", isomorphic(model1, m));
         }
     }
 
     @Test public void graph_put_2() {
         try ( RDFConnection conn = connection() ) {
-            conn.put(model1) ; 
-            conn.put(model2) ;
-            Model m = conn.fetch() ;
-            assertTrue("Models not isomorphic", isomorphic(m, model2)) ;
-            assertFalse("Models not isomorphic", isomorphic(m, model1)) ;
+            conn.put(model1); 
+            conn.put(model2);
+            Model m = conn.fetch();
+            assertTrue("Models not isomorphic", isomorphic(m, model2));
+            assertFalse("Models not isomorphic", isomorphic(m, model1));
         }
     }
 
     @Test public void graph_post_1() {
         try ( RDFConnection conn = connection() ) {
-            conn.load(model1) ;
-            Model m = conn.fetch() ;
-            assertTrue("Models not isomorphic", isomorphic(m, model1)) ;
+            conn.load(model1);
+            Model m = conn.fetch();
+            assertTrue("Models not isomorphic", isomorphic(m, model1));
         }
     }
     
     @Test public void graph_post_2() {
         try ( RDFConnection conn = connection() ) {
-            conn.load(model1) ;
-            conn.load(model2) ;
-            Model m = conn.fetch() ;
-            Model m0 = ModelFactory.createUnion(model2, model1) ;
-            assertTrue("Models are not isomorphic", isomorphic(m0, m)) ;
+            conn.load(model1);
+            conn.load(model2);
+            Model m = conn.fetch();
+            Model m0 = ModelFactory.createUnion(model2, model1);
+            assertTrue("Models are not isomorphic", isomorphic(m0, m));
         }
     }
 
@@ -195,64 +194,64 @@ public abstract class AbstractTestRDFConnection extends BaseTest {
     // Named graphs
     
     @Test public void named_graph_load_1() {
-        String testDataFile = DIR+"data.ttl" ; 
-        Model m0 = RDFDataMgr.loadModel(testDataFile) ;
+        String testDataFile = DIR+"data.ttl"; 
+        Model m0 = RDFDataMgr.loadModel(testDataFile);
         try ( RDFConnection conn = connection() ) {
             conn.load(graphName, testDataFile);
-            Model m = conn.fetch(graphName) ;
-            assertTrue("Models not isomorphic", isomorphic(m0, m)) ;
-            Model mDft = conn.fetch() ;
-            assertTrue(mDft.isEmpty()) ;
+            Model m = conn.fetch(graphName);
+            assertTrue("Models not isomorphic", isomorphic(m0, m));
+            Model mDft = conn.fetch();
+            assertTrue(mDft.isEmpty());
         }
     }
 
     @Test public void named_graph_put_1() {
         try ( RDFConnection conn = connection() ) {
             conn.put(graphName, model1); 
-            Dataset ds1 = conn.fetchDataset() ;
-            Model m0 = conn.fetch(graphName) ;
-            assertTrue("Models not isomorphic", isomorphic(model1, ds1.getNamedModel(graphName))) ;
-            Model m = conn.fetch(graphName) ;
-            assertTrue("Models not isomorphic", isomorphic(model1, m)) ;
+            Dataset ds1 = conn.fetchDataset();
+            Model m0 = conn.fetch(graphName);
+            assertTrue("Models not isomorphic", isomorphic(model1, ds1.getNamedModel(graphName)));
+            Model m = conn.fetch(graphName);
+            assertTrue("Models not isomorphic", isomorphic(model1, m));
         }
     }
 
     @Test public void named_graph_put_2() {
         try ( RDFConnection conn = connection() ) {
-            conn.put(graphName, model1) ; 
-            conn.put(graphName, model2) ;
-            Model m = conn.fetch(graphName) ;
-            assertTrue("Models not isomorphic", isomorphic(m, model2)) ;
-            assertFalse("Models not isomorphic", isomorphic(m, model1)) ;
+            conn.put(graphName, model1); 
+            conn.put(graphName, model2);
+            Model m = conn.fetch(graphName);
+            assertTrue("Models not isomorphic", isomorphic(m, model2));
+            assertFalse("Models not isomorphic", isomorphic(m, model1));
         }
     }
 
     @Test public void named_graph_put_2_different() {
         try ( RDFConnection conn = connection() ) {
-            conn.put(graphName, model1) ; 
-            conn.put(graphName2, model2) ;
-            Model m1 = conn.fetch(graphName) ;
-            Model m2 = conn.fetch(graphName2) ;
-            assertTrue("Models not isomorphic", isomorphic(m1, model1)) ;
-            assertTrue("Models not isomorphic", isomorphic(m2, model2)) ;
+            conn.put(graphName, model1); 
+            conn.put(graphName2, model2);
+            Model m1 = conn.fetch(graphName);
+            Model m2 = conn.fetch(graphName2);
+            assertTrue("Models not isomorphic", isomorphic(m1, model1));
+            assertTrue("Models not isomorphic", isomorphic(m2, model2));
         }
     }
 
     @Test public void named_graph_post_1() {
         try ( RDFConnection conn = connection() ) {
-            conn.load(graphName, model1) ;
-            Model m = conn.fetch(graphName) ;
-            assertTrue("Models not isomorphic", isomorphic(m, model1)) ;
+            conn.load(graphName, model1);
+            Model m = conn.fetch(graphName);
+            assertTrue("Models not isomorphic", isomorphic(m, model1));
         }
     }
     
     @Test public void named_graph_post_2() {
         try ( RDFConnection conn = connection() ) {
-            conn.load(graphName, model1) ;
-            conn.load(graphName, model2) ;
-            Model m = conn.fetch(graphName) ;
-            Model m0 = ModelFactory.createUnion(model2, model1) ;
-            assertTrue("Models are not isomorphic", isomorphic(m0, m)) ;
+            conn.load(graphName, model1);
+            conn.load(graphName, model2);
+            Model m = conn.fetch(graphName);
+            Model m0 = ModelFactory.createUnion(model2, model1);
+            assertTrue("Models are not isomorphic", isomorphic(m0, m));
         }
     }
 
@@ -262,46 +261,46 @@ public abstract class AbstractTestRDFConnection extends BaseTest {
     //@Test public void transaction_01() 
 
     private static boolean isomorphic(Dataset ds1, Dataset ds2) {
-        return IsoMatcher.isomorphic(ds1.asDatasetGraph(), ds2.asDatasetGraph()) ;
+        return IsoMatcher.isomorphic(ds1.asDatasetGraph(), ds2.asDatasetGraph());
     }
     
     private static boolean isomorphic(Model model1, Model model2) {
-        return model1.isIsomorphicWith(model2) ;
+        return model1.isIsomorphicWith(model2);
     }
     
 
     @Test public void query_ask_01() {
         try ( RDFConnection conn = connection() ) {
             Txn.executeRead(conn, ()->{
-                boolean b = conn.queryAsk("ASK{}") ;
-                assertTrue(b) ;
-            }) ;
+                boolean b = conn.queryAsk("ASK{}");
+                assertTrue(b);
+            });
         }
     }
 
     @Test public void query_ask_02() {
         try ( RDFConnection conn = connection() ) {
-            boolean b = conn.queryAsk("ASK{}") ;
-            assertTrue(b) ;
+            boolean b = conn.queryAsk("ASK{}");
+            assertTrue(b);
         }
     }
 
     @Test public void query_select_01() {
-        AtomicInteger counter = new AtomicInteger(0) ;
+        AtomicInteger counter = new AtomicInteger(0);
         try ( RDFConnection conn = connection() ) {
             Txn.executeWrite(conn, ()->conn.loadDataset(DIR+"data.trig"));
             Txn.executeRead(conn, ()->
                 conn.querySelect("SELECT * { ?s ?p ?o }" , (r)->counter.incrementAndGet()));
-            assertEquals(2, counter.get()) ;
+            assertEquals(2, counter.get());
         }
     }
 
     @Test public void query_select_02() {
-        AtomicInteger counter = new AtomicInteger(0) ;
+        AtomicInteger counter = new AtomicInteger(0);
         try ( RDFConnection conn = connection() ) {
             conn.loadDataset(DIR+"data.trig");
             conn.querySelect("SELECT * { ?s ?p ?o}" , (r)->counter.incrementAndGet());
-            assertEquals(2, counter.get()) ;
+            assertEquals(2, counter.get());
         }
     }
 
@@ -309,17 +308,17 @@ public abstract class AbstractTestRDFConnection extends BaseTest {
         try ( RDFConnection conn = connection() ) {
             Txn.executeWrite(conn, ()->conn.loadDataset(DIR+"data.trig"));
             Txn.executeRead(conn, ()-> {
-                Model m = conn.queryConstruct("CONSTRUCT WHERE { ?s ?p ?o }") ;
-                assertEquals(2, m.size()) ;
-            }) ;
+                Model m = conn.queryConstruct("CONSTRUCT WHERE { ?s ?p ?o }");
+                assertEquals(2, m.size());
+            });
         }
     }
 
     @Test public void query_construct_02() {
         try ( RDFConnection conn = connection() ) {
             conn.loadDataset(DIR+"data.trig");
-            Model m = conn.queryConstruct("CONSTRUCT WHERE { ?s ?p ?o }") ;
-            assertEquals(2, m.size()) ;
+            Model m = conn.queryConstruct("CONSTRUCT WHERE { ?s ?p ?o }");
+            assertEquals(2, m.size());
         }
     }
     
@@ -331,50 +330,50 @@ public abstract class AbstractTestRDFConnection extends BaseTest {
 
     @Test public void update_02() {
         try ( RDFConnection conn = connection() ) {
-            Txn.executeWrite(conn, ()->conn.update("INSERT DATA { <urn:x:s> <urn:x:p> <urn:x:o>}")) ;
+            Txn.executeWrite(conn, ()->conn.update("INSERT DATA { <urn:x:s> <urn:x:p> <urn:x:o>}"));
         }
     }
 
     // Not all Transactional support abort.
     @Test public void transaction_commit_read_01() {
-        String testDataFile = DIR+"data.trig" ; 
+        String testDataFile = DIR+"data.trig"; 
         try ( RDFConnection conn = connection() ) {
 
-            conn.begin(ReadWrite.WRITE) ;
+            conn.begin(ReadWrite.WRITE);
             conn.loadDataset(dataset);
-            conn.commit() ;
+            conn.commit();
             conn.end();
             
-            conn.begin(ReadWrite.READ) ;
-            Model m = conn.fetch() ;
-            assertTrue(isomorphic(m, dataset.getDefaultModel())) ;
-            conn.end() ;
+            conn.begin(ReadWrite.READ);
+            Model m = conn.fetch();
+            assertTrue(isomorphic(m, dataset.getDefaultModel()));
+            conn.end();
         }
     }
     
     // Not all RDFConnections support abort.
     @Test public void transaction_abort_read02() {
-        Assume.assumeTrue(supportsAbort()) ;
+        Assume.assumeTrue(supportsAbort());
         
-        String testDataFile = DIR+"data.trig" ; 
+        String testDataFile = DIR+"data.trig"; 
         try ( RDFConnection conn = connection() ) {
-            conn.begin(ReadWrite.WRITE) ;
+            conn.begin(ReadWrite.WRITE);
             conn.loadDataset(testDataFile);
             conn.abort();
             conn.end();
             
-            conn.begin(ReadWrite.READ) ;
-            Model m = conn.fetch() ;
-            assertTrue(m.isEmpty()) ;
-            conn.end() ;
+            conn.begin(ReadWrite.READ);
+            Model m = conn.fetch();
+            assertTrue(m.isEmpty());
+            conn.end();
         }
     }
 
     //@Test(expected=JenaTransactionException.class)
     public void transaction_bad_01() {
         try ( RDFConnection conn = connection() ) {
-            conn.begin(ReadWrite.WRITE) ;
-            // Should have conn.commit() ;
+            conn.begin(ReadWrite.WRITE);
+            // Should have conn.commit();
             conn.end();
         }
     }

http://git-wip-us.apache.org/repos/asf/jena/blob/53758b5f/jena-rdfconnection/src/test/java/org/apache/jena/rdfconnection/TS_RDFConnection.java
----------------------------------------------------------------------
diff --git a/jena-rdfconnection/src/test/java/org/apache/jena/rdfconnection/TS_RDFConnection.java b/jena-rdfconnection/src/test/java/org/apache/jena/rdfconnection/TS_RDFConnection.java
index ae03c22..3f8af53 100644
--- a/jena-rdfconnection/src/test/java/org/apache/jena/rdfconnection/TS_RDFConnection.java
+++ b/jena-rdfconnection/src/test/java/org/apache/jena/rdfconnection/TS_RDFConnection.java
@@ -18,8 +18,8 @@
 
 package org.apache.jena.rdfconnection;
 
-import org.junit.runner.RunWith ;
-import org.junit.runners.Suite ;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
 
 @RunWith(Suite.class)
 @Suite.SuiteClasses( {

http://git-wip-us.apache.org/repos/asf/jena/blob/53758b5f/jena-rdfconnection/src/test/java/org/apache/jena/rdfconnection/TestRDFConnectionLocalMRSW.java
----------------------------------------------------------------------
diff --git a/jena-rdfconnection/src/test/java/org/apache/jena/rdfconnection/TestRDFConnectionLocalMRSW.java b/jena-rdfconnection/src/test/java/org/apache/jena/rdfconnection/TestRDFConnectionLocalMRSW.java
index adadc30..7305a40 100644
--- a/jena-rdfconnection/src/test/java/org/apache/jena/rdfconnection/TestRDFConnectionLocalMRSW.java
+++ b/jena-rdfconnection/src/test/java/org/apache/jena/rdfconnection/TestRDFConnectionLocalMRSW.java
@@ -18,21 +18,21 @@
 
 package org.apache.jena.rdfconnection;
 
-import org.apache.jena.query.Dataset ;
-import org.apache.jena.query.DatasetFactory ;
+import org.apache.jena.query.Dataset;
+import org.apache.jena.query.DatasetFactory;
 import org.apache.jena.rdfconnection.RDFConnection;
 import org.apache.jena.rdfconnection.RDFConnectionFactory;
 
 public class TestRDFConnectionLocalMRSW extends AbstractTestRDFConnection {
 
     @Override
-    protected boolean supportsAbort() { return false ; }
+    protected boolean supportsAbort() { return false; }
     
     @Override
     protected RDFConnection connection() {
         // General purpose, mixed storage, MRSW dataset.  
-        Dataset ds = DatasetFactory.create() ;
-        return RDFConnectionFactory.connect(ds) ;
+        Dataset ds = DatasetFactory.create();
+        return RDFConnectionFactory.connect(ds);
     }
 }
 

http://git-wip-us.apache.org/repos/asf/jena/blob/53758b5f/jena-rdfconnection/src/test/java/org/apache/jena/rdfconnection/TestRDFConnectionLocalTxnMem.java
----------------------------------------------------------------------
diff --git a/jena-rdfconnection/src/test/java/org/apache/jena/rdfconnection/TestRDFConnectionLocalTxnMem.java b/jena-rdfconnection/src/test/java/org/apache/jena/rdfconnection/TestRDFConnectionLocalTxnMem.java
index 7059b12..53b77b3 100644
--- a/jena-rdfconnection/src/test/java/org/apache/jena/rdfconnection/TestRDFConnectionLocalTxnMem.java
+++ b/jena-rdfconnection/src/test/java/org/apache/jena/rdfconnection/TestRDFConnectionLocalTxnMem.java
@@ -18,21 +18,21 @@
 
 package org.apache.jena.rdfconnection;
 
-import org.apache.jena.query.Dataset ;
-import org.apache.jena.query.DatasetFactory ;
+import org.apache.jena.query.Dataset;
+import org.apache.jena.query.DatasetFactory;
 import org.apache.jena.rdfconnection.RDFConnection;
 import org.apache.jena.rdfconnection.RDFConnectionFactory;
 
 public class TestRDFConnectionLocalTxnMem extends AbstractTestRDFConnection {
 
     @Override
-    protected boolean supportsAbort() { return true ; }
+    protected boolean supportsAbort() { return true; }
 
     @Override
     protected RDFConnection connection() {
         // Full transactional in-memory dataset.  
-        Dataset ds = DatasetFactory.createTxnMem() ;
-        return RDFConnectionFactory.connect(ds) ;
+        Dataset ds = DatasetFactory.createTxnMem();
+        return RDFConnectionFactory.connect(ds);
     }
 }
 

http://git-wip-us.apache.org/repos/asf/jena/blob/53758b5f/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index af6a72c..9b005e3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -159,9 +159,11 @@
         <module>jena-fuseki2</module>
         <module>jena-permissions</module>
 
-        <!-- Tests of artifacts that require 
-             For example, use Fuseki as a test server
-             to test remote client APIs.
+        <!--
+            Tests of artifacts that require additional 
+            modules built later in the build process.
+            For example, use Fuseki as a test server to
+            test remote client APIs.
         -->
         <module>jena-integration-tests</module>
 


[02/11] jena git commit: JENA-1267: Module jena-rdfconnection

Posted by an...@apache.org.
JENA-1267: Module jena-rdfconnection


Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/2e26b78e
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/2e26b78e
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/2e26b78e

Branch: refs/heads/master
Commit: 2e26b78edcf1b92e1b8b22acc53e9294fcc9f5ea
Parents: c10dff4
Author: Andy Seaborne <an...@apache.org>
Authored: Fri Dec 16 15:02:10 2016 +0000
Committer: Andy Seaborne <an...@apache.org>
Committed: Fri Dec 16 15:02:10 2016 +0000

----------------------------------------------------------------------
 jena-rdfconnection/Documentation.md             | 205 ++++++++
 jena-rdfconnection/LICENSE                      | 177 +++++++
 jena-rdfconnection/NOTICE                       |   5 +
 jena-rdfconnection/README.md                    |   6 +
 jena-rdfconnection/pom.xml                      | 163 +++++++
 .../rdfconnection/JenaConnectionException.java  |  29 ++
 .../org/apache/jena/rdfconnection/RDFConn.java  |  40 ++
 .../jena/rdfconnection/RDFConnection.java       | 362 ++++++++++++++
 .../rdfconnection/RDFConnectionFactory.java     |  84 ++++
 .../jena/rdfconnection/RDFConnectionLocal.java  | 286 +++++++++++
 .../rdfconnection/RDFConnectionModular.java     | 199 ++++++++
 .../jena/rdfconnection/RDFConnectionRemote.java | 478 +++++++++++++++++++
 .../RDFDatasetAccessConnection.java             |  57 +++
 .../rdfconnection/RDFDatasetConnection.java     | 150 ++++++
 .../rdfconnection/SparqlQueryConnection.java    | 105 ++++
 .../rdfconnection/SparqlUpdateConnection.java   |  53 ++
 .../examples/RDFConnectionExample1.java         |  45 ++
 .../examples/RDFConnectionExample2.java         |  67 +++
 .../examples/RDFConnectionExample3.java         |  42 ++
 jena-rdfconnection/src/main/resources/LICENSE   | 177 +++++++
 jena-rdfconnection/src/main/resources/NOTICE    |   5 +
 .../AbstractTestRDFConnection.java              | 382 +++++++++++++++
 .../jena/rdfconnection/TS_RDFConnection.java    |  32 ++
 .../TestRDFConnectionLocalMRSW.java             |  38 ++
 .../TestRDFConnectionLocalTxnMem.java           |  38 ++
 .../src/test/resources/log4j.properties         |  40 ++
 .../testing/RDFConnection/data.trig             |  16 +
 .../testing/RDFConnection/data.ttl              |   6 +
 28 files changed, 3287 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/2e26b78e/jena-rdfconnection/Documentation.md
----------------------------------------------------------------------
diff --git a/jena-rdfconnection/Documentation.md b/jena-rdfconnection/Documentation.md
new file mode 100644
index 0000000..af5ff6a
--- /dev/null
+++ b/jena-rdfconnection/Documentation.md
@@ -0,0 +1,205 @@
+# RDF Connection : SPARQL operations API
+
+`RDFConnection` provides a unified set of operations for working on RDF
+with SPARQL operations. It provides <a
+href="http://www.w3.org/TR/sparql11-query/">SPARQL Query</a>, <a
+href="http://www.w3.org/TR/sparql11-update/">SPARQL Update</a> and the <a
+href="http://www.w3.org/TR/sparql11-http-rdf-update/">SPARQL Graph
+Store</a> operations.  The interface is uniform - the same interface
+applies to local data and to remote data using HTTP and the SPARQL
+protocols ( <a href="http://www.w3.org/TR/sparql11-protocol/">SPARQL
+protocol</a> and <a
+href="http://www.w3.org/TR/sparql11-http-rdf-update/">SPARQL Graph Store
+Protocol</a>).
+
+## Outline
+
+`RDFConnection` provides a number of different styles for working with RDF
+data in Java.  It provides support for try-resource and functional code
+passing styles, as well the more basic sequence of methods calls.
+
+`try-resources` to manage the connection, and two operations, one to load
+some data, and one to make a query:
+
+```
+try ( RDFConnection conn = RDFConnectionFactory.connect(...) ) {
+    conn.load("data.ttl") ;
+    conn.querySelect("SELECT DISTINCT ?s { ?s ?p ?o }", (qs)->
+       Resource subject = qs.getResource("s") ;
+       System.out.println("Subject: "+subject) ;
+    }) ;
+}
+```
+This could have been written as (approximately -- the error handling is better
+in the example above):
+
+```
+RDFConnection conn = RDFConnectionFactory.connect(...)
+conn.load("data.ttl") ;
+QueryExecution qExec = conn.query("SELECT DISTINCT ?s { ?s ?p ?o }") ;
+ResultSet rs = qExec.execSelect() ;
+while(rs.hasNext()) {
+    QuerySolution qs = rs.next() ;
+    Resource subject = qs.getResource("s") ;
+    System.out.println("Subject: "+subject) ;
+}
+qExec.close() ;
+conn.close() ;
+```
+
+Jena also provides a separate
+[SPARQL over JDBC driver](http://jena.staging.apache.org/documentation/jdbc/index.html)
+library.
+
+## Transactions
+
+Transactions are the preferred way to work with RDF data.
+Operations on an `RDFConnection` outside of an application-controlled
+transaction will cause the system to add one for the duration of the
+operation. This "autocommit" feature may lead to inefficient operations due
+to excessive overhead.
+
+The `Txn` class provides a Java8-style transaction API.  Transactions are
+code passed in the `Txn` library that handles the transaction lifecycle.
+
+```
+try ( RDFConnection conn = RDFConnectionFactory.connect(...) ) {
+    Txn.execWrite(conn, ()-> {
+        conn.load("data1.ttl") ;
+        conn.load("data2.ttl") ;
+        conn.querySelect("SELECT DISTINCT ?s { ?s ?p ?o }", (qs)->
+           Resource subject = qs.getResource("s") ;
+           System.out.println("Subject: "+subject) ;
+        }) ;
+    }) ;
+}
+```
+
+The traditional style of explicit `begin`, `commit`, `abort` is also available.
+
+```
+try ( RDFConnection conn = RDFConnectionFactory.connect(...) ) {
+    conn.begin(ReadWrite.WRITE) ;
+    try {
+        conn.load("data1.ttl") ;
+        conn.load("data2.ttl") ;
+        conn.querySelect("SELECT DISTINCT ?s { ?s ?p ?o }", (qs)->
+           Resource subject = qs.getResource("s") ;
+           System.out.println("Subject: "+subject) ;
+        }) ;
+        conn.commit() ;
+    } finally { conn.end() ; }
+}
+```
+
+The use of `try-finally` ensures that transactions are properly finished.
+The `conn.end()` provides an abort in case an exception occurs in the
+transaction and a commit has not been issued.  The use of `try-finally`
+ensures that transactions are properly finished.
+
+`Txn` is wrapping these steps up and calling the application supplied code
+for the transaction body.
+
+### Remote Transactions
+
+SPARQL does not define a remote transaction standard protocol. Each remote
+operation shuld be atomic (all happens or nothing happens) - this is the
+responsibility of the remote server.
+
+An `RDFConenction` will at least provide the client-side locking features.
+This means that overlapping operations that chnage data are naturally
+handled by the transaction pattern within a single JVM.
+
+## Graph Store Protocol
+
+The <a href="http://www.w3.org/TR/sparql11-http-rdf-update/">SPARQL Graph
+Store Protocol</a> is a set of operations to work on whole graphs in a
+dataset.  It provides a standardised way to manage the data in a dataset.
+
+The operations are to fetch a graph, set the RDF data in a graph,
+add more RDF data into a graph, and delete a graph from a dataset.
+
+For example: load two files:
+```
+  try ( RDFConnection conn = RDFConnectionFactory.connect(...) ) {
+    conn.load("data1.ttl") ;
+    conn.load("data2.nt") ;
+  } 
+```
+The file extension is used to determine the syntax.
+
+There is also a set of scripts to help do these operations from the command
+line with <a href="http://jena.apache.org/documentation/fuseki2/soh.html"
+>SOH</a>. It is possible to write curl scripts as well.  The SPARQL Graph
+Store Protocol provides a standardised way to manage the data in a dataset.
+
+In addition, `RDFConnection` provides an extension to give the same style
+of operation to work on a whole dataset (deleting the dataset is not
+provided).
+
+```
+    conn.loadDataset("data-complete.trig") ;
+```
+
+## Query Usage
+
+`RDFConnection` provides methods for each of the SPARQL query forms (`SELECT`,
+`CONSTRUCT`, `DESCRIBE`, `ASK`) as well as a way to get the lower level
+`QueryExecution` for specialized configuration.
+
+When creating an `QueryExecution` explicitly, care shoud be taken to close
+it. If the application wishes to capture the result set from a SELECT query and
+retain it across the lifetime of the transaction or `QueryExecution`, then
+the application create a copy which is not attached to any external system
+with `ResultSetFactory.copyResults`.
+
+```
+  try ( RDFConnection conn = RDFConnectionFactory.connect("foo") ) {
+      ResultSet safeCopy =
+          Txn.execReadReturn(conn, ()-> {
+              // Process results by row:
+              conn.querySelect("SELECT DISTINCT ?s { ?s ?p ?o }", (qs)->{
+                  Resource subject = qs.getResource("s") ;
+                  System.out.println("Subject: "+subject) ;
+              }) ;
+              ResultSet rs = conn.query("SELECT * { ?s ?p ?o }").execSelect() ;
+              return ResultSetFactory.copyResults(rs) ;
+          }) ;
+  }
+```
+
+## Update Usage
+
+SPARQL Update opertions can be performed and mixed with other operations.
+
+```
+  try ( RDFConnection conn = RDFConnectionFactory.connect(...) ) {
+      Txn.execWrite(conn, ()-> {
+         conn.update("DELETE DATA { ... }" ) ;
+         conn.load("data.ttl") ;
+         }) ;
+```
+
+## Dataset operations
+
+In addition to the SPARQL Graph Store Protocol, operations on whole
+datasets are provided for fetching (HTTP GET), adding data (HTTP POST) and
+settign the data (HTTP PUT) on a dataset URL.  This assumes the remote
+server supported these REST-style operations.  Apache Jena Fuseki does
+provide these.
+
+## Subinterfaces
+
+To help structure code, the `RDFConnection` consists of a number of
+different interfaces.  An `RDFConnection` can be passed to application code
+as one of these interfaces so that only certain subsets of the full
+operations are visible to the called code.
+
+* query via `SparqlQueryConnection`
+* update via `SparqlUpdateConnection`
+* graph store protocol `RDFDatasetAccessConnection` (read operations),
+   and `RDFDatasetConnection` (read and write operations).
+
+## Examples
+
+https://github.com/afs/jena-rdfconnection/tree/master/src/main/java/rdfconnection/examples

http://git-wip-us.apache.org/repos/asf/jena/blob/2e26b78e/jena-rdfconnection/LICENSE
----------------------------------------------------------------------
diff --git a/jena-rdfconnection/LICENSE b/jena-rdfconnection/LICENSE
new file mode 100644
index 0000000..f433b1a
--- /dev/null
+++ b/jena-rdfconnection/LICENSE
@@ -0,0 +1,177 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS

http://git-wip-us.apache.org/repos/asf/jena/blob/2e26b78e/jena-rdfconnection/NOTICE
----------------------------------------------------------------------
diff --git a/jena-rdfconnection/NOTICE b/jena-rdfconnection/NOTICE
new file mode 100644
index 0000000..81363e4
--- /dev/null
+++ b/jena-rdfconnection/NOTICE
@@ -0,0 +1,5 @@
+Apache Jena - RDF Connection
+Copyright 2016 The Apache Software Foundation
+
+This code is licensed under an Apache Software License.
+See LICENSE.

http://git-wip-us.apache.org/repos/asf/jena/blob/2e26b78e/jena-rdfconnection/README.md
----------------------------------------------------------------------
diff --git a/jena-rdfconnection/README.md b/jena-rdfconnection/README.md
new file mode 100644
index 0000000..1fee5e2
--- /dev/null
+++ b/jena-rdfconnection/README.md
@@ -0,0 +1,6 @@
+RDF Connection
+==============
+
+An API for SPARQL client functionality.
+
+Works for local and remote data.

http://git-wip-us.apache.org/repos/asf/jena/blob/2e26b78e/jena-rdfconnection/pom.xml
----------------------------------------------------------------------
diff --git a/jena-rdfconnection/pom.xml b/jena-rdfconnection/pom.xml
new file mode 100644
index 0000000..c58cce4
--- /dev/null
+++ b/jena-rdfconnection/pom.xml
@@ -0,0 +1,163 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+   Licensed 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.
+ 
+   See the NOTICE file distributed with this work for additional
+   information regarding copyright ownership.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" 
+	 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.jena</groupId>
+  <artifactId>jena-rdfconnection</artifactId>
+  <packaging>jar</packaging>
+  <name>Apache Jena - RDF Connection</name>
+  <version>3.2.0-SNAPSHOT</version>
+
+  <description>RDF Connection</description>
+
+  <parent>
+    <groupId>org.apache.jena</groupId>
+    <artifactId>jena-parent</artifactId>
+    <version>18-SNAPSHOT</version>
+    <relativePath>../jena-parent</relativePath>
+  </parent>
+
+  <licenses>
+    <license>
+      <name>Apache 2.0 License</name>
+      <url>http://www.apache.org/licenses/LICENSE-2.0</url>
+    </license>
+  </licenses>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.jena</groupId>
+      <artifactId>jena-arq</artifactId>
+      <version>3.2.0-SNAPSHOT</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.jena</groupId>
+      <artifactId>jena-base</artifactId>
+      <version>3.2.0-SNAPSHOT</version>
+      <classifier>tests</classifier>
+      <scope>test</scope>
+    </dependency>
+    
+    <dependency>
+      <groupId>org.apache.jena</groupId>
+      <artifactId>jena-arq</artifactId>
+      <version>3.2.0-SNAPSHOT</version>
+      <classifier>tests</classifier>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.jena</groupId>
+      <artifactId>jena-core</artifactId>
+      <classifier>tests</classifier>
+      <version>3.2.0-SNAPSHOT</version>
+      <scope>test</scope>
+    </dependency>    
+
+    <!-- Testing -->
+    <!-- Test is also done in jena-integration-tests -->
+    
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-log4j12</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>log4j</groupId>
+      <artifactId>log4j</artifactId>
+      <scope>test</scope>
+    </dependency> 
+
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+      </plugin>
+
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <configuration>
+          <includes>
+            <include>**/TS_*.java</include>
+          </includes>
+        </configuration>
+      </plugin>
+
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-jar-plugin</artifactId>
+        <executions>
+          <execution>
+            <goals>
+              <goal>test-jar</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-javadoc-plugin</artifactId>
+        <configuration>
+          <version>true</version>
+          <show>public</show>
+          <quiet>true</quiet>
+          <encoding>UTF-8</encoding>
+          <windowtitle>Apache Jena RDF Connection</windowtitle>
+          <doctitle>Apache Jena RDF Connection ${project.version}</doctitle>
+          <bottom>Licenced under the Apache License, Version 2.0</bottom>
+        </configuration>
+      </plugin>
+
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-resources-plugin</artifactId>
+      </plugin>
+
+      <plugin>
+        <groupId>org.apache.rat</groupId>
+        <artifactId>apache-rat-plugin</artifactId>
+        <configuration>
+          <excludes>
+            <exclude>Documentation.md</exclude>
+            <exclude>README.*</exclude>
+          </excludes>
+        </configuration>
+      </plugin>
+    </plugins>
+
+  </build>
+
+</project>

http://git-wip-us.apache.org/repos/asf/jena/blob/2e26b78e/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/JenaConnectionException.java
----------------------------------------------------------------------
diff --git a/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/JenaConnectionException.java b/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/JenaConnectionException.java
new file mode 100644
index 0000000..3bc6296
--- /dev/null
+++ b/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/JenaConnectionException.java
@@ -0,0 +1,29 @@
+/*
+ * 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 org.apache.jena.shared.JenaException ;
+
+/** Exceptions related to {@link RDFConnection} */ 
+public class JenaConnectionException extends JenaException {
+    public JenaConnectionException()                                  { super(); }
+    public JenaConnectionException(String message)                    { super(message); }
+    public JenaConnectionException(Throwable cause)                   { super(cause) ; }
+    public JenaConnectionException(String message, Throwable cause)   { super(message, cause) ; }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/jena/blob/2e26b78e/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFConn.java
----------------------------------------------------------------------
diff --git a/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFConn.java b/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFConn.java
new file mode 100644
index 0000000..27d8f96
--- /dev/null
+++ b/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFConn.java
@@ -0,0 +1,40 @@
+/*
+ * 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;
+
+/** package-wide utilities etc */
+/*package*/ class RDFConn {
+    private static String dftName =  "default" ;
+    
+    /*package*/ static boolean isDefault(String name) {
+        return name == null || name.equals(dftName) ;
+    }
+    
+    /*package*/ static String queryStringForGraph(String graphName) {
+        return 
+            (RDFConn.isDefault(graphName) )
+            ? "?default"
+            : "?graph="+graphName ;
+    }
+    
+    /*package*/ static String urlForGraph(String graphStoreProtocolService, String graphName) {
+        return graphStoreProtocolService + queryStringForGraph(graphName) ;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/2e26b78e/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFConnection.java
----------------------------------------------------------------------
diff --git a/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFConnection.java b/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFConnection.java
new file mode 100644
index 0000000..2610bb3
--- /dev/null
+++ b/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFConnection.java
@@ -0,0 +1,362 @@
+/*
+ * 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 java.util.function.Consumer ;
+
+import org.apache.jena.query.* ;
+import org.apache.jena.rdf.model.Model ;
+import org.apache.jena.sparql.core.Transactional ;
+import org.apache.jena.system.Txn ;
+import org.apache.jena.update.Update ;
+import org.apache.jena.update.UpdateFactory ;
+import org.apache.jena.update.UpdateRequest ;
+
+/**
+ * Interface for SPARQL operations on a datasets, whether local or remote.
+ * Operations can performed via this interface or via the various
+ * interfaces for a subset of the operations.  
+ * 
+ * <ul>
+ * <li>query ({@link SparqlQueryConnection}) 
+ * <li>update ({@link SparqlUpdateConnection})
+ * <li>graph store protocol ({@link RDFDatasetConnection}). 
+ * </ul>
+ *
+ * For remote operations, the
+ * <a href="http://www.w3.org/TR/sparql11-protocol/">SPARQL Protocol</a> is used
+ * for query and updates and
+ * <a href="http://www.w3.org/TR/sparql11-http-rdf-update/">SPARQL Graph Store
+ * Protocol</a> for the graph operations and in addition, there are analogous
+ * operations on datasets (fetch, load, put; but not delete).
+ * 
+ * {@code RDFConnection} provides transaction boundaries. If not in a
+ * transaction, an implicit transactional wrapper is applied ("autocommit").
+ * 
+ * Remote SPARQL operations are atomic but without additional capabilities from
+ * the remote server, multiple operations are not combined into a single
+ * transaction.
+ * 
+ * Not all implementations may implement all operations. See the implementation
+ * notes for details.
+ * 
+ * @see RDFConnectionFactory
+ * @see RDFConnectionLocal
+ * @see RDFConnectionRemote
+ */  
+public interface RDFConnection
+    // Default implementations could be pushed up but then they can't be mentioned here.  
+    extends
+        SparqlQueryConnection, SparqlUpdateConnection, RDFDatasetConnection,
+        Transactional, AutoCloseable 
+ {
+    // Inherits interfaces : re-mentioned to get the javadoc in one place.
+    
+    // ---- SparqlQueryConnection
+
+    /**
+     * Execute a SELECT query and process the ResultSet with the handler code.  
+     * @param query
+     * @param resultSetAction
+     */
+    @Override
+    public default void queryResultSet(String query, Consumer<ResultSet> resultSetAction) {
+        queryResultSet(QueryFactory.create(query), resultSetAction) ;
+    }
+    
+    /**
+     * Execute a SELECT query and process the ResultSet with the handler code.  
+     * @param query
+     * @param resultSetAction
+     */
+    @Override
+    public default void queryResultSet(Query query, Consumer<ResultSet> resultSetAction) {
+        if ( ! query.isSelectType() )
+            throw new JenaConnectionException("Query is not a SELECT query") ;
+
+        Txn.executeRead(this, ()->{ 
+            try ( QueryExecution qExec = query(query) ) {
+                ResultSet rs = qExec.execSelect() ;
+                resultSetAction.accept(rs);
+            }
+        } ) ; 
+    }
+
+    /**
+     * Execute a SELECT query and process the rows of the results with the handler code.  
+     * @param query
+     * @param rowAction
+     */
+    @Override
+    public default void querySelect(String query, Consumer<QuerySolution> rowAction) {
+        querySelect(QueryFactory.create(query), rowAction) ;
+    }
+    
+    /**
+     * Execute a SELECT query and process the rows of the results with the handler code.  
+     * @param query
+     * @param rowAction
+     */
+    @Override
+    public default void querySelect(Query query, Consumer<QuerySolution> rowAction) {
+        if ( ! query.isSelectType() )
+            throw new JenaConnectionException("Query is not a SELECT query") ;
+        Txn.executeRead(this, ()->{ 
+            try ( QueryExecution qExec = query(query) ) {
+                qExec.execSelect().forEachRemaining(rowAction);
+            }
+        } ) ; 
+    }
+
+    /** Execute a CONSTRUCT query and return as a Model */
+    @Override
+    public default Model queryConstruct(String query) {
+        return queryConstruct(QueryFactory.create(query)) ;
+    }
+    
+    /** Execute a CONSTRUCT query and return as a Model */
+    @Override
+    public default Model queryConstruct(Query query) {
+        return 
+            Txn.calculateRead(this, ()->{ 
+                try ( QueryExecution qExec = query(query) ) {
+                    return qExec.execConstruct() ;
+                }
+            } ) ; 
+    }
+
+    /** Execute a DESCRIBE query and return as a Model */
+    @Override
+    public default Model queryDescribe(String query) {
+        return queryDescribe(QueryFactory.create(query)) ;
+    }
+    
+    /** Execute a DESCRIBE query and return as a Model */
+    @Override
+    public default Model queryDescribe(Query query) {
+        return 
+            Txn.calculateRead(this, ()->{ 
+                try ( QueryExecution qExec = query(query) ) {
+                    return qExec.execDescribe() ;
+                }
+            } ) ; 
+    }
+    
+    /** Execute a ASK query and return a boolean */
+    @Override
+    public default boolean queryAsk(String query) {
+        return queryAsk(QueryFactory.create(query)) ;
+    }
+
+    /** Execute a ASK query and return a boolean */
+    @Override
+    public default boolean queryAsk(Query query) {
+        return 
+            Txn.calculateRead(this, ()->{ 
+                try ( QueryExecution qExec = query(query) ) {
+                    return qExec.execAsk() ;
+                }
+            } ) ; 
+    }
+
+    /** Setup a SPARQL query execution.
+     * 
+     *  See also {@link #querySelect(Query, Consumer)}, {@link #queryConstruct(Query)}, 
+     *  {@link #queryDescribe(Query)}, {@link #queryAsk(Query)}
+     *  for ways to execute queries for of a specific form.
+     * 
+     * @param query
+     * @return QueryExecution
+     */
+    @Override
+    public QueryExecution query(Query query) ;
+
+    /** Setup a SPARQL query execution.
+     * 
+     *  See also {@link #querySelect(String, Consumer)}, {@link #queryConstruct(String)}, 
+     *  {@link #queryDescribe(String)}, {@link #queryAsk(String)}
+     *  for ways to execute queries for of a specific form.
+     * 
+     * @param queryString 
+     * @return QueryExecution
+     */
+    @Override
+    public default QueryExecution query(String queryString) {
+        return query(QueryFactory.create(queryString)) ;
+    }
+    
+    // ---- SparqlUpdateConnection
+    
+    /** Execute a SPARQL Update.
+     * 
+     * @param update
+     */
+    @Override
+    public default void update(Update update) {
+        update(new UpdateRequest(update)) ;
+    }
+
+    /** Execute a SPARQL Update.
+     * 
+     * @param update
+     */
+    @Override
+    public void update(UpdateRequest update) ; 
+    
+    /** Execute a SPARQL Update.
+     * 
+     * @param updateString
+     */
+    @Override
+    public default void update(String updateString) {
+        update(UpdateFactory.create(updateString)) ;
+    }
+    
+    // ---- RDFDatasetConnection
+    
+    /** Load (add, append) RDF into a named graph in a dataset.
+     * This is SPARQL Graph Store Protocol HTTP POST or equivalent. 
+     * 
+     * @param graphName Graph name (null or "default" for the default graph)
+     * @param file File of the data.
+     */
+    @Override
+    public void load(String graphName, String file) ;
+    
+    /** Load (add, append) RDF into the default graph of a dataset.
+     * This is SPARQL Graph Store Protocol HTTP POST or equivalent. 
+     * 
+     * @param file File of the data.
+     */
+    @Override
+    public void load(String file) ;
+
+    /** Load (add, append) RDF into a named graph in a dataset.
+     * This is SPARQL Graph Store Protocol HTTP POST or equivalent. 
+     * 
+     * @param graphName Graph name (null or "default" for the default graph)
+     * @param model Data.
+     */
+    @Override
+    public void load(String graphName, Model model) ;
+    
+    /** Load (add, append) RDF into the default graph of a dataset.
+     * This is SPARQL Graph Store Protocol HTTP POST or equivalent. 
+     * 
+     * @param model Data.
+     */
+    @Override
+    public void load(Model model) ;
+
+    /** Set the contents of a named graph of a dataset.
+     * Any existing data is lost. 
+     * This is SPARQL Graph Store Protocol HTTP PUT or equivalent. 
+     *
+     * @param graphName Graph name (null or "default" for the default graph)
+     * @param file File of the data.
+     */
+    @Override
+    public void put(String graphName, String file) ;
+    
+    /** Set the contents of the default graph of a dataset.
+     * Any existing data is lost. 
+     * This is SPARQL Graph Store Protocol HTTP PUT or equivalent. 
+     * 
+     * @param file File of the data.
+     */
+    @Override
+    public void put(String file) ;
+        
+    /** Set the contents of a named graph of a dataset.
+     * Any existing data is lost. 
+     * This is SPARQL Graph Store Protocol HTTP PUT or equivalent. 
+     *
+     * @param graphName Graph name (null or "default" for the default graph)
+     * @param model Data.
+     */
+    @Override
+    public void put(String graphName, Model model) ;
+    
+    /** Set the contents of the default graph of a dataset.
+     * Any existing data is lost. 
+     * This is SPARQL Graph Store Protocol HTTP PUT or equivalent. 
+     * 
+     * @param model Data.
+     */
+    @Override
+    public void put( Model model) ;
+        
+    /**
+     * Delete a graph from the dataset.
+     * Null or "default" measn the default graph, which is cleared, not removed.
+     * 
+     * @param graphName
+     */
+    @Override
+    public void delete(String graphName) ;
+
+    /**
+     * Remove all data from the default graph.
+     */ 
+    @Override
+    public void delete() ;
+    
+    /* Load (add, append) RDF triple or quad data into a dataset. Triples wil go into the default graph.
+     * This is not a SPARQL Graph Store Protocol operation.
+     * It is an HTTP POST equivalent to the dataset.
+     */
+    @Override
+    public void loadDataset(String file) ;
+
+    /* Load (add, append) RDF triple or quad data into a dataset. Triples wil go into the default graph.
+     * This is not a SPARQL Graph Store Protocol operation.
+     * It is an HTTP POST equivalent to the dataset.
+     */
+    @Override
+    public void loadDataset(Dataset dataset) ;
+
+    /* Set RDF triple or quad data as the dataset contents.
+     * Triples will go into the default graph, quads in named graphs.
+     * This is not a SPARQL Graph Store Protocol operation.
+     * It is an HTTP PUT equivalent to the dataset.
+     */
+    @Override
+    public void putDataset(String file) ;
+    
+    /* Set RDF triple or quad data as the dataset contents.
+     * Triples will go into the default graph, quads in named graphs.
+     * This is not a SPARQL Graph Store Protocol operation.
+     * It is an HTTP PUT equivalent to the dataset.
+     */
+    @Override
+    public void putDataset(Dataset dataset) ;
+
+    //    /** Clear the dataset - remove all named graphs, clear the default graph. */
+    //    public void clearDataset() ;
+    
+    
+    /** Test whether this connection is closed or not */
+    @Override
+    public boolean isClosed() ;
+    
+    /** Close this connection.  Use with try-resource. */ 
+    @Override 
+    public void close() ;
+}
+

http://git-wip-us.apache.org/repos/asf/jena/blob/2e26b78e/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFConnectionFactory.java
----------------------------------------------------------------------
diff --git a/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFConnectionFactory.java b/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFConnectionFactory.java
new file mode 100644
index 0000000..ee78a8d
--- /dev/null
+++ b/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFConnectionFactory.java
@@ -0,0 +1,84 @@
+/*
+ * 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 org.apache.jena.query.Dataset ;
+import org.apache.jena.system.JenaSystem ;
+
+// Pool stuff
+public class RDFConnectionFactory {
+    static { JenaSystem.init(); }
+    
+    /** Create a connection to a remote location by URL.
+     * This is the URL for the dataset.
+     * 
+     *  This call assumes the names of services as:
+     *  <ul>
+     *  <li>SPARQL Query endpoint : "sparql"
+     *  <li>SPARQL Update endpoint : "update"
+     *  <li>SPARQL Graph Store Protocol : "data"
+     *  </ul>
+     *  These are the default names in <a href="http://jena.apache.org/documentation/fuseki2">Fuseki</a> 
+     *  Other names can be specificied using {@link #connect(String, String, String, String)}
+     *     
+     * @param destination
+     * @return RDFConnection
+     * @see #connect(String, String, String, String)
+     */
+    public static RDFConnection connect(String destination) {
+        return new RDFConnectionRemote(destination) ;
+    }
+
+    /** Create a connection to a remote location by URL.
+     * This is the URL for the dataset.
+     * 
+     *  This call requires specifying the names of the service.
+     */ 
+    public static RDFConnection connect(String queryServiceEndpoint,
+                                        String updateServiceEndpoint,
+                                        String graphStoreProtocolEndpoint) {
+        return new RDFConnectionRemote(queryServiceEndpoint, updateServiceEndpoint, graphStoreProtocolEndpoint) ;
+   }
+
+    
+    /** Create a connection to a remote location by URL.
+     * This is the URL for the dataset.
+     * 
+     *  This call requires specifying the names of the servicerelative to the dataset URL.
+     *  
+     */ 
+    public static RDFConnection connect(String datasetURL,
+                                        String queryServiceEndpoint,
+                                        String updateServiceEndpoint,
+                                        String graphStoreProtocolEndpoint) {
+        return new RDFConnectionRemote(datasetURL, queryServiceEndpoint, updateServiceEndpoint, graphStoreProtocolEndpoint) ;
+    }
+
+    /**
+     * Connect to a local (same JVM) dataset.
+     * @param dataset
+     * @return RDFConnection
+     */
+    public static RDFConnection connect(Dataset dataset) {
+        return new RDFConnectionLocal(dataset) ;
+    }
+
+    //public RDFConnection getFromPool() ;
+}
+

http://git-wip-us.apache.org/repos/asf/jena/blob/2e26b78e/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFConnectionLocal.java
----------------------------------------------------------------------
diff --git a/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFConnectionLocal.java b/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFConnectionLocal.java
new file mode 100644
index 0000000..2f7be62
--- /dev/null
+++ b/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFConnectionLocal.java
@@ -0,0 +1,286 @@
+/*
+ * 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 java.util.Objects ;
+
+import org.apache.jena.graph.Graph ;
+import org.apache.jena.query.* ;
+import org.apache.jena.rdf.model.Model ;
+import org.apache.jena.rdf.model.ModelFactory ;
+import org.apache.jena.riot.Lang ;
+import org.apache.jena.riot.RDFDataMgr ;
+import org.apache.jena.riot.RDFLanguages ;
+import org.apache.jena.sparql.ARQException ;
+import org.apache.jena.sparql.core.DatasetGraph ;
+import org.apache.jena.sparql.core.DatasetGraphFactory ;
+import org.apache.jena.sparql.core.DatasetGraphReadOnly ;
+import org.apache.jena.sparql.graph.GraphReadOnly ;
+import org.apache.jena.system.Txn ;
+import org.apache.jena.update.UpdateExecutionFactory ;
+import org.apache.jena.update.UpdateRequest ;
+
+/** 
+ * 
+ */
+
+public class RDFConnectionLocal implements RDFConnection {
+    // XXX Expose copy-mode
+
+    
+    private ThreadLocal<Boolean> transactionActive = ThreadLocal.withInitial(()->false) ;
+    private static boolean isolateByCopy = true ; 
+    private Dataset dataset ;
+    
+    public RDFConnectionLocal(Dataset dataset) {
+        this.dataset = dataset ;
+    }
+    
+    @Override
+    public QueryExecution query(Query query) {
+        checkOpen() ;
+        return Txn.calculateRead(dataset, ()->QueryExecutionFactory.create(query, dataset)) ;
+    }
+
+    @Override
+    public void update(UpdateRequest update) {
+        checkOpen() ;
+        Txn.executeWrite(dataset, ()->UpdateExecutionFactory.create(update, dataset).execute() ) ; 
+    }
+
+    @Override
+    public void load(String graph, String file) {
+        checkOpen() ;
+        doPutPost(graph, file, false) ;
+    }
+
+    @Override
+    public void load(String file) {
+        checkOpen() ;
+        doPutPost(null, file, false) ;
+    }
+
+    @Override
+    public void load(String graphName, Model model) {
+        checkOpen() ;
+        Txn.executeWrite(dataset, ()-> {
+            Model modelDst = modelFor(graphName) ; 
+            modelDst.add(model) ;
+        }) ;
+    }
+
+    @Override
+    public void load(Model model) { 
+        load(null, model) ;
+    }
+
+    /**
+     * There may be differences between local and remote behaviour. A local
+     * connection may return direct references to a dataset so updates on
+     * returned
+     */
+
+    @Override
+    public Model fetch(String graph) {
+        return Txn.calculateRead(dataset, ()-> {
+            Model model = modelFor(graph) ; 
+            return isolate(model) ; 
+        }) ;
+    }
+
+    @Override
+    public Model fetch() {
+        checkOpen() ;
+        return fetch(null) ;
+    }
+
+    @Override
+    public void put(String file) {
+        checkOpen() ;
+        doPutPost(null, file, true) ;
+    }
+
+    @Override
+    public void put(String graph, String file) {
+        checkOpen() ;
+        doPutPost(graph, file, true) ;
+    }
+
+    @Override
+    public void put(Model model) {
+        put(null, model) ; 
+    }
+
+    @Override
+    public void put(String graphName, Model model) {
+        checkOpen() ;
+        Txn.executeWrite(dataset, ()-> {
+            Model modelDst = modelFor(graphName) ; 
+            modelDst.removeAll();
+            modelDst.add(model) ;
+        }) ;
+    }
+
+    @Override
+    public void delete(String graph) {
+        checkOpen() ;
+        Txn.executeWrite(dataset,() ->{
+            if ( RDFConn.isDefault(graph) ) 
+                dataset.getDefaultModel().removeAll();
+            else 
+                dataset.removeNamedModel(graph);
+        }) ;
+    }
+
+    @Override
+    public void delete() {
+        checkOpen() ;
+        delete(null) ;
+    }
+
+    private void doPutPost(String graph, String file, boolean replace) {
+        Objects.requireNonNull(file) ;
+        Lang lang = RDFLanguages.filenameToLang(file) ;
+        
+        Txn.executeWrite(dataset,() ->{
+            if ( RDFLanguages.isTriples(lang) ) {
+                Model model = RDFConn.isDefault(graph) ? dataset.getDefaultModel() : dataset.getNamedModel(graph) ;
+                if ( replace )
+                    model.removeAll() ;
+                RDFDataMgr.read(model, file); 
+            }
+            else if ( RDFLanguages.isQuads(lang) ) {
+                if ( replace )
+                    dataset.asDatasetGraph().clear(); 
+                // Try to POST to the dataset.
+                RDFDataMgr.read(dataset, file); 
+            }
+            else
+                throw new ARQException("Not an RDF format: "+file+" (lang="+lang+")") ;
+        }) ;
+    }
+
+    /**
+     * Called to isolate a model from it's storage. Must be inside a
+     * transaction.
+     */
+    private Model isolate(Model model) {
+        if ( ! isolateByCopy ) {
+            // Half-way - read-only but dataset changes can be seen. 
+            Graph g = new GraphReadOnly(model.getGraph()) ;
+            return ModelFactory.createModelForGraph(g) ;
+        }
+        // Copy.
+        Model m2 = ModelFactory.createDefaultModel() ;
+        m2.add(model) ;
+        return m2 ;
+    }
+
+    /**
+     * Called to isolate a dataset from it's storage. Must be inside a
+     * transaction.
+     */
+    private Dataset isolate(Dataset dataset) {
+        if ( ! isolateByCopy ) {
+            DatasetGraph dsg = new DatasetGraphReadOnly(dataset.asDatasetGraph()) ;
+            return DatasetFactory.wrap(dsg) ;
+        }
+
+        // Copy.
+        DatasetGraph dsg2 = DatasetGraphFactory.create() ;
+        dataset.asDatasetGraph().find().forEachRemaining(q -> dsg2.add(q) );
+        return DatasetFactory.wrap(dsg2) ;
+    }
+
+    private Model modelFor(String graph) {
+        if ( RDFConn.isDefault(graph)) 
+            return dataset.getDefaultModel() ;
+        return dataset.getNamedModel(graph) ;
+    }
+
+    @Override
+    public Dataset fetchDataset() {
+        checkOpen() ;
+        return Txn.calculateRead(dataset,() -> isolate(dataset)) ;   
+    }
+
+    @Override
+    public void loadDataset(String file) {
+        checkOpen() ;
+        Txn.executeWrite(dataset,() ->{
+            RDFDataMgr.read(dataset, file);
+        }) ;
+    }
+
+    @Override
+    public void loadDataset(Dataset dataset) {
+        Txn.executeWrite(dataset,() ->{
+            dataset.asDatasetGraph().find().forEachRemaining((q)->this.dataset.asDatasetGraph().add(q)) ;
+        }) ;
+    }
+
+    @Override
+    public void putDataset(String file) {
+        checkOpen() ;
+        Txn.executeWrite(dataset,() ->{
+            dataset.asDatasetGraph().clear();
+            RDFDataMgr.read(dataset, file);
+        }) ;
+    }
+
+    @Override
+    public void putDataset(Dataset dataset) {
+        Txn.executeWrite(dataset,() ->{
+            this.dataset = isolate(dataset) ;
+        }) ;
+    }
+
+    @Override
+    public void close() {
+        dataset = null ;
+    }
+    
+    @Override
+    public boolean isClosed() {
+        return dataset == null ;
+    }
+
+    private void checkOpen() {
+        if ( dataset == null )
+            throw new ARQException("closed") ;
+    }
+
+    @Override
+    public void begin(ReadWrite readWrite)  { dataset.begin(readWrite); }
+
+    @Override
+    public void commit()                    { dataset.commit(); }
+
+    @Override
+    public void abort()                     { dataset.abort(); }
+
+    @Override
+    public boolean isInTransaction()        { return dataset.isInTransaction() ; }
+
+    @Override
+    public void end()                       { dataset.end() ; }
+    
+   
+}
+

http://git-wip-us.apache.org/repos/asf/jena/blob/2e26b78e/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFConnectionModular.java
----------------------------------------------------------------------
diff --git a/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFConnectionModular.java b/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFConnectionModular.java
new file mode 100644
index 0000000..8f36355
--- /dev/null
+++ b/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFConnectionModular.java
@@ -0,0 +1,199 @@
+/*
+ * 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 org.apache.jena.query.Dataset ;
+import org.apache.jena.query.Query ;
+import org.apache.jena.query.QueryExecution ;
+import org.apache.jena.query.ReadWrite ;
+import org.apache.jena.rdf.model.Model ;
+import org.apache.jena.sparql.core.Transactional ;
+import org.apache.jena.update.UpdateRequest ;
+
+/** 
+ * 
+ */
+public class RDFConnectionModular implements RDFConnection {
+    
+    private final SparqlQueryConnection queryConnection ;
+    private final SparqlUpdateConnection updateConnection ;
+    private final RDFDatasetConnection datasetConnection ;
+    private final Transactional transactional ;
+    
+    @Override
+    public void begin(ReadWrite readWrite) { transactional.begin(readWrite); }
+    @Override
+    public void commit() { transactional.commit(); }
+    @Override
+    public void abort() { transactional.abort(); }
+    @Override
+    public void end() { transactional.end(); }
+    @Override
+    public boolean isInTransaction() { 
+        return transactional.isInTransaction() ;
+    }
+    
+    public RDFConnectionModular(SparqlQueryConnection queryConnection ,
+                                SparqlUpdateConnection updateConnection ,
+                                RDFDatasetConnection datasetConnection ) {
+        this.queryConnection = queryConnection ;
+        this.updateConnection = updateConnection ;
+        this.datasetConnection = datasetConnection ;
+        this.transactional = 
+            updateConnection  != null ? updateConnection :
+            datasetConnection != null ? datasetConnection :
+            queryConnection   != null ? queryConnection :
+            null ;
+    }
+    
+    public RDFConnectionModular(RDFConnection connection ) {
+        this.queryConnection = connection ;
+        this.updateConnection = connection ;
+        this.datasetConnection = connection ;
+        this.transactional = connection ;
+    }
+
+    private SparqlQueryConnection queryConnection() {
+        if ( queryConnection == null )
+            throw new UnsupportedOperationException("No SparqlQueryConnection") ;
+        return queryConnection ;
+    }
+    
+    private SparqlUpdateConnection updateConnection() {
+        if ( updateConnection == null )
+            throw new UnsupportedOperationException("No SparqlUpdateConnection") ;
+        return updateConnection ;
+    }
+
+    private RDFDatasetConnection datasetConnection() {
+        if ( datasetConnection == null )
+            throw new UnsupportedOperationException("No RDFDatasetConnection") ;
+        return datasetConnection ;
+    }
+    
+    
+
+    @Override
+    public QueryExecution query(Query query) { return queryConnection().query(query) ; }
+
+    @Override
+    public void update(UpdateRequest update) {
+        updateConnection().update(update) ;
+    }
+
+    @Override
+    public void load(String graphName, String file) {
+        datasetConnection().load(graphName, file) ;
+    }
+
+    @Override
+    public void load(String file) {
+        datasetConnection().load(file) ;
+    }
+
+    @Override
+    public void load(String graphName, Model model) {
+        datasetConnection().load(graphName, model) ;
+    }
+
+    @Override
+    public void load(Model model) {
+        datasetConnection().load(model) ;
+    }
+
+    @Override
+    public void put(String graphName, String file) {
+        datasetConnection().put(graphName, file) ;
+    }
+
+    @Override
+    public void put(String file) {
+        datasetConnection().put(file) ;
+    }
+
+    @Override
+    public void put(String graphName, Model model) {
+        datasetConnection().put(graphName, model) ;
+    }
+
+    @Override
+    public void put(Model model) {
+        datasetConnection().put(model) ;
+    }
+
+    @Override
+    public void delete(String graphName) {
+        datasetConnection().delete(graphName) ;
+    }
+
+    @Override
+    public void delete() {
+        datasetConnection().delete() ;
+    }
+
+    @Override
+    public void loadDataset(String file) {
+        datasetConnection().loadDataset(file) ;
+    }
+
+    @Override
+    public void loadDataset(Dataset dataset) {
+        datasetConnection().loadDataset(dataset) ;
+    }
+
+    @Override
+    public void putDataset(String file) {
+        datasetConnection().putDataset(file) ;
+    }
+
+    @Override
+    public void putDataset(Dataset dataset) {
+        datasetConnection().putDataset(dataset) ;
+    }
+
+    //    /** Clear the dataset - remove all named graphs, clear the default graph. */
+    //    public void clearDataset() ;
+    
+    @Override
+    public Model fetch(String graphName) {
+        return datasetConnection.fetch(graphName) ;
+    }
+    @Override
+    public Model fetch() {
+        return datasetConnection().fetch() ;
+    }
+    @Override
+    public Dataset fetchDataset() {
+        return datasetConnection().fetchDataset() ;
+    }
+    @Override
+    public boolean isClosed() { return false ; }
+    
+    /** Close this connection.  Use with try-resource. */ 
+    @Override 
+    public void close() {
+        if ( queryConnection != null )
+            queryConnection.close(); 
+        if ( updateConnection != null )
+            updateConnection.close();
+        if ( datasetConnection != null )
+            datasetConnection.close() ;
+    }
+}
+

http://git-wip-us.apache.org/repos/asf/jena/blob/2e26b78e/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFConnectionRemote.java
----------------------------------------------------------------------
diff --git a/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFConnectionRemote.java b/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFConnectionRemote.java
new file mode 100644
index 0000000..02d7bef
--- /dev/null
+++ b/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFConnectionRemote.java
@@ -0,0 +1,478 @@
+/*
+ * 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 java.util.Objects.requireNonNull ;
+
+import java.io.File ;
+import java.io.InputStream ;
+import java.util.concurrent.locks.ReentrantLock ;
+import java.util.function.Supplier ;
+
+import org.apache.http.HttpEntity ;
+import org.apache.http.client.HttpClient ;
+import org.apache.http.entity.EntityTemplate ;
+import org.apache.http.protocol.HttpContext ;
+import org.apache.jena.atlas.io.IO ;
+import org.apache.jena.atlas.web.HttpException ;
+import org.apache.jena.atlas.web.TypedInputStream ;
+import org.apache.jena.graph.Graph ;
+import org.apache.jena.query.* ;
+import org.apache.jena.rdf.model.Model ;
+import org.apache.jena.rdf.model.ModelFactory ;
+import org.apache.jena.riot.* ;
+import org.apache.jena.riot.web.HttpCaptureResponse ;
+import org.apache.jena.riot.web.HttpOp ;
+import org.apache.jena.riot.web.HttpResponseLib ;
+import org.apache.jena.sparql.ARQException ;
+import org.apache.jena.sparql.core.DatasetGraph ;
+import org.apache.jena.sparql.core.Transactional ;
+import org.apache.jena.system.Txn ;
+import org.apache.jena.update.UpdateExecutionFactory ;
+import org.apache.jena.update.UpdateProcessor ;
+import org.apache.jena.update.UpdateRequest ;
+import org.apache.jena.web.HttpSC ;
+
+/** 
+ * 
+ */
+public class RDFConnectionRemote implements RDFConnection {
+    private static final String fusekiDftSrvQuery   = "sparql" ;
+    private static final String fusekiDftSrvUpdate  = "update" ;
+    private static final String fusekiDftSrvGSP     = "data" ;
+    
+    private boolean isOpen = true ; 
+    private final String destination ;
+    private final String svcQuery ;
+    private final String svcUpdate ;
+    private final String svcGraphStore ;
+    private HttpClient httpClient ;
+    private HttpContext httpContext = null ;
+    
+    // Builder?
+    // HttpContext, HttpClient.
+    // Statics for "query", "query+update" : SparqlQueryConnectionRemote > SparqlUpdateConnectionRemote > RDFConnectionRemote
+    // XXX Very long "HttpOp.execHttpPost"
+    
+    /** Create connection that wil use the {@link HttpClient} using URL of the dataset and default service names */
+    public RDFConnectionRemote(HttpClient httpClient, String destination) {
+        this(httpClient,
+             requireNonNull(destination),
+             fusekiDftSrvQuery, 
+             fusekiDftSrvUpdate,
+             fusekiDftSrvGSP) ;
+    }
+
+
+    /** Create connection, using URL of the dataset and default service names */
+    public RDFConnectionRemote(String destination) {
+        this(requireNonNull(destination),
+             fusekiDftSrvQuery, 
+             fusekiDftSrvUpdate,
+             fusekiDftSrvGSP) ;
+    }
+
+    // ??
+    /** Create connection, using full URLs for services. Pass a null for "no service endpoint". */
+    public RDFConnectionRemote(String sQuery, String sUpdate, String sGSP) {
+        this(null, sQuery, sUpdate, sGSP) ;
+    }
+    
+    /** Create connection, using URL of the dataset and short names for the services */
+    public RDFConnectionRemote(String destination, String sQuery, String sUpdate, String sGSP) {
+        this(null, destination, sQuery, sUpdate, sGSP) ;
+    }
+    
+    /** Create connection, using URL of the dataset and short names for the services */
+    public RDFConnectionRemote(HttpClient httpClient, String destination, String sQuery, String sUpdate, String sGSP) {
+        this.destination = destination ;
+        this.svcQuery = formServiceURL(destination,sQuery) ;
+        this.svcUpdate = formServiceURL(destination,sUpdate) ;
+        this.svcGraphStore = formServiceURL(destination,sGSP) ;
+//        if ( httpClient == null )
+//            httpClient = HttpOp.getDefaultHttpClient() ;
+        this.httpClient = httpClient ;
+    }
+    
+    public HttpClient getHttpClient() {
+        return httpClient ;
+    }
+
+    public void setHttpClient(HttpClient httpClient) {
+        this.httpClient = httpClient ;
+    }
+
+    public HttpContext getHttpContext() {
+        return httpContext ;
+    }
+
+    public void setHttpContext(HttpContext httpContext) {
+        this.httpContext = httpContext ;
+    }
+
+    private static String formServiceURL(String destination, String srvEndpoint) {
+        if ( destination == null )
+            return srvEndpoint ;
+        String dest = destination ;
+        if ( dest.endsWith("/") )
+            dest = dest.substring(0, dest.length()-1) ;
+        return dest+"/"+srvEndpoint ;
+    }
+
+    @Override
+    public QueryExecution query(Query query) {
+        checkQuery();
+        return exec(()->QueryExecutionFactory.createServiceRequest(svcQuery, query)) ;
+    }
+
+    @Override
+    public void update(UpdateRequest update) {
+        checkUpdate();
+        UpdateProcessor proc = UpdateExecutionFactory.createRemote(update, svcUpdate) ;
+        exec(()->proc.execute());
+    }
+    
+    @Override
+    public Model fetch(String graphName) {
+        checkGSP() ;
+        String url = RDFConn.urlForGraph(svcGraphStore, graphName) ;
+        Graph graph = fetch$(url) ;
+        return ModelFactory.createModelForGraph(graph) ;
+    }
+    
+    @Override
+    public Model fetch() {
+        checkGSP() ;
+        return fetch(null) ;
+    }
+    
+    private Graph fetch$(String url) {
+        HttpCaptureResponse<Graph> graph = HttpResponseLib.graphHandler() ;
+        exec(()->HttpOp.execHttpGet(url, WebContent.defaultGraphAcceptHeader, graph, this.httpClient, this.httpContext)) ;
+        return graph.get() ;
+    }
+
+    @Override
+    public void load(String graph, String file) {
+        checkGSP() ;
+        upload(graph, file, false) ;
+    }
+    
+    @Override
+    public void load(String file) {
+        checkGSP() ;
+        upload(null, file, false) ;
+    }
+    
+    @Override
+    public void load(Model model) {
+        doPutPost(model, null, false) ;
+    }
+    
+    @Override
+    public void load(String graphName, Model model) {
+        doPutPost(model, graphName, false) ;
+    }
+    
+    @Override
+    public void put(String graph, String file) {
+        checkGSP() ;
+        upload(graph, file, true) ;
+    }
+    
+    @Override
+    public void put(String file) { 
+        checkGSP() ;
+        upload(null, file, true) ; 
+    }
+    
+    @Override
+    public void put(String graphName, Model model) {
+        checkGSP() ;
+        doPutPost(model, graphName, true) ;
+    }
+
+    @Override
+    public void put(Model model) {
+        checkGSP() ;
+        doPutPost(model, null, true) ;
+    }
+    
+    private void upload(String graph, String file, boolean replace) {
+        // if triples
+        Lang lang = RDFLanguages.filenameToLang(file) ;
+        if ( RDFLanguages.isQuads(lang) )
+            throw new ARQException("Can't load quads into a graph") ;
+        if ( ! RDFLanguages.isTriples(lang) )
+            throw new ARQException("Not an RDF format: "+file+" (lang="+lang+")") ;
+        String url = RDFConn.urlForGraph(svcGraphStore, graph) ;
+        doPutPost(url, file, lang, replace) ;
+    }
+
+    private void doPutPost(String url, String file, Lang lang, boolean replace) {
+        File f = new File(file) ;
+        long length = f.length() ; 
+        InputStream source = IO.openFile(file) ;
+        // Charset.
+        exec(()->{
+            if ( replace )
+                HttpOp.execHttpPut(url, lang.getContentType().getContentType(), source, length, httpClient, this.httpContext) ;
+            else    
+                HttpOp.execHttpPost(url, lang.getContentType().getContentType(), source, length, null, null, httpClient, this.httpContext) ;
+        }) ;
+    }
+
+    private void doPutPost(Model model, String name, boolean replace) {
+        String url = RDFConn.urlForGraph(svcGraphStore, name) ;
+        exec(()->{
+            Graph graph = model.getGraph() ;
+            if ( replace )
+                HttpOp.execHttpPut(url, graphToHttpEntity(graph), httpClient, this.httpContext) ;
+            else    
+                HttpOp.execHttpPost(url, graphToHttpEntity(graph), null, null, httpClient, this.httpContext) ;
+        });
+    }
+
+    @Override
+    public void delete(String graph) {
+        checkGSP() ;
+        String url = RDFConn.urlForGraph(svcGraphStore, graph) ;
+        exec(()->HttpOp.execHttpDelete(url));
+    }
+
+    @Override
+    public void delete() {
+        checkGSP() ;
+        delete(null) ;
+    }
+
+    @Override
+    public Dataset fetchDataset() {
+        if ( destination == null )
+            throw new ARQException("Dataset operations not available - no dataset URL provided") ; 
+        Dataset ds = DatasetFactory.createTxnMem() ;
+        Txn.executeWrite(ds, ()->{
+            TypedInputStream s = exec(()->HttpOp.execHttpGet(destination, WebContent.defaultDatasetAcceptHeader)) ;
+            Lang lang = RDFLanguages.contentTypeToLang(s.getContentType()) ;
+            RDFDataMgr.read(ds, s, lang) ;
+        }) ;
+        return ds ;
+    }
+
+    @Override
+    public void loadDataset(String file) { 
+        if ( destination == null )
+            throw new ARQException("Dataset operations not available - no dataset URl provided") ; 
+        doPutPostDataset(file, false) ; 
+    }
+    
+    @Override
+    public void loadDataset(Dataset dataset) {
+        if ( destination == null )
+            throw new ARQException("Dataset operations not available - no dataset URl provided") ; 
+        doPutPostDataset(dataset, false) ; 
+    }
+
+    @Override
+    public void putDataset(String file) {
+        if ( destination == null )
+            throw new ARQException("Dataset operations not available - no dataset URl provided") ; 
+        doPutPostDataset(file, true) ;
+    }
+    
+    @Override
+    public void putDataset(Dataset dataset) {
+        if ( destination == null )
+            throw new ARQException("Dataset operations not available - no dataset URl provided") ; 
+        doPutPostDataset(dataset, true) ; 
+    }
+
+    private void doPutPostDataset(String file, boolean replace) {
+        Lang lang = RDFLanguages.filenameToLang(file) ;
+        File f = new File(file) ;
+        long length = f.length() ;
+        exec(()->{
+            InputStream source = IO.openFile(file) ;
+            if ( replace )
+                HttpOp.execHttpPut(destination, lang.getContentType().getContentType(), source, length, httpClient, httpContext) ;
+            else    
+                HttpOp.execHttpPost(destination, lang.getContentType().getContentType(), source, length, null, null, httpClient, httpContext) ;
+        });
+    }
+
+    private void doPutPostDataset(Dataset dataset, boolean replace) {
+        exec(()->{
+            DatasetGraph dsg = dataset.asDatasetGraph() ;
+            if ( replace )
+                HttpOp.execHttpPut(destination, datasetToHttpEntity(dsg), httpClient, null) ;
+            else    
+                HttpOp.execHttpPost(destination, datasetToHttpEntity(dsg), httpClient, null) ;
+        });
+    }
+
+
+    private void checkQuery() {
+        checkOpen() ;
+        if ( svcQuery == null )
+            throw new ARQException("No query service defined for this RDFConnection") ;
+    }
+    
+    private void checkUpdate() {
+        checkOpen() ;
+        if ( svcUpdate == null )
+            throw new ARQException("No update service defined for this RDFConnection") ;
+    }
+    
+    private void checkGSP() {
+        checkOpen() ;
+        if ( svcGraphStore == null )
+            throw new ARQException("No SPARQL Graph Store service defined for this RDFConnection") ;
+    }
+    
+    private void checkDataset() {
+        checkOpen() ;
+        if ( destination == null )
+            throw new ARQException("Dataset operations not available - no dataset URL provided") ; 
+    }
+
+    private void checkOpen() {
+        if ( ! isOpen )
+            throw new ARQException("closed") ;
+    }
+
+    @Override
+    public void close() {
+        isOpen = false ;
+    }
+
+    @Override
+    public boolean isClosed() {
+        return ! isOpen ;
+    }
+
+    /** Create an HttpEntity for the graph */  
+    protected HttpEntity graphToHttpEntity(Graph graph) {
+        return graphToHttpEntity(graph, RDFFormat.NTRIPLES) ;
+    }
+    
+    /** Create an HttpEntity for the graph */
+    protected HttpEntity graphToHttpEntity(Graph graph, RDFFormat syntax) {
+        EntityTemplate entity = new EntityTemplate((out)->RDFDataMgr.write(out, graph, syntax)) ;
+        String ct = syntax.getLang().getContentType().getContentType() ;
+        entity.setContentType(ct) ;
+        return entity ;
+    }
+
+    /** Create an HttpEntity for the dataset */  
+    protected HttpEntity datasetToHttpEntity(DatasetGraph dataset) {
+        return datasetToHttpEntity(dataset, RDFFormat.NQUADS) ;
+    }
+    
+    /** Create an HttpEntity for the dataset */  
+    protected HttpEntity datasetToHttpEntity(DatasetGraph dataset, RDFFormat syntax) {
+        EntityTemplate entity = new EntityTemplate((out)->RDFDataMgr.write(out, dataset, syntax)) ;
+        String ct = syntax.getLang().getContentType().getContentType() ;
+        entity.setContentType(ct) ;
+        return entity ;
+    }
+
+    /** Convert HTTP status codes to exceptions */ 
+    static void exec(Runnable action)  {
+        try { action.run() ; }
+        catch (HttpException ex) { handleHttpException(ex, false) ; }
+    }
+
+    /** Convert HTTP status codes to exceptions */ 
+    static <X> X exec(Supplier<X> action)  {
+        try { return action.get() ; }
+        catch (HttpException ex) { handleHttpException(ex, true) ; return null ;}
+    }
+
+    private static void handleHttpException(HttpException ex, boolean ignore404) {
+        if ( ex.getResponseCode() == HttpSC.NOT_FOUND_404 && ignore404 )
+            return  ;
+        throw ex ;
+    }
+
+    /** Engine for the transaction lifecycle.
+     * MR+SW
+     */
+    
+    static class TxnLifecycle implements Transactional {
+        // MR+SW policy.
+        private ReentrantLock lock = new ReentrantLock() ;
+        private ThreadLocal<ReadWrite> mode = ThreadLocal.withInitial(()->null) ;
+        @Override
+        public void begin(ReadWrite readWrite) {
+            if ( readWrite == ReadWrite.WRITE )
+                lock.lock();
+            mode.set(readWrite);
+        }
+
+        @Override
+        public void commit() {
+            if ( mode.get() == ReadWrite.WRITE)
+                lock.unlock();
+            mode.set(null);
+        }
+
+        @Override
+        public void abort() {
+            if ( mode.get() == ReadWrite.WRITE )
+                lock.unlock();
+            mode.set(null);
+        }
+
+        @Override
+        public boolean isInTransaction() {
+            return mode.get() != null ;
+        }
+
+        @Override
+        public void end() {
+            ReadWrite rw = mode.get() ;
+            if ( rw == null )
+                return ;
+            if ( rw == ReadWrite.WRITE ) {
+                abort() ;
+                return ;
+            }
+            mode.set(null) ;
+        }
+    }
+    
+    private TxnLifecycle inner = new TxnLifecycle() ;
+    
+    @Override
+    public void begin(ReadWrite readWrite)  { inner.begin(readWrite); }
+
+    @Override
+    public void commit()                    { inner.commit(); }
+            
+    @Override
+    public void abort()                     { inner.abort(); }
+
+    @Override
+    public boolean isInTransaction()        { return inner.isInTransaction() ; }
+
+    @Override
+    public void end()                       { inner.end(); }
+
+}
+

http://git-wip-us.apache.org/repos/asf/jena/blob/2e26b78e/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFDatasetAccessConnection.java
----------------------------------------------------------------------
diff --git a/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFDatasetAccessConnection.java b/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFDatasetAccessConnection.java
new file mode 100644
index 0000000..a9bfbd1
--- /dev/null
+++ b/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFDatasetAccessConnection.java
@@ -0,0 +1,57 @@
+/*
+ * 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 org.apache.jena.query.Dataset ;
+import org.apache.jena.rdf.model.Model ;
+import org.apache.jena.sparql.core.Transactional ;
+
+/**
+ * SPARQL Graph Store Protocol (read operations) and whole dataset access.
+ * {@link RDFDatasetConnection} adds the write operations.
+ *
+ * @see RDFDatasetConnection
+ * @see RDFConnection
+ * @see RDFConnectionFactory
+ */  
+public interface RDFDatasetAccessConnection extends Transactional, AutoCloseable
+{
+    /** Fetch a named graph.
+     * This is SPARQL Graph Store Protocol HTTP GET or equivalent. 
+     * 
+     * @param graphName URI string for the graph name (null or "default" for the default graph)
+     * @return Model
+     */
+    public Model fetch(String graphName) ;
+    
+    /** Fetch the default graph.
+     * This is SPARQL Graph Store Protocol HTTP GET or equivalent. 
+     * @return Model
+     */
+    public Model fetch() ;
+    
+    /** Fetch the contents of the dataset */ 
+    public Dataset fetchDataset() ;
+    
+    /** Test whether this connection is closed or not */
+    public boolean isClosed() ;
+    
+    /** Close this connection.  Use with try-resource. */ 
+    @Override public void close() ;
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/2e26b78e/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFDatasetConnection.java
----------------------------------------------------------------------
diff --git a/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFDatasetConnection.java b/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFDatasetConnection.java
new file mode 100644
index 0000000..688e654
--- /dev/null
+++ b/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/RDFDatasetConnection.java
@@ -0,0 +1,150 @@
+/*
+ * 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 org.apache.jena.query.Dataset ;
+import org.apache.jena.rdf.model.Model ;
+import org.apache.jena.sparql.core.Transactional ;
+
+/**
+ * SPARQL Graph Store Protocol and whole dataset access.
+ * This adds the write operations. The read operations are defined by {@link RDFDatasetAccessConnection}.  
+ * 
+ * @see RDFDatasetAccessConnection
+ * @see RDFConnection
+ * @see RDFConnectionFactory
+ */  
+public interface RDFDatasetConnection extends RDFDatasetAccessConnection, Transactional, AutoCloseable
+{
+    /** Load (add, append) RDF into a named graph in a dataset.
+     * This is SPARQL Graph Store Protocol HTTP POST or equivalent. 
+     * 
+     * @param graphName Graph name (null or "default" for the default graph)
+     * @param file File of the data.
+     */
+    public void load(String graphName, String file) ;
+    
+    /** Load (add, append) RDF into the default graph of a dataset.
+     * This is SPARQL Graph Store Protocol HTTP POST or equivalent. 
+     * 
+     * @param file File of the data.
+     */
+    public void load(String file) ;
+
+    /** Load (add, append) RDF into a named graph in a dataset.
+     * This is SPARQL Graph Store Protocol HTTP POST or equivalent. 
+     * 
+     * @param graphName Graph name (null or "default" for the default graph)
+     * @param model Data.
+     */
+    public void load(String graphName, Model model) ;
+    
+    /** Load (add, append) RDF into the default graph of a dataset.
+     * This is SPARQL Graph Store Protocol HTTP POST or equivalent. 
+     * 
+     * @param model Data.
+     */
+    public void load(Model model) ;
+
+    /** Set the contents of a named graph of a dataset.
+     * Any existing data is lost. 
+     * This is SPARQL Graph Store Protocol HTTP PUT or equivalent. 
+     *
+     * @param graphName Graph name (null or "default" for the default graph)
+     * @param file File of the data.
+     */
+    public void put(String graphName, String file) ;
+    
+    /** Set the contents of the default graph of a dataset.
+     * Any existing data is lost. 
+     * This is SPARQL Graph Store Protocol HTTP PUT or equivalent. 
+     * 
+     * @param file File of the data.
+     */
+    public void put(String file) ;
+        
+    /** Set the contents of a named graph of a dataset.
+     * Any existing data is lost. 
+     * This is SPARQL Graph Store Protocol HTTP PUT or equivalent. 
+     *
+     * @param graphName Graph name (null or "default" for the default graph)
+     * @param model Data.
+     */
+    public void put(String graphName, Model model) ;
+    
+    /** Set the contents of the default graph of a dataset.
+     * Any existing data is lost. 
+     * This is SPARQL Graph Store Protocol HTTP PUT or equivalent. 
+     * 
+     * @param model Data.
+     */
+    public void put( Model model) ;
+        
+    /**
+     * Delete a graph from the dataset.
+     * Null or "default" measn the default graph, which is cleared, not removed.
+     * 
+     * @param graphName
+     */
+    public void delete(String graphName) ;
+
+    /**
+     * Remove all data from the default graph.
+     */ 
+    public void delete() ;
+    
+    /* Load (add, append) RDF triple or quad data into a dataset. Triples wil go into the default graph.
+     * This is not a SPARQL Graph Store Protocol operation.
+     * It is an HTTP POST equivalent to the dataset.
+     */
+    public void loadDataset(String file) ;
+
+    /* Load (add, append) RDF triple or quad data into a dataset. Triples wil go into the default graph.
+     * This is not a SPARQL Graph Store Protocol operation.
+     * It is an HTTP POST equivalent to the dataset.
+     */
+    public void loadDataset(Dataset dataset) ;
+
+    /* Set RDF triple or quad data as the dataset contents.
+     * Triples will go into the default graph, quads in named graphs.
+     * This is not a SPARQL Graph Store Protocol operation.
+     * It is an HTTP PUT equivalent to the dataset.
+     */
+    public void putDataset(String file) ;
+    
+    /* Set RDF triple or quad data as the dataset contents.
+     * Triples will go into the default graph, quads in named graphs.
+     * This is not a SPARQL Graph Store Protocol operation.
+     * It is an HTTP PUT equivalent to the dataset.
+     */
+    public void putDataset(Dataset dataset) ;
+
+    //    /** Clear the dataset - remove all named graphs, clear the default graph. */
+//    public void clearDataset() ;
+    
+    
+    /** Test whether this connection is closed or not */
+    @Override
+    public boolean isClosed() ;
+    
+    /** Close this connection.  Use with try-resource. */ 
+    @Override 
+    public void close() ;
+}
+