db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t...@apache.org
Subject svn commit: r406921 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests: master/DerbyNet/ master/DerbyNetClient/ suites/ tests/derbynet/ tests/junitTests/derbyNet/ util/
Date Tue, 16 May 2006 12:20:46 GMT
Author: tmnk
Date: Tue May 16 05:20:43 2006
New Revision: 406921

URL: http://svn.apache.org/viewcvs?rev=406921&view=rev
Log:
- DERBY-1303 The test of derbynet/SuicideOfStreaming.java is failed when programs are build
as Insane - Patch by Tomohito Nakayama (tomonaka@basil.ocn.ne.jp)

Added:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/derbyNet/OwnServerTests.java
  (with props)
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/derbyNet/OwnServerTests_app.properties
  (with props)
Removed:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/SuicideOfStreaming.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/SuicideOfStreaming.out
Modified:
    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/SuicideOfStreaming.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/build.xml
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/derbyNet/copyfiles.ant
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/BaseTestCase.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/derbynetmats.runall
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/derbynetmats.runall?rev=406921&r1=406920&r2=406921&view=diff
==============================================================================
--- 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 May 16 05:20:43 2006
@@ -41,5 +41,5 @@
 store/holdCursorJDBC30.sql
 tools/importExport.java
 tools/ieptests.sql
-derbynet/SuicideOfStreaming.java
+junitTests/derbyNet/OwnServerTests.junit
 derbynet/OutBufferedStream.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/SuicideOfStreaming.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/SuicideOfStreaming.java?rev=406921&r1=406920&r2=406921&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/SuicideOfStreaming.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/SuicideOfStreaming.java
Tue May 16 05:20:43 2006
@@ -36,8 +36,9 @@
 
 import org.apache.derby.drda.NetworkServerControl;
 import org.apache.derby.tools.ij;
+import org.apache.derby.client.am.SqlCode;
 import org.apache.derbyTesting.functionTests.util.TestUtil;
-
+import org.apache.derbyTesting.functionTests.util.BaseJDBCTestCase;
 
 /**
  *
@@ -47,7 +48,7 @@
  * See SuicideOfStreaming_app.properties also.
  *
  */
