You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by rv...@apache.org on 2013/06/06 19:29:58 UTC

svn commit: r1490369 - in /jena/Experimental/jena-jdbc: jena-jdbc-core/src/test/java/org/apache/jena/jdbc/connections/ jena-jdbc-core/src/test/java/org/apache/jena/jdbc/statements/ jena-jdbc-driver-remote/src/test/java/org/apache/jena/jdbc/remote/ jena...

Author: rvesse
Date: Thu Jun  6 17:29:57 2013
New Revision: 1490369

URL: http://svn.apache.org/r1490369
Log:
More tests for JDBC statements

Added:
    jena/Experimental/jena-jdbc/jena-jdbc-driver-remote/src/test/java/org/apache/jena/jdbc/remote/statements/
    jena/Experimental/jena-jdbc/jena-jdbc-driver-remote/src/test/java/org/apache/jena/jdbc/remote/statements/TestRemoteEndpointStatements.java
Modified:
    jena/Experimental/jena-jdbc/jena-jdbc-core/src/test/java/org/apache/jena/jdbc/connections/AbstractJenaConnectionTests.java
    jena/Experimental/jena-jdbc/jena-jdbc-core/src/test/java/org/apache/jena/jdbc/statements/AbstractJenaStatementTests.java
    jena/Experimental/jena-jdbc/jena-jdbc-driver-remote/src/test/java/org/apache/jena/jdbc/remote/TS_JdbcDriverRemote.java

Modified: jena/Experimental/jena-jdbc/jena-jdbc-core/src/test/java/org/apache/jena/jdbc/connections/AbstractJenaConnectionTests.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-jdbc/jena-jdbc-core/src/test/java/org/apache/jena/jdbc/connections/AbstractJenaConnectionTests.java?rev=1490369&r1=1490368&r2=1490369&view=diff
==============================================================================
--- jena/Experimental/jena-jdbc/jena-jdbc-core/src/test/java/org/apache/jena/jdbc/connections/AbstractJenaConnectionTests.java (original)
+++ jena/Experimental/jena-jdbc/jena-jdbc-core/src/test/java/org/apache/jena/jdbc/connections/AbstractJenaConnectionTests.java Thu Jun  6 17:29:57 2013
@@ -1942,6 +1942,33 @@ public abstract class AbstractJenaConnec
         conn.close();
         Assert.assertTrue(conn.isClosed());
     }
