You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by km...@apache.org on 2007/04/10 17:47:53 UTC
svn commit: r527162 - in
/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests:
master/ master/DerbyNet/ master/DerbyNet/ibm15/ master/DerbyNet/ver2.8/
master/DerbyNetClient/ master/DerbyNetClient/jdk14/ master/j9_foundation/
suites/ ...
Author: kmarsden
Date: Tue Apr 10 08:47:52 2007
New Revision: 527162
URL: http://svn.apache.org/viewvc?view=rev&rev=527162
Log:
DERBY-2523 convert jdbcapi/LOBTest.java to Junit.
Moved parts of the test into BlobClob4Blob and CastingTest.java. Metadata already covered by ResultSetMiscTest.
Removed:
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/LOBTest.out
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/ibm15/LOBTest.out
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/ver2.8/LOBTest.out
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/LOBTest.out
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/jdk14/LOBTest.out
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/LOBTest.out
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/j9_foundation/LOBTest.out
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/LOBTest.java
Modified:
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/jdbcapi.runall
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/BlobClob4BlobTest.java
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CastingTest.java
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/jdbcapi.runall
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/jdbcapi.runall?view=diff&rev=527162&r1=527161&r2=527162
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/jdbcapi.runall (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/jdbcapi.runall Tue Apr 10 08:47:52 2007
@@ -2,7 +2,6 @@
jdbcapi/checkDriver.java
jdbcapi/nullSQLText.java
jdbcapi/resultsetStream.java
-jdbcapi/LOBTest.java
jdbcapi/parameterMapping.java
jdbcapi/testRelative.java
jdbcapi/SURTest_ij.sql
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/BlobClob4BlobTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/BlobClob4BlobTest.java?view=diff&rev=527162&r1=527161&r2=527162
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/BlobClob4BlobTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/BlobClob4BlobTest.java Tue Apr 10 08:47:52 2007
@@ -34,9 +34,11 @@
import org.apache.derbyTesting.junit.BaseJDBCTestCase;
import org.apache.derbyTesting.junit.CleanDatabaseTestSetup;
import org.apache.derbyTesting.junit.DatabasePropertyTestSetup;
+import org.apache.derbyTesting.junit.Utilities;
import junit.framework.*;
import java.sql.*;
+
import org.apache.derbyTesting.junit.TestConfiguration;
/**
@@ -3134,6 +3136,59 @@
assertEquals("FAIL - wrong not null row count null:" + nullCount,
9, rowCount);
assertEquals("FAIL - wrong null blob count", 1, nullCount);
+ }
+
+ /**
+ * From LobTest.java, test various inserts on a BLOB column
+ *
+ * @throws SQLException
+ */
+ public void testBlobInsert() throws SQLException {
+ String[] typeNames = { "int", "char(10)", "varchar(80)", "long varchar",
+ "char(10) for bit data", "long varchar for bit data", "blob(80)" };
+
+ Connection conn = getConnection();
+ Statement s = conn.createStatement();
+
+ // create table for testing
+
+ s.execute("create table blobCheck (bl blob(80)) ");
+
+ int columns = typeNames.length;
+ // test insertion of literals.
+ for (int i = 0; i < columns; i++) {
+
+ if (typeNames[i].indexOf("blob") == -1)
+ continue;
+
+ // Check char literals.
+ // (fail)
+ String insert = "insert into blobCheck (bl"
+ + " ) values ('string' )";
+ assertStatementError("42821",s,insert);
+ // (succeed)
+ insert = "insert into blobCheck (bl" + " ) values (cast ("
+ + Utilities.stringToHexLiteral("string") + " as blob(80)) )";
+ s.execute(insert);
+ // Check bit literals.
+ // (fail)
+ insert = "insert into blobCheck (bl" + " ) values (X'48' )";
+ assertStatementError("42821",s,insert);
+ // old CS compatible value: ( b'01001' )
+ // (succeed)
+ insert = "insert into blobCheck (bl"
+ + " ) values (cast (X'C8' as blob(80)) )";
+ s.execute(insert);
+ // Check hex literals.
+ // (fail)
+ insert = "insert into blobCheck (bl" + " ) values ( X'a78a' )";
+ assertStatementError("42821",s,insert);
+ // (succeed)
+ insert = "insert into blobCheck (bl"
+ + " ) values (cast (X'a78a' as blob(80)) )";
+ s.execute(insert);
+ }
+ s.execute("drop table blobCheck");
}
private void checkException(String SQLState, SQLException se)
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CastingTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CastingTest.java?view=diff&rev=527162&r1=527161&r2=527162
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CastingTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CastingTest.java Tue Apr 10 08:47:52 2007
@@ -22,6 +22,7 @@
package org.apache.derbyTesting.functionTests.tests.lang;
import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
@@ -92,7 +93,26 @@
"BLOB(1k)",
};
-
+ public static int[] jdbcTypes = {
+ java.sql.Types.SMALLINT,
+ java.sql.Types.INTEGER,
+ java.sql.Types.BIGINT,
+ java.sql.Types.DECIMAL,
+ java.sql.Types.REAL,
+ java.sql.Types.DOUBLE,
+ java.sql.Types.CHAR,
+ java.sql.Types.VARCHAR,
+ java.sql.Types.LONGVARCHAR,
+ java.sql.Types.BINARY,
+ java.sql.Types.VARBINARY,
+ java.sql.Types.LONGVARBINARY,
+ java.sql.Types.CLOB,
+ java.sql.Types.DATE,
+ java.sql.Types.TIME,
+ java.sql.Types.TIMESTAMP,
+ java.sql.Types.BLOB
+ };
+
public static int NULL_DATA_OFFSET = 0; // offset of NULL value
public static int VALID_DATA_OFFSET = 1; // offset of NULL value
@@ -370,6 +390,8 @@
ResultSet rs = s.executeQuery(query);
rs.next();
String val = rs.getString(1);
+ ResultSetMetaData rsmd = rs.getMetaData();
+ assertEquals(rsmd.getColumnType(1), jdbcTypes[targetType]);
rs.close();
if (dataOffset == 0)
assertNull(val);