-public class SuicideOfStreaming {
+public class SuicideOfStreaming extends BaseJDBCTestCase {
     
     private static NetworkServerControl networkServer = null;
     
@@ -55,7 +56,7 @@
 	
 	try{
 	    
-	    ij.getPropertyArg(args);
+	    setSystemProperty("derby.debug.suicideOfLayerBStreaming","true");
 	    
 	    startServer();
 	    
@@ -64,8 +65,10 @@
 	    
 	    shutdownServer();
 	    
+	    fail("Streaming was not encountered exception. Suicide of streaming seems to be failed.");
+
 	}catch(Throwable t){
-	    t.printStackTrace();
+	    examineThrowable(t);
 	    
 	}
     }
@@ -78,7 +81,7 @@
 	       InstantiationException
     {
 
-	Connection conn = getConnection();
+	Connection conn = connectServer();
 	
 	Statement createTableSt = conn.createStatement();
 	createTableSt.execute("create table TEST_TABLE( TEST_COL blob( 65536 ))");
@@ -99,7 +102,7 @@
     {
 	
 	Connection conn = 
-	    getConnection();
+	    connectServer();
 	
 	conn.setAutoCommit(false);
 	
@@ -202,7 +205,7 @@
     }
     
     
-    private static Connection getConnection()
+    private static Connection connectServer()
 	throws SQLException {
 	
 	return DriverManager.getConnection(TestUtil.getJdbcUrlPrefix("localhost",
@@ -214,4 +217,61 @@
     }
 
     
+    
+    private static void examineThrowable( Throwable t ) {
+	
+	if(t instanceof SQLException){
+	    examineSQLException( ( SQLException ) t );
+	    
+	}else{
+	    t.printStackTrace();
+	    fail( t.getMessage() );
+	    
+	}
+
+    }
+    
+
+    private static void examineSQLException( SQLException sqlex ) {
+	
+	if( ( usingDerbyNetClient() && 
+	      examineExpectedInDerbyNetClient(sqlex) ) || 
+	    ( usingDerbyNet() && 
+	      examineExpectedInDerbyNet(sqlex) ) ){
+	    
+	    return;
+
+	}
+	    
+	fail(sqlex.getMessage() + "," +
+	     "SqlState: " + sqlex.getSQLState() + "," + 
+	     "SqlCode: " + sqlex.getErrorCode() );
+	
+    }
+
+
+    private static boolean examineExpectedInDerbyNetClient( SQLException sqlex ) {
+	return 
+	    sqlex.getSQLState().equals("08006") && 
+	    sqlex.getErrorCode() == SqlCode.disconnectError.getCode();
+    }
+
+
+    private static boolean examineExpectedInDerbyNet( SQLException sqlex ) {
+	return sqlex.getErrorCode() == SqlCode.disconnectError.getCode();
+    }
+    
+    
+    //JUnit test support.
+    //
+    public SuicideOfStreaming(){
+	super("testSuicideOfStreaming");
+    }
+    
+    
+    public void testSuicideOfStreaming(){
+	main(new String[0]);
+    }
+    
 }
+

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/build.xml
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/build.xml?rev=406921&r1=406920&r2=406921&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/build.xml
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/build.xml
Tue May 16 05:20:43 2006
@@ -65,6 +65,7 @@
       destdir="${out.dir}">
       <classpath>
         <pathelement path="${compile.classpath}"/>
+	<pathelement path="${junit}"/>
       </classpath>
       <include name="${this.dir}/*.java"/>
       <exclude name="${this.dir}/dataSourcePermissions_net.java"/>

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/derbyNet/OwnServerTests.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/derbyNet/OwnServerTests.java?rev=406921&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/derbyNet/OwnServerTests.java
(added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/derbyNet/OwnServerTests.java
Tue May 16 05:20:43 2006
@@ -0,0 +1,52 @@
+/*
+
+Derby - Class org.apache.derbyTesting.functionTests.tests.junitTests.derbyNet.OwnServerTests
+
+Copyright 1999, 2005 The Apache Software Foundation or its licensors, as applicable.
+
+Licensed 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.junitTests.derbyNet;
+
+import org.apache.derbyTesting.functionTests.util.BaseTestCase;
+import org.apache.derbyTesting.functionTests.tests.derbynet.SuicideOfStreaming;
+import org.apache.derby.iapi.services.sanity.SanityManager;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * This class deals tests which starts its own Network Server in JUnit framework.
+ */
+
+public class OwnServerTests extends BaseTestCase {
+    
+    public OwnServerTests(){
+	super("ownServerTests");
+    }
+    
+    public static Test suite(){
+	
+	TestSuite suite = new TestSuite();
+	
+	if(SanityManager.DEBUG){
+	    suite.addTest( new SuicideOfStreaming() );
+	}
+	
+	return suite;
+	
+    }
+    
+}

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

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/derbyNet/OwnServerTests_app.properties
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/derbyNet/OwnServerTests_app.properties?rev=406921&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/derbyNet/OwnServerTests_app.properties
(added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/derbyNet/OwnServerTests_app.properties
Tue May 16 05:20:43 2006
@@ -0,0 +1 @@
+startServer=false

Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/derbyNet/OwnServerTests_app.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/derbyNet/copyfiles.ant
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/derbyNet/copyfiles.ant?rev=406921&r1=406920&r2=406921&view=diff
==============================================================================
--- 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 May 16 05:20:43 2006
@@ -1 +1,2 @@
 CompatibilityTest_app.properties
+OwnServerTests_app.properties

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/BaseTestCase.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/BaseTestCase.java?rev=406921&r1=406920&r2=406921&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/BaseTestCase.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/BaseTestCase.java
Tue May 16 05:20:43 2006
@@ -22,6 +22,10 @@
 import junit.framework.TestCase;
 import java.io.PrintStream;
 import java.sql.SQLException;
+import java.security.AccessController;
+
+import java.security.PrivilegedActionException;
+
 /**
  * Base class for JUnit tests.
  */
@@ -91,5 +95,30 @@
     }
 
     private final static PrintStream out = System.out;
+    
+    /**
+     * Set system property
+     *
+     * @param name name of the property
+     * @param value value of the property
+     */
+    protected static void setSystemProperty(final String name, 
+					    final String value)
+	throws PrivilegedActionException {
+	
+	AccessController.doPrivileged
+	    (new java.security.PrivilegedAction(){
+		    
+		    public Object run(){
+			System.setProperty( name, value);
+			return null;
+			
+		    }
+		    
+		}
+	     );
+	
+    }
+    
     
 } // End class BaseTestCase



Mime
View raw message