db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From be...@apache.org
Subject svn commit: r464504 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests: master/ suites/ tests/jdbcapi/ tests/largedata/
Date Mon, 16 Oct 2006 14:16:44 GMT
Author: bernt
Date: Mon Oct 16 07:16:43 2006
New Revision: 464504

URL: http://svn.apache.org/viewvc?view=rev&rev=464504
Log:
DERBY-1893 Convert largedata/lobLengthTests.java to junit. Comitted by Øystein Grøvlen

Added:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/LobLengthTest.java
  (with props)
Removed:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/lobLengthTests.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/largedata/lobLengthTests.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/largedata/lobLengthTests_app.properties
Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/largeDataTests.runall
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/_Suite.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/largedata/copyfiles.ant

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/largeDataTests.runall
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/largeDataTests.runall?view=diff&rev=464504&r1=464503&r2=464504
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/largeDataTests.runall
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/largeDataTests.runall
Mon Oct 16 07:16:43 2006
@@ -1,2 +1 @@
-largedata/lobLengthTests.java
 largedata/LobLimits.java

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/LobLengthTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/LobLengthTest.java?view=auto&rev=464504
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/LobLengthTest.java
(added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/LobLengthTest.java
Mon Oct 16 07:16:43 2006
@@ -0,0 +1,130 @@
+/*
+
+   Derby - Class org.apache.derbyTesting.functionTests.tests.jdbcapi.LobLengthTest
+
+   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.derbyTesting.functionTests.tests.jdbcapi;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.Statement;
+import java.sql.SQLException;
+
+import java.io.ByteArrayInputStream;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import org.apache.derbyTesting.junit.BaseJDBCTestCase;
+
+/**
+ * This tests a fix for a defect (DERBY-121) where the server and
+ * client were processing lob lengths incorrectly.  For lob lengths
+ * that are represented by 24 or more bits, the server and Derby
+ * client were doing incorrect bit-shifting.  This test makes sure
+ * that problem no longer occurs.
+ */
+
+public class LobLengthTest extends BaseJDBCTestCase {
+
+
+    /* Connection to be used in test */
+    private Connection conn = null; 
+
+    /**
+     * Creates a new instance of LobLengthTest
+     *
+     * @param name name of the test.
+     */
+    public LobLengthTest(String name)
+    {
+        super(name);
+    }
+
+    
+    public static Test suite() 
+    {
+        final TestSuite suite = new TestSuite();
+        
+        suite.addTest(new LobLengthTest("testLongLobLengths"));
+
+        return suite;
+    }
+
+
+    /**
+     * Create a JDBC connection using the arguments passed
+     * in from the harness, and create the table to be used by the test.
+     */
+    public void setUp() throws Exception
+    {
+        conn = getConnection();
+        conn.setAutoCommit(false);
+
+        // Create a test table.
+        Statement st = conn.createStatement();
+        st.execute("create table lobTable100M(bl blob(100M))");
+        st.close();
+    }
+
+
+    /**
+     * Cleanup: Drop table and close connection.
+     */
+    public void tearDown() throws Exception 
+    {
+        Statement st = conn.createStatement();
+        st.execute("drop table lobTable100M");
+        st.close();
+
+        conn.commit();
+        conn.close();
+    }
+
+
+    /**
+     * There was a defect (DERBY-121) where the server and client
+     * were processing lob lengths incorrectly.  For lob lengths
+     * that are represented by 24 or more bits, the server and
+     * Derby client were doing incorrect bit-shifting.  This
+     * test makes sure that problem no longer occurs.
+     */
+    public void testLongLobLengths() throws Exception
+    {
+        PreparedStatement pSt = conn.prepareStatement(
+            "insert into lobTable100M(bl) values (?)");
+
+        // The error we're testing occurs when the server
+        // is shifting bits 24 and higher of the lob's
+        // length (in bytes).  This means that, in order
+        // to check for the error, we have to specify a
+        // lob length (in bytes) that requires at least
+        // 24 bits to represent.  Thus for a blob the
+        // length of the test data must be specified as
+        // at least 2^24 bytes (hence the '16800000' in
+        // the next line).
+        byte [] bA = new byte[16800000];
+        pSt.setBinaryStream(1,
+            new java.io.ByteArrayInputStream(bA), bA.length);
+
+        // Now try the insert; this is where the server processes
+        // the lob length.
+        pSt.execute();
+        pSt.close();
+    }
+}

Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/LobLengthTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/_Suite.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/_Suite.java?view=diff&rev=464504&r1=464503&r2=464504
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/_Suite.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/_Suite.java
Mon Oct 16 07:16:43 2006
@@ -49,6 +49,7 @@
 
 		suite.addTest(ConcurrencyTest.suite());
 		suite.addTest(HoldabilityTest.suite());
+        suite.addTest(LobLengthTest.suite()); 
 		suite.addTest(ProcedureTest.suite());
 		suite.addTest(SURQueryMixTest.suite());
 		suite.addTest(SURTest.suite());

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/largedata/copyfiles.ant
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/largedata/copyfiles.ant?view=diff&rev=464504&r1=464503&r2=464504
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/largedata/copyfiles.ant
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/largedata/copyfiles.ant
Mon Oct 16 07:16:43 2006
@@ -1,2 +1 @@
-lobLengthTests_app.properties
 LobLimits_app.properties



Mime
View raw message