Changeset: 2232a2c1f642 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=2232a2c1f642
Modified Files:
        java/tests/Test_PSlargebatchval.java
        java/tests/build.xml
Branch: Dec2011
Log Message:

JDBC add test for bug #2952


diffs (90 lines):

diff --git a/java/tests/Test_PSlargebatchval.java 
b/java/tests/Test_PSlargebatchval.java
new file mode 100644
--- /dev/null
+++ b/java/tests/Test_PSlargebatchval.java
@@ -0,0 +1,61 @@
+/*
+ * The contents of this file are subject to the MonetDB Public License
+ * Version 1.1 (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.monetdb.org/Legal/MonetDBLicense
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is the MonetDB Database System.
+ *
+ * The Initial Developer of the Original Code is CWI.
+ * Portions created by CWI are Copyright (C) 1997-July 2008 CWI.
+ * Copyright August 2008-2011 MonetDB B.V.
+ * All Rights Reserved.
+ */
+
+import java.sql.*;
+import java.util.*;
+import java.nio.charset.Charset;
+
+public class Test_PSlargebatchval {
+       public static void main(String[] args) throws Exception {
+               Class.forName("nl.cwi.monetdb.jdbc.MonetDriver");
+               Connection con = DriverManager.getConnection(args[0]);
+               Statement stmt = con.createStatement();
+               PreparedStatement pstmt;
+
+               // >> true: auto commit should be on
+               System.out.println("0. true\t" + con.getAutoCommit());
+
+               byte[] errorBytes = new byte[] { (byte) 0xe2, (byte) 0x80, 
(byte) 0xa7 };
+               String errorStr = new String(errorBytes, 
Charset.forName("UTF-8"));
+               StringBuilder repeatedErrorStr = new StringBuilder();
+               for (int i = 0; i < 8170;i++) {
+                       repeatedErrorStr.append(errorStr);
+               }
+
+               try {
+                       stmt.execute("CREATE TABLE x (c INT, a CLOB, b 
DOUBLE)");
+                       pstmt = con.prepareStatement("INSERT INTO x VALUES 
(?,?,?)");
+                       pstmt.setLong(1, 1);
+                       pstmt.setString(2, repeatedErrorStr.toString());
+                       pstmt.setDouble(3, 1.0);
+                       pstmt.addBatch();
+                       pstmt.executeBatch();
+
+                       pstmt.close();
+                       stmt.close();
+               } catch (SQLException e) {
+                       System.out.println("FAILED :( "+ e.getMessage());
+                       while ((e = e.getNextException()) != null)
+                               System.out.println("FAILED :( " + 
e.getMessage());
+                       System.out.println("ABORTING TEST!!!");
+               }
+
+               con.close();
+       }
+}
diff --git a/java/tests/build.xml b/java/tests/build.xml
--- a/java/tests/build.xml
+++ b/java/tests/build.xml
@@ -112,6 +112,7 @@ All Rights Reserved.
     <antcall target="Test_PSgeneratedkeys" />
     <antcall target="Test_PSlargeresponse" />
     <antcall target="Test_PSlargeamount" />
+    <antcall target="Test_PSlargebatchval" />
     <antcall target="Test_PStimedate" />
     <antcall target="Test_PStimezone" />
     <antcall target="Test_PStypes" />
@@ -218,6 +219,12 @@ All Rights Reserved.
     </antcall>
   </target>
 
+  <target name="Test_PSlargebatchval">
+    <antcall target="test_class">
+      <param name="test.class" value="Test_PSlargebatchval" />
+    </antcall>
+  </target>
+
   <target name="Test_PStimedate">
     <antcall target="test_class">
       <param name="test.class" value="Test_PStimedate" />
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to