db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From krist...@apache.org
Subject svn commit: r474803 - in /db/derby/code/trunk/java: drda/org/apache/derby/impl/drda/ testing/org/apache/derbyTesting/functionTests/suites/ testing/org/apache/derbyTesting/functionTests/tests/derbynet/ testing/org/apache/derbyTesting/functionTests/tests...
Date Tue, 14 Nov 2006 14:36:40 GMT
Author: kristwaa
Date: Tue Nov 14 06:36:38 2006
New Revision: 474803

URL: http://svn.apache.org/viewvc?view=rev&rev=474803
Log:
DERBY-2054: Rewrite test derbynet/SuicideOfStreaming to JUnit. Moved tests ByteArrayCombinerStreamTest
and SqlExceptionTest from old harness to suites.All.

Added:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/SuicideOfStreamingTest.java
  (with props)
Removed:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ByteArrayCombinerStreamTest_app.properties
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/SqlExceptionTest_app.properties
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/SuicideOfStreaming.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/SuicideOfStreaming_app.properties
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/derbyNet/OwnServerTests.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/derbyNet/OwnServerTests_app.properties
Modified:
    db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DDMWriter.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/derbynetclientmats.runall
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/derbynetmats.runall
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ByteArrayCombinerStreamTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/SqlExceptionTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/_Suite.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/derbyNet/copyfiles.ant

Modified: db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DDMWriter.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DDMWriter.java?view=diff&rev=474803&r1=474802&r2=474803
==============================================================================
--- db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DDMWriter.java (original)
+++ db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DDMWriter.java Tue Nov 14 06:36:38
2006
@@ -702,7 +702,7 @@
 		    
 		    if( SanityManager.DEBUG ){
 		
-			if( PropertyUtil.getSystemProperty("derby.debug.suicideOfLayerBStreaming") != null )
+			if( PropertyUtil.getSystemBoolean("derby.debug.suicideOfLayerBStreaming") )
 			    throw new IOException();
 				}
 		    

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/derbynetclientmats.runall
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/derbynetclientmats.runall?view=diff&rev=474803&r1=474802&r2=474803
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/derbynetclientmats.runall
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/derbynetclientmats.runall
Tue Nov 14 06:36:38 2006
@@ -3,6 +3,4 @@
 jdbcapi/xaStateTran.sql
 jdbcapi/XATest.java
 jdbcapi/checkDataSource.java
-derbynet/ByteArrayCombinerStreamTest.junit
-derbynet/SqlExceptionTest.junit
 lang/grantRevoke.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/derbynetmats.runall
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/derbynetmats.runall?view=diff&rev=474803&r1=474802&r2=474803
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/derbynetmats.runall
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/derbynetmats.runall
Tue Nov 14 06:36:38 2006
@@ -41,5 +41,4 @@
 store/holdCursorJDBC30.sql
 tools/importExport.java
 tools/ieptests.sql
-junitTests/derbyNet/OwnServerTests.junit
-derbynet/OutBufferedStream.java
\ No newline at end of file
+derbynet/OutBufferedStream.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ByteArrayCombinerStreamTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ByteArrayCombinerStreamTest.java?view=diff&rev=474803&r1=474802&r2=474803
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ByteArrayCombinerStreamTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ByteArrayCombinerStreamTest.java
Tue Nov 14 06:36:38 2006
@@ -22,6 +22,9 @@
 
 import org.apache.derbyTesting.junit.BaseTestCase;
 
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
 import org.apache.derby.client.am.ByteArrayCombinerStream;
 
 import java.io.*;
@@ -237,5 +240,10 @@
         assertEquals(data[3], (byte)combiner.read());
         assertEquals(data[4], (byte)combiner.read());
         assertEquals(-1, (byte)combiner.read());
+    }
+
+    public static Test suite() {
+        return new TestSuite(ByteArrayCombinerStreamTest.class,
+                             "ByteArrayCombinerStreamTest");
     }
 } // End class ByteArrayCombinerStreamTest

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/SqlExceptionTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/SqlExceptionTest.java?view=diff&rev=474803&r1=474802&r2=474803
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/SqlExceptionTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/SqlExceptionTest.java
Tue Nov 14 06:36:38 2006
@@ -20,6 +20,10 @@
 package org.apache.derbyTesting.functionTests.tests.derbynet;
 
 import org.apache.derbyTesting.junit.BaseTestCase;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
 import org.apache.derby.client.am.SqlException;
 import org.apache.derby.client.am.ClientMessageId;
 import org.apache.derby.shared.common.reference.SQLState;
@@ -83,5 +87,10 @@
         
         assertNotNull(javae.getNextException());
         assertEquals(javae.getNextException().getSQLState(), "08000");
