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 2006/04/20 01:14:44 UTC

svn commit: r395430 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests: master/TestEnc.out suites/encodingTests.runall tests/derbynet/TestEnc.java

Author: kmarsden
Date: Wed Apr 19 16:14:44 2006
New Revision: 395430

URL: http://svn.apache.org/viewcvs?rev=395430&view=rev
Log:
DERBY-901 encoding test for client messages.

Contributed by Sunitha Kamhampati


Added:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/TestEnc.out   (with props)
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/TestEnc.java   (with props)
Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/encodingTests.runall

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/TestEnc.out
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/TestEnc.out?rev=395430&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/TestEnc.out (added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/TestEnc.out Wed Apr 19 16:14:44 2006
@@ -0,0 +1 @@
+Message Syntax error: Encountered "<EOF>" at line 1, column 10.

Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/TestEnc.out
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/encodingTests.runall
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/encodingTests.runall?rev=395430&r1=395429&r2=395430&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/encodingTests.runall (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/encodingTests.runall Wed Apr 19 16:14:44 2006
@@ -1,2 +1,2 @@
 jdbcapi/lobStreams.java
-lang/ConcurrentImplicitCreateSchema.java
+derbynet/TestEnc.java

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/TestEnc.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/TestEnc.java?rev=395430&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/TestEnc.java (added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/TestEnc.java Wed Apr 19 16:14:44 2006
@@ -0,0 +1,87 @@
+/*
+
+Derby - Class org.apache.derbyTesting.functionTests.tests.derbynet.TestEnc
+
+Copyright 2006 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.derbynet;
+
+import java.io.PrintWriter;
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+import org.apache.derby.tools.ij;
+
+/**
+ * This test is part of the encodingTests suite and has regression testcases that
+ * have caused problems because of usage of non-portable methods, constructors like
+ * String(byte[]) etc. These problems were noticed on Z/OS but can be reproduced
+ * when server and client are running with different native encoding
+ */
+public class TestEnc {
+    
+    private PrintWriter out;
+    
+    public static void main(String args[]) throws Exception {
+        new TestEnc().go(args);
+    }
+    
+    public void go(String[] args) throws Exception {
+        
+        // Load the JDBC Driver class
+        // use the ij utility to read the property file and
+        // make the initial connection.
+        ij.getPropertyArg(args);
+        Connection conn = ij.startJBMS();
+        
+        conn.setAutoCommit(true);
+        Statement stmt = conn.createStatement();
+        
+        // Error messages on z/os were garbled because
+        // of different native encoding on server/client
+        // Related jira issues are 
+        // DERBY-583,DERBY-900,DERBY-901,DERBY-902.
+        try {
+            stmt.execute("select bla");
+        } catch (SQLException e) {
+            if (e.getSQLState().equals("42X01")) {
+                System.out.println("Message "+e.getMessage());
+            }
+            else
+                handleSQLException("DERBY-583",e,false);
+        }
+        finally {
+            if (stmt != null)
+                stmt.close();
+        }
+    }
+    
+    public void handleSQLException(String method,
+            SQLException e,
+            boolean expected) throws Exception {
+        do {
+            out.print("\t" + method + " \tException " +
+                    "SQLSTATE:" + e.getSQLState());
+            if (expected)
+                out.println("  (EXPECTED)");
+            else
+                e.printStackTrace(out);
+            e = e.getNextException();
+        } while (e != null);
+        
+    }
+}

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