jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rve...@apache.org
Subject svn commit: r1491639 - in /jena/Experimental/jena-jdbc/jena-jdbc-core/src: main/java/org/apache/jena/jdbc/ main/java/org/apache/jena/jdbc/results/metadata/ test/java/org/apache/jena/jdbc/statements/
Date Mon, 10 Jun 2013 23:31:54 GMT
Author: rvesse
Date: Mon Jun 10 23:31:54 2013
New Revision: 1491639

URL: http://svn.apache.org/r1491639
Log:
Add some more logging statements, fix some test bugs

Modified:
    jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/JdbcCompatibility.java
    jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/results/metadata/SelectResultsMetadata.java
    jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/results/metadata/TripleResultsMetadata.java
    jena/Experimental/jena-jdbc/jena-jdbc-core/src/test/java/org/apache/jena/jdbc/statements/AbstractJenaStatementTests.java

Modified: jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/JdbcCompatibility.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/JdbcCompatibility.java?rev=1491639&r1=1491638&r2=1491639&view=diff
==============================================================================
--- jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/JdbcCompatibility.java
(original)
+++ jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/JdbcCompatibility.java
Mon Jun 10 23:31:54 2013
@@ -33,7 +33,6 @@ import org.apache.jena.jdbc.results.meta
 import org.apache.jena.jdbc.results.metadata.columns.IntegerColumn;
 import org.apache.jena.jdbc.results.metadata.columns.StringColumn;
 import org.apache.jena.jdbc.results.metadata.columns.TimeColumn;
-
 import com.hp.hpl.jena.graph.Node;
 import com.hp.hpl.jena.vocabulary.XSD;
 