+    
+    /**
+     * Runs a batch of operations and checks the results results
+     * 
+     * @throws SQLException
+     */
+    @Test
+    public void connection_statement_batch_08() throws SQLException {
+        JenaConnection conn = this.getConnection();
+        conn.setHoldability(ResultSet.HOLD_CURSORS_OVER_COMMIT);
+        Statement stmt = conn.createStatement();
+
+        // Create a a batch
+        stmt.addBatch("SELECT * WHERE { ?s ?p ?o }");
+        stmt.addBatch("ASK WHERE { }");
+        stmt.addBatch("CONSTRUCT WHERE { ?s ?p ?o }");
+        stmt.addBatch("DESCRIBE <http://example>");
+        
+        // Clear the batch
+        stmt.clearBatch();
+        
+        int[] batchResults = stmt.executeBatch();
+        Assert.assertEquals(0, batchResults.length);
+        
+        stmt.close();
+        conn.close();
+    }
 
     /**
      * Tests pre-processor management operations

Modified: jena/Experimental/jena-jdbc/jena-jdbc-core/src/test/java/org/apache/jena/jdbc/statements/AbstractJenaStatementTests.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-jdbc/jena-jdbc-core/src/test/java/org/apache/jena/jdbc/statements/AbstractJenaStatementTests.java?rev=1490369&r1=1490368&r2=1490369&view=diff
==============================================================================
--- jena/Experimental/jena-jdbc/jena-jdbc-core/src/test/java/org/apache/jena/jdbc/statements/AbstractJenaStatementTests.java (original)
+++ jena/Experimental/jena-jdbc/jena-jdbc-core/src/test/java/org/apache/jena/jdbc/statements/AbstractJenaStatementTests.java Thu Jun  6 17:29:57 2013
@@ -240,4 +240,184 @@ public abstract class AbstractJenaStatem
             conn.close();
         }
     }
+    
+    /**
+     * Tests error cases for trying to execute things on closed statements
+     * @throws SQLException 
+     */
+    @Test(expected = SQLException.class)
+    public void statement_closed_execute_01() throws SQLException {
+        JenaConnection conn = this.getConnection();
+        Statement stmt = conn.createStatement();
+        
+        stmt.close();
+        
+        try {
+            stmt.execute("SELECT * WHERE { ?s ?p ?o }");
+        } finally {
+            conn.close();
+        }
+    }
+    
+    /**
+     * Tests error cases for trying to execute things on closed statements
+     * @throws SQLException 
+     */
+    @Test(expected = SQLException.class)
+    public void statement_closed_execute_02() throws SQLException {
+        JenaConnection conn = this.getConnection();
+        Statement stmt = conn.createStatement();
+        
+        stmt.close();
+        
+        try {
+            stmt.execute("SELECT * WHERE { ?s ?p ?o }", 0);
+        } finally {
+            conn.close();
+        }
+    }
+    
+    /**
+     * Tests error cases for trying to execute things on closed statements
+     * @throws SQLException 
+     */
+    @Test(expected = SQLException.class)
+    public void statement_closed_execute_03() throws SQLException {
+        JenaConnection conn = this.getConnection();
+        Statement stmt = conn.createStatement();
+        
+        stmt.close();
+        
+        try {
+            stmt.execute("SELECT * WHERE { ?s ?p ?o }", new int[0]);
+        } finally {
+            conn.close();
+        }
+    }
+    
+    /**
+     * Tests error cases for trying to execute things on closed statements
+     * @throws SQLException 
+     */
+    @Test(expected = SQLException.class)
+    public void statement_closed_execute_04() throws SQLException {
+        JenaConnection conn = this.getConnection();
+        Statement stmt = conn.createStatement();
+        
+        stmt.close();
+        
+        try {
+            stmt.execute("SELECT * WHERE { ?s ?p ?o }", new String[0]);
+        } finally {
+            conn.close();
+        }
+    }
+    
+    /**
+     * Tests error cases for trying to execute things on closed statements
+     * @throws SQLException 
+     */
+    @Test(expected = SQLException.class)
+    public void statement_closed_execute_05() throws SQLException {
+        JenaConnection conn = this.getConnection();
+        Statement stmt = conn.createStatement();
+        
+        stmt.close();
+        
+        try {
+            stmt.executeQuery("SELECT * WHERE { ?s ?p ?o }");
+        } finally {
+            conn.close();
+        }
+    }
+    
+    /**
+     * Tests error cases for trying to execute things on closed statements
+     * @throws SQLException 
+     */
+    @Test(expected = SQLException.class)
+    public void statement_closed_execute_06() throws SQLException {
+        JenaConnection conn = this.getConnection();
+        Statement stmt = conn.createStatement();
+        
+        stmt.close();
+        
+        try {
+            stmt.executeQuery("SELECT * WHERE { ?s ?p ?o }");
+        } finally {
+            conn.close();
+        }
+    }
+    
+    /**
+     * Tests error cases for trying to execute things on closed statements
+     * @throws SQLException 
+     */
+    @Test(expected = SQLException.class)
+    public void statement_closed_execute_07() throws SQLException {
+        JenaConnection conn = this.getConnection();
+        Statement stmt = conn.createStatement();
+        
+        stmt.close();
+        
+        try {
+            stmt.executeUpdate("DELETE WHERE { ?s ?p ?o }");
+        } finally {
+            conn.close();
+        }
+    }
+    
+    /**
+     * Tests error cases for trying to execute things on closed statements
+     * @throws SQLException 
+     */
+    @Test(expected = SQLException.class)
+    public void statement_closed_execute_08() throws SQLException {
+        JenaConnection conn = this.getConnection();
+        Statement stmt = conn.createStatement();
+        
+        stmt.close();
+        
+        try {
+            stmt.executeUpdate("DELETE WHERE { ?s ?p ?o }", 0);
+        } finally {
+            conn.close();
+        }
+    }
+    
+    /**
+     * Tests error cases for trying to execute things on closed statements
+     * @throws SQLException 
+     */
+    @Test(expected = SQLException.class)
+    public void statement_closed_execute_09() throws SQLException {
+        JenaConnection conn = this.getConnection();
+        Statement stmt = conn.createStatement();
+        
+        stmt.close();
+        
+        try {
+            stmt.executeUpdate("DELETE WHERE { ?s ?p ?o }", new int[0]);
+        } finally {
+            conn.close();
+        }
+    }
+    
+    /**
+     * Tests error cases for trying to execute things on closed statements
+     * @throws SQLException 
+     */
+    @Test(expected = SQLException.class)
+    public void statement_closed_execute_10() throws SQLException {
+        JenaConnection conn = this.getConnection();
+        Statement stmt = conn.createStatement();
+        
+        stmt.close();
+        
+        try {
+            stmt.executeUpdate("DELETE WHERE { ?s ?p ?o }", new String[0]);
+        } finally {
+            conn.close();
+        }
+    }
 }

