Return-Path: Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: (qmail 78188 invoked from network); 18 Jul 2008 22:23:28 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 18 Jul 2008 22:23:28 -0000 Received: (qmail 19231 invoked by uid 500); 18 Jul 2008 22:23:28 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 19208 invoked by uid 500); 18 Jul 2008 22:23:28 -0000 Mailing-List: contact derby-commits-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: "Derby Development" List-Id: Delivered-To: mailing list derby-commits@db.apache.org Received: (qmail 19199 invoked by uid 99); 18 Jul 2008 22:23:27 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 18 Jul 2008 15:23:27 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 18 Jul 2008 22:22:42 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 4130C23889FE; Fri, 18 Jul 2008 15:23:07 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r678063 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests: jdbc4/ClobTest.java jdbcapi/BlobClob4BlobTest.java jdbcapi/LargeDataLocksTest.java tools/ImportExportTest.java Date: Fri, 18 Jul 2008 22:23:06 -0000 To: derby-commits@db.apache.org From: kmarsden@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080718222307.4130C23889FE@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: kmarsden Date: Fri Jul 18 15:23:05 2008 New Revision: 678063 URL: http://svn.apache.org/viewvc?rev=678063&view=rev Log: DERBY-3780 fix some encoding problems in tests. Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/ClobTest.java 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/jdbcapi/LargeDataLocksTest.java db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ImportExportTest.java Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/ClobTest.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/ClobTest.java?rev=678063&r1=678062&r2=678063&view=diff ============================================================================== --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/ClobTest.java (original) +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/ClobTest.java Fri Jul 18 15:23:05 2008 @@ -693,7 +693,7 @@ //Doing a setString now on the Clob //should reflect the same extension //in the InputStream also. - clob.setString((str1.getBytes().length)+1, str2); + clob.setString((str1.length())+1, str2); //Now get the reader from the Clob after //the update has been done. 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?rev=678063&r1=678062&r2=678063&view=diff ============================================================================== --- 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 Fri Jul 18 15:23:05 2008 @@ -24,6 +24,7 @@ import java.io.InputStream; import java.io.Reader; import java.io.StringReader; +import java.io.UnsupportedEncodingException; import java.util.Arrays; import java.util.Random; import java.util.zip.CRC32; @@ -1839,14 +1840,14 @@ length = random.nextInt(blobLength - start) + 1; println("start:" + start + " length:" + length); searchBytes = blob.getBytes(start, length); - String searchString = new String(searchBytes); + String searchString = new String(searchBytes, "US-ASCII"); // get random position to start the search from distance = random.nextInt(maxStartPointDistance); startSearchPos = Math.max((start - distance), 1); // make sure that the searched string does not happen // before the expected position byte[] tmp = blob.getBytes(startSearchPos, start); - if (new String(tmp).indexOf(searchString) != -1) + if (new String(tmp,"US-ASCII").indexOf(searchString) != -1) { startSearchPos = start; } @@ -1898,19 +1899,19 @@ start = Math.max(random.nextInt(blobLength - 1), 1); length = random.nextInt(blobLength - start) + 1; println("start:" + start + " length:" + length); - searchString = new String(blob.getBytes(start, length)); + searchString = new String(blob.getBytes(start, length),"US-ASCII"); // get random position to start the search from distance = random.nextInt(maxStartPointDistance); startSearchPos = Math.max((start - distance), 1); // make sure that the searched string does not happen // before the expected position String tmp = new String( - blob.getBytes(startSearchPos, start)); + blob.getBytes(startSearchPos, start),"US-ASCII"); if (tmp.indexOf(searchString) != -1) { startSearchPos = start; } - ps.setBytes(1, searchString.getBytes()); + ps.setBytes(1, searchString.getBytes("US-ASCII")); ps.setInt(2, startSearchPos); ps.setInt(3, start); ps.executeUpdate(); @@ -1926,7 +1927,7 @@ start = rs2.getInt(3); searchString = new String( - searchBlob.getBytes(1L, (int)searchBlob.length())); + searchBlob.getBytes(1L, (int)searchBlob.length()),"US-ASCII"); println("startSearchPos: " + startSearchPos + "searchString: " + searchString); foundAt = blob.position(searchBlob, startSearchPos); @@ -2610,7 +2611,7 @@ "insert into testBlob (b, a) values (?, ?)"); for (int i=0; i<10; i++) { ps.setInt(1, i); - ps.setBytes(2, (blobData + i).getBytes()); + ps.setBytes(2, (blobData + i).getBytes("US-ASCII")); ps.execute(); } ps.close(); @@ -2640,7 +2641,7 @@ } private void checkContentsBeforeAndAfterUpdatingBlob(ResultSet rs) - throws SQLException { + throws SQLException, UnsupportedEncodingException { Blob b; byte[] value, expectedValue; String blobData = "initial blob "; @@ -2649,12 +2650,12 @@ b = rs.getBlob(2); // check contents value = b.getBytes(1, blobData.length() + 1); - expectedValue = (blobData + rs.getInt(1)).getBytes(); + expectedValue = (blobData + rs.getInt(1)).getBytes("US-ASCII"); assertTrue("FAIL - wrong blob value", Arrays.equals(value, expectedValue)); // update contents - value = (updatedBlobData + rs.getInt(1)).getBytes(); + value = (updatedBlobData + rs.getInt(1)).getBytes("US-ASCII"); b.setBytes(1, value); rs.updateBlob(2, b); rs.updateRow(); @@ -2664,7 +2665,7 @@ b = rs.getBlob(2); // check contents value = b.getBytes(1, updatedBlobData.length() + 1); - expectedValue = (updatedBlobData + rs.getInt(1)).getBytes(); + expectedValue = (updatedBlobData + rs.getInt(1)).getBytes("US-ASCII"); assertTrue("FAIL - wrong blob value", Arrays.equals(value, expectedValue)); } @@ -2685,7 +2686,7 @@ "insert into testBlob (b, a) values (?, ?)"); for (int i=0; i<10; i++) { ps.setInt(1, i); - ps.setBytes(2, (blobData + i).getBytes()); + ps.setBytes(2, (blobData + i).getBytes("US-ASCII")); ps.execute(); } ps.close(); @@ -2714,7 +2715,7 @@ } private void updateBlobWithUpdateBinaryStream(ResultSet rs) - throws SQLException { + throws SQLException, UnsupportedEncodingException { Blob b; byte[] value, expectedValue; String blobData = "initial blob "; @@ -2723,12 +2724,13 @@ b = rs.getBlob(2); // check contents value = b.getBytes(1, blobData.length() + 1); - expectedValue = (blobData + rs.getInt(1)).getBytes(); + expectedValue = (blobData + rs.getInt(1)).getBytes("US-ASCII"); + assertTrue("FAIL - wrong blob value", Arrays.equals(value, expectedValue)); // update contents - value = (updatedBlobData + rs.getInt(1)).getBytes(); + value = (updatedBlobData + rs.getInt(1)).getBytes("US-ASCII"); InputStream updateValue = new ByteArrayInputStream(value); rs.updateBinaryStream(2, updateValue, value.length); rs.updateRow(); @@ -2738,7 +2740,7 @@ b = rs.getBlob(2); // check contents value = b.getBytes(1, updatedBlobData.length() + 1); - expectedValue = (updatedBlobData + rs.getInt(1)).getBytes(); + expectedValue = (updatedBlobData + rs.getInt(1)).getBytes("US-ASCII"); assertTrue("FAIL - wrong blob value", Arrays.equals(value, expectedValue)); } Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/LargeDataLocksTest.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/LargeDataLocksTest.java?rev=678063&r1=678062&r2=678063&view=diff ============================================================================== --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/LargeDataLocksTest.java (original) +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/LargeDataLocksTest.java Fri Jul 18 15:23:05 2008 @@ -23,6 +23,7 @@ import java.io.IOException; import java.io.InputStream; +import java.io.UnsupportedEncodingException; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; @@ -33,6 +34,7 @@ import junit.framework.TestSuite; import org.apache.derbyTesting.junit.BaseJDBCTestCase; +import org.apache.derbyTesting.junit.BaseTestCase; import org.apache.derbyTesting.junit.CleanDatabaseTestSetup; import org.apache.derbyTesting.junit.TestConfiguration; import org.apache.derbyTesting.junit.Utilities; @@ -166,7 +168,6 @@ /** * Create and populate table - * * @see org.apache.derbyTesting.junit.CleanDatabaseTestSetup#decorateSQL(java.sql.Statement) */ protected void decorateSQL(Statement s) throws SQLException { @@ -184,7 +185,12 @@ ps.setCharacterStream(1, new java.io.StringReader(Utilities .repeatChar("a", 38000)), 38000); - ps.setBytes(2, Utilities.repeatChar("a", 38000).getBytes()); + try { + ps.setBytes(2, Utilities.repeatChar("a", 38000).getBytes("US-ASCII")); + } catch (UnsupportedEncodingException ue) { + // Shouldn't happen US-ASCII should always be supported + BaseTestCase.fail(ue.getMessage(),ue); + } ps.setInt(3, 38000); ps.executeUpdate(); ps.close(); Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ImportExportTest.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ImportExportTest.java?rev=678063&r1=678062&r2=678063&view=diff ============================================================================== --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ImportExportTest.java (original) +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ImportExportTest.java Fri Jul 18 15:23:05 2008 @@ -162,7 +162,7 @@ public void testEarlyEndOfFile() throws Exception { Connection c = getConnection(); try { - doImportFromFile(c, "extin/EndOfFile.txt" , "T4" , null , null , null, 0); + doImportFromFile(c, "extin/EndOfFile.txt" , "T4" , null , null , "US-ASCII", 0); } catch (SQLException e) { assertSQLState("XIE0E", e); }