@@ -53,7 +52,7 @@ import com.hp.hpl.jena.vocabulary.XSD;
  * 
  */
 public class JdbcCompatibility {
-
+    
     /**
      * Private constructor prevents instantiation
      */

Modified: jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/results/metadata/SelectResultsMetadata.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/results/metadata/SelectResultsMetadata.java?rev=1491639&r1=1491638&r2=1491639&view=diff
==============================================================================
--- jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/results/metadata/SelectResultsMetadata.java
(original)
+++ jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/results/metadata/SelectResultsMetadata.java
Mon Jun 10 23:31:54 2013
@@ -29,6 +29,8 @@ import org.apache.jena.jdbc.results.Sele
 import org.apache.jena.jdbc.results.metadata.columns.ColumnInfo;
 import org.apache.jena.jdbc.results.metadata.columns.SparqlColumnInfo;
 import org.apache.jena.jdbc.results.metadata.columns.StringColumn;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import com.hp.hpl.jena.query.ResultSet;
 import com.hp.hpl.jena.query.ResultSetFactory;
@@ -41,6 +43,8 @@ import com.hp.hpl.jena.sparql.resultset.
  * 
  */
 public class SelectResultsMetadata extends JenaResultsMetadata {
+    
+    private static final Logger LOGGER = LoggerFactory.getLogger(SelectResultsMetadata.class);
 
     @SuppressWarnings("unused")
     private ResultSetPeekable innerResults;
@@ -102,12 +106,15 @@ public class SelectResultsMetadata exten
             if (!columnsAsStrings && !columnsDetected) {
                 // Low compatibility, report columns as being typed as JAVA_OBJECT with ARQ
Node as the column class
                 columns[i] = new SparqlColumnInfo(vars.get(i), Types.JAVA_OBJECT, columnNullable);
+                LOGGER.info("Low JDBC compatibility, column " + vars.get(i) + " is being
typed as Node");
             } else if (columnsAsStrings) {
-                // Medium compatibility, report columns as being typed as NVARChar with String
as the column class
+                // Medium compatibility, report columns as being typed as NVARCHAR with String
as the column class
                 columns[i] = new StringColumn(vars.get(i), columnNullable);
+                LOGGER.info("Medium JDBC compatibility, column " + vars.get(i) + " is being
typed as String");
             } else if (columnsDetected) {
                 // High compatibility, detect columns types based on first row of results
                 columns[i] = JdbcCompatibility.detectColumnType(vars.get(i), b.get(Var.alloc(vars.get(i))),
true);
+                LOGGER.info("High compatibility, column " + vars.get(i) + " was detected
as being of type " + columns[i].getClassName());
             } else {
                 throw new SQLFeatureNotSupportedException("Unknown JDBC compatibility level
was set");
             }

Modified: jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/results/metadata/TripleResultsMetadata.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/results/metadata/TripleResultsMetadata.java?rev=1491639&r1=1491638&r2=1491639&view=diff
==============================================================================
--- jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/results/metadata/TripleResultsMetadata.java
(original)
+++ jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/results/metadata/TripleResultsMetadata.java
Mon Jun 10 23:31:54 2013
@@ -30,6 +30,8 @@ import org.apache.jena.jdbc.results.Trip
 import org.apache.jena.jdbc.results.metadata.columns.ColumnInfo;
 import org.apache.jena.jdbc.results.metadata.columns.SparqlColumnInfo;
 import org.apache.jena.jdbc.results.metadata.columns.StringColumn;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import com.hp.hpl.jena.graph.Node;
 import com.hp.hpl.jena.graph.Triple;
@@ -39,6 +41,8 @@ import com.hp.hpl.jena.graph.Triple;
  * 
  */
 public class TripleResultsMetadata extends JenaResultsMetadata {
+    
+    private static final Logger LOGGER = LoggerFactory.getLogger(TripleResultsMetadata.class);
 
     /**
      * Constant for the subject column label
@@ -105,14 +109,17 @@ public class TripleResultsMetadata exten
                 // Low compatibility, report columns as being typed as
                 // JAVA_OBJECT with ARQ Node as the column class
                 columns[i] = new SparqlColumnInfo(COLUMN_NAMES[i], Types.JAVA_OBJECT, columnNoNulls);
+                LOGGER.info("Low JDBC compatibility, column " + COLUMN_NAMES[i] + " is being
typed as Node");
             } else if (columnsAsStrings) {
                 // Medium compatibility, report columns as being typed as
                 // NVARChar with String as the column class
                 columns[i] = new StringColumn(COLUMN_NAMES[i], columnNoNulls);
+                LOGGER.info("Medium JDBC compatibility, column " + COLUMN_NAMES[i] + " is
being typed as String");
             } else if (columnsDetected) {
                 // High compatibility, detect columns types based on first row
                 // of results
                 columns[i] = JdbcCompatibility.detectColumnType(COLUMN_NAMES[i], getValue(t,
i), false);
+                LOGGER.info("High compatibility, column " + COLUMN_NAMES[i] + " was detected
as being of type " + columns[i].getClassName());
             } else {
                 throw new SQLFeatureNotSupportedException("Unknown JDBC compatibility level
was set");
             }

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=1491639&r1=1491638&r2=1491639&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
Mon Jun 10 23:31:54 2013
@@ -1920,7 +1920,7 @@ public abstract class AbstractJenaStatem
         stmt.setObject(1, "value");
         ParameterizedSparqlString pss = stmt.getParameterizedString();
         Assert.assertTrue(pss.toString().contains("\"value\""));
-        
+
         stmt.close();
         conn.close();
     }
@@ -1939,7 +1939,7 @@ public abstract class AbstractJenaStatem
         stmt.setObject(1, 123);
         ParameterizedSparqlString pss = stmt.getParameterizedString();
         Assert.assertTrue(pss.toString().contains("123"));
-        
+
         stmt.close();
         conn.close();
     }
@@ -1958,7 +1958,7 @@ public abstract class AbstractJenaStatem
         stmt.setObject(1, 123l);
         ParameterizedSparqlString pss = stmt.getParameterizedString();
         Assert.assertTrue(pss.toString().contains("123"));
-        
+
         stmt.close();
         conn.close();
     }
@@ -1978,7 +1978,7 @@ public abstract class AbstractJenaStatem
         ParameterizedSparqlString pss = stmt.getParameterizedString();
         Assert.assertTrue(pss.toString().contains("123"));
         Assert.assertTrue(pss.toString().contains(XSDDatatype.XSDbyte.getURI()));
-        
+
         stmt.close();
         conn.close();
     }
@@ -1997,7 +1997,7 @@ public abstract class AbstractJenaStatem
         stmt.setObject(1, BigDecimal.valueOf(1234, 1));
         ParameterizedSparqlString pss = stmt.getParameterizedString();
         Assert.assertTrue(pss.toString().contains("123.4"));
-        
+
         stmt.close();
         conn.close();
     }
@@ -2016,7 +2016,7 @@ public abstract class AbstractJenaStatem
         stmt.setObject(1, (short) 123);
         ParameterizedSparqlString pss = stmt.getParameterizedString();
         Assert.assertTrue(pss.toString().contains("123"));
-        
+
         stmt.close();
         conn.close();
     }
@@ -2036,7 +2036,7 @@ public abstract class AbstractJenaStatem
         ParameterizedSparqlString pss = stmt.getParameterizedString();
         Assert.assertTrue(pss.toString().contains("12.3"));
         Assert.assertTrue(pss.toString().contains(XSDDatatype.XSDfloat.getURI()));
-        
+
         stmt.close();
         conn.close();
     }
@@ -2055,7 +2055,7 @@ public abstract class AbstractJenaStatem
         stmt.setObject(1, 12.3d);
         ParameterizedSparqlString pss = stmt.getParameterizedString();
         Assert.assertTrue(pss.toString().contains("12.3"));
-        
+
         stmt.close();
         conn.close();
     }
@@ -2074,7 +2074,7 @@ public abstract class AbstractJenaStatem
         stmt.setObject(1, true);
         ParameterizedSparqlString pss = stmt.getParameterizedString();
         Assert.assertTrue(pss.toString().contains("true"));
-        
+
         stmt.close();
         conn.close();
     }
@@ -2093,7 +2093,7 @@ public abstract class AbstractJenaStatem
         stmt.setObject(1, new Date(0));
         ParameterizedSparqlString pss = stmt.getParameterizedString();
         Assert.assertTrue(pss.toString().contains(XSDDatatype.XSDdate.getURI()));
-        
+
         stmt.close();
         conn.close();
     }
@@ -2112,7 +2112,7 @@ public abstract class AbstractJenaStatem
         stmt.setObject(1, new Time(0));
         ParameterizedSparqlString pss = stmt.getParameterizedString();
         Assert.assertTrue(pss.toString().contains(XSDDatatype.XSDtime.getURI()));
-        
+
         stmt.close();
         conn.close();
     }
@@ -2132,7 +2132,7 @@ public abstract class AbstractJenaStatem
         stmt.setObject(1, new URL("http://example.org"));
         ParameterizedSparqlString pss = stmt.getParameterizedString();
         Assert.assertTrue(pss.toString().contains("<http://example.org>"));
-        
+
         stmt.close();
         conn.close();
     }
@@ -2153,7 +2153,7 @@ public abstract class AbstractJenaStatem
         stmt.setObject(1, new URI("http://example.org"));
         ParameterizedSparqlString pss = stmt.getParameterizedString();
         Assert.assertTrue(pss.toString().contains("<http://example.org>"));
-        
+
         stmt.close();
         conn.close();
     }
@@ -2172,7 +2172,7 @@ public abstract class AbstractJenaStatem
         stmt.setObject(1, IRIFactory.iriImplementation().create("http://example.org"));
         ParameterizedSparqlString pss = stmt.getParameterizedString();
         Assert.assertTrue(pss.toString().contains("<http://example.org>"));
-        
+
         stmt.close();
         conn.close();
     }
@@ -2191,7 +2191,7 @@ public abstract class AbstractJenaStatem
         stmt.setObject(1, IRIFactory.iriImplementation().create("http://example.org"), Types.NVARCHAR);
         ParameterizedSparqlString pss = stmt.getParameterizedString();
         Assert.assertTrue(pss.toString().contains("\"http://example.org\""));
-        
+
         stmt.close();
         conn.close();
     }
@@ -2210,7 +2210,7 @@ public abstract class AbstractJenaStatem
         stmt.setObject(1, IRIFactory.iriImplementation().create("http://example.org"), Types.JAVA_OBJECT);
         ParameterizedSparqlString pss = stmt.getParameterizedString();
         Assert.assertTrue(pss.toString().contains("<http://example.org>"));
-        
+
         stmt.close();
         conn.close();
     }
@@ -2230,7 +2230,7 @@ public abstract class AbstractJenaStatem
         ParameterizedSparqlString pss = stmt.getParameterizedString();
         Assert.assertTrue(pss.toString().contains("12.3"));
         Assert.assertFalse(pss.toString().contains(XSDDatatype.XSDfloat.getURI()));
-        
+
         stmt.close();
         conn.close();
     }
@@ -2249,7 +2249,7 @@ public abstract class AbstractJenaStatem
         stmt.setObject(1, 12.3d, Types.DOUBLE);
         ParameterizedSparqlString pss = stmt.getParameterizedString();
         Assert.assertTrue(pss.toString().contains("12.3"));
-        
+
         stmt.close();
         conn.close();
     }
@@ -2268,7 +2268,7 @@ public abstract class AbstractJenaStatem
         stmt.setObject(1, 123l, Types.BIGINT);
         ParameterizedSparqlString pss = stmt.getParameterizedString();
         Assert.assertTrue(pss.toString().contains("123"));
-        
+
         stmt.close();
         conn.close();
     }
@@ -2287,7 +2287,7 @@ public abstract class AbstractJenaStatem
         stmt.setObject(1, 123, Types.BIGINT);
         ParameterizedSparqlString pss = stmt.getParameterizedString();
         Assert.assertTrue(pss.toString().contains("123"));
-        
+
         stmt.close();
         conn.close();
     }
@@ -2306,7 +2306,7 @@ public abstract class AbstractJenaStatem
         stmt.setObject(1, (short) 123, Types.BIGINT);
         ParameterizedSparqlString pss = stmt.getParameterizedString();
         Assert.assertTrue(pss.toString().contains("123"));
-        
+
         stmt.close();
         conn.close();
     }
@@ -2325,7 +2325,7 @@ public abstract class AbstractJenaStatem
         stmt.setObject(1, (byte) 123, Types.BIGINT);
         ParameterizedSparqlString pss = stmt.getParameterizedString();
         Assert.assertTrue(pss.toString().contains("123"));
-        
+
         stmt.close();
         conn.close();
     }
@@ -2344,7 +2344,7 @@ public abstract class AbstractJenaStatem
         stmt.setObject(1, Quad.defaultGraphIRI);
         ParameterizedSparqlString pss = stmt.getParameterizedString();
         Assert.assertTrue(pss.toString().contains("<urn:x-arq:DefaultGraph>"));
-        
+
         stmt.close();
         conn.close();
     }
@@ -2363,7 +2363,7 @@ public abstract class AbstractJenaStatem
         stmt.setObject(1, ModelFactory.createDefaultModel().createResource("urn:x-arq:DefaultGraph"));
         ParameterizedSparqlString pss = stmt.getParameterizedString();
         Assert.assertTrue(pss.toString().contains("<urn:x-arq:DefaultGraph>"));
-        
+
         stmt.close();
         conn.close();
     }
@@ -2383,7 +2383,7 @@ public abstract class AbstractJenaStatem
         stmt.setObject(1, c);
         ParameterizedSparqlString pss = stmt.getParameterizedString();
         Assert.assertTrue(pss.toString().contains(Integer.toString(c.get(Calendar.YEAR))));
-        
+
         stmt.close();
         conn.close();
     }
@@ -3007,7 +3007,7 @@ public abstract class AbstractJenaStatem
         Calendar c = Calendar.getInstance();
         stmt.setObject(1, c, Types.TIME);
         ParameterizedSparqlString pss = stmt.getParameterizedString();
-        Assert.assertTrue(pss.toString().contains(Integer.toString(c.get(Calendar.HOUR))));
+        Assert.assertTrue(pss.toString().contains(Integer.toString(c.get(Calendar.HOUR_OF_DAY))));
 
         stmt.close();
         conn.close();
@@ -3027,7 +3027,7 @@ public abstract class AbstractJenaStatem
         Calendar c = Calendar.getInstance();
         stmt.setObject(1, NodeFactoryExtra.dateTimeToNode(c), Types.TIME);
         ParameterizedSparqlString pss = stmt.getParameterizedString();
-        Assert.assertTrue(pss.toString().contains(Integer.toString(c.get(Calendar.HOUR))));
+        Assert.assertTrue(pss.toString().contains(Integer.toString(c.get(Calendar.HOUR_OF_DAY))));
 
         stmt.close();
         conn.close();
@@ -3068,7 +3068,7 @@ public abstract class AbstractJenaStatem
         Date dt = new Date(Calendar.getInstance().getTimeInMillis());
         stmt.setObject(1, dt, Types.TIME);
         ParameterizedSparqlString pss = stmt.getParameterizedString();
-        Assert.assertTrue(pss.toString().contains(Integer.toString(Calendar.getInstance().get(Calendar.HOUR))));
+        Assert.assertTrue(pss.toString().contains(Integer.toString(Calendar.getInstance().get(Calendar.HOUR_OF_DAY))));
 
         stmt.close();
         conn.close();
@@ -3489,13 +3489,20 @@ public abstract class AbstractJenaStatem
         Time t = new Time(c.getTimeInMillis());
         stmt.setObject(1, t, Types.JAVA_OBJECT);
         ParameterizedSparqlString pss = stmt.getParameterizedString();
-        Assert.assertTrue(pss.toString().contains(Integer.toString(c.get(Calendar.HOUR))));
+        Assert.assertTrue(pss.toString().contains(Integer.toString(c.get(Calendar.HOUR_OF_DAY))));
         Assert.assertTrue(pss.toString().contains(XSDDatatype.XSDtime.getURI()));
 
         stmt.close();
         conn.close();
     }
 
+    /**
+     * Tests that the various set methods of {@link JenaPreparedStatement}
+     * function correctly
+     * 
+     * @throws SQLException
+     * @throws MalformedURLException
+     */
     @Test
     public void prepared_statement_setters_82() throws SQLException {
         JenaConnection conn = this.getConnection();



Mime
View raw message