Modified: jena/Experimental/jena-jdbc/jena-jdbc-driver-remote/src/test/java/org/apache/jena/jdbc/remote/TS_JdbcDriverRemote.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-jdbc/jena-jdbc-driver-remote/src/test/java/org/apache/jena/jdbc/remote/TS_JdbcDriverRemote.java?rev=1490369&r1=1490368&r2=1490369&view=diff
==============================================================================
--- jena/Experimental/jena-jdbc/jena-jdbc-driver-remote/src/test/java/org/apache/jena/jdbc/remote/TS_JdbcDriverRemote.java (original)
+++ jena/Experimental/jena-jdbc/jena-jdbc-driver-remote/src/test/java/org/apache/jena/jdbc/remote/TS_JdbcDriverRemote.java Thu Jun  6 17:29:57 2013
@@ -24,6 +24,7 @@ import org.apache.jena.jdbc.remote.metad
 import org.apache.jena.jdbc.remote.results.TestRemoteEndpointResults;
 import org.apache.jena.jdbc.remote.results.TestRemoteEndpointResultsWithGraphUris;
 import org.apache.jena.jdbc.remote.results.TestRemoteEndpointResultsWithResultSetTypes;
+import org.apache.jena.jdbc.remote.statements.TestRemoteEndpointStatements;
 import org.junit.runner.RunWith;
 import org.junit.runners.Suite;
 
@@ -38,6 +39,7 @@ import org.junit.runners.Suite;
     TestRemoteEndpointConnectionWithGraphUris.class,
     TestRemoteEndpointConnectionWithResultSetTypes.class,
     TestRemoteConnectionMetadata.class,
+    TestRemoteEndpointStatements.class,
     TestRemoteEndpointResults.class,
     TestRemoteEndpointResultsWithGraphUris.class,
     TestRemoteEndpointResultsWithResultSetTypes.class

Added: jena/Experimental/jena-jdbc/jena-jdbc-driver-remote/src/test/java/org/apache/jena/jdbc/remote/statements/TestRemoteEndpointStatements.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-jdbc/jena-jdbc-driver-remote/src/test/java/org/apache/jena/jdbc/remote/statements/TestRemoteEndpointStatements.java?rev=1490369&view=auto
==============================================================================
--- jena/Experimental/jena-jdbc/jena-jdbc-driver-remote/src/test/java/org/apache/jena/jdbc/remote/statements/TestRemoteEndpointStatements.java (added)
+++ jena/Experimental/jena-jdbc/jena-jdbc-driver-remote/src/test/java/org/apache/jena/jdbc/remote/statements/TestRemoteEndpointStatements.java Thu Jun  6 17:29:57 2013
@@ -0,0 +1,68 @@
+/**
+ * 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.jdbc.remote.statements;
+
+import java.sql.SQLException;
+import org.apache.jena.fuseki.BaseServerTest;
+import org.apache.jena.fuseki.ServerTest;
+import org.apache.jena.jdbc.JdbcCompatibility;
+import org.apache.jena.jdbc.connections.JenaConnection;
+import org.apache.jena.jdbc.remote.connections.RemoteEndpointConnection;
+import org.apache.jena.jdbc.statements.AbstractJenaStatementTests;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+
+/**
+ * Tests for the {@link RemoteEndpointStatement}
+ *
+ */
+public class TestRemoteEndpointStatements extends AbstractJenaStatementTests {
+        
+    /**
+     * Setup for the tests by allocating a Fuseki instance to work with
+     */
+    @BeforeClass
+    public static void setup() {
+        ServerTest.allocServer();
+    }
+    
+    /**
+     * Clean up after each test by resetting the Fuseki instance
+     */
+    @After
+    public void cleanupTest() {
+        ServerTest.resetServer();
+    }
+    
+    /**
+     * Clean up after tests by de-allocating the Fuseki instance
+     */
+    @AfterClass
+    public static void cleanup() {
+        ServerTest.freeServer();
+    }
+
+    @Override
+    protected JenaConnection getConnection() throws SQLException {
+        return new RemoteEndpointConnection(BaseServerTest.serviceQuery, BaseServerTest.serviceUpdate, JenaConnection.DEFAULT_HOLDABILITY, JdbcCompatibility.DEFAULT);
+    }
+
+
+}