+    }
+
+    public static Test suite() {
+        return new TestSuite(SqlExceptionTest.class,
+                             "SqlExceptionTest");
     }
 }

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/SuicideOfStreamingTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/SuicideOfStreamingTest.java?view=auto&rev=474803
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/SuicideOfStreamingTest.java
(added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/SuicideOfStreamingTest.java
Tue Nov 14 06:36:38 2006
@@ -0,0 +1,145 @@
+/*
+
+Derby - Class org.apache.derbyTesting.functionTests.tests.derbynet.SuicideOfStreamingTest
+
+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.derbynet;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.derbyTesting.junit.BaseJDBCTestCase;
+import org.apache.derbyTesting.junit.CleanDatabaseTestSetup;
+import org.apache.derbyTesting.junit.TestConfiguration;
+import org.apache.derbyTesting.functionTests.util.streams.LoopingAlphabetStream;
+
+import java.io.InputStream;
+import java.io.IOException;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.Statement;
+import java.sql.SQLException;
+
+import org.apache.derby.iapi.services.sanity.SanityManager;
+
+/**
+ * Test that an exception is raised if the flow of data from the server to the
+ * client is aborted.
+ *
+ * This test is somewhat special, and care should be taken if new tests are
+ * added here. The requirements for this test are:<ol>
+ *      <li>Must be run with the network client driver (DerbyNetClient)</li>
+ *      <li>Derby must have been built in SANE mode</li>
+ *      <li>System property <i>derby.debug.suicideOfLayerBStreaming</i>
must be
+ *          set to <i>true</i> in the server-side VM</li></ol>
+ * 
+ * Note that action must be taken if this test is to be run with a separate VM
+ * for the network server (includes running the server on a remote host).
+ */
+public class SuicideOfStreamingTest
+    extends BaseJDBCTestCase {
+
+    /**
+     * Create instance of the named test.
+     */
+    public SuicideOfStreamingTest(String name) {
+        super(name);
+    }
+
+    /**
+     * Create table, insert row and set debug property.
+     */
+    public void setUp()
+            throws Exception {
+        // Create the table.
+        Statement createTableSt = createStatement();
+        createTableSt.execute(
+                "create table TEST_TABLE( TEST_COL blob( 65536 ))");
+        createTableSt.close();
+        // Insert a row.
+        PreparedStatement insertLobSt = prepareStatement(
+                "insert into TEST_TABLE (TEST_COL) values (?)");
+        int lobLength = 65536;
+        insertLobSt.setBinaryStream(1,
+                new LoopingAlphabetStream(lobLength), lobLength);
+        insertLobSt.executeUpdate();
+        insertLobSt.close();
+        setSystemProperty("derby.debug.suicideOfLayerBStreaming", "true");
+    }
+
+    /**
+     * Unset the debug property.
+     */
+    public void tearDown()
+            throws SQLException {
+        removeSystemProperty("derby.debug.suicideOfLayerBStreaming");
+    }
+
+    /**
+     * Test that the client throws an exception when an exception is thrown on
+     * the server side when streaming from the database.
+     */
+    public void testInterruptedReadOfLob()
+            throws IOException, SQLException {
+        PreparedStatement fetchLobSt = prepareStatement(
+                "select TEST_COL from TEST_TABLE");
+        ResultSet rs = fetchLobSt.executeQuery();
+        try {
+            rs.next();
+            InputStream is = rs.getBinaryStream(1);
+            // Read the stream.
+            int c;
+            while ( (c = is.read() ) > -1) {}
+            fail("Reading stream should have raised exception.");
+        } catch (SQLException sqle) {
+            assertSQLState("58009", sqle);
+        }
+        rs.close();
+        fetchLobSt.close();
+    }
+
+    /**
+     * Return a test suite.
+     *
+     * @return an empty suite if Derby is built with in INSANE mode,
+     *      a suite with one or more tests otherwise.
+     */
+    public static Test suite() {
+        if (SanityManager.DEBUG) {
+            // [NOTE] Observe that the CleanDatabaseTestSetup is wrapping the
+            //      client/server decorator. This is intentional, because the
+            //      network server tend to enter an invalid state when setting
+            //      the debug property used by this test. To avoid the error,
+            //      we use an embedded connection to clean the database, while
+            //      the test itself uses a network connection.
+            //      This means this test will not run with a remote server.
+
+            // [NOTE] To observe the protocol error that should not be seen,
+            //      move the CleanDatabaseTestSetup inside the client/server
+            //      decorator. The error is intermittent, so more than one run
+            //      may be required.
+            return new CleanDatabaseTestSetup(
+                    TestConfiguration.clientServerDecorator(
+                        new TestSuite(SuicideOfStreamingTest.class,
+                                      "SuicideOfStreamingTest")));
+        }
+        return new TestSuite("SuicideOfStreamingTest <DISABLED IN INSANE MODE>");
+    }
+
+} // End class SuicideOfStreamingTest

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

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/_Suite.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/_Suite.java?view=diff&rev=474803&r1=474802&r2=474803
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/_Suite.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/_Suite.java
Tue Nov 14 06:36:38 2006
@@ -44,9 +44,12 @@
 
         TestSuite suite = new TestSuite("derbynet");
         
+        suite.addTest(ByteArrayCombinerStreamTest.suite());
         suite.addTest(ShutDownDBWhenNSShutsDownTest.suite());
-        
+        suite.addTest(SqlExceptionTest.suite());
+        suite.addTest(SuicideOfStreamingTest.suite());
+ 
         return suite;
     }
     
-}
\ No newline at end of file
+}

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/derbyNet/copyfiles.ant
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/derbyNet/copyfiles.ant?view=diff&rev=474803&r1=474802&r2=474803
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/derbyNet/copyfiles.ant
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/derbyNet/copyfiles.ant
Tue Nov 14 06:36:38 2006
@@ -1,2 +1 @@
 CompatibilityTest_app.properties
-OwnServerTests_app.properties



Mime
View raw message