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/10/08 16:26:16 UTC

[4/7] jena git commit: Use try-resource.

Use try-resource.

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

Branch: refs/heads/master
Commit: 3097c5e65bfc2f3a7943efdc9921ee0d18359546
Parents: 21b3b60
Author: Andy Seaborne <an...@apache.org>
Authored: Sat Oct 8 16:23:52 2016 +0100
Committer: Andy Seaborne <an...@apache.org>
Committed: Sat Oct 8 16:23:52 2016 +0100

----------------------------------------------------------------------
 .../jdbc/remote/TestRemoteEndpointDriver.java   | 21 +++++++++-----------
 .../TestRemoteEndpointConnectionWithAuth.java   |  8 ++++----
 .../TestRemoteEndpointResultsWithAuth.java      |  8 ++++----
 3 files changed, 17 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/3097c5e6/jena-jdbc/jena-jdbc-driver-remote/src/test/java/org/apache/jena/jdbc/remote/TestRemoteEndpointDriver.java
----------------------------------------------------------------------
diff --git a/jena-jdbc/jena-jdbc-driver-remote/src/test/java/org/apache/jena/jdbc/remote/TestRemoteEndpointDriver.java b/jena-jdbc/jena-jdbc-driver-remote/src/test/java/org/apache/jena/jdbc/remote/TestRemoteEndpointDriver.java
index a99417d..5c3ae8d 100644
--- a/jena-jdbc/jena-jdbc-driver-remote/src/test/java/org/apache/jena/jdbc/remote/TestRemoteEndpointDriver.java
+++ b/jena-jdbc/jena-jdbc-driver-remote/src/test/java/org/apache/jena/jdbc/remote/TestRemoteEndpointDriver.java
@@ -58,10 +58,9 @@ public class TestRemoteEndpointDriver extends AbstractJenaDriverTests {
         // May specify key=value pairs multiple times
         String url = JenaDriver.DRIVER_PREFIX + RemoteEndpointDriver.REMOTE_DRIVER_PREFIX + RemoteEndpointDriver.PARAM_QUERY_ENDPOINT + "=http://example.org/query&" + RemoteEndpointDriver.PARAM_DEFAULT_GRAPH_URI + "=http://graph/1&" + RemoteEndpointDriver.PARAM_DEFAULT_GRAPH_URI + "=http://graph/2";
         RemoteEndpointDriver driver = (RemoteEndpointDriver)this.getDriver();
-        RemoteEndpointConnection conn = (RemoteEndpointConnection) driver.connect(url, new Properties());
-        
-        Assert.assertEquals(2, conn.getDefaultGraphURIs().size());
-        conn.close();
+        try(RemoteEndpointConnection conn = (RemoteEndpointConnection) driver.connect(url, new Properties())) {
+            Assert.assertEquals(2, conn.getDefaultGraphURIs().size());
+        }
     }
     
     /**
@@ -73,10 +72,9 @@ public class TestRemoteEndpointDriver extends AbstractJenaDriverTests {
         // May specify key=value,value as comma separated list
         String url = JenaDriver.DRIVER_PREFIX + RemoteEndpointDriver.REMOTE_DRIVER_PREFIX + RemoteEndpointDriver.PARAM_QUERY_ENDPOINT + "=http://example.org/query&" + RemoteEndpointDriver.PARAM_DEFAULT_GRAPH_URI + "=http://graph/1,http://graph/2";
         RemoteEndpointDriver driver = (RemoteEndpointDriver)this.getDriver();
-        RemoteEndpointConnection conn = (RemoteEndpointConnection) driver.connect(url, new Properties());
-        
-        Assert.assertEquals(2, conn.getDefaultGraphURIs().size());
-        conn.close();
+       try(RemoteEndpointConnection conn = (RemoteEndpointConnection) driver.connect(url, new Properties())){
+           Assert.assertEquals(2, conn.getDefaultGraphURIs().size());
+       }
     }
     
     /**
@@ -88,9 +86,8 @@ public class TestRemoteEndpointDriver extends AbstractJenaDriverTests {
         // May specify combination of multiple key=value pairs and key=value,value comma separated list(s)
         String url = JenaDriver.DRIVER_PREFIX + RemoteEndpointDriver.REMOTE_DRIVER_PREFIX + RemoteEndpointDriver.PARAM_QUERY_ENDPOINT + "=http://example.org/query&" + RemoteEndpointDriver.PARAM_DEFAULT_GRAPH_URI + "=http://graph/1,http://graph/2&" + RemoteEndpointDriver.PARAM_DEFAULT_GRAPH_URI + "=http://graph/3";
         RemoteEndpointDriver driver = (RemoteEndpointDriver)this.getDriver();
-        RemoteEndpointConnection conn = (RemoteEndpointConnection) driver.connect(url, new Properties());
-        
-        Assert.assertEquals(3, conn.getDefaultGraphURIs().size());
-        conn.close();
+        try(RemoteEndpointConnection conn = (RemoteEndpointConnection) driver.connect(url, new Properties())) {
+            Assert.assertEquals(3, conn.getDefaultGraphURIs().size());
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/jena/blob/3097c5e6/jena-jdbc/jena-jdbc-driver-remote/src/test/java/org/apache/jena/jdbc/remote/connections/TestRemoteEndpointConnectionWithAuth.java
----------------------------------------------------------------------
diff --git a/jena-jdbc/jena-jdbc-driver-remote/src/test/java/org/apache/jena/jdbc/remote/connections/TestRemoteEndpointConnectionWithAuth.java b/jena-jdbc/jena-jdbc-driver-remote/src/test/java/org/apache/jena/jdbc/remote/connections/TestRemoteEndpointConnectionWithAuth.java
index 91969b1..2355c7a 100644
--- a/jena-jdbc/jena-jdbc-driver-remote/src/test/java/org/apache/jena/jdbc/remote/connections/TestRemoteEndpointConnectionWithAuth.java
+++ b/jena-jdbc/jena-jdbc-driver-remote/src/test/java/org/apache/jena/jdbc/remote/connections/TestRemoteEndpointConnectionWithAuth.java
@@ -69,11 +69,11 @@ public class TestRemoteEndpointConnectionWithAuth extends AbstractRemoteEndpoint
         
         realmFile = File.createTempFile("realm", ".properties");
 
-        FileWriter writer = new FileWriter(realmFile);
-        writer.write(USER + ": " + PASSWORD + ", fuseki\n");
-        writer.close();
+        try(FileWriter writer = new FileWriter(realmFile)) {
+            writer.write(USER + ": " + PASSWORD + ", fuseki\n");
+        }
 
-        DatasetGraph dsg = DatasetGraphFactory.createMem();
+        DatasetGraph dsg = DatasetGraphFactory.create();
         // This must agree with ServerTest
         ServerConfig conf = FusekiConfig.defaultConfiguration(ServerTest.datasetPath, dsg, true, false);
         conf.port = ServerTest.port;

http://git-wip-us.apache.org/repos/asf/jena/blob/3097c5e6/jena-jdbc/jena-jdbc-driver-remote/src/test/java/org/apache/jena/jdbc/remote/results/TestRemoteEndpointResultsWithAuth.java
----------------------------------------------------------------------
diff --git a/jena-jdbc/jena-jdbc-driver-remote/src/test/java/org/apache/jena/jdbc/remote/results/TestRemoteEndpointResultsWithAuth.java b/jena-jdbc/jena-jdbc-driver-remote/src/test/java/org/apache/jena/jdbc/remote/results/TestRemoteEndpointResultsWithAuth.java
index 200feb3..8295116 100644
--- a/jena-jdbc/jena-jdbc-driver-remote/src/test/java/org/apache/jena/jdbc/remote/results/TestRemoteEndpointResultsWithAuth.java
+++ b/jena-jdbc/jena-jdbc-driver-remote/src/test/java/org/apache/jena/jdbc/remote/results/TestRemoteEndpointResultsWithAuth.java
@@ -75,11 +75,11 @@ public class TestRemoteEndpointResultsWithAuth extends AbstractRemoteEndpointRes
 
         realmFile = File.createTempFile("realm", ".properties");
 
-        FileWriter writer = new FileWriter(realmFile);
-        writer.write(USER + ": " + PASSWORD + ", fuseki\n");
-        writer.close();
+        try(FileWriter writer = new FileWriter(realmFile)) {
+            writer.write(USER + ": " + PASSWORD + ", fuseki\n");
+        }
 
-        DatasetGraph dsg = DatasetGraphFactory.createMem();
+        DatasetGraph dsg = DatasetGraphFactory.create();
         // This must agree with ServerTest
         ServerConfig conf = FusekiConfig.defaultConfiguration(ServerTest.datasetPath, dsg, true, false);
         conf.port = ServerTest.port;